SAP 内表和JSON相互转换

report ztest4.

data:lv_json     type string,
     lt_scarr    type standard table of scarr.

select * into table lt_scarr from scarr up to 2 rows.

* 将内表转化为JSON
lv_json = /ui2/cl_json=>serialize( data = lt_scarr ).
cl_demo_output=>write( lv_json ).

* 将JSON转化为n内表
clear lt_scarr.
/ui2/cl_json=>deserialize( exporting json = lv_json changing data = lt_scarr ).
cl_demo_output=>write( lt_scarr ).
cl_demo_output=>display( ).

原文地址:https://www.cnblogs.com/freeandeasy/p/14115718.html