cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
johnc222
Helper II
Helper II

Extract string values from JSON Parse

I cannot for the life of me get flow to extract each value from my JSON array

 

Need it to pull string values from each part of the array and then be able to pull that info into an email in later steps.

 

My current set up is like this - but im hitting a wall here.. JSON does tend to pull Null values if the field is blank in PowerApps

 

How do i reference each object in the email below? 

 

johnc222_0-1618326310904.png

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User III
Dual Super User III

To avoid the apply to each loop you will need to manually input the JSON for each value using an Index.  Something like this

body('Parse_JSON')[0]?['B211IN']

where [0] is the first row, [1] is the second, etc.



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

9 REPLIES 9
johnc222
Helper II
Helper II

 

Tried also to use Compose

johnc222_0-1618326780352.png

 

 

Pstork1
Dual Super User III
Dual Super User III

You should use value not body in the Parse JSON.  Body is an object that contains an array.  value is the array itself.  If you use value in the array you should be able to reference each property using the name.  

outputs('Parse_JSON')?['B211IN']

You can wrap that in a Coalesce to substitute a different value for Null properties.



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

So using your suggestion i think this is where i had problem before - does not seem to be pulling the value through?

johnc222_0-1618327066800.png

 

Pstork1
Dual Super User III
Dual Super User III

Based on the schema you posted B211IN is a null object., not string.  Double check your schema.  It should look something like this

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "B211IN": {
                "type": "string"
            },
            "B211OUT": {
                "type": "string"
            }
....

 



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

Hi @Pstork1 

 

Right now it is like this - because not all values are filled - sometimes they return null as pulling this data from PowerApps- if i try to change to string value as above i get an error because null is not a string value i believe was the issue i had with this

 

{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "B211IN": {},
      "B211OUT": {},
      "B2171IN": {},
      "B2171OUT": {},
      "B2172IN": {},
      "B2172OUT": {}
    }
  }
}

OUTPUT 

[
  {
    "B211IN": "TESTCAR"
  },
  {
    "B211OUT": null
  },
  {
    "B2171IN": null
  },
  {
    "B2171OUT": null
  },
  {
    "B2172IN": null
  },
  {
    "B2172OUT": null
  }
]

 

 

Basically i just want to reference each field value taken from PowerApps JSON and then add their value to an email below. If i directly reference the Parse value it will Apply for Each and send 6 different emails 

johnc222_0-1618327855611.png

 

 

Pstork1
Dual Super User III
Dual Super User III

To handle properties in the array that can be string or null use a schema like this, not one without a type.

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "B211IN": {
                "type": ["string", "null"]
            },
            "B211OUT": {
                "type": ["string", "null"]
            }
....

 



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

To avoid the apply to each loop you will need to manually input the JSON for each value using an Index.  Something like this

body('Parse_JSON')[0]?['B211IN']

where [0] is the first row, [1] is the second, etc.



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

@Pstork1 Thank you so much for your help so far -

 

still does not appear to pull the string value through am i doing something wrong?

 

johnc222_0-1618328409504.png

johnc222_1-1618328463694.png

 

 

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (74,603)