Dictionary within List - Help required to extract the values

Hello Experts,

My use case is RPA receives input values through API to start the job process. One of the argument field ‘ApprovalFlow’ has the value with the below format (it seems to be dictionary within List). I need to write a logic to extract the details of each dictionary value, could some one assist? Thank you very much in advance.

"ApprovalFlow": [
  {
    "Authority": "GM",
    "UserName": "Employee 1"
  }, {
    "Authority": "SCO",
    "UserName": "Employee 2"
  }
]

Hi @rdinesh0331

If you read this JSon, you can get the count of objects in ApprovalFlow
Loop through the members present in the approvalflow, now irrespective of 2 members or 4 or any number it should be able to read it and store all of it in a temp DataTable or a String type of variable with some separators.

Thanks
Happy Automation!

That is an array of JObjects. Arrays are denoted by [ and ]

In your example, the two elements of the array are JObjects with Authority and UserName properties.

In order to give you exact code to get these values out, we’ll need to see the entire JSON data. Save it to a text file and put attach that file to your reply. But in general, you’d…

assign MyJObj (datatype JObject) = JOBject.Parse(variableWithEntireJSON)
assign MyJArray (datatype JArray) = JArray.Parse(MyJobj(“ApprovalFlow”).ToString)

Now the MyJArray variable will be an array of the two JObjects. You can access them like any normal array, for example…

MyJArray(0)(“Authority”).ToString

Or you can loop through MyJArray with a For Each.

Sample input below. These details sent by API team to RPA process to start the trigger.

“AffirmativeCovenants”: “Test affirmativeCovenants (213)”,
“ApplicationName”: “Test applicationName (57)”,
“ApplicationType”: “CNR”,
“ApprovalFlow”: [
{
“Authority”: “GM”,
“UserName”: “Employee 1”
}, {
“Authority”: “SCO”,
“UserName”: “Employee 2”
}
],
“Baserate”: “Test+”,
“BaserateComment”: “Test baseRateComments (213)”,
“BookingOfficeId”: “8801”,
“BookingOfficeName”: “NEW YORK BRANCH”,
“BorrowerSmun”: “34434334”,
“Collateral”: “Test collateral (213)”

We assume that the JSON is a JObject.

One of many options - Extraction to a DataTable:

grafik

grafik
Out: myJObject

Assign Activity:
dtData = myJObject("ApprovalFlow").ToObject(Of Datatable)

2 Likes

Thanks everyone, I could extract the values using Deserialize JSON Array activity and then iterate through each Jarray item.