JSON2ABAPType: generating ABAP JSON data type is defined according to the structure

A paper figure shows that the tool will be introduced:

 

JSON is a common data format, often used for interface development. ABAP developers typically use / ui2 / cl_json to convert to the corresponding ABAP JSON data type .

Before the conversion, ABAP must define the appropriate type, for example, if the data to be converted as follows JSON,

{
    "KEY1": "VALUE1",
    "KEY2": "VALUE2"
}

ABAP must define the appropriate structure type,

TYPES: BEGIN OF t_record,
        key1 TYPE string,
        key2 TYPE string,
       END OF t_record.

Conversion code is as follows,

types: begin of t_record,
         key1 type string,
         key2 type string,
       end of t_record.

data: json type string.
data: record type t_record.

json = '{"key1": "VALUE1",  "key2": "VALUE2"}'.

/ui2/cl_json=>deserialize( exporting json = json changing data = record ).

This is a simple example, if a complex JSON format, record type definition will become a work of dedicated ... not only takes time and effort handwriting structure definition, once the error, but also spend a lot of time to troubleshoot error .

 

JSON2ABAPType is an open source tool that can automatically generate ABAP data structure defined by the JSON, JSON supports complex structure can save time and effort of developers.

 

Project Address: https://github.com/fidley/JSON2ABAPType

 

Precautions:

1, the latest version of the tool is dependent / ui2 / cl_json, if your older version, you can play needs related SAPNotes ( 2,526,405  , 2629179 ).

2, JSON data field can be omitted, pay attention to generate ABAP defined by the complete JSON structure, or it may generate an incomplete definition of ABAP (thanks ABAP shiny tips).

3, recommended ABAPGIT install it.

 

After installation, run the program using transaction code SE38 ZJSON2ABAPTYPE.

 

Guess you like

Origin www.cnblogs.com/hhelibeb/p/11646238.html