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
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Users online (2,698)