ABAP and JSON? Didn’t we had that before? Yes we had but since the JSON support was made available in Release 7.40 and downported to 7.02 and 7.31 (SAP Notes 1648418 and 1650141) it shouldn’t be missed in a systematic overview over all important ABAP News for Release 7.40.
I will take the chance to shortly wrap up the facts about ABAP and JSON and point to the documentation where you can learn more.
ABAP and JSON
The support of JSON in ABAP is based on the support of XML (but note that JSON is not XML).
The trick is the usage of a JSON-XML-Format that maps JSON to XML and vice versa.
Like XML data, JSON data can be
- parsed or rendered
For parsing and rendering of JSON data XML-readers and XML-writers of the sXML-Library are made to JSON-readers and JSON-writers by using the special format IF_SXML=>CO_XT_JSON. A JSON-reader understands JSON data and renders it internally like JSON-XML. A JSON-writer understands JSON-XML and creates JSON from that input.
When serializing ABAP data to JSON and deseralizing from JSON data to ABAP, you deal with asJSON, the canonical representation of ABAP data. asJSON can be seen as the JSON-XML representation of asXML (although there is not such an intermediate step internally).