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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s