Reading a .Json argument in UiPath

Hello Everyone,

I have a requirement to read a “json” Argument from another application into UiPath. How can I do this? What type of argument or variable I should use?

The sample is as below:

{
“Input”:
{
“Key1”: “value1”,
“Key2”: “value2”,
“Key3”: “value3”,
}
}

Note that I cannot save it as a text file and using Argument type as string doesn’t work because of the double quotes. Is there any other way to achieve this?

Thank you in advance.

Hello @voranir,

Please check the following documentation, it details the “Deserialize Json” activity:

After that, you can refer to a determinated key, such as:

jsonObject(“Key1”).toString

Best regards!

Great, this helps!!

The problem here is that if the value has double quotes in it, the string variable for the json will not work.

Example - 'Key1: ‘This is a “test” value’,

Glad to hear that it helps.

What error does come up when you invoke the deserialize activity?

Double quotes often represent an escape character, so it can generate some problems.

image

I am just assigning the Json string to the string variable. Attached is the error

Hello @voranir,

The error comes up because Strings have to be declared in a single row.
Kindly try removing all the unnecesary white spaces and line breaks so the String variable gets declared in a single line.

If you are getting the JSON from another source, and if you pass that directly to the activity, it won’t give you the error with the double quotes.

You must have that entire JSON in a single line if you want to assign it to a string type variable.

Else if you use that JSON directly within the deserialize JSON activity after replacing all the double quotes, it will work

Thanks guys, this works!!

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