ABAP JSON轉換
阿新 • • 發佈:2017-11-08
str zcl val export blog begin name obj serialize
REPORT ztest_json. DATA: json_ser TYPE REF TO cl_trex_json_serializer, json_des TYPE REF TO zcl_trex_json_deserializer. TYPES:BEGIN OF zsml, functionname(30), bcpcode(30), status(1), msg(256), result(1024), END OF zsml. DATA ls_json TYPE zsml. DATA lt_json TYPE TABLE OF zsml.DATA lv_json TYPE string. * 設置報文內容(json格式字符串) ls_json-functionname = ‘XXXXXX‘. ls_json-bcpcode = ‘20170214000000‘. ls_json-status = ‘S‘. ls_json-msg = ‘請調用接口抓取數據‘. ls_json-result = ‘‘. APPEND ls_json TO lt_json. * 內表->JSON CREATE OBJECT json_ser EXPORTING DATA = lt_json[]. CALLMETHOD json_ser->serialize. CALL METHOD json_ser->get_data RECEIVING rval = lv_json. *JSON->內表 CREATE OBJECT json_des. CLEAR lt_json. CALL METHOD json_des->deserialize EXPORTING json = lv_json IMPORTING abap = lt_json[].
ABAP JSON轉換