<?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 How to conditionally rename field in array of objects in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-conditionally-rename-field-in-array-of-objects/m-p/658273#M111354</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I have query&lt;/P&gt;&lt;P&gt;| makeresults&lt;BR /&gt;| eval _raw="{\"name\": \"my name\", \"values\": [{\"rank\": 1, \"value\": \"\"}, {\"rank\": 2, \"value\": \"a\"}, {\"rank\": 3, \"value\": \"b\"}, {\"rank\": 4, \"value\": \"c\"}]}"&lt;BR /&gt;| spath&lt;BR /&gt;| rename values{}.rank as rank&lt;BR /&gt;| rename values{}.value as value&lt;BR /&gt;| table name, rank, value&lt;BR /&gt;&lt;BR /&gt;Producing result&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="screenshot.PNG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/27256i7D19977B94FC16A1/image-size/large?v=v2&amp;amp;px=999" role="button" title="screenshot.PNG" alt="screenshot.PNG" /&gt;&lt;/span&gt;&lt;BR /&gt;Because in the first item of values, value is empty the values in the table are shifted one up and are not aligned with the rank.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;How could I conditionally update the value to, say, [empty] if that is empty string in the data?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Sep 2023 12:20:20 GMT</pubDate>
    <dc:creator>stenvala</dc:creator>
    <dc:date>2023-09-21T12:20:20Z</dc:date>
    <item>
      <title>How to conditionally rename field in array of objects</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-conditionally-rename-field-in-array-of-objects/m-p/658273#M111354</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I have query&lt;/P&gt;&lt;P&gt;| makeresults&lt;BR /&gt;| eval _raw="{\"name\": \"my name\", \"values\": [{\"rank\": 1, \"value\": \"\"}, {\"rank\": 2, \"value\": \"a\"}, {\"rank\": 3, \"value\": \"b\"}, {\"rank\": 4, \"value\": \"c\"}]}"&lt;BR /&gt;| spath&lt;BR /&gt;| rename values{}.rank as rank&lt;BR /&gt;| rename values{}.value as value&lt;BR /&gt;| table name, rank, value&lt;BR /&gt;&lt;BR /&gt;Producing result&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="screenshot.PNG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/27256i7D19977B94FC16A1/image-size/large?v=v2&amp;amp;px=999" role="button" title="screenshot.PNG" alt="screenshot.PNG" /&gt;&lt;/span&gt;&lt;BR /&gt;Because in the first item of values, value is empty the values in the table are shifted one up and are not aligned with the rank.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;How could I conditionally update the value to, say, [empty] if that is empty string in the data?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 12:20:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-conditionally-rename-field-in-array-of-objects/m-p/658273#M111354</guid>
      <dc:creator>stenvala</dc:creator>
      <dc:date>2023-09-21T12:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to conditionally rename field in array of objects</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-conditionally-rename-field-in-array-of-objects/m-p/658291#M111361</link>
      <description>&lt;P&gt;Fill in the empty values using the &lt;FONT face="georgia,palatino"&gt;mvmap&lt;/FONT&gt; function.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="{\"name\": \"my name\", \"values\": [{\"rank\": 1, \"value\": \"\"}, {\"rank\": 2, \"value\": \"a\"}, {\"rank\": 3, \"value\": \"b\"}, {\"rank\": 4, \"value\": \"c\"}]}"
| spath
| rename values{}.rank as rank
| rename values{}.value as value
| eval value=mvmap(value,if(value="", "[empty]", value))
| table name, rank, value&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 13:39:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-conditionally-rename-field-in-array-of-objects/m-p/658291#M111361</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-09-21T13:39:54Z</dc:date>
    </item>
  </channel>
</rss>

