How to iterate through json file

Hi @DanielMitchell

As discussed in this post, I’m trying to create a new address detail entry on a website based on this json. STA_JSON_SAMPLE.json (2.6 KB)

I need some help on how to use the for each function for that.

Thank you

@JCH
Please see the attached xaml file. The previousResidentialAddress item is a JArray, so you must first useDeserialize JSON Array to get an array of JObjects, then from there you can access each address.
Main.xaml (8.2 KB)

1 Like

Thank you @DanielMitchell.

I’m trying to understand how this works… If we tell it: ForEach “address”. How does it know that “address” refers to each object in the array? I don’t see it defined anywhere.

image

@JCH
There are a few activities such as For Each and For Each Row where you can declare a variable inside the activity itself. address is a variable, it just doesn’t show up in the variable pane of Studio. You can rename address to be anything that you want and UiPath will initialize a variable with that name when it runs. The type of the variable is set by the TypeArgument parameter of the activity.

1 Like

Ah ok that makes sense now. Thanks so much explaining that!

1 Like

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