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.


Posted

in

,

by

Tags:

Comments

2 responses to “Parsing JSON in ABAP”

  1. ilhan kazanci Avatar

    Thank you for these tips. I had an conflict when try to transport json data. / ui2 / cl_json deserialize method is useful but some json structured field name over 30 character. Unfortunately I could’t catch these fields. SAP have a solution but you need to import some SAP-note into the your SAP system.
    /ui5/cl_json_parser method is solved the problem. Than you again.

    1. Dr. Kerem Koseoglu Avatar

      Glad to be helpful!

Leave a comment