I want to get the "marketSegment" from the json file

source.json (2.0 MB)

from this json file i wants to get the marketSegment to an array
Thanks in Advance

1 Like

Hi @Roshan_Ouseppachan

try out this syntax




First you need to load this information into a variable of type JSON, if you are getting this information using the activities from the UiPath.WebAPI.Activities package, normally the return is in string format.

So the first thing we need to do is convert to a JSON variable. For that we will use the activity “Deserialize JSON”, you will inform your string variable in the input properties and in the output property you will inform a variable of the type “JObject”.

Now with the variable “JObject” we will need to make two loops.
The first loop will go through the “segmentAggregates” array and the second loop will go through the “aggregates” array which is where the “marketSegment” attribute is.

To make the loops we will use the “For Each” activity, in the “TypeArgument” property you will use “Newtonsoft.Json.Linq.JObject” for both “For Each”.

In the first loop you will need to put the following in the property “value” jobjSource(“data”)(“dayByDayDashboard”)(“segmentAggregates”).
jobjSource is the variable converted to JObject.

In the second loop in the “value” property you will put segmentAggregates(“aggregates”).
segmentAggregates is the internal variable of the first loop.

inside the second loop, you can use a “Message Box” with aggregates(“marketSegment”).ToString to check if it’s working properly.
aggregates is the internal variable of the second loop.

As I thought my explanation was not as clear as possible, I’m putting the example I used to test and formulate this answer.

I hope it helps you.
Main.xaml (6,4,KB)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.