cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
KrisvanderMast
Level: Power Up

Parsing json - get first item of an array

From an HTTP get call I'm getting this json back:
 
[{"Value": "BRUUL","Id": 39318,"Brussels": false}]
 
I simply want to take the value for the Id property of the first item in the array.
 
I've been reading up on articles I found via several search engines, trying with compose and set variable but either it goes into a apply each block, which I don't want, or I keep on getting the entire above string sent back to my Power Virtual Agent.
1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Parsing json - get first item of an array

Hi @KrisvanderMast 

 

After you parse your JSON using parse JSON action use following expression :

body('Parse_JSON_2')[0]['Id'] this will give you id of first item

 

-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

 

View solution in original post

5 REPLIES 5
Super User
Super User

Re: Parsing json - get first item of an array

Hi @KrisvanderMast 

 

After you parse your JSON using parse JSON action use following expression :

body('Parse_JSON_2')[0]['Id'] this will give you id of first item

 

-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

 

View solution in original post

KrisvanderMast
Level: Power Up

Re: Parsing json - get first item of an array

Hi,

 

that gives me the following error:

 

Correct to include a valid reference to 'Parse_JSON_2' for the input parameter(s) of action 'Initialize_variable'.

 

 

Super User
Super User

Re: Parsing json - get first item of an array

Hi @KrisvanderMast 

 

Parse_JSON_2 is the action name in my FLOW, in your flow you should use action name that in your flow. share a screen capture of your flow i will let you know what to use.

 

-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

 

KrisvanderMast
Level: Power Up

Re: Parsing json - get first item of an array

Did a rename of my action and it worked. 

 

Is there some overview/list of functions like body() and the likes I can take a look at and learn?

Super User
Super User

Re: Parsing json - get first item of an array

Hi @KrisvanderMast 

 

Checkout following link:

https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference

 

-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons in April

Read the announcement for more information!

firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Kudoed Authors
Users online (3,981)