<?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: Complex JSON structure to ABAP in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/complex-json-structure-to-abap/m-p/470475#M15128</link>
    <description>&lt;P&gt;Go through this link:&lt;/P&gt;&lt;P&gt;&lt;A href="https://wiki.scn.sap.com/wiki/display/Snippets/One+more+ABAP+to+JSON+Serializer+and+Deserializer" target="test_blank"&gt;https://wiki.scn.sap.com/wiki/display/Snippets/One+more+ABAP+to+JSON+Serializer+and+Deserializer&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Json integer could be ABAP string by this document, but it have examples with hierarchical data. &lt;/P&gt;</description>
    <pubDate>Wed, 10 May 2017 09:37:15 GMT</pubDate>
    <dc:creator>vladimir_erakovic</dc:creator>
    <dc:date>2017-05-10T09:37:15Z</dc:date>
    <item>
      <title>Complex JSON structure to ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/complex-json-structure-to-abap/m-p/470473#M15126</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am struggling with converting a JSON structure to ABAP data.&lt;/P&gt;&lt;P&gt;The JSON looks like &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;{
  "_id": "string",
  "error": "string",
  "request": "string", 

  "predictions": [
    {
      "name": "string",
      "results": [         {
          "label": "string",
          "score": 0
        }
      ]
    }
  ],
  "status": "QUEUED",  
  "tenantName": "string",
  "error_description": "string"
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and I tried with creating a nested ABAP structure like&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;types: begin of classificationResults_s,
 label type string,
 score type string,
 end of classificationResults_s.


types: results type standard table of classificationResults_s with non-unique default key.


types: begin of prediction_s,
 name type string,
 results type results,
 end of prediction_s.

types: predictions type table of prediction_s with non-unique default key.


TYPES: BEGIN OF response,
              _id TYPE string,
            error TYPE string,
           request type string,
       predictions type predictions,
            status type string,
          tenantName type string,
  error_description type string,
    END OF response.
data: wa_response type response.


CALL METHOD /UI2/CL_JSON=&amp;gt;DESERIALIZE
 EXPORTING
  JSON = response
 CHANGING
  DATA = wa_response&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But that never gives me any result.&lt;/P&gt;&lt;P&gt;When I try with a structure containing only one internal table everything works just fine. However, when introducing the second layer (results in this case) the deserialization returns an empty data structure.&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 06:24:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/complex-json-structure-to-abap/m-p/470473#M15126</guid>
      <dc:creator>marcus_schiffer</dc:creator>
      <dc:date>2017-05-10T06:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Complex JSON structure to ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/complex-json-structure-to-abap/m-p/470474#M15127</link>
      <description>&lt;P&gt;Hi Marcus,&lt;/P&gt;&lt;P&gt;It seams to me that your problem is just in camel case: tenantName from JSON should be tenant_name in your ABAP structure and then when calling deserialize
