JSON-XML - XML Representation of JSON
7.31 | 7.40 | 7.54
The components of arrays, separated by commas, are mapped as subelements of the element <array>, but the type-specific mapping rule applies to each element.
The components of objects, separated by commas, are mapped as subelements of the element <object>. There are two representation methods:
- "n":... → <... name="n">...</...>
- "n":... → <member name="n"><...>...</...></member>
In the shorter method, used by default, a component is mapped like an element of an array, with the name n added to the type-specific XML element of the component as the content of the attribute name.
In the second longer method, the type-specific XML element of a component is nested in an additional element <member>, which then has the attribute name with the name of the component.
- In the longer alternative for object components, each component in JSON-XML is identified clearly by a <member> element. This can make it easier to distinguish objects of arrays if only partial fragments of JSON data are being edited.
- The longer alternative for object components with <member> elements can be a better option for simple transformations, when ABAP data is serialized to JSON or deserialized from JSON.
- A JSON writer that renders JSON-XML to JSON accepts both alternatives for object components. A JSON reader that parses JSON data to JSON-XML creates the shorter variant by default. To create the longer variant with <member> elements, the method SET_OPTION of the interface IF_SXML_READER can be used to set the option IF_SXML_READER=>CO_OPT_SEP_MEMBER.
- The program DEMO_JSON_XML shows examples of the default JSON-XML representation of valid JSON data.
- For information about the rendering and parsing of JSON-XML representations in both alternatives for object components, see Object Components in JSON-XML.