How to print the Json Array using for each loop

Hi Guys,

Below is my JsonResponse of type JsonArray and I want to iterate through this using for each loop. Can you please help if you have solved similar kind of problem?

image

JsonResponse
[{“predictions”:1,“confidences”:0.7164001138},{“predictions”:0,“confidences”:0.845748191},{“predictions”:1,“confidences”:0.6578971967},{“predictions”:0,“confidences”:0.9666104859},{“predictions”:1,“confidences”:0.694211731}]

I want the Output to be be printed for each line as below:

1
0
1
0
1

Also, please see the below screenshot and see what I am missing.

Hi @shreyash_shirbhate

Use this Assign acticity inside the For each loop

Use Assign activity
RHS : item.GetValue(“predictions”).ToString

Regards
Gokul

2 Likes

Hi @shreyash_shirbhate

You have to deserialize json for each iteration and print the Jobj(“predections”).ToString to get your desired output

refer below image for more reference

Hope is solves your issue

Update us whether you got your desired solution or not

thanks
Robin

in general the main steps are mentioned above

  • set the typeargument from for each activity to JObject
  • retrieve the value with yourLoopVar(YourPropertyName).Value(Of YourDataType) using the preferred Value(Of…) method

e.g.
item(“predictions”).Value(of String) - getting String
or
grafik
etc…

1 Like

Thanks @Gokul001 @Robinnavinraj_S @ppr .

All the solutions you guys gave are working fine. :grinning:

1 Like

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