Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Transforming JSON array to ABAP internal table

Former Member
15,682

Hi,

I have tried using the method - cl_fdt_json=>json_to_data to transform JSON to ABAP.

It worked for simple fields but for Arrays it failed.

Need  your expert opinion on this.

Regards,

Faiz

1 ACCEPTED SOLUTION
Read only

Former Member
3,240

Hi,

I was able to transform the data using

cl_fdt_json=>json_to_data( EXPORTING  iv_json = abap_string
                              CHANGING   ca_data = out_structure ).


Regards,

Faiz

Hi,

I was able to transform the data using

cl_fdt_json=>json_to_data( EXPORTING  iv_json = abap_string
                              CHANGING   ca_data = out_structure ).


Regards,

Faiz

4 REPLIES 4
Read only

Former Member
0 Likes
3,240

try as below


DATA: lv_json type string, "your json string

            lv_data type zstructure. "your structure


DATA(lr_reader) = cl_sxml_string_reader=>create( cl_abap_codepage=>convert_to( lv_json ) ).
       CALL TRANSFORMATION id
         SOURCE XML lr_reader
         RESULT data = lv_data.

Read only

Sandra_Rossi
Active Contributor
0 Likes
3,240

Mohammad is right, in that you should use the official way for handling JSON, i.e. use sXML classes (as per the ABAP documentation, read it please).

What we don't know, is the exact type of your internal table containing the JSON, and if it's of byte type in which code page the JSON is stored...

Read only

Former Member
3,241

Hi,

I was able to transform the data using

cl_fdt_json=>json_to_data( EXPORTING  iv_json = abap_string
                              CHANGING   ca_data = out_structure ).


Regards,

Faiz

Read only

0 Likes
3,240

Hi Faizur,

Greeting of the day,

Thank you very much.... It is 100% working.

Regrads,

Srinivasa Reddy.