<?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 field name mapping in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/json-field-name-mapping/m-p/12715057#M2019376</link>
    <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;gregfranco&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;About MANDT field - I am still not sure what do you want to archieve. Remove MANDT field from ABAP structure to which you are deserializing JSON? Check example below, it works even if there is no MANDT field in ABAP structure.&lt;BR /&gt;&lt;BR /&gt;About date + time, this works OK for me. No need to use TS parameter (you work with date, not timestamp).&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES: BEGIN OF ty_s_data,
         date TYPE d,
         time TYPE t,
       END OF ty_s_data.
DATA: ls_data TYPE ty_s_data,
      lv_act  TYPE string.

lv_act = '{"MANDT":"200","DATE":"2016-07-08","TIME":"12:34:56"}'.

/ui2/cl_json=&amp;gt;deserialize( EXPORTING json = lv_act CHANGING data = ls_data ).&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 19 Jan 2023 08:54:10 GMT</pubDate>
    <dc:creator>Tomas_Buryanek</dc:creator>
    <dc:date>2023-01-19T08:54:10Z</dc:date>
    <item>
      <title>json field name mapping</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/json-field-name-mapping/m-p/12715053#M2019372</link>
      <description>&lt;P&gt;hello experts,&lt;/P&gt;
  &lt;P&gt;I currently have a json output where I should map abap deep structure field names to the expected json output.&lt;/P&gt;
  &lt;P&gt;ex: /XYZ/V_CRNCY -&amp;gt; VCRNCY. I'm currently using a REPLACE ALL REGEX to remove the /XYZ/ from each field but I think there should be a way to do this using the /ui2/cl_json class attributes.&lt;/P&gt;
  &lt;P&gt;In addition, I should return the values of each deep structure in a results array, remove client field from output and format dates so that there are no dashes where the data type is DATS&lt;/P&gt;
  &lt;P&gt;ex: "STRUCT_NAV": [&lt;/P&gt;
  &lt;P&gt; {&lt;/P&gt;
  &lt;P&gt; "MANDT": "200",&lt;/P&gt;
  &lt;P&gt; }&lt;/P&gt;
  &lt;P&gt;]&lt;/P&gt;
  &lt;P&gt;"STRUCT_NAV": { &lt;/P&gt;
  &lt;P&gt; "results": []&lt;/P&gt;
  &lt;P&gt;}&lt;/P&gt;
  &lt;P&gt;I've attached my structure and current json where I am attempting to use /ui2/cl_json class to serialize and output the json. I apologize if I haven't provided enough information and will be glad to provide more to receive some help.&lt;/P&gt;
  &lt;P&gt;&lt;A href="https://answers.sap.com/storage/temp/2132674-sample.txt" data-attachment="2132674"&gt;sample.txt&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2023 13:46:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/json-field-name-mapping/m-p/12715053#M2019372</guid>
      <dc:creator>former_member837595</dc:creator>
      <dc:date>2023-01-18T13:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: json field name mapping</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/json-field-name-mapping/m-p/12715054#M2019373</link>
      <description>&lt;P&gt;Thank you for
visiting SAP Community to get answers to your questions.&lt;/P&gt;

&lt;P&gt;As you're looking to get the most out of your community membership,
please consider including a profile picture to increase user engagement &amp;amp;
additional resources to your reference that can really benefit you:&lt;/P&gt;&lt;P&gt;I suggest you use the "Insert Code option for the question.&lt;/P&gt;

&lt;P&gt;Profile &lt;A href="https://developers.sap.com/tutorials/community-profile.html" target="test_blank"&gt;https://developers.sap.com/tutorials/community-profile.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Tips for Questions: &lt;A href="https://community.sap.com/resources/questions-and-answers" target="test_blank"&gt;https://community.sap.com/resources/questions-and-answers&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Consider taking our Q&amp;amp;A tutorial at:
&lt;A href="https://developers.sap.com/tutorials/community-qa.html" target="test_blank"&gt;https://developers.sap.com/tutorials/community-qa.html&lt;/A&gt;.&lt;/P&gt;

