Do you know the situation? You are good at working with JSON, but the API only gives you XML text? Frustrated you sit there and down your coffee cup in one gulp and are already googling for a possibility to read XML with FileMaker and you know it will take a long time to inform about XML? Well, I can save you the googling, because you can also work with XML texts with the MBS FileMaker Plugin. But this is not the main topic today. The plugin offers you a way to convert XML text to JSON text.
For this we have the function "XML.ToJSON".
In the parameters we pass an XML.
Additionally, we can specify some options if we want to.
The options are always assigned a certain numerical value.
With the 1 we specify that we want to ignore errors that occur and parse the XML anyway. We read the XML but this can lead to the fact that the XML is not read completely in case of an error and the JSON is incomplete. The XML is read up to the error. The valid XML part is then parsed. The error is ignored. In this case the tag
The 2 defines whether the attributes should be directly embedded in the JSON or listed in a separate object.
The 4 converts values described with true and false into boolean values. If we specify 8, numbers will be read as numbers and not as text. This is only the case if you were not previously defined as text in the XML. If it is defined as text in the XML then it also stays as text.
With the 16 namespaces are displayed.
We can combine the options by adding the numbers and passing them as parameters to the function.
Have fun trying it out. If you have any questions you can contact us