Skip to Content
Author's profile photo Kerem Koseoglu

Parsing JSON in ABAP

SAP ECC has two beautiful classes for JSON parsing operations.

/ui2/cl_json is useful in case you know the structure of the JSON file. Similar to the CALL TRANSFORMATION command; you can parse a JSON string directly if you have a corresponding nested structure. This class is very forgiving too; it doesn’t raise any exceptions if your structure has missing or excess fields. Turning a nested ABAP structure into a JSON string is also possible.

/ui5/cl_json_parser is useful in case you don’t know the exact structure of the JSON file. When you pass the JSON string to this class, it simply transforms the data into an internal table of key / value pairs. It is your responsibility to loop through this ITAB to fetch whatever you are looking for. It doesn’t transform your nested structure into JSON format at this time though – it parses JSON strings only.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Thanks, it makes life a lot easier in many cases where writing the XSLT or ST codes were testing and very annoying. JSON feels easier to handle.

      Author's profile photo Alexey Arseniev
      Alexey Arseniev

      Hi Kerem,

      recent versions of /UI2/CL_JSON can now deserialize completely unknown or partially unknown structures (explicit or implicit data generation). As result, you will get a dynamically created ABAP object you can traverse as any other ABAP object with unknown structure (using ASSIGN ...) or with helper classes for dynamic access. See details in the description of the class.

      Best regards,


      Author's profile photo DTPL Basis
      DTPL Basis

      How do i convert boolean & null to json using /UI2/CL_JSON