0

My JSON array is as follows.

[{"20656":"20656","20648":"20648","20666":"20666","20657":"20657","20658":"20658","20659":"20659","20660":"20660","20665":"20665","20672":"20672","20667":"20667","24517":"24517","20677":"20677","20662":"20662","24605":"24605","20675":"20675","20663":"20663","20649":"20649","20664":"20664","20668":"20668","20669":"20669","20670":"20670","20671":"20671","20673":"20673","20674":"20674","20676":"20676"}]

How do I use each individual value and use it as a variable for my next query.

Thanks,

1
  • Can you contact the provider and ask them to send you JSON that is more in the spirit of JSON? Even just an Array of values would be better. The format they chose is (variable element names) adding unnecessary complication. Commented Aug 31, 2019 at 12:36

2 Answers 2

1

Assuming your variable looks like this

enter image description here

Add Select Action

enter image description here

Which has From property set to

split(replace(replace(replace(variables('MyJsonArray'),'[{',''),'}]',''),'"',''),',')

And Map to pair MyID with expression

substring(item(),0,lastIndexOf(item(),':'))

Now you can simply iternate over all IDs with simple Foreach and refer to each ID by using expression

item()['MyID']

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

perfect. Works!
0

You can use "Parse JSON" action to parse your json data.

First, I create a "Initialize variable" action to store the json data(shown as below screenshot)

enter image description here

Then create "Parse JSON" action to parse the json object above.

enter image description here

If you don't know how to create the schema, you can click "Use sample payload to generate schema" and input your json data into it. It will generate the schema for you automatically. You can also refer to this tutorial: https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-perform-data-operations#parse-json-action

After that, we can use each individual value as variable in our logic app.(I created "Initialize variable 2" in the screenshot below as an example).

enter image description here

2 Comments

Sorry, the "Type" in the first screenshot should be "Array". I have updated my answer.
I tried that but the values change every month. So, parse JSON gets confused.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.