<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Need to Convert json to abap structure but having problems in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-convert-json-to-abap-structure-but-having-problems/m-p/694636#M31343</link>
    <description>&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The CL_FDT_CLASS will work. There needs to be a little conversion before you pass values into the class.Check this link&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://answers.sap.com/questions/383255/how-to-convert-json-response-from-rest-api-to-abap.html" target="test_blank"&gt;https://answers.sap.com/questions/383255/how-to-convert-json-response-from-rest-api-to-abap.html&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Nov 2018 15:45:03 GMT</pubDate>
    <dc:creator>former_member593648</dc:creator>
    <dc:date>2018-11-07T15:45:03Z</dc:date>
    <item>
      <title>Need to Convert json to abap structure but having problems</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-convert-json-to-abap-structure-but-having-problems/m-p/694635#M31342</link>
      <description>&lt;P&gt;So I am doing a get request to a webservice and getting from that a json.&lt;/P&gt;
  &lt;P&gt;The problem is that I am not able to convert it and I have tried three ways but all failed.&lt;/P&gt;
  &lt;P&gt;Try 1&lt;/P&gt;
  &lt;P&gt;I used the method cl_fdt_json=&amp;gt;json_to_data &lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;call method cl_fdt_json=&amp;gt;json_to_data
        exporting
          iv_json = gv_response
        changing
          ca_data =  gt_data_json.
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;And the table in output remains initial .&lt;/P&gt;
  &lt;P&gt;Try 2 &lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;data gr_json_deserializer type ref to cl_trex_json_deserializer
create object gr_json_deserializer.
    call method gr_json_deserializer-&amp;gt;deserialize
     exporting
        json = gv_response
      importing
        abap = gt_data_json.
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Try 3&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;CALL TRANSFORMATION id
           SOURCE XML gv_response
           RESULT data = gt_data_json.
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;None of this is working .&lt;/P&gt;
  &lt;P&gt;Here is the json that has to be converted:&lt;/P&gt;
  &lt;P&gt;&lt;A href="https://answers.sap.com/storage/temp/239577-json.txt"&gt;json.txt&lt;/A&gt;&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;This is the structure I used to handle this.&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;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&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Don't look at the data type since I was going to change them if it was going to work&lt;/P&gt;
  &lt;P&gt;Can anyone help me ? I am stuck&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 11:08:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-convert-json-to-abap-structure-but-having-problems/m-p/694635#M31342</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-11-07T11:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Convert json to abap structure but having problems</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-convert-json-to-abap-structure-but-having-problems/m-p/694636#M31343</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The CL_FDT_CLASS will work. There needs to be a little conversion before you pass values into the class.Check this link&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://answers.sap.com/questions/383255/how-to-convert-json-response-from-rest-api-to-abap.html" target="test_blank"&gt;https://answers.sap.com/questions/383255/how-to-convert-json-response-from-rest-api-to-abap.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 15:45:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-convert-json-to-abap-structure-but-having-problems/m-p/694636#M31343</guid>
      <dc:creator>former_member593648</dc:creator>
      <dc:date>2018-11-07T15:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Convert json to abap structure but having problems</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-convert-json-to-abap-structure-but-having-problems/m-p/694637#M31344</link>
      <description>&lt;P&gt;Which little conversion exactly? I can not see it in the URL&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2018 07:59:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-convert-json-to-abap-structure-but-having-problems/m-p/694637#M31344</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2018-11-08T07:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Convert json to abap structure but having problems</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-convert-json-to-abap-structure-but-having-problems/m-p/694638#M31345</link>
      <description>&lt;P&gt;Hi Tomas,&lt;/P&gt;&lt;P&gt;Check this code segment..this works just fine for me. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TYPES : BEGIN OF str_json,

        success(20),

        msg(20),

        matnr(20),

        matkl(20),

        END OF str_json.

DATA : response TYPE string VALUE '{"success":"false","msg":"Not valid","matnr":"1234","matkl":"123489"}',

     lt_data_json TYPE str_json.


CALL METHOD cl_fdt_json=&amp;gt;json_to_data

  EXPORTING

    iv_json = response

  CHANGING

    ca_data = lt_data_json.
&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Nov 2018 19:18:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-to-convert-json-to-abap-structure-but-having-problems/m-p/694638#M31345</guid>
      <dc:creator>former_member593648</dc:creator>
      <dc:date>2018-11-08T19:18:31Z</dc:date>
    </item>
  </channel>
</rss>

