Skip to Content

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.

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. 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,

    Alexey.

    (4) 

Leave a Reply