Hi,
I'm using the json funtion to convert from xml with this structure
As you can see, some elements have several children, some have no children and some have only one.
The problem when converting to json is that those who have several children get an array of 'Child' but those with just one child get an object, as seen below:
This causes a problem when formatting the json in the Parse JSON node.
The schema I'm going for is this:
But when trying to parse the json I get this error:
If I change the schema to expect an object, the same thing happens but with reversed.
Is there a way to force the 'Child' nodes to convert always as an array whether there's one or many of them?
I hope I made myself clear.
Thank you in advance.
Solved! Go to Solution.
Hi @AyCN
I did tested this now.
If you add the additional types it should work. Its similar to @Pstork1 suggested.
Here is my test result
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogI don't know of any way to impose a format on the conversion. But you can fix the error in the parse JSON by changing the type to expect either an array or a string value. But that won't really solve the problem since you'll now have to treat each Child value differently when you go to use them. Here's the fix for the JSON schema
"Child": {
"type": [
"array",
"string"
],
"items": { }
}
Hi @AyCN
I did tested this now.
If you add the additional types it should work. Its similar to @Pstork1 suggested.
Here is my test result
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blog@abm Adding the additional types is exactly what I recommended. The only problem is that now the Child element may be a string or an array. The rest of the flow will have to deal with that, which could be a problem.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.