How-To: Convert XML to JSON
This article provides guidance for converting XML data to JSON in HighByte Intelligence Hub.
What Does This Article Cover?
- Reading XML Files
- Convert XML data to JSON format
- Other related material
Reading XML files
The File Connection in version 4.1 and greater has the ability to decode the file contents automatically. In the screen shot below, the File Connection is reading an XML file as an input. The File Encoding is set to Auto. The File Connection will automatically decode the input into an XML payload. See Results. The XML file for this example can be found here.
Convert XML data to JSON format
The screenshot below shows a pipeline that convers the XML to JSON. The first stage read the Sample.xml setup in the previous step. Since the XML is not an object, it needs to be read in into a Key named XMLFile. The SetXMLFileAsParent stage will move XMLFile key to the top level of the message. The message is now ready to convert to JSON.
The XML Parser stage reads the XML string to JSON. The Incoming Type = String. If the file was still in Binary format, the Incoming Type would need to be set to File. The result is the XML data in JSON format.
Other related material: