Hi,
I recently switch from using Power Automate Parse JSON action to Power Apps ParseJSON (preview) to later on compose array because for flow it took too long for the end user.
When I tried to do so by following documentation I have got an error which I'm reporting because it may be an easy fix.
Bullet points:
1. JSON to be parsed stored in JsonString_1 control (TextInput):
{
"Data": [
{
"MATCH": {
"0": {
"TEXT": "ABC",
"SCORE": 1
}
}
}
]
}
2. This is external response so it is as it is - not possible to change (I modified it to reflect only necessary part)
3. As you see this is nested, but even tho it should be easily possible to extract.
4. "0":{ part cause the problem
5. Formula which should work but IS NOT WORKING:
ForAll(
Table(
ParseJSON(
JsonString_1.Text
).Data
)
,{
TEXT: Text(
ThisRecord.Value.MATCH.0.TEXT
)
,SCORE: Value(
ThisRecord.Value.MATCH.0.SCORE
)
}
)
6. In order for this to work I need to use Substitute function to replace "0":{ with anything else than number - in my case it is "ALL":{
7. It is not possible to hardcode ""0":{" in Substitute function because of misinterpretation of " so I need to call datasource (Dataverse in my case) to retrieve both old text and new text for Substitute function.
8. After Substitution JSON look like below
{
"Data": [
{
"MATCH": {
"ALL": {
"TEXT": "ABC",
"SCORE": 1
}
}
}
]
}
9. And ParseJSON code which IS WORKING look like below
ForAll(
Table(
ParseJSON(
JsonString_1.Text
).Data
)
,{
TEXT: Text(
ThisRecord.Value.MATCH.ALL.TEXT
)
,SCORE: Value(
ThisRecord.Value.MATCH.ALL.SCORE
)
}
)
10. In my case I'm pretty sure that zero in this part: "0":{ caused error.
I hope I was clear enough to explain this error - if not feel free to reach out to me for more details 🙂
It would be great not to be forced to use such a way around because it may not be so obvious for everyone.