Hello, So I see plenty of examples on how to take an JSON string the bot got from another service and deserialize it into an array for it to process.
But I’m trying to go in the other direction. My bot has gathered various bits of information into an array and I want to encode that into a single JSON string that it can then pass out to the next service to handle.
Use the Deserialize JSON activity for this. If you can’t find the activity it means you have to install the UiPath.Web.Activities package using Manage Packages.
The result is a Newtonsoft.Json.Linq.JObject object. There’s a good general example of querying a complicated JObject instance here, but for your specific question you just want to navigate to the url property (which is an array) and then iterate through the array. This sequence will print the array values to the output window:
jsonString: type = String
urlObject: type = JObject (Newtonsoft.Json.Linq.JObject)
I have a scenario where my Json String format is not fixed. Dor a particular key I have an array of key-value pairs also their count is not fixed. For each transaction it is going to be different . All would have different values as well.
Below is the example of Json String:
“key1” : “value1”,
“key2” : “value2”,
“key3” : “value3”,
In this video I do a lot of stuff with JSON Chapter included:
All you need to know about JSON and UiPath, 4 different cases of parsing JSON also the creation of the Same JSON also JSON to Datatable, and DataTable to JSON.
0:45 Install Deserialize JSON
1:10 Present all types of JSON that will use
1:35 Deserialize simple JSON
2:50 Deserialize a JSON with an Object inside
3:55 Deserialize a JSON with Array inside
6:00 When we use Deserialize JSON Array activity
7:00 Deserialize a JSON with a List of Strings inside
9:45 Create a simple JSON
11:05 Create a JSON with an Object inside
12:17 Create a JSON with Array inside
14:05 Create a JSON with a List of Strings inside
12:35 Script that writes data on the Queue
15:55 Datatable to JSON
17:50 JSON to Datatable