How To Extract The Data From A JSON – In UiPath

Some business processes may consume the JSON as an input/output to exchange data to/from a web server.

When receiving data from a web server, the data is always a string.

Let’s explore how to extract the field from a JSON string!!!

Example

Implementation using UiPath :

Let us implement a workflow which consumes a JSON string and extracts the required fields.

Step 1:
Drag “Assign” activity into the designer panel and assign some JSON string as shown below.

“{
‘fruit’: ‘Apple’,
‘size’: ‘Large’,
‘color’: ‘Red’
}”

Extract Data from JSON string 1

Step 2:
Drag “Deserialize JSON” activity into the designer panel to deserialize a JSON string. Supply the variable “json_Data” to it as input and create a variable called “out_Json” of JsonObject type.

Extract Data from JSON string 2Extract Data from JSON string 3

Step 3:
Drag “Message Box” activity into the designer panel to display the “Fruit Name”.

Extract Data from JSON string 4.PNG

Similarly, we can extract any number of required fields by passing the names of the appropriate tokens 🙂

Step 5:
Finally, let’s run the project to display the “Fruit Name”.

Extract Data from JSON string 5.PNG

Click here to download the Source Code…

Hope it has helped you… 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: