Hope you are all doing great.
I started using the tool few days ago and I would need your help team.
After spending an entire trying to extract data from a JSON using Deserialize/DeserializeArraw/Jobject/Jarray…, I have to admit that I need people like you with experience and knowledge.
I am trying to extract data(“IdColl”) by looping in a JSON based on a HttpRequest.
Below is an example of the JSON and within it, I have several blocs of data within each the “IdColl” exists. I need to retrieve each IdColl. Could you please share your wisdom ?
Use Deserialize JSON activity. It will give you an out put of type JsonObject. Lets us say you store the JsonObject to a variable jsonObject, for example. Now you can get values from the JsonObject like below.
When I try deserirializing it I obtain this error
Deserialize JSON: Deserialized JSON type ‘Newtonsoft.Json.Linq.JArray’ is not compatible with expected type ‘Newtonsoft.Json.Linq.JObject’. Path ‘’, line 1, position 1261.
Thank you for the feedback.
With Jarray, when I use Writeline activity JSONLastObjectArra(“IdColl”).ToString
I receive the message
Write Line: Accessed JArray values with invalid key value: “IdColl”. Int32 array index expected.
The data that you have is a JArray, perhaps you would require it’s content directly in the form of a Datatable ? If so, You could use the below Expression :
Let us know if this is what was required else provide some more info what output format you need / If it is a Collection of values or a Single value extraction.
In general when we have a Json Array (Starts with “[”) we need to Deserialize the JsonArray so:
Pass the JSON as a String
It will return a JArray variable
Now you can Deserialize this Jarray variable based on its index, for example ReturnJarray(0).Tostring
It will return a JObject, in general i like to work with Dictionary(String, Object), so i create a dictionary variable and receive the output from the Deserialize JSON
With it you can get a value from your JSON based on a key: value, for example: IdColl = YourDictionary(“IdColl”).ToString
Note: Always check if it has another JArray inside, if thats the case, repeat the process
Probably we have a lot of ways to do that, but i’m sharing one i frequently use