<?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: How to omit empty key-value pairs from Payload in Workato Pros Discussion Board</title>
    <link>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-omit-empty-key-value-pairs-from-payload/m-p/9514#M3888</link>
    <description>&lt;P&gt;Skip is just another way of providing nil, but it doesn't remove the key.&lt;/P&gt;&lt;P&gt;Only compact removes the key, but the problem with compact is it's &lt;STRONG&gt;not recursive. &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If&amp;nbsp;you use compact on an array, it's only going to remove nil items from the array. It's not going to skim through the contents of each item in the array and remove keys with nil values.&lt;/P&gt;&lt;P&gt;My preferred way of solving this is with a Ruby action. Add your array or object as the input, and clean it up using the below code. The "data" object is an example of an array of objects with various null keys to purge.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="ruby"&gt;data = [
  {"one": "a", "two": "b", "three": null},
  {"one": "a", "two": null, "three": null},
  {"one": null, "two": "b", "three": null},
  {"one": null, "two": [1,2,3], "three": {"four": "hello", "five": null}}
]

def deep_compact(obj)
  case obj
  when Hash
    obj.transform_values { |v| deep_compact(v) }.compact
  when Array
    obj.map { |v| deep_compact(v) }
  else
    obj
  end
end

cleaned_data = deep_compact(data)

