09-01-2022 2:30 AM
Hi,
I have an incoming Json string into my RFC function module. I need to parse this into a ABAP structure.
As there would be too many fields coming from the Json string, is there a way I can only parse the fields
that I need into my internal table / structure?
Appreciate if you could share any sample code.
09-01-2022 6:21 AM
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.
09-01-2022 6:21 AM
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.
09-01-2022 2:50 PM
Thanks, looks like /ui5/cl_json_parser is useful in my case as I am not aware of the Json structure.
Do you have a sample how i can use this class?
09-02-2022 7:56 AM
ramesh.putta here is a sample ABAP code; which reads data from Jira and parses the JSON response over /ui5/cl_json_parser: ycl_ticksys_jira_reader.clas.abap
09-01-2022 7:12 AM
You should tell us what JSON parsing technology you want to use. How to parse JSON has been asked so many times in the forum.