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

Store Complex JSON in collection

Hello experts,

 

I have data in complex JSON format, i want to store all address in Collection, which reside under resourceSets -> resources -> value 

 

{
"authenticationResultCode": "",
"brandLogoUri": "",
"copyright": "",
"resourceSets": [
{
"estimatedTotal": 1,
"resources": [
{
"__type": "",
"value": [
{
"__type": "LocalBusiness",
"address": {
"countryRegion": "Norway",
"locality": "Oslo",
"adminDistrict": "Oslo",
"countryRegionIso2": "Nw",
"addressLine": "City Road",
"formattedAddress": "City Road"
},
"name": "City BT"
},
{
"__type": "LocalBusiness",
"address": {
"countryRegion": "Norway",
"locality": "Oslo",
"adminDistrict": "Oslo",
"countryRegionIso2": "Nw",
"addressLine": "BT Station Road",
"formattedAddress": "BT Station Road"
},
"name": "City Bus"
}
]
}
]
}
],
"statusCode": 200,
"statusDescription": "OK",
"traceId": ""
}

 

 

How can i achieve this, please help!

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Hi @sachinsoni ,

Do you want to parse the JSON data within your app, and then retrieve the address attribute into a collection?

How do you get the JSON data? Using Custom connector?

 

If you want to  parse the JSON data within your app, and then retrieve the address attribute into a collection, I afraid that there is no way to achieve your needs in PowerApps currently.

 

Currently, within PowerApps, there is no function supported to parse a JSON data. If you would like this feature to be added in PowerApps, please submit an idea to PowerApps Ideas Forum:

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/idb-p/PowerAppsIdeas

 

As an alternative solution, I think the combination of Power Automate and Power Apps could achieve your needs. You could consider fire a flow from your canvas app, then parse the JSON data (JSON String value) within the flow, then retrieve the desired table value and return back to your canvas app.

 

I have made a test on my side, please take a try with the following workaround:

Flow's configuration:

6.JPG

Within the "Initialize variable" action, Value field set to following (the JSON String value you mentioned above😞

{"authenticationResultCode":"","brandLogoUri":"","copyright":"","resourceSets":[{"estimatedTotal":1,"resources":[{"__type":"","value":[{"__type":"LocalBusiness","address":{"countryRegion":"Norway","locality":"Oslo","adminDistrict":"Oslo","countryRegionIso2":"Nw","addressLine":"City Road","formattedAddress":"City Road"},"name":"City BT"},{"__type":"LocalBusiness","address":{"countryRegion":"Norway","locality":"Oslo","adminDistrict":"Oslo","countryRegionIso2":"Nw","addressLine":"BT Station Road","formattedAddress":"BT Station Road"},"name":"City Bus"}]}]}],"statusCode":200,"statusDescription":"OK","traceId":""}

Within the "Response" action, Body field set to following expression:

json(variables('JSONString'))?['resourceSets'][0]?['resources'][0]?['value']

The "Response Body JSON Schema" field set to following:

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "__type": {
                "type": "string"
            },
            "address": {
                "type": "object",
                "properties": {
                    "countryRegion": {
                        "type": "string"
                    },
                    "locality": {
                        "type": "string"
                    },
                    "adminDistrict": {
                        "type": "string"
                    },
                    "countryRegionIso2": {
                        "type": "string"
                    },
                    "addressLine": {
                        "type": "string"
                    },
                    "formattedAddress": {
                        "type": "string"
                    }
                }
            },
            "name": {
                "type": "string"
            }
        },
        "required": [
            "__type",
            "address",
            "name"
        ]
    }
}

 

App's configuration:

 

7.JPG

Firstly, you need to add your above flow connection into your canvas app, then bind it to the "FireFlowToParse" button. Set the OnSelect property of the "FireFlowToParse" button to following:

ClearCollect(ReturnedResult,'PowerApp->Initializevariable,Response'.Run());
Clear(AddressCollection);
ForAll(
      ReturnedResult,
      Collect(AddressCollection, address)
)

The AddressCollection would be populated with proper records as below:

8.JPG

Please consider take a try with above solution, check if the issue is solved.

 

If the JSON data you mentioned is from your custom connector, you could consider add the custom connector action in your flow to send HTTP request, then try above solution, returned desired table value back to your canvas app.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Highlighted
Community Support
Community Support

Hi @sachinsoni ,

Do you want to parse the JSON data within your app, and then retrieve the address attribute into a collection?

How do you get the JSON data? Using Custom connector?

 

If you want to  parse the JSON data within your app, and then retrieve the address attribute into a collection, I afraid that there is no way to achieve your needs in PowerApps currently.

 

Currently, within PowerApps, there is no function supported to parse a JSON data. If you would like this feature to be added in PowerApps, please submit an idea to PowerApps Ideas Forum:

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/idb-p/PowerAppsIdeas

 

As an alternative solution, I think the combination of Power Automate and Power Apps could achieve your needs. You could consider fire a flow from your canvas app, then parse the JSON data (JSON String value) within the flow, then retrieve the desired table value and return back to your canvas app.

 

I have made a test on my side, please take a try with the following workaround:

Flow's configuration:

6.JPG

Within the "Initialize variable" action, Value field set to following (the JSON String value you mentioned above😞

{"authenticationResultCode":"","brandLogoUri":"","copyright":"","resourceSets":[{"estimatedTotal":1,"resources":[{"__type":"","value":[{"__type":"LocalBusiness","address":{"countryRegion":"Norway","locality":"Oslo","adminDistrict":"Oslo","countryRegionIso2":"Nw","addressLine":"City Road","formattedAddress":"City Road"},"name":"City BT"},{"__type":"LocalBusiness","address":{"countryRegion":"Norway","locality":"Oslo","adminDistrict":"Oslo","countryRegionIso2":"Nw","addressLine":"BT Station Road","formattedAddress":"BT Station Road"},"name":"City Bus"}]}]}],"statusCode":200,"statusDescription":"OK","traceId":""}

Within the "Response" action, Body field set to following expression:

json(variables('JSONString'))?['resourceSets'][0]?['resources'][0]?['value']

The "Response Body JSON Schema" field set to following:

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "__type": {
                "type": "string"
            },
            "address": {
                "type": "object",
                "properties": {
                    "countryRegion": {
                        "type": "string"
                    },
                    "locality": {
                        "type": "string"
                    },
                    "adminDistrict": {
                        "type": "string"
                    },
                    "countryRegionIso2": {
                        "type": "string"
                    },
                    "addressLine": {
                        "type": "string"
                    },
                    "formattedAddress": {
                        "type": "string"
                    }
                }
            },
            "name": {
                "type": "string"
            }
        },
        "required": [
            "__type",
            "address",
            "name"
        ]
    }
}

 

App's configuration:

 

7.JPG

Firstly, you need to add your above flow connection into your canvas app, then bind it to the "FireFlowToParse" button. Set the OnSelect property of the "FireFlowToParse" button to following:

ClearCollect(ReturnedResult,'PowerApp->Initializevariable,Response'.Run());
Clear(AddressCollection);
ForAll(
      ReturnedResult,
      Collect(AddressCollection, address)
)

The AddressCollection would be populated with proper records as below:

8.JPG

Please consider take a try with above solution, check if the issue is solved.

 

If the JSON data you mentioned is from your custom connector, you could consider add the custom connector action in your flow to send HTTP request, then try above solution, returned desired table value back to your canvas app.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (8,788)