<?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: Transform ABAP Hierarchy table to nested JSON in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/transform-abap-hierarchy-table-to-nested-json/m-p/363097#M7787</link>
    <description>&lt;P&gt;You may use the ID transformation with the source = your internal table, and the result = an SXML instance set for instance with &lt;/P&gt;&lt;P&gt;writer = cl_sxml_string_writer=&amp;gt;create( type = if_sxml=&amp;gt;co_xt_json ). It's documented in the ABAP official doc. The component names will be upper case. There are a few discussions in the forum about this topic.&lt;/P&gt;</description>
    <pubDate>Wed, 26 Oct 2016 16:50:15 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2016-10-26T16:50:15Z</dc:date>
    <item>
      <title>Transform ABAP Hierarchy table to nested JSON</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/transform-abap-hierarchy-table-to-nested-json/m-p/363096#M7786</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have an internal table, e.g.&lt;/P&gt;&lt;P&gt;ID | ParentID | Name&lt;/P&gt;&lt;P&gt;1 | | One&lt;BR /&gt;2 | | Two&lt;BR /&gt;3 | 2 | Two.One&lt;BR /&gt;4 | 3 | Two.One.One&lt;/P&gt;&lt;P&gt;This should be transformed to JSON like this:&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;  "root": {&lt;BR /&gt;    "id": "1",&lt;BR /&gt;    "name": "One"&lt;BR /&gt;  },&lt;BR /&gt;  {&lt;BR /&gt;    "id": "2",&lt;BR /&gt;    "name": "Two",&lt;BR /&gt;    "children": [&lt;BR /&gt;      {&lt;BR /&gt;        "id: "3",&lt;BR /&gt;        "name": "Two.One",&lt;BR /&gt;        "children": [&lt;BR /&gt;          {&lt;BR /&gt;            "id": "4",&lt;BR /&gt;            "name": "Two.One.One"&lt;/P&gt;&lt;P&gt;          }&lt;/P&gt;&lt;P&gt;        ]&lt;/P&gt;&lt;P&gt;      }&lt;BR /&gt;    ]&lt;BR /&gt;  }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Now I am wondering whether there is already a transformation that does this, or maybe someone can help me to create my own transformation for this.&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;&lt;P&gt;Ole&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2016 14:38:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/transform-abap-hierarchy-table-to-nested-json/m-p/363096#M7786</guid>
      <dc:creator>former_member256686</dc:creator>
      <dc:date>2016-10-26T14:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: Transform ABAP Hierarchy table to nested JSON</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/transform-abap-hierarchy-table-to-nested-json/m-p/363097#M7787</link>
      <description>&lt;P&gt;You may use the ID transformation with the source = your internal table, and the result = an SXML instance set for instance with &lt;/P&gt;&lt;P&gt;writer = cl_sxml_string_writer=&amp;gt;create( type = if_sxml=&amp;gt;co_xt_json ). It's documented in the ABAP official doc. The component names will be upper case. There are a few discussions in the forum about this topic.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2016 16:50:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/transform-abap-hierarchy-table-to-nested-json/m-p/363097#M7787</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2016-10-26T16:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: Transform ABAP Hierarchy table to nested JSON</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/transform-abap-hierarchy-table-to-nested-json/m-p/363098#M7788</link>
      <description>&lt;P&gt;Thank you, Sandra, that answer was really helpful.&lt;/P&gt;&lt;P&gt;This is not exactly what I had in mind. The result of the ID transformation is not nested at all, and all the columns are transferred. That's not what I wanted.&lt;/P&gt;&lt;P&gt;But your answer let me have another look at the documentation, and I found this: &lt;A href="http://help.sap.com/abapdocu_740/de/abenabap_json_token_writer_abexa.htm" target="test_blank"&gt;http://help.sap.com/abapdocu_740/de/abenabap_json_token_writer_abexa.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Class CL_SXML_STRING_WRITER can be used to write JSON directly, using methods of interface IF_SXML_WRITER. So for Transformation from ABAP to JSON, I don't need a transformation at all, but I can do this in a class. Recursive method calls will help to build the nested structure. That should definitely work.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2016 13:15:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/transform-abap-hierarchy-table-to-nested-json/m-p/363098#M7788</guid>
      <dc:creator>former_member256686</dc:creator>
      <dc:date>2016-10-27T13:15:32Z</dc:date>
    </item>
  </channel>
</rss>

