cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KrisvanderMast
New Member

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
DeepakS
Super User
Super User

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
DeepakS
Super User
Super User

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

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'.

 

 

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.

 

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?

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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,236)