How can i extract the value of a key from the server response and store it in a variable?

hai all.
this is my server response and i want to extract only the switchID
{"Data":[{"userID":"101","switchID":"abc123","switchStatus":"0"},{"userID":"101","switchID":"efg456","switchStatus":"0"}]}

which is in json format

can any one tell me the approach that i should follow or if i get the logical blocks
that will be more useful for me.

Thank u

You need the web component for the JsonTextDecodeWithDictionaries block

1 Like

I could able to extract the data, i was stuct for long time in this task
Thank you

hai, how can i extract all the switchID's and have extracted switchID's in an array .
there are 2 switchID's but now i am able to extract only first switchID.
{"Data":[{"userID":"101","switchID":"abc123","switchStatus":"0"},{"userID":"101","switchID":"efg456","switchStatus":"0"}]}

i need all the switchID's to be extracted and stored in an array no matter how many switchID's my server response displays.

can u help me?

You probably want to be able to identify which switchID belongs to which userID ?

Something like this: (modify to suit your needs, you could add to a list, for example)

No problem with that because my logic works such a way that my server responses based on the userID that i have sent .
All the needed was too get all the switchID.

cool this will help me .
Thank you

There are some blocks that make this process more efficient, namely the get value at key path and list by walking key path blocks:

The former will return the value "abc123" in your example data or "not found" if nothing is found. The latter will return ["abc123", "efg456"] or [] if there were no data. The blocks are slightly more compact and they also prevent the potential logic bug of looking up a value in the middle that doesn't exist and causing the code to error out.

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