<?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>Question Re: SAP Cloud Platform Integration – Groovy script to remove an empty array from an object array in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/sap-cloud-platform-integration-groovy-script-to-remove-an-empty-array-from/qaa-p/12143554#M4539100</link>
    <description>&lt;P&gt;Thank you.  That worked perfectly and as I try to learn Groovy scripting, I learned about escape characters.  &lt;/P&gt;</description>
    <pubDate>Mon, 23 Mar 2020 13:15:44 GMT</pubDate>
    <dc:creator>beverely_parks2</dc:creator>
    <dc:date>2020-03-23T13:15:44Z</dc:date>
    <item>
      <title>SAP Cloud Platform Integration – Groovy script to remove an empty array from an object array</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-cloud-platform-integration-groovy-script-to-remove-an-empty-array-from/qaq-p/12143551</link>
      <description>&lt;P&gt;I'm working on an implementation where the receiver is requesting a JSON file format. I'm using integration mapping to create an XML that matches the JSON format. I'm then executing standard XML to JSON conversion followed by a groovy script to remove the "element" entries from each object array. My final step is that if an object array contains an empty element, the result should be an empty object array that looks like: "TestQualitativeMeasurement":[]. &lt;/P&gt;
  &lt;P&gt;If I create the element regardless of data, convert XML to JSON, and execute my script, my results look like "TestQualitativeMeasurement":[""] (Receiver is not accepting this as an empty object)&lt;/P&gt;
  &lt;P&gt;I've tried not mapping the element if there is no data but this results in the object array end up looking like "TestQualitativeMeasurement":"" and is missing the [] object qualifers required.&lt;/P&gt;
  &lt;P&gt;Would anyone be able to advise me on how to accomplish this? I believe that I should be able to do this within my groovy script but I haven't found the right combination.&lt;/P&gt;
  &lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 19:52:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-cloud-platform-integration-groovy-script-to-remove-an-empty-array-from/qaq-p/12143551</guid>
      <dc:creator>beverely_parks2</dc:creator>
      <dc:date>2020-03-20T19:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: SAP Cloud Platform Integration – Groovy script to remove an empty array from an object array</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-cloud-platform-integration-groovy-script-to-remove-an-empty-array-from/qaa-p/12143552#M4539098</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;beverely.parks2&lt;/SPAN&gt;, Can you please attach XML, Groovy and/or Mapping screenshot and/or code? &lt;BR /&gt;What is the result if you don't execute your remove script at all just the XML &amp;gt; JSON mapping? BP, Peter&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2020 03:03:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-cloud-platform-integration-groovy-script-to-remove-an-empty-array-from/qaa-p/12143552#M4539098</guid>
      <dc:creator>catano</dc:creator>
      <dc:date>2020-03-21T03:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: SAP Cloud Platform Integration – Groovy script to remove an empty array from an object array</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-cloud-platform-integration-groovy-script-to-remove-an-empty-array-from/qaa-p/12143553#M4539099</link>
      <description>&lt;P&gt;Hi Beverly,&lt;/P&gt;&lt;P&gt;since JSON is just a "String", you could simply run a search-replace script after your JSON conversion.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import com.sap.gateway.ip.core.customdev.util.Message
def Message processData(Message message) {
    def body = message.getBody(java.lang.String) as String
    body = body.replace("[\"\"]","[]")
    message.setBody(body)
    return message
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Mar 2020 09:58:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-cloud-platform-integration-groovy-script-to-remove-an-empty-array-from/qaa-p/12143553#M4539099</guid>
      <dc:creator>r_herrmann</dc:creator>
      <dc:date>2020-03-23T09:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: SAP Cloud Platform Integration – Groovy script to remove an empty array from an object array</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-cloud-platform-integration-groovy-script-to-remove-an-empty-array-from/qaa-p/12143554#M4539100</link>
      <description>&lt;P&gt;Thank you.  That worked perfectly and as I try to learn Groovy scripting, I learned about escape characters.  &lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 13:15:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-cloud-platform-integration-groovy-script-to-remove-an-empty-array-from/qaa-p/12143554#M4539100</guid>
      <dc:creator>beverely_parks2</dc:creator>
      <dc:date>2020-03-23T13:15:44Z</dc:date>
    </item>
  </channel>
</rss>

