web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to Dynamically Pro...
Power Apps
Suggested Answer

How to Dynamically Process Nested JSON in Power Apps Without Predefined Schema?

(2) ShareShare
ReportReport
Posted on by 1

I am working on a Power Apps application where I need to handle data returned from an API dynamically. The API response contains nested JSON objects, arrays, and sometimes objects within arrays. The challenge is that the structure of the JSON can change over time, making it impractical to hardcode field names or manually map properties.

Here are two examples of the API response structures I receive:

Example 1:

{
  "content": [
    {
      "name": "Marywood University",
      "alpha_two_code": "US",
      "domains": ["marywood.edu"],
      "country": "United States",
      "web_pages": ["https://www.google.com"],
      "state-province": null
    },
    {
      "name": "Lindenwood University",
      "alpha_two_code": "US",
      "domains": ["lindenwood.edu"],
      "country": "United States",
      "web_pages": ["https://www.google.com"],
      "state-province": null
    }
  ]
}

Example 2:

{
  "results": [
    {
      "gender": "female",
      "name": {
        "title": "Ms",
        "first": "Jessica",
        "last": "Perry"
      },
      "location": {
        "street": {
          "number": 8932,
          "name": "Manor Road"
        },
        "city": "Kilcoole",
        "state": "Meath",
        "country": "Ireland"
      },
      "email": "jessica.perry@example.com"
    }
  ]
}

I need to dynamically process this data in Power Apps without hardcoding field names, while still accommodating changes in the API's response format.
 
The Method I try is:
  1. Tried Flattening in Power Apps:

    • I used functions like ParseJSON, Table, and ForAll to dynamically extract the properties of the JSON. However, Power Apps lacks native support for iterating over object properties or handling arrays within nested JSON dynamically.
  2. Tried Key-Value Pair Mapping:

    • I attempted to extract key-value pairs from the JSON using nested ForAll loops, but encountered errors like Name isn't valid or Text function has invalid arguments when processing dynamic fields like PropertyName and PropertyValue.

Expected Outcome:
I want to create a solution where Power Apps can dynamically process JSON data (including nested objects and arrays), regardless of the structure, and display it in a gallery or collection without requiring manual adjustments each time the API changes.

 
  • Suggested answer
    RahulAnsari37 Profile Picture
    86 on at

    Hey,

    I completely understand your frustration. You are running into a hard boundary of how Power Fx handles untyped objects.

    The short answer is: Power Apps cannot natively iterate over unknown JSON keys.

    While the ParseJSON() function successfully creates an untyped object, Power Apps does not have a "reflection" function (like Object.keys() in JavaScript) to dynamically read the property names. To extract data from an untyped object, the platform strictly requires you to hardcode the dot-notation path (e.g., Value.name.first).

    To achieve your expected outcome, you must transform that dynamic JSON into a predictable schema before it is parsed by your Canvas App.

    The Solution: Standardized Key-Value Arrays
    You need a middleman (typically a Power Automate flow) to intercept the API response and flatten the nested, unpredictable JSON into a strict array of Key/Value pairs.

    Instead of returning the raw API response to Power Apps, use a flow to flatten the payload. Because Power Automate also struggles with dynamic keys natively, the easiest way to do this is by passing the JSON into an "Execute JavaScript Code" action (Premium) or through a Custom Connector using a simple script. If you haven't set up JS in a flow before,here is an excellent step-by-step guide on how to execute JavaScript in Power Automate.

    You want the script to traverse the JSON and output a flat array formatted exactly like this:

    [
      { "Property": "name.title", "Value": "Ms" },
      { "Property": "name.first", "Value": "Jessica" },
      { "Property": "location.city", "Value": "Kilcoole" },
      { "Property": "email", "Value": "jessica.perry@example.com" }
    ]

    Once your flow returns this structured, standardized array to Power Apps, your app's dynamic processing becomes effortless.

    You simply load that array into a collection and point your Gallery to it. You only need two text labels in the gallery: ThisItem.Property and ThisItem.Value.

    Using this method, if the API changes tomorrow and adds 20 new nested fields, your Canvas App requires zero manual adjustments. The flow's script will automatically catch the new fields, convert them into new rows in the array, and your gallery will seamlessly populate them.

    ✅ If this helps solve the issue, please mark it as a Verified Answer so others facing a similar issue can find it easily. Thanks!!

  • Suggested answer
    WarrenBelz Profile Picture
    156,754 Most Valuable Professional on at
    The first thing I suggest you read is this article on the ParseJSON function - I believe it will do what you require.
     
    Please ✅ Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like ♥
    Visit my blog
    Practical Power Apps    LinkedIn  
  • Suggested answer
    M Bilal Khan Profile Picture
    1,160 on at

    If the API schema can genuinely change over time, I wouldn't try to recursively flatten the entire JSON inside Power Apps.

    ParseJSON() is useful when you know what you want to extract, but Power Fx doesn't have a simple native equivalent of something like Object.keys() that lets you recursively enumerate every property of an unknown JSON object. That's why the dynamic PropertyName / PropertyValue approach becomes difficult.

    I'd use Power Automate (or an API/backend layer) as the JSON transformation step:

    API → Power Automate → normalize JSON → Power Apps

    For example, have the flow recursively walk the JSON and return a generic table such as:

    Path                         Value              Type
    -------------------------------------------------------
    content[0].name              Marywood University String
    content[0].alpha_two_code    US                 String
    content[0].domains[0]        marywood.edu       String
    content[0].state-province    null               Null
    results[0].name.title        Ms                 String
    results[0].name.first        Jessica            String
    results[0].location.city     Kilcoole            String
    results[0].location.street.number 8932           Number
    

    Then Power Apps doesn't need to know whether the response contains content, results, name, location, etc. It simply displays the returned Path / Value / Type collection.

    If you only need to support a few known response shapes, I'd actually recommend not making it completely dynamic. Define the schema and use ParseJSON() + ForAll() directly in Power Apps. It's much easier to maintain and gives you strongly typed data.

    But if the requirement is truly:

    “The API can introduce/remove/rename properties and the app must continue working without changes”

    then I'd put the recursive JSON processing outside Power Apps.

    One other option is to return the JSON as-is and build a custom PCF control to recursively render the object. That makes sense if you need a generic JSON viewer directly inside the canvas app, but for most business apps I'd keep the transformation in Power Automate/backend and let Power Apps consume a simple table.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 271

#3
Mohsin Ali Profile Picture

Mohsin Ali 223

Last 30 days Overall leaderboard