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

Parsing JSON with Array - First item is empty

Hello to all,

New to Power Apps and JSON, so might by a very stupid question (but tried to do my homework and searched net for solutions first).

 

Use case: JSON is array of (LinkedIn) profiles, where jobs, school etc. are nested array's withing a profile. Getting out the "top level" tupels such as fullname, headline etc. is no problem.

 

Issue: Getting to the nested arrays fails, as the first element of the parsed JSON seems to be empty. Only the second element contains the first object? Attached the flow setup, the flow result with the first element (failing), and the second element (successful)

 

Question: How do I get rid of the first (empty) element? The JSON is "a given". I can't change that. All I control is the schema(s), and the flow.

 

SCREENSHOTS

Flow Input

Flow InputFlow Input

Body Error - First element is empty

Flow Output Error (empty first element)Flow Output Error (empty first element)

 

Output Success - Second element of Body

Flow Output SuccessFlow Output Success

INPUT JSON

[{"baseUrl":"","error":"Empty line","timestamp":"2021-12-09T11:58:41.226Z"},{"general":{"imgUrl":"https://someurl.com","fullName":"Jamie Oliver","headline":"President XYZ","location":"Mars","profileUrl":"https://www.xing.com/123","connectionDegree":"1st","mutualConnectionsText":"22 mutual connections: John Doe and 21 others","description":"","subscribers":"99","firstName":"Jamie","lastName":"Oliver","company":"XYZ","school":"University of Southern Mars"},"jobs":[{"companyUrl":"https://someurl.com","companyName":"XYZ","jobTitle":"President","dateRange":"Jan 2022 - Present · 1 yr","location":"Boom Town, Mars","logoUrl":"https://someurl.com"},{"companyUrl":"https://someurl.com","companyName":"ALPHA Bravo","jobTitle":"Managing Director","dateRange":"Jan 2015 - Dec 2021 · 7 yrs","location":"New York, USA","logoUrl":"https://someurl.com"}],"schools":[{"schoolUrl":"https://someurl.com","schoolName":"University of Southern Mars","degree":"Business Management","dateRange":"2002 - 2003","logoUrl":"https://someurl.com"},{"schoolUrl":"https://someurl.com","schoolName":"NYU","degree":"B.S. Marsology","dateRange":"1991 - 1997","logoUrl":"https://someurl.com"}],"details":{"linkedinProfile":"https://someurl.com","connectedOn":"September 13, 2015"},"skills":[{"name":"Gravitation","endorsements":22},{"name":"Marsology","endorsements":21}],"allSkills":"Gravitation and Marsology","query":"UID_string","timestamp":"2021-12-09T11:58:50.191Z"}]

SCHEMA USED

{
  "type""array",
  "items": {
    "type""object",
    "properties": {
      "baseUrl": {
        "type""string"
      },
      "error": {
        "type""string"
      },
      "timestamp": {
        "type""string"
      },
      "general": {
        "type""object",
        "properties": {
          "imgUrl": {
            "type""string"
          },
          "fullName": {
            "type""string"
          },
          "headline": {
            "type""string"
          },
          "location": {
            "type""string"
          },
          "profileUrl": {
            "type""string"
          },
          "connectionDegree": {
            "type""string"
          },
          "mutualConnectionsText": {
            "type""string"
          },
          "description": {
            "type""string"
          },
          "subscribers": {
            "type""string"
          },
          "firstName": {
            "type""string"
          },
          "lastName": {
            "type""string"
          },
          "company": {
            "type""string"
          },
          "school": {
            "type""string"
          }
        }
      },
      "jobs": {
        "type""array",
        "items": {
          "type""object",
          "properties": {
            "companyUrl": {
              "type""string"
            },
            "companyName": {
              "type""string"
            },
            "jobTitle": {
              "type""string"
            },
            "dateRange": {
              "type""string"
            },
            "location": {
              "type""string"
            },
            "logoUrl": {
              "type""string"
            }
          },
          "required": [
            "companyUrl",
            "companyName",
            "jobTitle",
            "dateRange",
            "location",
            "logoUrl"
          ]
        }
      },
      "schools": {
        "type""array",
        "items": {
          "type""object",
          "properties": {
            "schoolUrl": {
              "type""string"
            },
            "schoolName": {
              "type""string"
            },
            "degree": {
              "type""string"
            },
            "dateRange": {
              "type""string"
            },
            "logoUrl": {
              "type""string"
            }
          },
          "required": [
            "schoolUrl",
            "schoolName",
            "degree",
            "dateRange",
            "logoUrl"
          ]
        }
      },
      "details": {
        "type""object",
        "properties": {
          "linkedinProfile": {
            "type""string"
          },
          "connectedOn": {
            "type""string"
          }
        }
      },
      "skills": {
        "type""array",
        "items": {
          "type""object",
          "properties": {
            "name": {
              "type""string"
            },
            "endorsements": {
              "type""integer"
            }
          },
          "required": [
            "name",
            "endorsements"
          ]
        }
      },
      "allSkills": {
        "type""string"
      },
      "query": {
        "type""string"
      }
    },
    "required": [
      "timestamp"
    ]
  }
}
1 ACCEPTED SOLUTION

Accepted Solutions
mahoneypat
Dual Super User
Dual Super User

You can add a Filter Array action before your Apply to each like so.  Then use the body of the Filter as the input to your Apply to each.

 

mahoneypat_0-1639141755619.png

 

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
mahoneypat
Dual Super User
Dual Super User

You can add a Filter Array action before your Apply to each like so.  Then use the body of the Filter as the input to your Apply to each.

 

mahoneypat_0-1639141755619.png

 

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thanks Pat! 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Users online (2,556)