&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; /ui2/cl_json=&amp;gt;deserialize( EXPORTING json = request_data
                                       pretty_name = /ui2/cl_json=&amp;gt;pretty_mode-camel_case
                            CHANGING  data = ls_transport_task ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Also score: 0 in your JSON should be score: "0" when you use string data type in your structure.&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 09:28:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/complex-json-structure-to-abap/m-p/470474#M15127</guid>
      <dc:creator>vladimir_erakovic</dc:creator>
      <dc:date>2017-05-10T09:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Complex JSON structure to ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/complex-json-structure-to-abap/m-p/470475#M15128</link>
      <description>&lt;P&gt;Go through this link:&lt;/P&gt;&lt;P&gt;&lt;A href="https://wiki.scn.sap.com/wiki/display/Snippets/One+more+ABAP+to+JSON+Serializer+and+Deserializer" target="test_blank"&gt;https://wiki.scn.sap.com/wiki/display/Snippets/One+more+ABAP+to+JSON+Serializer+and+Deserializer&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Json integer could be ABAP string by this document, but it have examples with hierarchical data. &lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 09:37:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/complex-json-structure-to-abap/m-p/470475#M15128</guid>
      <dc:creator>vladimir_erakovic</dc:creator>
      <dc:date>2017-05-10T09:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: Complex JSON structure to ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/complex-json-structure-to-abap/m-p/470476#M15129</link>
      <description>&lt;P&gt;SAP's basics about ABAP and JSON:&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.sap.com/http.svc/rc/abapdocu_751_index_htm/7.51/en-US/index.htm?file=abenabap_json.htm" target="test_blank"&gt;https://help.sap.com/http.svc/rc/abapdocu_751_index_htm/7.51/en-US/index.htm?file=abenabap_json.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 09:45:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/complex-json-structure-to-abap/m-p/470476#M15129</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-05-10T09:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: Complex JSON structure to ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/complex-json-structure-to-abap/m-p/470477#M15130</link>
      <description>&lt;P&gt;Hi Vladimir,&lt;/P&gt;&lt;P&gt;thanks for the hints. However, I am still not able to convert that JSON to ABAP.&lt;/P&gt;&lt;P&gt;I found my result a bit different from the JSON object definition (see below) But nevertheless, I still see no conversion.&lt;/P&gt;&lt;P&gt;The response JSON is a bit different and looks like this.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;{
  "_id": "90807dce-44bd-40d5-861e-88bc85091039", 
  "predictions": [
    {
      "name": "bild.jpg", 
      "results": [
        {
          "label": "grille", 
          "score": 0.227078
        }, 
        {
          "label": "Model T", 
          "score": 0.17371
        }, 
        {
          "label": "sports car", 
          "score": 0.151759
        }, 
        {
          "label": "car wheel", 
          "score": 0.090716
        }, 
        {
          "label": "racer", 
          "score": 0.084748
        }
      ]
    }
  ], 
  "processed_time": "Fri, 12 May 2017 07:25:34 GMT", 
  "request": {
    "files": [
      "bild.jpg"
    ], 
    "options": {}, 
    "tenantName": "imgclassif-tech-user", 
    "texts": []
  }, 
  "status": "DONE", 
  "tenantName": "imgclassif-tech-user"
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It seems that more than one nested structure is a problem . &lt;/P&gt;&lt;P&gt;I changed structures etc accordingly but no success.&lt;/P&gt;&lt;P&gt;Or is there any other thing to consider ?&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 08:07:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/complex-json-structure-to-abap/m-p/470477#M15130</guid>
      <dc:creator>marcus_schiffer</dc:creator>
      <dc:date>2017-05-12T08:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: Complex JSON structure to ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/complex-json-structure-to-abap/m-p/470478#M15131</link>
      <description>&lt;P&gt;I used transformations (as proposed in the link above) to convert JSON to ABAP. There are a few blogs about it and some questions with useful answers.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 08:30:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/complex-json-structure-to-abap/m-p/470478#M15131</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2017-05-12T08:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: Complex JSON structure to ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/complex-json-structure-to-abap/m-p/470479#M15132</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;after removing newline and all blanks it works.&lt;/P&gt;&lt;P&gt;However, I want the blanks becuase the text fields have blanks that are also removed (Model T --&amp;gt; ModelT)&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPLACE ALL OCCURRENCES OF REGEX '[ ]' IN response WITH ``.
REPLACE all occurrences of cl_abap_char_utilities=&amp;gt;newline in response with ''.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any idea what causes this behaviour and what else I could do to keep the blanks ?&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 12:57:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/complex-json-structure-to-abap/m-p/470479#M15132</guid>
      <dc:creator>marcus_schiffer</dc:creator>
      <dc:date>2017-05-12T12:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: Complex JSON structure to ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/complex-json-structure-to-abap/m-p/470480#M15133</link>
      <description>&lt;P&gt;Hi Marcus,&lt;/P&gt;&lt;P&gt;Were you able to resolve this issue.I am also facing with similar issue&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pratik&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 19:21:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/complex-json-structure-to-abap/m-p/470480#M15133</guid>
      <dc:creator>former_member595281</dc:creator>
      <dc:date>2019-06-20T19:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: Complex JSON structure to ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/complex-json-structure-to-abap/m-p/470481#M15134</link>
      <description>&lt;P&gt;I did it using json_to_data :&lt;/P&gt;&lt;P&gt;  DATA: lo_json TYPE REF TO cl_clb_parse_json .&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;  CREATE OBJECT lo_json.&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;  CALL METHOD lo_json-&amp;gt;json_to_data( &lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;
      iv_json = p_string &lt;/P&gt;&lt;P&gt;    CHANGING&lt;/P&gt;&lt;P&gt;
      c_data  = wa_response ).&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Where p_string (TYPE  STRINGVAL) is the json. wa_response is the same you did.&lt;/P&gt;</description>
      <pubDate>Tue, 19 May 2020 16:21:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/complex-json-structure-to-abap/m-p/470481#M15134</guid>
      <dc:creator>former_member50933</dc:creator>
      <dc:date>2020-05-19T16:21:44Z</dc:date>
    </item>
  </channel>
</rss>