{
  cleaned_data: cleaned_data
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;The end result:&lt;/P&gt;&lt;LI-CODE lang="ruby"&gt;{
    "output": {
        "cleaned_data": [
            {
                "one": "a",
                "two": "b"
            },
            {
                "one": "a"
            },
            {
                "two": "b"
            },
            {
                "two": [
                    1,
                    2,
                    3
                ],
                "three": {
                    "four": "hello"
                }
            }
        ],
        "log": ""
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Apr 2025 04:07:45 GMT</pubDate>
    <dc:creator>gary1</dc:creator>
    <dc:date>2025-04-04T04:07:45Z</dc:date>
    <item>
      <title>How to omit empty key-value pairs from Payload</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-omit-empty-key-value-pairs-from-payload/m-p/9513#M3887</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;My process is that I have a list of data, I extract the relevant data from the list, add the data to the payload, and then POST that data to a particular endpoint. The key consideration is that when a key-value pair has a null value, that key-value pair should be omitted from the payload. Every system I have seen has a consideration for this, but what I understood to be the solution here is not working. &lt;STRONG&gt;I employed the "SKIP" function in an "If value is present, pass value, if not then SKIP" logic (Figure 1). &lt;/STRONG&gt;That said, &lt;STRONG&gt;when the value is not present, the key-value pair is still being included &lt;/STRONG&gt;with "null" (Figure 2).&lt;/P&gt;&lt;P&gt;My impression is that this should not be happening. I have had to create separate outbound schemas for every potential combination of fields that are null vs populated, which is insane. What other methods can I employ to achieve the same goal?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Figure 1&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-04-03 at 3.06.14 PM.png" style="width: 400px;"&gt;&lt;img src="https://systematic.workato.com/t5/image/serverpage/image-id/1974iB4A6C031ADE35E7D/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="Screenshot 2025-04-03 at 3.06.14 PM.png" alt="Screenshot 2025-04-03 at 3.06.14 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Figure 2&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-04-03 at 3.06.31 PM.png" style="width: 400px;"&gt;&lt;img src="https://systematic.workato.com/t5/image/serverpage/image-id/1975iC16F73F2F9DB200D/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="Screenshot 2025-04-03 at 3.06.31 PM.png" alt="Screenshot 2025-04-03 at 3.06.31 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Note 1: I am using the Dayforce SDK&lt;/P&gt;&lt;P&gt;Note 2: I have already attempted to use a common data model schema and the the .COMPACT function, however it had unintended consequences for integers in the payload that has made it untenable as a solution.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#compact #skip #automation #Dayforce&lt;/P&gt;</description>
      <pubDate>Thu, 03 Apr 2025 21:16:13 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-omit-empty-key-value-pairs-from-payload/m-p/9513#M3887</guid>
      <dc:creator>spencerstone</dc:creator>
      <dc:date>2025-04-03T21:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to omit empty key-value pairs from Payload</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-omit-empty-key-value-pairs-from-payload/m-p/9514#M3888</link>
      <description>&lt;P&gt;Skip is just another way of providing nil, but it doesn't remove the key.&lt;/P&gt;&lt;P&gt;Only compact removes the key, but the problem with compact is it's &lt;STRONG&gt;not recursive. &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If&amp;nbsp;you use compact on an array, it's only going to remove nil items from the array. It's not going to skim through the contents of each item in the array and remove keys with nil values.&lt;/P&gt;&lt;P&gt;My preferred way of solving this is with a Ruby action. Add your array or object as the input, and clean it up using the below code. The "data" object is an example of an array of objects with various null keys to purge.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="ruby"&gt;data = [
  {"one": "a", "two": "b", "three": null},
  {"one": "a", "two": null, "three": null},
  {"one": null, "two": "b", "three": null},
  {"one": null, "two": [1,2,3], "three": {"four": "hello", "five": null}}
]

def deep_compact(obj)
  case obj
  when Hash
    obj.transform_values { |v| deep_compact(v) }.compact
  when Array
    obj.map { |v| deep_compact(v) }
  else
    obj
  end
end

cleaned_data = deep_compact(data)

{
  cleaned_data: cleaned_data
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;The end result:&lt;/P&gt;&lt;LI-CODE lang="ruby"&gt;{
    "output": {
        "cleaned_data": [
            {
                "one": "a",
                "two": "b"
            },
            {
                "one": "a"
            },
            {
                "two": "b"
            },
            {
                "two": [
                    1,
                    2,
                    3
                ],
                "three": {
                    "four": "hello"
                }
            }
        ],
        "log": ""
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2025 04:07:45 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-omit-empty-key-value-pairs-from-payload/m-p/9514#M3888</guid>
      <dc:creator>gary1</dc:creator>
      <dc:date>2025-04-04T04:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to omit empty key-value pairs from Payload</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-omit-empty-key-value-pairs-from-payload/m-p/9515#M3889</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://systematic.workato.com/t5/user/viewprofilepage/user-id/11063"&gt;@spencerstone&lt;/a&gt;,&lt;BR /&gt;Did you try the optional field value on the CDM.&lt;BR /&gt;Regards,&lt;BR /&gt;Prudvi&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2025 04:32:51 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-omit-empty-key-value-pairs-from-payload/m-p/9515#M3889</guid>
      <dc:creator>Prudvi</dc:creator>
      <dc:date>2025-04-04T04:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to omit empty key-value pairs from Payload</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-omit-empty-key-value-pairs-from-payload/m-p/9523#M3890</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://systematic.workato.com/t5/user/viewprofilepage/user-id/11063"&gt;@spencerstone&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;Here is my solution using formulae:&lt;BR /&gt;1. Apply &lt;STRONG&gt;variable.blank?? skip :&amp;nbsp;variable&lt;/STRONG&gt;&lt;BR /&gt;2. Response - [{}] --&amp;gt;&amp;nbsp; (apply difference operator)&amp;nbsp;&lt;BR /&gt;Please let me know if you need further clarifications, Happy to help&lt;BR /&gt;&lt;BR /&gt;Thanks and Regards,&lt;BR /&gt;Shivakumara K A&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Remove Empty brackets.png" style="width: 757px;"&gt;&lt;img src="https://systematic.workato.com/t5/image/serverpage/image-id/1977i60B4C27D2685576C/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="Remove Empty brackets.png" alt="Remove Empty brackets.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Skip the null or empty.png" style="width: 750px;"&gt;&lt;img src="https://systematic.workato.com/t5/image/serverpage/image-id/1976i86A87931CAD91C01/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="Skip the null or empty.png" alt="Skip the null or empty.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="COntains null.png" style="width: 649px;"&gt;&lt;img src="https://systematic.workato.com/t5/image/serverpage/image-id/1978i07BDC52613D0F16D/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="COntains null.png" alt="COntains null.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="null removed.png" style="width: 790px;"&gt;&lt;img src="https://systematic.workato.com/t5/image/serverpage/image-id/1979i27112BDD62963534/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="null removed.png" alt="null removed.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2025 07:15:38 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-omit-empty-key-value-pairs-from-payload/m-p/9523#M3890</guid>
      <dc:creator>shivakumara</dc:creator>
      <dc:date>2025-04-04T07:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to omit empty key-value pairs from Payload</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-omit-empty-key-value-pairs-from-payload/m-p/9536#M3894</link>
      <description>&lt;P&gt;This is great - the method worked a charm. The key here is that the Ruby method allows a recursive search through an array. Since I was dealing with multiple hashes &amp;amp; arrays, the Deep_Compact Ruby method worked perfectly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I were working with a more simple structure, as in a single hash, the SKIP formula would have worked perfectly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2025 21:27:01 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-omit-empty-key-value-pairs-from-payload/m-p/9536#M3894</guid>
      <dc:creator>spencerstone</dc:creator>
      <dc:date>2025-04-04T21:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to omit empty key-value pairs from Payload</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-omit-empty-key-value-pairs-from-payload/m-p/10730#M4233</link>
      <description>&lt;P&gt;@&lt;A class="" href="https://systematic.workato.com/t5/user/viewprofilepage/user-id/8685" target="_self"&gt;&lt;SPAN class=""&gt;shivakumara&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;a href="https://systematic.workato.com/t5/user/viewprofilepage/user-id/11321"&gt;@Prudvi&lt;/a&gt;&amp;nbsp;&lt;a href="https://systematic.workato.com/t5/user/viewprofilepage/user-id/1188"&gt;@gary1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you are interested in a no-code solution to omitting nested null key-value pairs from a JSON payload, please add signal to the below ideas:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://ideas.workato.com/app/#/case/415544?cpid=931134c4-fa0c-41ba-815c-c31e90cf9eaa" target="_blank" rel="noopener"&gt;https://ideas.workato.com/app/#/case/415544?cpid=931134c4-fa0c-41ba-815c-c31e90cf9eaa&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://ideas.workato.com/app/#/case/504059?cpid=23919909-12f4-4112-8d25-efba83464960" target="_blank" rel="noopener"&gt;https://ideas.workato.com/app/#/case/504059?cpid=23919909-12f4-4112-8d25-efba83464960&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FYI the only solution our consultant team has found that has worked is the Deep Compact Ruby formula that Gary shared, and a JavaScript code snippet that one of my teammates wrote. There needs to be a better solution here!&amp;nbsp;&lt;/P&gt;&lt;P&gt;To access the ideas, you may need to log out of Workato, go to this link&amp;nbsp;&lt;A href="https://docs.workato.com/en/contact-us.html#for-requesting-enhancements:~:text=US%20Data%20Center,opens%20new%20window" target="_blank" rel="noopener"&gt;https://docs.workato.com/en/contact-us.html#for-requesting-enhancements:~:text=US%20Data%20Center,opens%20new%20window&lt;/A&gt;&amp;nbsp;then log in again! Weird process but it worked for me&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2025 18:35:00 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-omit-empty-key-value-pairs-from-payload/m-p/10730#M4233</guid>
      <dc:creator>spencerstone</dc:creator>
      <dc:date>2025-08-18T18:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to omit empty key-value pairs from Payload</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-omit-empty-key-value-pairs-from-payload/m-p/10731#M4234</link>
      <description>&lt;P&gt;Thanks for sharing. I voted for it.&lt;/P&gt;&lt;P&gt;While I'm here...&lt;/P&gt;&lt;P&gt;This may have zero relevance for you, but would you mind voting on this request for me? It has languished in the queue for a couple years and it would be a huge improvement for the work I do.&lt;/P&gt;&lt;P&gt;&lt;A href="https://ideas.workato.com/app/#/case/288061?cpid=9bc8cfd7-90d4-4bd0-a768-986da12e1afe&amp;amp;section=my_profile" target="_blank" rel="noopener"&gt;https://ideas.workato.com/app/#/case/288061?cpid=9bc8cfd7-90d4-4bd0-a768-986da12e1afe&amp;amp;section=my_profile&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;a href="https://systematic.workato.com/t5/user/viewprofilepage/user-id/8685"&gt;@shivakumara&lt;/a&gt;&amp;nbsp;&lt;a href="https://systematic.workato.com/t5/user/viewprofilepage/user-id/11321"&gt;@Prudvi&lt;/a&gt;&amp;nbsp;&lt;a href="https://systematic.workato.com/t5/user/viewprofilepage/user-id/3769"&gt;@mppowe&lt;/a&gt;&amp;nbsp; : )&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2025 18:49:21 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-omit-empty-key-value-pairs-from-payload/m-p/10731#M4234</guid>
      <dc:creator>gary1</dc:creator>
      <dc:date>2025-08-18T18:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to omit empty key-value pairs from Payload</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-omit-empty-key-value-pairs-from-payload/m-p/10751#M4238</link>
      <description>&lt;P&gt;Done, and while we're here, what about this one.&amp;nbsp; The recipe diff always flags every Recipe Function call I make, which makes the diff cumbersome and less useful.&amp;nbsp; Does it do that for anyone else?&amp;nbsp; It says I'm the only one who wants it, but... I wonder...&lt;/P&gt;&lt;P&gt;&lt;A href="https://ideas.workato.com/app/#/case/476366?currentProductId=caf1efdf-1d7e-4b7b-aeb9-28e4b0f4b25c&amp;amp;cpid=615496f7-6655-468b-b597-7369d7ceef6b" target="_blank"&gt;https://ideas.workato.com/app/#/case/476366?currentProductId=caf1efdf-1d7e-4b7b-aeb9-28e4b0f4b25c&amp;amp;cpid=615496f7-6655-468b-b597-7369d7ceef6b&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Aug 2025 20:30:32 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-omit-empty-key-value-pairs-from-payload/m-p/10751#M4238</guid>
      <dc:creator>mppowe</dc:creator>
      <dc:date>2025-08-19T20:30:32Z</dc:date>
    </item>
  </channel>
</rss>

