Hi Francis,
the matching structure would be:
DATA: BEGIN OF ls_data, field2 TYPE i, field3 TYPE string, BEGIN OF field4, field5 TYPE string, BEGIN OF field6, field7 TYPE string, field8 TYPE i, END OF field6, END OF field4, END OF ls_data.
And the code to deserialize using simple transformation:
"lv_json = `{"field1":{"field2":2,"field3":"value_b","field4":{"field5":"value_c","field6":{"field7":"value_d","field8":1}}}}`. lv_json = `{"FIELD1":{"FIELD2":2,"FIELD3":"VALUE_B","FIELD4":{"FIELD5":"VALUE_C","FIELD6":{"FIELD7":"VALUE_D","FIELD8":1}}}}`. CALL TRANSFORMATION id SOURCE XML lv_json RESULT field1 = ls_data.
But take into account, that your attribute names shall be written in upper case, otherwise, it would not work.
If this is not possible, you need to first traverse the whole JSON tree and transform all attribute names to upper cases. As it suggested in the standard program DEMO_JSON_NAMES_TO_UPPER (SE38).
BR, Alexey.
You can try CL_TREX_JSON_DESERIALIZER like per https://wiki.scn.sap.com/wiki/display/Snippets/One+more+ABAP+to+JSON+Serializer+and+Deserializer
You can also convert the same without transformation by using the classes provide by sap. Make sure the abap table is in the format of the json structure.
https://wiki.scn.sap.com/wiki/display/Snippets/One+more+ABAP+to+JSON+Serializer+and+Deserializer
BR,
Mahesh
This blog may have the information you want:
https://blogs.sap.com/2013/04/15/abap-2-json-and-json-2-abap-with-st/
Add comment