<?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: JSON to ABAP in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/json-to-abap/m-p/635561#M26876</link>
    <description>&lt;P&gt;Hint 1: share a sample of the JSON response.&lt;/P&gt;</description>
    <pubDate>Wed, 14 Feb 2018 08:18:48 GMT</pubDate>
    <dc:creator>matt</dc:creator>
    <dc:date>2018-02-14T08:18:48Z</dc:date>
    <item>
      <title>JSON to ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/json-to-abap/m-p/635560#M26875</link>
      <description>&lt;P&gt;Hi experts,&lt;/P&gt;
  &lt;P&gt;I am trying to consume a rest API in abap. i get the response in json format (string).&lt;/P&gt;
  &lt;P&gt;I want to convert this output to internal structure. I tried all possible sap methods and scn links, but no luck.&lt;/P&gt;
  &lt;P&gt;In all trials 'response' if my json output and lt_data is the exact structure of the output from se11.&lt;/P&gt;
  &lt;P&gt;Try 1&lt;/P&gt;
  &lt;P&gt;CREATE OBJECT lr_json_deserializer.&lt;BR /&gt; lr_json_deserializer-&amp;gt;deserialize( EXPORTING json = response IMPORTING abap = lt_data ).&lt;/P&gt;
  &lt;P&gt;reason: sap interprets 'city' attribute as , city = " dublin ", but json reads as "city" : "dublin"&lt;/P&gt;
  &lt;P&gt;Try 2&lt;/P&gt;
  &lt;P&gt;CALL TRANSFORMATION id SOURCE XML response&lt;BR /&gt; RESULT text = lt_data.&lt;/P&gt;
  &lt;P&gt;reason: no matter what no response&lt;/P&gt;
  &lt;P&gt;Try 3&lt;/P&gt;
  &lt;P&gt;CALL METHOD cl_fdt_json=&amp;gt;json_to_dataEXPORTING&lt;BR /&gt; iv_json = responseCHANGING&lt;BR /&gt; ca_data = lt_data.&lt;/P&gt;
  &lt;P&gt;reason: take only 1 attribute and if it is more than one treats as only 1 string.&lt;/P&gt;
  &lt;P&gt;Anyone with hints is highly appreciated.&lt;/P&gt;
  &lt;P&gt;Thank you very much. Shaila&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 23:26:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/json-to-abap/m-p/635560#M26875</guid>
      <dc:creator>shaila_kasha</dc:creator>
      <dc:date>2018-02-13T23:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: JSON to ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/json-to-abap/m-p/635561#M26876</link>
      <description>&lt;P&gt;Hint 1: share a sample of the JSON response.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2018 08:18:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/json-to-abap/m-p/635561#M26876</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2018-02-14T08:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: JSON to ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/json-to-abap/m-p/635562#M26877</link>
      <description>&lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Hint 2: Learn the basics of ABAP and JSON &lt;/P&gt;
  &lt;P&gt;&lt;A href="https://help.sap.com/http.svc/rc/abapdocu_752_index_htm/7.52/en-US/index.htm?file=abenabap_json.htm"&gt;https://help.sap.com/http.svc/rc/abapdocu_752_index_htm/7.52/en-US/index.htm?file=abenabap_json.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2018 08:32:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/json-to-abap/m-p/635562#M26877</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2018-02-14T08:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: JSON to ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/json-to-abap/m-p/635563#M26878</link>
      <description>&lt;P&gt;Thank you very much for the responses.&lt;/P&gt;
  &lt;P&gt;Below is sample response string: &lt;/P&gt;
  &lt;P&gt;data: lv_value type string value ' { "Field 1" : "value1 ", "field2" : "value2 "} '&lt;/P&gt;
  &lt;P&gt;I am able to convert json to abap using below class.&lt;/P&gt;
  &lt;P&gt;REPLACE ALL OCCURRENCES OF REGEX cl_abap_char_utilities=&amp;gt;cr_lf&lt;BR /&gt; IN lv_value WITH ''.&lt;BR /&gt;DATA: lt_data TYPE yresponse_strut. "this is the exact same structure as output defined in SE11.&lt;BR /&gt; &lt;BR /&gt; CALL METHOD cl_fdt_json=&amp;gt;json_to_data&lt;BR /&gt; EXPORTING&lt;BR /&gt; iv_json = lv_value&lt;BR /&gt; CHANGING&lt;BR /&gt; ca_data = lt_data.&lt;/P&gt;
  &lt;P&gt;however now i have another problem. I need to send the request in JSON format also. however i have abap structure format. so i tried to use the below method. Although i get the format like string format into lv_body, same as lv_value, and when i pass the same response to REST API, i am not getting the response. Error says invalid json format. For some reasons below method is not giving te response with cl_abap_char_utilities=&amp;gt;cr_lf charaters and Json wants in this format.&lt;/P&gt;
  &lt;P&gt;CALL METHOD cl_fdt_json=&amp;gt;data_to_json&lt;BR /&gt; EXPORTING&lt;BR /&gt; ia_data = ls_request&lt;BR /&gt; RECEIVING&lt;BR /&gt; rv_json = lv_body.&lt;/P&gt;
  &lt;P&gt;any hints will be highly appreciated.&lt;/P&gt;
  &lt;P&gt;Thank you, shaila.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2018 22:28:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/json-to-abap/m-p/635563#M26878</guid>
      <dc:creator>shaila_kasha</dc:creator>
      <dc:date>2018-02-14T22:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: JSON to ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/json-to-abap/m-p/635564#M26879</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
  &lt;P&gt;I was able to solve this by using same class below. the only difference is that we need to append/concatenate the service request details in the receiving string value..&lt;/P&gt;
  &lt;P&gt;CALL METHOD cl_fdt_json=&amp;gt;data_to_json&lt;BR /&gt;EXPORTING&lt;BR /&gt;ia_data = ls_request&lt;BR /&gt;RECEIVING&lt;BR /&gt;rv_json = lv_body.&lt;/P&gt;
  &lt;P&gt;Thank you all.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2018 04:17:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/json-to-abap/m-p/635564#M26879</guid>
      <dc:creator>shaila_kasha</dc:creator>
      <dc:date>2018-02-16T04:17:22Z</dc:date>
    </item>
  </channel>
</rss>

