DeserializeJsonArray

This activity is used to convert the details of an input file, a JSON object or a variable
to an array of data. An array of data is a list of values.

(Navigate to the bottom of this page to download the sample file for this activity).

Technical Reference

 

 

 

 

 

 

 

MISC

Display Name: Displays the name of the activity. You can also customize the activity name to help in troubleshooting.

SkipOnError: It specifies whether to continue executing the workflow even if it throws an error. This supports only Boolean value “True or False.”

True: Continues to execute the workflow irrespective of any error thrown.

False: The workflow aborts if it throws any error.

Version: Specifies the version of the Json feature in use.

 

OUTPUT

JsonArray: It helps to view the output of the JSON file in an array format. 

Result:  Returns the success state of the activity in Boolean value.

* Represents mandatory fields to execute the workflow

Use Case

The following usecase helps us to understand how the deserialization of JSON is used
in the workflow. Here the input is a JSON file which contans a combination of mixed
variables such as name of the person,age and name of the car.

The following are the scenarios covered in the example.

Scenario 1: Utilizing the input file to iterate and convert the values to an array format.
Scenario 2: Utilizing the array variable to iterate and convert the values to Jobject.
 

Scenario 1

In the following steps, we are using the deserialize Json array and ForEach activity
to iterate and convert each value to an array format from the input file.

Steps to execute the bot

1.     Drag and drop the deserialize Json array activity into the Get Json Object activity.

2.     Declare a variable here in the JsonArray box of the output segment. Here it 
is Jarray. 

3.     Drag and drop a ForEach activity into the workflow.

4.     Navigate to the property section and change the Type Argument as Object from
the drop down since 

5.     Now we need to assign a value for each item in the Foreach activity. Here the
value for ForEach is changed from "item to obj" and in is the variable declared
above, which is Jarray.

Scenario 2

It's a continuation from scenario1. The input here will be the variable declared (Obj)
in ForEach activity. From this variable (Obj) we are going to iterate and convert the Jobject
value and get the key and value for each property. 

6.    Now drag and drop a sequence activity into the Foreach activity.

7.    Drag and drop a deserialize json object activity into the sequence.

8.    Click on the activity and navigate to the property window, specify the input variable as
obj.ToString().

9.    Declare a variable in the JsonObject box of the output segment in the Deserialize
Json Object property window. Here it is JObject.

10. Drag and drop another ForEach activity below this activity as the values stored
in the variable is stored as JObject and we need to extract each property from it.

11. Click on the for each activity in the workflow and navigate to the property section.
Change the Type Argument as JProperty.

12. Now we need to assign a value for each item in the Foreach activity. Here the
value for ForEach is changed from "item to prop" and in is the variable declared
above, which is JObject.properties.

13. Now drag and drop two write line activities below this, as we have two different
properties for three different objects. For example we have a key which is “name”
and we have a value for that which is “XXXX1”

14. So let’s use a “key” and “value” tag for each property that we extract from the above
JObject.

15. Here the input string that we use is "Key : " + prop.name.tostring()
                                                            "Value : " + prop.Value.ToString()

Use this as the input string in each of the write line activity.

16. Execute the workflow.        

The bot executes the activity, converts the given json file to an array of data and then uses
the deserialize json object activity to deserialize the array of data and give an output as
individual detail.

Please find the attached Sample Json file for reference below in creating a workflow.

File
Jsonsample(1)_0.txt (153 bytes)