sXML library for XML and JSON
In this chapter, we will handle conversion of the XML format to JSON format. It's become much easier since releases 7.02 and 7.03/7.31 (Kernelpatch 116), as JSON is now natively supported. To handle JSON format, we will use the sXML library.
Before we start, there are a few important things to mention:
- In SAP, we will be dealing with so-called JSON-XML. It's a special XML format that enables JSON data to be described using an XML representation.
- In sXML, JSON is handled by a new format stored behind the constant value of the sXML interface,
IF_SXML=>CO_XT_JSON
.
- For serialization and deserialization we will be using transformation with identity ID.
JSON-XML format is required because ST can't interpret JSON; it can use only XML. So, the trick is to get the temporary format and then use the JSON writer class to convert it into the final format. So as to have a better understanding of what the JSON format is, analyze the following example:
//JSON { "CARRID...