<?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 convert JSON Keys and values as columns in splunk in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-Keys-and-values-as-columns-in-splunk/m-p/219120#M98866</link>
    <description>&lt;P&gt;Try this spath example:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/6.4.2/SearchReference/Spath#Example_3:_Extract_and_expand_JSON_events_with_multi-valued_fields"&gt;https://docs.splunk.com/Documentation/Splunk/6.4.2/SearchReference/Spath#Example_3:_Extract_and_expand_JSON_events_with_multi-valued_fields&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 09 Aug 2016 01:07:32 GMT</pubDate>
    <dc:creator>jkat54</dc:creator>
    <dc:date>2016-08-09T01:07:32Z</dc:date>
    <item>
      <title>How to convert JSON Keys and values as columns in splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-Keys-and-values-as-columns-in-splunk/m-p/219119#M98865</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I want to flatten json data to columns for my report purpose. I might not be explaining my requirement properly, here is what my data and result has to be.&lt;/P&gt;

&lt;P&gt;Input:&lt;/P&gt;

&lt;P&gt;{&lt;BR /&gt;
    "name" : "srini",&lt;BR /&gt;
    "value" {&lt;BR /&gt;
        "1": "val1",&lt;BR /&gt;
        "2" : "val2",&lt;BR /&gt;
        "3" : "val3"&lt;BR /&gt;
    }&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;Output:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;name, name.key, name.value
------------------------------------------
srini      1         val1
srini      2         val2
srini      3         val3
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Aug 2016 01:02:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-Keys-and-values-as-columns-in-splunk/m-p/219119#M98865</guid>
      <dc:creator>sdaruna</dc:creator>
      <dc:date>2016-08-09T01:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert JSON Keys and values as columns in splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-Keys-and-values-as-columns-in-splunk/m-p/219120#M98866</link>
      <description>&lt;P&gt;Try this spath example:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/6.4.2/SearchReference/Spath#Example_3:_Extract_and_expand_JSON_events_with_multi-valued_fields"&gt;https://docs.splunk.com/Documentation/Splunk/6.4.2/SearchReference/Spath#Example_3:_Extract_and_expand_JSON_events_with_multi-valued_fields&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 01:07:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-Keys-and-values-as-columns-in-splunk/m-p/219120#M98866</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-08-09T01:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert JSON Keys and values as columns in splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-Keys-and-values-as-columns-in-splunk/m-p/219121#M98867</link>
      <description>&lt;P&gt;I think your JSON is wrong and there's a colon missing after value.&lt;BR /&gt;
In any case, see if the below helps:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval json = "
{
   \"name\" : \"srini\",
   \"value\": {
      \"1\": \"val1\",
      \"2\" : \"val2\",
      \"3\" : \"val3\"
   }
}
"
| spath input=json
| fields - json
| untable name key value
| rex field=key "(?&amp;lt;key&amp;gt;\d+)"
| rename key AS name.key, value AS name.value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Output (see picture below):&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/1698i0AFF55BD91D58013/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 08:27:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-Keys-and-values-as-columns-in-splunk/m-p/219121#M98867</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-08-09T08:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert JSON Keys and values as columns in splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-Keys-and-values-as-columns-in-splunk/m-p/219122#M98868</link>
      <description>&lt;P&gt;I have so many key value pairs under "value" field. So it is not possible to specify each and every key of "value" field.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 20:39:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-Keys-and-values-as-columns-in-splunk/m-p/219122#M98868</guid>
      <dc:creator>sdaruna</dc:creator>
      <dc:date>2016-08-09T20:39:15Z</dc:date>
    </item>
  </channel>
</rss>

