Obtain the values of nested JSON objects in UiPath Studio

How to get the values of nested JSON objects in UiPath Studio

Activities "Deserialize JSON" and "Deserialize JSON Array" can be used to work with JSON objects. 

To get the values of nested JSON objects, users can deserialize the JSON object twice.

Example of JSON:



"{
    "name":"John",
    "age":31,
    "cars": {
        "car1":"Ford",
        "car2":"BMW",
        "car3":"Fiat"
    }
}"

 

Please notice that the JSON should be written without indents, and between double quotes. Strings inside the JSON should be written with single quotes.
The above JSON will be: "{ 'name':'John', 'age':31, 'cars': { 'car1':'Ford', 'car2':'BMW', 'car3':'Fiat' } }".


To get the value of car2, users can create a workflow like the following workflow:
 



Please follow the below specifications:

1. Variables


2. First "Deserialize JSON" Activity Properties 


3. Second "Deserialize JSON" Activity Properties 


4. First "Assign" Activity Properties 




5. Second "Assign"  Activity Properties