cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
monroehorn
Frequent Visitor

Parson JSON with Multiple Levels

Hello,

 

I am trying to build a flow that uses an API that returns the JSON below. I am able to get the response and use Parse JSON to parse it successfully, but I am having problems getting access to the collection of "resources." The JSON has a "meta" level and a "resources" level.

 

The JSON sample below only has one resource (a single contact) but ultimately it will have multiple resources.

 

Once I have parsed the JSON I want to go through and get the data from each resource and use it in the flow. When I add an Apply to Each step I get the following options:

parse options.jpg

 

I have used an Apply to Each to cycle through resources and also to cycle through items (which embeds it in an Apply to Each for resources). But I can never seem to get access to the actual properties of the item like the first name of a contact.

 

How can I setup my flow so that I have access to the fields for each item returned?

 

Thank you in advance!

 

 

 

 

{
  "meta": {
    "per_page": 1,
    "total": 186,
    "pages": 186,
    "page": 1
  },
  "resources": [
    {
      "updated": "2021-01-06T14:38:56-0500",
      "creator": "Monroe Horn",
      "object_type": "contact",
      "is_editable": true,
      "record_type": "person",
      "updater": "Monroe Horn",
      "is_important": null,
      "children": [],
      "company_last_contacted": {
        "out": {
          "user_id": "5f89ccd2f92ea1782bc8c173",
          "deletion_tstamp": null,
          "type": "message",
          "object_id": "6f13b31a-1c6d-ede3-7c2c-1ffe918fb7f5",
          "tstamp": "2020-12-22T23:42:53"
        },
        "in": {
          "user_id": "5f89ccd2f92ea1782bc8c173",
          "deletion_tstamp": "2020-12-23T00:44:35.516000",
          "type": "message",
          "object_id": "76a33628-27f5-7275-19a2-46ce026fc988",
          "tstamp": "2020-12-23T00:08:51"
        }
      },
      "created": "2020-10-26T12:27:53-0400",
      "fields": {
        "parent company": [
          {
            "is_primary": false,
            "modifier": "",
            "extra_value": "5f96f909f92ea11d6dc855d5",
            "value": "Goulston & Storrs",
            "label": "parent company"
          }
        ],
        "first name": [
          {
            "is_primary": false,
            "modifier": "",
            "value": "Angel",
            "label": "first name"
          }
        ],
        "last name": [
          {
            "is_primary": false,
            "modifier": "",
            "value": "Garcia-Manso",
            "label": "last name"
          }
        ],
        "title": [
          {
            "is_primary": false,
            "modifier": "",
            "value": "PMO Director",
            "label": "title"
          }
        ],
        "linkedin": [
          {
            "is_primary": false,
            "modifier": "",
            "value": "https://www.linkedin.com/in/angelgarciamanso",
            "label": "linkedin"
          }
        ],
        "lead status": [
          {
            "is_primary": false,
            "modifier": "",
            "value": "Not Lead",
            "label": "lead status"
          }
        ],
        "discovered gender": [
          {
            "is_primary": false,
            "modifier": "",
            "value": "Male",
            "label": "discovered gender"
          }
        ],
        "phone": [
          {
            "is_primary": false,
            "modifier": "mobile",
            "value": "+1 (401) 793-1831",
            "label": "phone"
          }
        ],
        "email": [
          {
            "is_primary": false,
            "modifier": "work",
            "value": "agarcia225@gmail.com",
            "label": "email"
          }
        ],
        "lead type": [
          {
            "is_primary": false,
            "modifier": "",
            "value": "Colleague",
            "label": "lead type"
          }
        ]
      },
      "privacy": {
        "read": {
          "user_ids": [],
          "group_ids": []
        },
        "edit": {
          "user_ids": [],
          "group_ids": []
        }
      },
      "id": "5f96f909f92ea11d6dc855d0",
      "last_contacted": {
        "user_id": "5f89ccd2f92ea1782bc8c173",
        "deletion_tstamp": "2020-12-23T00:44:35.516000",
        "type": "message",
        "object_id": "76a33628-27f5-7275-19a2-46ce026fc988",
        "tstamp": "2020-12-23T00:08:51"
      },
      "creator_id": "5f89ccd2f92ea1782bc8c173",
      "avatar_url": "https://nimbleappcdn.azureedge.net/api/avatars/5b5af0359a4d8a278407e6a7/5f96f909f92ea11d6dc855d0/person/2",
      "reminder": null,
      "owner_id": "5f89ccd2f92ea1782bc8c173"
    }
  ]
}

 

 

 

 

 
1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User
Super User

It's a bit of a tricky one because although it is easy to get to the bit you want which is all under "fields". Everything within that is an array, such as:

"first name": [
          {
            "is_primary": false,
            "modifier": "",
            "value": "Angel",
            "label": "first name"
          }
        ]

You wouldn't normally expect something like first name to be in an array, because how many first names can you really have 😂

 

Same with gender, you can't be multiple genders (or maybe you can thesedays). But you get my point. Are you ever expecting to get more than one value in these arrays? If not you can use a first expression to avoid any loops. 

 

Would you like me to knock something together for you quick? What fields are you actually interested in?

View solution in original post

2 REPLIES 2
Paulie78
Super User
Super User

It's a bit of a tricky one because although it is easy to get to the bit you want which is all under "fields". Everything within that is an array, such as:

"first name": [
          {
            "is_primary": false,
            "modifier": "",
            "value": "Angel",
            "label": "first name"
          }
        ]

You wouldn't normally expect something like first name to be in an array, because how many first names can you really have 😂

 

Same with gender, you can't be multiple genders (or maybe you can thesedays). But you get my point. Are you ever expecting to get more than one value in these arrays? If not you can use a first expression to avoid any loops. 

 

Would you like me to knock something together for you quick? What fields are you actually interested in?

monroehorn
Frequent Visitor

That would be amazing. Thank you so much. I'm most interested in First Name, Last Name, and email addresses.

 

I will be getting more than one pretty much all the time. I just pulled one back to keep the JSON sample short. I think the structure is strange, too. I don't see how I would have a "primary" first name or "primary" gender. It seems like they took properties that would be more complicated, like an address or phone number, and applied the same logic to all of the properties.

 

Thanks again!

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.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

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

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.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,115)