cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ford_wilkinson
Helper I
Helper I

How do I get the values out of a parsed JSON?

Good afternoon -- pretty sure I've just been looking at this too long but here is my issue:

I am getting a JSON Payload that looks like this:

{
"@odata.context": "https://aos-rts-stus2.hr.talent.dynamics.com/namespaces/c99ebd9289f6b16/data/$metadata#Edm.String",

}

 

I know how to use the "Parse Json" to separate them into 2 objects, @odata.context and value.  The problem is that the value I need is the BlobUrl value in the "value" section.  When I parse it, I simply get the "@odata.context" and in their entirety.  

 

How do I extract the BlobUrl so I can use it later in my Flow or Logic App?


Thanks for any help.  Been staring at this all day.


Ford

1 ACCEPTED SOLUTION

Accepted Solutions
eliotcole
Impactful Individual
Impactful Individual

Nono, it's no problem, @ford_wilkinson, just needed that bit more context is all.

 

OK, so I'm going to assume that your HTTP action is just called HTTP, and that code there is the only code that arrives in the body part of the code. Assuming that then if I placed a Compose straight afterwards, I would use this expression:

json(body('HTTP')?['value'])?['BlobUrl']

What it's doing is the data inside the 'value' field (as you can see) is a string of text. Even though we can both tell that it's JSON data in there, you can see that it's a string because:

  1. Quoted - It's encased in speech marks / quotations.
  2. Escaped - Certain characters are 'escaped', ie. they have forward slashes before them (\") so that the system knows to treat them as text and not a part of the JSON.

So, in order for the expression to understand that string, it needs to convert it into JSON, which is why the json() function is wrapped around the value data.

 

Once it's a real boy you can ask it for the correct internal field, and it will provide it, json(YOUR_STRING_DATA)?['BlobURL']. 😃

View solution in original post

7 REPLIES 7
eliotcole
Impactful Individual
Impactful Individual

If I were to make a wild stab without a parse, assuming the input is variables('inputJsonVAR') (change accordingly), then I'd say this should work:

 

variables('inputJsonVAR')?['value']?['BlobUrl']

 

 

However, since that 'value' data is possibly all as a string, not JSON, it might need a little more working.

 

EDIT - Here you go, this should do the trick:

json(variables('inputJsonVAR')?['value'])?['BlobUrl']

Again, change that variables reference to wherever you have the data coming in from.

Its been a long day.  Can you show me what that would look like in the GUI or where to stick the code (what action?), thanks!

json(variables('inputJsonVAR')?['value'])?['BlobUrl']

 

eliotcole
Impactful Individual
Impactful Individual

Show me yours and I'll show you mine. 😉

 

Need some context really ... but you can put that anywhere you need it, really.

 

If you figure it out, remember to change the "variables('inputJsonVAR')" part to whereever the data is coming from.

 

If not, lemme see what you're working with, then I'll get you an example, mate. 🙂

No problem.  I'm doing an HTTP request to my system to get an Azure storage blob URL to download and this is what it responds with:

{
  "value""{\"BlobId\":\"{F8331906-5699-4BF2-9257-4B3D2C5F3E4C}\",\"BlobUrl\":\"https://dynamics36.blob.core.windows.net/dmf/ford.txt?sv=2014-02-14&sr=b&sig=PPS79xKPgI%3D&st=2021-0..."}"
}
 
I need to parse out the "BlobUrl" parameter out of the JSON array so I can enter it into the step to upload the "file".  I doubt I will use this HTTP request to upload it but I need the "BlobURL" parameter to get my file uploaded.  Not sure how to split that out of the array.
 

Sorry for the noob questions..  Just stuck and its frustrating!

 

Thank you,

 

Ford

 

eliotcole
Impactful Individual
Impactful Individual

Nono, it's no problem, @ford_wilkinson, just needed that bit more context is all.

 

OK, so I'm going to assume that your HTTP action is just called HTTP, and that code there is the only code that arrives in the body part of the code. Assuming that then if I placed a Compose straight afterwards, I would use this expression:

json(body('HTTP')?['value'])?['BlobUrl']

What it's doing is the data inside the 'value' field (as you can see) is a string of text. Even though we can both tell that it's JSON data in there, you can see that it's a string because:

  1. Quoted - It's encased in speech marks / quotations.
  2. Escaped - Certain characters are 'escaped', ie. they have forward slashes before them (\") so that the system knows to treat them as text and not a part of the JSON.

So, in order for the expression to understand that string, it needs to convert it into JSON, which is why the json() function is wrapped around the value data.

 

Once it's a real boy you can ask it for the correct internal field, and it will provide it, json(YOUR_STRING_DATA)?['BlobURL']. 😃

View solution in original post

Wow -- I've been banging my head for HOURS on this...  Thank you!!  It worked PERFECTLY!!  Thank you thank you thank you!

eliotcole
Impactful Individual
Impactful Individual

Glad I could help, mate! 🙂

 

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (2,117)