首页 > 代码库 > ABAP 内表数据 与 Json串 相互转换

ABAP 内表数据 与 Json串 相互转换

  DATA: json_ser TYPE REF TO CL_TREX_JSON_SERIALIZER,  
            json_des TYPE REF TO CL_TREX_JSON_DESERIALIZER.  
  DATA: jsonstr TYPE string.

  CREATE OBJECT json_ser  
    EXPORTING  
      data = itab[].  
  CALL METHOD json_ser->SERIALIZE.  
  CALL METHOD json_ser->GET_DATA  
    RECEIVING  
      rval = jsonstr.  

 

  CREATE OBJECT json_des.  
  CALL METHOD json_des->DESERIALIZE  
    EXPORTING  
      json = jsonstr  
    IMPORTING  
      abap = itab[]. 

 

ABAP 内表数据 与 Json串 相互转换