<?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 parse a JSON array into Splunk table? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-JSON-array-into-Splunk-table/m-p/347760#M102992</link>
    <description>&lt;P&gt;Ok, this is great information.  so how do I display the values if I do the &lt;CODE&gt;spath output=outlet_states path=object.outlet_states&lt;/CODE&gt; right now they are just coming up blank if I do &lt;CODE&gt;table outlet_states&lt;/CODE&gt;, Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 08 Mar 2017 13:04:03 GMT</pubDate>
    <dc:creator>bshega</dc:creator>
    <dc:date>2017-03-08T13:04:03Z</dc:date>
    <item>
      <title>How to parse a JSON array into Splunk table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-JSON-array-into-Splunk-table/m-p/347754#M102986</link>
      <description>&lt;P&gt;I have been searching for how to do this and I haven't really come across anything that matches my use case.&lt;/P&gt;

&lt;P&gt;I have the following object in Splunk:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="NewRecordingEvent"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2601i3CFB313E3CDDC21B/image-size/large?v=v2&amp;amp;px=999" role="button" title="NewRecordingEvent" alt="NewRecordingEvent" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I am creating a table to display all of the data and everything is working except for the &lt;CODE&gt;outlet_states&lt;/CODE&gt; the field is just blank for all of them.&lt;/P&gt;

&lt;P&gt;How can I parse these so that they show up? I'd also eventually like to be able to make them like &lt;CODE&gt;Outlet 1: Off&lt;/CODE&gt;, &lt;CODE&gt;Outlet 2: Off&lt;/CODE&gt;, etc...&lt;/P&gt;

&lt;P&gt;Any help is greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2017 19:58:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-JSON-array-into-Splunk-table/m-p/347754#M102986</guid>
      <dc:creator>bshega</dc:creator>
      <dc:date>2017-03-07T19:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse a JSON array into Splunk table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-JSON-array-into-Splunk-table/m-p/347755#M102987</link>
      <description>&lt;P&gt;The json array fields should be appearing as multivalued fields when you table them. Are you not seeing them? What's the search you're using?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2017 20:42:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-JSON-array-into-Splunk-table/m-p/347755#M102987</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-03-07T20:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse a JSON array into Splunk table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-JSON-array-into-Splunk-table/m-p/347756#M102988</link>
      <description>&lt;P&gt;This is the query that I'm using&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="iot-production" trigger="NewRecordingEvent" | spath output=name path=object.name | spath output=serial_number path=object.serial_number | spath output=action_time path=object.created_at | convert timeformat="%m-%d-%Y %l:%M %p" ctime(_time) AS created_at_fmt | spath output=current_temperature path=object.current_temperature | spath output=mode path=object.mode | spath output=target_temperature path=object.target_temperature | spath output=preset_greeting path=object.preset_greeting | spath output=preset_title path=object.preset_title | spath output=outlet_states path=object.outlet_states | spath output=timer_length path=object.timer_length | spath output=active_preset path=object.active_preset | spath output=rssi path=object.rssi | search serial_number=1004039 | table name serial_number created_at_fmt current_temperature mode target_temperature preset_greeting preset_title outlet_states timer_length active_preset rssi | rename name as "Name", serial_number as "Serial Number", created_at_fmt as "Time", current_temperature as "Current Temperature", mode as "Mode", target_temperature as "Target Temperature", preset_greeting as "Preset Greeting", preset_title as "Preset Title", outlet_states as "Outlet States", timer_length as "Timer Length", active_preset as "Active Preset", rssi as "RSSI"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Mar 2017 20:43:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-JSON-array-into-Splunk-table/m-p/347756#M102988</guid>
      <dc:creator>bshega</dc:creator>
      <dc:date>2017-03-07T20:43:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse a JSON array into Splunk table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-JSON-array-into-Splunk-table/m-p/347757#M102989</link>
      <description>&lt;P&gt;I think I see I have to do something like &lt;CODE&gt;spath output=outlet1 path=object.outlet_states{0}&lt;/CODE&gt; I thought maybe I could have just gotten an array in the field like &lt;CODE&gt;[true, true, false, false]&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2017 20:53:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-JSON-array-into-Splunk-table/m-p/347757#M102989</guid>
      <dc:creator>bshega</dc:creator>
      <dc:date>2017-03-07T20:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse a JSON array into Splunk table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-JSON-array-into-Splunk-table/m-p/347758#M102990</link>
      <description>&lt;P&gt;Can you try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="iot-production" trigger="NewRecordingEvent" 
