Skip to Content
0
Former Member
Nov 07, 2018 at 11:08 AM

Need to Convert json to abap structure but having problems

1767 Views

So I am doing a get request to a webservice and getting from that a json.

The problem is that I am not able to convert it and I have tried three ways but all failed.

Try 1

I used the method cl_fdt_json=>json_to_data

call method cl_fdt_json=>json_to_data
        exporting
          iv_json = gv_response
        changing
          ca_data =  gt_data_json.

And the table in output remains initial .

Try 2

data gr_json_deserializer type ref to cl_trex_json_deserializer
create object gr_json_deserializer.
    call method gr_json_deserializer->deserialize
     exporting
        json = gv_response
      importing
        abap = gt_data_json.

Try 3

CALL TRANSFORMATION id
           SOURCE XML gv_response
           RESULT data = gt_data_json.

None of this is working .

Here is the json that has to be converted:

json.txt

This is the structure I used to handle this.

types: begin of zstockblock,
           qty_ordered type i,
           sku         type string,
           end of zstockblock.


    types: begin of z_stockblock_v,
           entity_id type i,
           items     type zstockblock,
           total_count type i,
          end of z_stockblock_v.
data gt_data_json    type table of z_stockblock_v

Don't look at the data type since I was going to change them if it was going to work

Can anyone help me ? I am stuck

Attachments

json.txt (801 B)