<?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: Deserialization JSON with variable fieldname in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/deserialization-json-with-variable-fieldname/m-p/12306180#M1990568</link>
    <description>&lt;P&gt;Hi Jaime , &lt;/P&gt;&lt;P&gt;Instead of using strict types, You can use the below code to generate a dynamic object with content. Later you can use directly or convert it to your table type. I can use the generate method at SAP_UI 754. Maybe earlier not released. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA : lo_data TYPE  REF TO data.
DATA: lv_json TYPE string.

lv_json = '{ "0": {}, "1": { "documentType": "Organization" }, "2": { "documentType": "Trial" } } '.
lo_data = /ui2/cl_json=&amp;gt;generate( json = lv_json ).

ASSIGN lo_data TO FIELD-SYMBOL(&amp;lt;lo_data&amp;gt;).&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 27 Dec 2020 10:49:29 GMT</pubDate>
    <dc:creator>yunustuzun</dc:creator>
    <dc:date>2020-12-27T10:49:29Z</dc:date>
    <item>
      <title>Deserialization JSON with variable fieldname</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deserialization-json-with-variable-fieldname/m-p/12306179#M1990567</link>
      <description>&lt;P&gt;I'm trying to deserialize a JSON with a variable sequential name:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;{
  "Records" : {
    "0" : { },
    "1" : {
      "documentType" : "Organization",
      "status" : "published",
      "selectAttributes" : [ "SystemID", "Name", "TimeCreated" ],
      "filterExpressions" : [ {
        "name" : "createdDateFrom",
        "field" : "TimeCreated",
        "op" : "&amp;gt;=",
        "defaultValue" : "2017-11-05T01:01:59Z"
      }, {
        "name" : "createdDateTo",
        "field" : "TimeCreated",
        "op" : "&amp;lt;=",
        "defaultValue" : "2017-11-06T01:01:59Z"
      } ],
      "viewTemplateName" : "RfxItemSummaryFactSystemView",
      "type" : "custom"
    },
    "2" : {
      "documentType" : "DynamicFormDocument_CaixaContract",
      "status" : "published",
      "selectAttributes" : [ "LoadCreateTime", "LoadUpdateTime", "ParentAgreement", "DFormId", "DetailLineNumber", "SourceSystem", "AclId", "FlexTypeId", "cus_ExistecesidedatosalPr" ],
      "filterExpressions" : [ {
        "name" : "updatedDateFrom",
        "field" : "TimeCreated",
        "op" : "&amp;gt;=",
        "defaultValue" : "2017-11-05T01:01:59Z"
      }, {
        "name" : "updatedDateTo",
        "field" : "TimeCreated",
        "op" : "&amp;lt;=",
        "defaultValue" : "2017-11-06T01:01:59Z"
      } ],
      "viewTemplateName" : "test1",
      "type" : "custom"
    }
  }
}
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;PRE&gt;&lt;CODE&gt;    TYPES:
      BEGIN OF ts_filter_expression,
        name          TYPE string,
        field         TYPE string,
        op            TYPE string,
        default_value TYPE string,
      END OF ts_filter_expression,
      tt_filter_expressions TYPE STANDARD TABLE OF ts_filter_expression WITH EMPTY KEY.

    TYPES:
      BEGIN OF ts_view_template,
        view_template_name TYPE string,
        type               TYPE string,
        status             TYPE string,
        document_type      TYPE string,
        select_attributes  TYPE STANDARD TABLE OF string WITH EMPTY KEY,
        filter_expresions  TYPE tt_filter_expressions,
      END OF ts_view_template,
      tt_view_templates TYPE STANDARD TABLE OF ts_view_template WITH EMPTY KEY.

    DATA:
      BEGIN OF data,
        records TYPE tt_view_templates,
      END OF data.

    /ui2/cl_json=&amp;gt;deserialize(
      EXPORTING
        json             = json
        assoc_arrays     = abap_true
        assoc_arrays_opt = abap_true
      CHANGING
        data             = data ).
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;How I can map the sequential field content to the table?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2020 17:28:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deserialization-json-with-variable-fieldname/m-p/12306179#M1990567</guid>
      <dc:creator>JaimeRodriguez</dc:creator>
      <dc:date>2020-12-15T17:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: Deserialization JSON with variable fieldname</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deserialization-json-with-variable-fieldname/m-p/12306180#M1990568</link>
      <description>&lt;P&gt;Hi Jaime , &lt;/P&gt;&lt;P&gt;Instead of using strict types, You can use the below code to generate a dynamic object with content. Later you can use directly or convert it to your table type. I can use the generate method at SAP_UI 754. Maybe earlier not released. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA : lo_data TYPE  REF TO data.
DATA: lv_json TYPE string.

lv_json = '{ "0": {}, "1": { "documentType": "Organization" }, "2": { "documentType": "Trial" } } '.
lo_data = /ui2/cl_json=&amp;gt;generate( json = lv_json ).

ASSIGN lo_data TO FIELD-SYMBOL(&amp;lt;lo_data&amp;gt;).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 27 Dec 2020 10:49:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deserialization-json-with-variable-fieldname/m-p/12306180#M1990568</guid>
      <dc:creator>yunustuzun</dc:creator>
      <dc:date>2020-12-27T10:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: Deserialization JSON with variable fieldname</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deserialization-json-with-variable-fieldname/m-p/12306181#M1990569</link>
      <description>&lt;P&gt;Hi Yunus,&lt;/P&gt;&lt;P&gt;Method "generate" is not available in the system version.&lt;/P&gt;&lt;P&gt;Finally, I used project &lt;A href="https://github.com/sbcgua/ajson" target="_blank"&gt;ajson&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2020 10:34:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deserialization-json-with-variable-fieldname/m-p/12306181#M1990569</guid>
      <dc:creator>JaimeRodriguez</dc:creator>
      <dc:date>2020-12-29T10:34:42Z</dc:date>
    </item>
  </channel>
</rss>