&lt;P&gt;I hope you find this advice useful, and we're happy to have you as part
of the SAP Community!&lt;/P&gt;

&lt;P&gt;All the best,&lt;/P&gt;

&lt;P&gt;Dedi&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2023 13:48:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/json-field-name-mapping/m-p/12715054#M2019373</guid>
      <dc:creator>former_member27</dc:creator>
      <dc:date>2023-01-18T13:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: json field name mapping</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/json-field-name-mapping/m-p/12715055#M2019374</link>
      <description>&lt;P&gt;Hello Gregory,&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;For mapping different names JSON vs. ABAP you can use parameter NAME_MAPPINGS in DESERIALIZE method like you are using. But I am afraid you need to list all the possible field names. Not dynamic like you are trying to. /XYZ/AAA_TUVWX =&amp;gt; AAA_TUVWX, /XYZ/ORG_INST_DT =&amp;gt; ORG_INST_DT etc...&lt;/LI&gt;&lt;LI&gt;Using REPLACE might be also a option (just be careful not replacing something in values).&lt;/LI&gt;&lt;LI&gt;I do not understand how do you want to remove client field from which output? Is not it JSON string =&amp;gt; ABAP structure?&lt;/LI&gt;&lt;LI&gt;If date is in correct JSON format, then /ui2/cl_json can convert it to SAP date format itself. Othervise you will have to do it in ABAP.&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Wed, 18 Jan 2023 14:24:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/json-field-name-mapping/m-p/12715055#M2019374</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2023-01-18T14:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: json field name mapping</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/json-field-name-mapping/m-p/12715056#M2019375</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;Thanks for your reply Tomas.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;- I understand about the NAME_MAPPINGS. Since the field names won't change listing them all individually would be tedious at first but it would handle the situation without using REPLACE ALL REGEX which could potentially change future values as well.&lt;/P&gt;&lt;P&gt;- The client field is in the ABAP structure that tells us which system ID we're currently using. ex: "MANDT" : 200. The table being pulled from being PQRSTU for example. The json itab I use to feed into the ui2/cl_json serialize method is of the same type as the parent table so it has all the same fields. I've been trying to find a simple way to remove that field.&lt;/P&gt;&lt;P&gt;- Would I use TS_AS_ISO8601 = abap_true to modify the date value from 2021-03-01 -&amp;gt; 20210301 ? This didn't seem to apply the result I needed&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;"PQRSTU": [
      {
        "MANDT": "200",
        "PNGUID": "",
        "PNCNT": 1,
        "PNTXCNT": 1,
        "VERSN": 3,

TYPES: BEGIN OF ty_json,
            
            XYZ_NAV TYPE /XYZ/GB_TT_PQRSTU,
            
           END OF ty_json.
	lt_json TYPE TABLE OF ty_json,&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Jan 2023 17:05:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/json-field-name-mapping/m-p/12715056#M2019375</guid>
      <dc:creator>former_member837595</dc:creator>
      <dc:date>2023-01-18T17:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: json field name mapping</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/json-field-name-mapping/m-p/12715057#M2019376</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;gregfranco&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;About MANDT field - I am still not sure what do you want to archieve. Remove MANDT field from ABAP structure to which you are deserializing JSON? Check example below, it works even if there is no MANDT field in ABAP structure.&lt;BR /&gt;&lt;BR /&gt;About date + time, this works OK for me. No need to use TS parameter (you work with date, not timestamp).&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES: BEGIN OF ty_s_data,
         date TYPE d,
         time TYPE t,
       END OF ty_s_data.
DATA: ls_data TYPE ty_s_data,
      lv_act  TYPE string.

lv_act = '{"MANDT":"200","DATE":"2016-07-08","TIME":"12:34:56"}'.

/ui2/cl_json=&amp;gt;deserialize( EXPORTING json = lv_act CHANGING data = ls_data ).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Jan 2023 08:54:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/json-field-name-mapping/m-p/12715057#M2019376</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2023-01-19T08:54:10Z</dc:date>
    </item>
  </channel>
</rss>

