码迷,mamicode.com
首页 > Web开发 > 详细

ABAP JSON转换

时间:2017-11-08 17:50:12      阅读:323      评论:0      收藏:0      [点我收藏+]

标签:epo   xxxx   抓取数据   exp   import   imp   stat   cti   取数据   

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[].
  CALL METHOD 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转换

标签:epo   xxxx   抓取数据   exp   import   imp   stat   cti   取数据   

原文地址:http://www.cnblogs.com/caizjian/p/7804327.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!