cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pwapp
Level: Powered On

Accessing values in json object

Hello, 

 

Could anyone tell/teach me how to access the 'values' section(s) of the below JSON using Microsoft Flow?

 

I want to parse the values of "name" and "id" (e.g. 'London' and 'LON' and 'Hamlets' and 'HAM') to variables so I can use them in another part of the flow. 

 

I've highlighted the specific parts in red. 

 

Thank you Smiley Happy

 

----------------------

 

{
	"version": "1.0",
	"session": {
		"new": true,
		"sessionId": "removed",
		"application": {
			"applicationId": "removed"
		},
		"user": {
			"userId": "removed"
		}
	},
	"context": {
		"System": {
			"application": {
				"applicationId": "removed"
			},
			"user": {
				"userId": "removed"
			},
			"device": {
				"deviceId": "removed",
				"supportedInterfaces": {}
			},
			"apiEndpoint": "removed",
			"apiAccessToken": "removed"
		}
	},
	"request": {
		"type": "Request",
		"requestId": "removed",
		"timestamp": "2019-07-04T10:01:07Z",
		"locale": "en-GB",
		"intent": {
			"name": "removedname",
			"confirmationStatus": "NONE",
			"slots": {
				"varMainGroup": {
					"name": "varMainGroup",
					"value": "London",
					"resolutions": {
						"resolutionsPerAuthority": [{
							"authority": "removed",
							"status": {
								"code": "ER_SUCCESS_MATCH"
							},
							"values": [{
								"value": {
									"name": "London",
									"id": "LON"
								}
							}]
						}]
					},
					"confirmationStatus": "NONE",
					"source": "USER"
				},
				"varSubArea": {
					"name": "varSubArea",
					"value": "HAMLETS",
					"resolutions": {
						"resolutionsPerAuthority": [{
							"authority": "removed",
							"status": {
								"code": "ER_SUCCESS_MATCH"
							},
							"values": [{
								"value": {
									"name": "HAMLETS",
									"id": "HAM"
								}
							}]
						}]
					},
					"confirmationStatus": "NONE",
					"source": "USER"
				}
			}
		}
	}
}

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Accessing values in json object

To do this you will use a Parse Json action in the Flow.  Follow these steps.

  1. Add a Parse Json action to the Flow.  Create the Schema by inputting your sample schema into the action using the Use sample payload to generate schema link. Then add the JSON into the Content field.
  2. To get at your values you'll need to go through several layers since the records are nested
    1. Add an Apply to Each loop and load resolutionsPerAuthority from dynamic content
    2. Add an Apply to Each loop inside that loop and load values
  3. You should now have access to name and id as strings inside that nested loop.


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

Re: Accessing values in json object

To do this you will use a Parse Json action in the Flow.  Follow these steps.

  1. Add a Parse Json action to the Flow.  Create the Schema by inputting your sample schema into the action using the Use sample payload to generate schema link. Then add the JSON into the Content field.
  2. To get at your values you'll need to go through several layers since the records are nested
    1. Add an Apply to Each loop and load resolutionsPerAuthority from dynamic content
    2. Add an Apply to Each loop inside that loop and load values
  3. You should now have access to name and id as strings inside that nested loop.


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

Re: Accessing values in json object

Hi @Pstork1,

 

Spot on, worked first time thanks. I'm not entirely sure how it works but gets the result I needed thank you. Smiley Happy

Super User
Super User

Re: Accessing values in json object

Its because the JSON has nested records in it.  There is also a way to use index values to get at individual items, but I figured you wanted all of them.



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

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 139 members 4,596 guests
Please welcome our newest community members: