ParseJSON
JSON is an acronym for JavaScript Object Notation
Most of the REST API use this format to patch or get or delete the data in/from the server as it is lightweight object. it can easily transfered over network calls.
PS: REST stands Representational State Transfer and it is a software architecture that imposes conditions on how an API should work. (you can find more this architecture over internet)
To use a rest API in your power apps application we have to use custom connector or power automate http action to get the required results. As by standards rules of rest API, it will return the result in the JSON format but power apps won’t the JSON object yet.
Though we can format the expected result in power automate and pass it to canvas app but if the JSON has nested or complex the power automate will take more time and it will return a timeout error as we have only two minutes to maintain the connection between canvas app and power automate( this two minute for every call not for all calls).
To tackle this kind of scenario we have a function in canvas app which is ParseJSON.
ParseJSON will take a single parameter (string of JSON) and returns an untyped object.
Get Vidyadhar Baratam’s stories in your inbox
Join Medium for free to get updates from this writer.
Canvas App/Power Apps won’t understand untyped object. We have type cast the result accordingly.
Below is the syntax:
ParseJSON( JSONString )
- JSONString — Required. The JSON structure represented as text.
Example:
Consider below is the response from server
{
"parent": {
"child": "Naruto"
},
"age": 2
}First, we have to store in the variable as string but we can directly store above response in a variable. It will throw an error to avoid that we have to add escape character to avoid/prevent.
Set(varJSON,"{ \""parent\"": { \""child\"": \""Naruto\"" }, \""age\"": 2 }");Once, everything is in place we can easily fetch values.
For example to get child value, write the formula as shown below
Text( ParseJSON( Substitute(varJSON,"\","") ).parent.child )
//output: Naruto
/*
Remember to remove the escape character that,
we have added to store in a variable.
To remove, use Substitute function as written in above formula.
*/
Text( ParseJSON( Substitute(varJSON,"\","") ).age )
//output: 2Same, we can apply for array of values as well.
Hope this helps.
Thank you🙂🙂