| spath 
| rename object.* as *
| convert timeformat="%m-%d-%Y %l:%M %p" ctime(_time) AS created_at_fmt 
| search serial_number=1004039 
| table name serial_number created_at_fmt current_temperature mode target_temperature preset_greeting preset_title outlet_states timer_length active_preset rssi 
| rename name as "Name", serial_number as "Serial Number", created_at_fmt as "Time", current_temperature as "Current Temperature", mode as "Mode", target_temperature as "Target Temperature", preset_greeting as "Preset Greeting", preset_title as "Preset Title", outlet_states as "Outlet States", timer_length as "Timer Length", active_preset as "Active Preset", rssi as "RSSI"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Mar 2017 21:12:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-JSON-array-into-Splunk-table/m-p/347758#M102990</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-03-07T21:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse a JSON array into Splunk table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-JSON-array-into-Splunk-table/m-p/347759#M102991</link>
      <description>&lt;P&gt;If you search with &lt;CODE&gt;spath output=outlet_states path=object.outlet_states&lt;/CODE&gt; you should get a multivalue result. If you want to get individual you will have to use &lt;CODE&gt;spath output=outlet1 path=object.outlet_states{0}&lt;/CODE&gt; and similar commands.&lt;/P&gt;

&lt;P&gt;Which one do you want to use?&lt;/P&gt;

&lt;P&gt;Refer to Splunk Documentation on spath, which should have examples for both.&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;You can also enable automatic Key Value field extraction by setting KV_MODE=json in props.conf&lt;BR /&gt;
Refer to the documentation: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Automatickey-valuefieldextractionsatsearch-time"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Automatickey-valuefieldextractionsatsearch-time&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;In either case if you want to convert "false" to "off" you can use &lt;STRONG&gt;replace&lt;/STRONG&gt; command.&lt;/P&gt;

&lt;P&gt;For example your first query can be changed to &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;yourBaseSearch&amp;gt;
| spath output=outlet_states path=object.outlet_states |
| replace "false" with "off" in outlet_states 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Similarly your second option to &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;yourBaseSearch&amp;gt;
| spath output=outlet_states1 path=object.outlet_states{0} |
| replace "false" with "off" in outlet_states1 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Mar 2017 21:14:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-JSON-array-into-Splunk-table/m-p/347759#M102991</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-03-07T21:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse a JSON array into Splunk table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-JSON-array-into-Splunk-table/m-p/347760#M102992</link>
      <description>&lt;P&gt;Ok, this is great information.  so how do I display the values if I do the &lt;CODE&gt;spath output=outlet_states path=object.outlet_states&lt;/CODE&gt; right now they are just coming up blank if I do &lt;CODE&gt;table outlet_states&lt;/CODE&gt;, Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 13:04:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-JSON-array-into-Splunk-table/m-p/347760#M102992</guid>
      <dc:creator>bshega</dc:creator>
      <dc:date>2017-03-08T13:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse a JSON array into Splunk table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-JSON-array-into-Splunk-table/m-p/347761#M102993</link>
      <description>&lt;P&gt;@bshega... Will it be possible for you to copy paste a JSON mocked data sample as a code block? Use the 1010 button while pasting the code so the Splunk Answer does not interpret as special characters.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 10:25:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-JSON-array-into-Splunk-table/m-p/347761#M102993</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-03-09T10:25:56Z</dc:date>
    </item>
  </channel>
</rss>

