How to loop through a JSON String of below format

Hello everyone :slight_smile:

I’m back with another query, this time its regarding JSON string.

I have a JSON string which roughly looks like in the below format -

{
“MAINLIST”: [
{
“0”: “Unique Keyword1”
},
{
“0”: “Unique Keyword2”
}
],
“TEMP”: [
{
“0”: “Unique Keyword3”
},
{
“0”: “Unique Keyword4”
}
],
“TEMP2”: [
{
“0”: “Unique Keyword5”
},
{
“0”: “Unique Keyword6”
},
{
“0”: “Unique Keyword7”
}
]
}

My question is, how do I loop through all these array item and pick-out one ‘Unique Keyword’ based on one condition. ?

for example, my need here is I want to get the ‘Unique Keyword4’ from “TEMP” and use that string value for another condition check.

The values within the array will be many more, for rough purpose I’ve created this JSON

Your request is not fully clear

grafik

@ppr - thank you for your quick response.

What I am trying to achieve here is that, I need to loop through the above mentioned JSON string i.e. first in the “MAINLIST” then “TEMP” then in “TEMP2” and then try to get one particular value (from the key-value pair)

So I’ll have an operand 1 = “My String”
and then I’ll have another operand 2 = supposed to be the value we get from JSON String (basically we have to pass each value in this place from that JSON string for example ‘Unique Keyword4’ or ‘Unique Keyword2’ etc… and then check for a match)

and once we have both the values, we check
Operand 1 is equal to Operand 2
and then followed by other steps.

we can iterate over the properties:

And i guess here is the key info. It is confusing to extract a value when value is known. It looks like you want to check if a particular value is present

Just a starter help (totaly unstructured check)


grafik

Also can be modified e.g on:

  • incorporating more structure constraints within the check
  • filtering and returning e.g. the JObject holding the value …

Also have a look at this

1 Like

Thank you @ppr , your “starter help” pretty much solves more than 90% my concern :blush:

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