Well, its no surprise. They give us a potentially useful function like ParseJSON(), but the execution is convoluted. The example given in the documentation show putting the JSON string into quotes, and double-quoting text devices within the string. Of course, there is no straight forward way to do this.... is there?
https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-parsejson
The JSON I want to convert to a table is simple, and in a very tidy JSON file shown here:
[
{
"WorkOrderOB": "7307-18",
"Action": "Updated"
},
{
"WorkOrderOB": "4305-1",
"Action": "Created"
}
]
I dont like the idea of using Substitute() because you cannot be sure that a quote is not in the string. I thought this was going to be easy, once I got the JSON string from Flow into PA. Well, now there is another convoluted issue to overcome.
The example given is this:
ForAll( Table( ParseJSON( "[ { ""id"": 1, ""name"": ""one"" }, { ""id"": 2, ""name"": ""two"" } ]" ) ), { id: Value(ThisRecord.Value.id), name: Text(ThisRecord.Value.name) } )
This is the format that makes this statement work. But, how do I reliably get this format?
ForAll( Table( ParseJSON( "[
{
""WorkOrderOB"": ""7307-18"",
""Action"": ""Updated""
},
{
""WorkOrderOB"": ""4305-1"",
""Action"": ""Created""
}
]" ) ), { WorkOrderOB: Text(ThisRecord.Value.WorkOrderOB), Action: Text(ThisRecord.Value.Action) } )