How to use and store credentials using Json file(credential_store.json) and extracting the credentials

Hi All,

I am learning the concept of different ways of storing credentials in UiPath and came across this topic. Please find the link below.

image

Please can anyone explain how to use and store credentials using a JSON file and extract the details in UiPath?

Any insights or help is really appreciated.

Thanks and Regards
Ashwini

@ashwini_bagewadi

Generally json structure is like this

{"Creds":{"username":"abc","password":"def"}}

We can access the data by first deserializing this string using deserialize json activity and say the output is in variable jobj which is a jobject type variable

Jobj("Creds")("username").ToString for username and replace it with password to retrieve the password

Hope this helps

Cheers

1 Like

Thank you @Anil_G for your response, really appriciate it. I tried doing what you suggested, but the output of Deserialze JSON im getting datatype as “Object” not jobject. Could you please guide me as to where am I going wrong.

Please find the attached code.
File based credential store JSON file.zip (2.6 KB)

Thank you
Ashwini

@ashwini_bagewadi

In the deserialize json activity properties…you will see a type argument …which is to be changed to jobject…i guess jow it is object

Cheers

1 Like

Thank you so much @Anil_G for your time and help, the code you suggested worked amazingly well :smiley:, but a just have 1 question, what if I have an array of credentials, please find the attached notepad file/ Image for reference
Credentials - Copy.json (242 Bytes)

image

So using the name I want to fetch the particular credentials.
Could you please tell me how to fetch credentials from an Array of credentials using the name?

Thank you
Ashwini

@ashwini_bagewadi

After deserialize

Jobj("Credentials")(0)("name").ToString will give the first one

Like that change 0 to 1 etc to get each

You can as well use another deserialize on jobj("Credentials").ToString and type argument as Jarray and then use for loop to get each credential in the loop currentitem("name").ToString

Cheers

Thank you so much @Anil_G. Both the solutions you suggested worked pretty well. This concept is new to me so thank you for helping me out :grinning: Hope you have a wonderful day.

Thank you
Ashwini

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.