- Overview
- Cryptography
- Database
- Java
- Python
- WebAPI
Deserialize JSON
UiPath.WebAPI.Activities.DeserializeJson
-
JSON String - The string containing the JSON to be deserialized. The JSON should be written without indents, and between double quotes. Strings inside the JSON should be written with single quotes. For example, the following JSON is valid: "{'TenancyName': 'Documentation', 'UsernameOrEmail': 'Documentation', 'Password': 'Documentation'}".
Advanced options
Input
-
JSON Sample - The JSON sample for the output structure. The activitiy converts this sample into a similar object which you can use during design time.
-
Input Type - A dropdown list that enables you to select the argument type of the object to deserialize.
Output
- JSON object - The deserialized JSON, as a
Newtonsoft.Json.Linq.JObject
variable. For more information onNewtonsoft.Json.Linq.JObject
objects, go here.
Properties panel
Common
- DisplayName - The display name of the activity.
Input
-
JSON Sample - The JSON sample for the output structure. The activitiy converts this sample into a similar object which you can use during design time.
- JsonString - The string containing the JSON to be deserialized. The JSON should be written without indents, and between double quotes. Strings inside the JSON should be written with single quotes. For example, the following JSON is valid: "{'TenancyName': 'Documentation', 'UsernameOrEmail': 'Documentation', 'Password': 'Documentation'}".
Misc
- Private - If selected, the values of variables and arguments are no longer logged at Verbose level.
- TypeArgument - A drop-down list that enables you to select the type of output returned. The provided JSON string will be converted to an object of the selected type.
Output
- JsonObject - The deserialized JSON, as a
Newtonsoft.Json.Linq.JObject
variable. For more information onNewtonsoft.Json.Linq.JObject
objects, go here.
.json
files and strings.
.json
file.
This is how the automation process can be built:
- Open Studio and create a new Process.
-
Drag a Sequence to the Workflow Designer.
-
Create the following variables:
Variable Name
Variable Type
Default Value
JsonText
String
JsonObj
JObject
Age
GenericValue
-
-
Drag a Read Text File activity inside the sequence container.
- In the Properties panel, add the value
"JsonString.txt"
in the FileName field. - Add the variable
JsonText
in the Content field.
- In the Properties panel, add the value
-
Add a Deserialize JSON activity after the Read Text File activity.
- In the Properties panel, add the variable
JsonText
in the JsonString field and the variableJsonObj
in the JsonObject field. - Select the value
Newtonsoft.Json.Linq.JObject
from the TypeArgument drop-down list.
- In the Properties panel, add the variable
-
Place an Assign activity under the Deserialize JSON activity.
- Add the variable
Age
in the To field and the expressionJsonObj.SelectToken("age").ToString
in the Value field.
- Add the variable
-
Drag a Write Line activity after the Assign activity.
- Add the variable
Age
in the Text field.
- Add the variable
- Run the process. The robot extracts the age value from the
.json
file and displays it in the Output panel.
Here you can download an example.