Previously I wrote an article on how to convert between SOAP XML to REST JSON object and vice-versa. In short it was using a simple logic as shown:
— If XML is valid then will be converted to JSON
if XMLInput <> ‘’ then
SET OutputRoot.JSON.Data = InputRoot.XMLNSC;
end if;
— If JSON is valid then will be converted to XML
if JSONInput <> ‘’ then
SET OutputRoot.XMLNSC.Root = InputRoot.JSON.Data;
end if;
The problem with that conversion is that if I pass an xml list as an input, it will return me a JSON object with multiple key value pairs of the same name. It isn’t equal to JSON Array and the JSON string that is returned isn’t even a valid JSON object. So in this tutorial, I am creating a wrapper function to create a JSON Array from XML List.
#xml #esql #ibm-app-connect #ibm #json-array #json