I'm fetching XML data from a third party service. Sometimes I get a lots of results and other times I get none or one result.
<NOTICIAS>
<NOTICIA>
<clippingId>9ac48930-d1b5-4890-9347-ccc6b464e49d</clippingId>
<TITULO>SPARK Matosinhos: reabilitação inteligente</TITULO>
</NOTICIA>
</NOTICIAS>
When Applying:
json(xml(outputs('Compose')))
The behavior is uncontrollable.
If <NOTICIAS> has no children it will be of type string instead of object. I managed to solve this one though it creates complexity for such a simple task. Just checked the length if is zero, it is a string and nothing is done.
If only one <NOTICIA> the type of it will be of object
If many <NOTICIA> will be of type array
So parsing will not work. Or if I say that <NOTICIA> is of type: ["array","object"], it will parse but I am not able to condition to do something if object and another if an array. I cannot use length strategy again as it does not apply to objects.
Is there a way to check if it is an object or an array, so I can use a condition?
Or even better, is there any solution to control how JSON() parses the string?