<?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: Simple Json formatting into table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Simple-Json-formatting-into-table/m-p/236265#M70167</link>
    <description>&lt;P&gt;Referring to the example in &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.1/SearchReference/spath#Example_3:_Extract_and_expand_JSON_events_with_multi-valued_fields"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.1/SearchReference/spath#Example_3:_Extract_and_expand_JSON_events_with_multi-valued_fields&lt;/A&gt;, below works fine for me&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|stats count |eval json1="{
\"Diagnosis\": 
      {
   \"Version\": 2,
    \"dia\": 
    [
      {
        \"name\": \"EF\",
        \"stringValue\": \"Emergency\",
        \"isRequired\": false,
        \"Defaultvalue\": \"EF\"
      },
      {
        \"name\": \"WR\",
        \"stringValue\": 0,
        \"isRequired\": true,
        \"Defaultvalue\": \"EN\"
      } 
    ]
}     
}"
|spath input=json1|rename Diagnosis.dia{}.* as *
|eval values=mvzip(mvzip(mvzip(name,stringValue),isRequired),Defaultvalue)
|mvexpand values| eval values = split(values,",") 
|eval name=mvindex(values,0)|eval stringValue=mvindex(values,1) |eval isRequired=mvindex(values,2)|eval Defaultvalue=mvindex(values,3) | table name,stringValue,isRequired,Defaultvalue
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 01 Jul 2016 04:53:21 GMT</pubDate>
    <dc:creator>renjith_nair</dc:creator>
    <dc:date>2016-07-01T04:53:21Z</dc:date>
    <item>
      <title>Simple Json formatting into table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Simple-Json-formatting-into-table/m-p/236264#M70166</link>
      <description>&lt;P&gt;Hi, I posted similar question earlier but I dont see it anymore as posted so reposting simplified version.&lt;/P&gt;

&lt;P&gt;json has this format&lt;/P&gt;

&lt;P&gt;"Diagnosis": {&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"Version": 2,&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"dia": [&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"name": "EF",&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"stringValue": "Emergency",&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"isRequired": false,&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"Defaultvalue": "EF"&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;},&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"name": "WR",&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"stringValue": 0,&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"isRequired": true,&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"Defaultvalue": "EN"&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} ]&lt;BR /&gt;
The table needs to be in this format&lt;/P&gt;

&lt;P&gt;name        stringvalue               isrequired                 defaultValue&lt;BR /&gt;
EF               Emergency                false                             EF&lt;BR /&gt;
WR                  0                              true                             EN&lt;/P&gt;

&lt;P&gt;I am not able to figure out how to put in this format, I used spath but the columns entries do not match to corresponding rows...i.e. EF might match with 0 in stringValue instead in Emeregency . I saw mention that mvzip  might work but I do not know how to use it. Can someone please help me ?&lt;/P&gt;

&lt;P&gt;Thank you !&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2016 02:45:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Simple-Json-formatting-into-table/m-p/236264#M70166</guid>
      <dc:creator>psable</dc:creator>
      <dc:date>2016-07-01T02:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Json formatting into table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Simple-Json-formatting-into-table/m-p/236265#M70167</link>
      <description>&lt;P&gt;Referring to the example in &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.1/SearchReference/spath#Example_3:_Extract_and_expand_JSON_events_with_multi-valued_fields"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.1/SearchReference/spath#Example_3:_Extract_and_expand_JSON_events_with_multi-valued_fields&lt;/A&gt;, below works fine for me&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|stats count |eval json1="{
\"Diagnosis\": 
      {
   \"Version\": 2,
    \"dia\": 
    [
      {
        \"name\": \"EF\",
        \"stringValue\": \"Emergency\",
        \"isRequired\": false,
        \"Defaultvalue\": \"EF\"
      },
      {
        \"name\": \"WR\",
        \"stringValue\": 0,
        \"isRequired\": true,
        \"Defaultvalue\": \"EN\"
      } 
    ]
}     
}"
|spath input=json1|rename Diagnosis.dia{}.* as *
|eval values=mvzip(mvzip(mvzip(name,stringValue),isRequired),Defaultvalue)
|mvexpand values| eval values = split(values,",") 
|eval name=mvindex(values,0)|eval stringValue=mvindex(values,1) |eval isRequired=mvindex(values,2)|eval Defaultvalue=mvindex(values,3) | table name,stringValue,isRequired,Defaultvalue
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Jul 2016 04:53:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Simple-Json-formatting-into-table/m-p/236265#M70167</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2016-07-01T04:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Json formatting into table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Simple-Json-formatting-into-table/m-p/236266#M70168</link>
      <description>&lt;P&gt;Thanks for reply. For some reason, this one does not return any result for me, am I missing anything ?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2016 12:59:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Simple-Json-formatting-into-table/m-p/236266#M70168</guid>
      <dc:creator>psable</dc:creator>
      <dc:date>2016-07-01T12:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Json formatting into table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Simple-Json-formatting-into-table/m-p/236267#M70169</link>
      <description>&lt;P&gt;This is just a sample dummy search and you need to apply this in your original. Are you not getting anything if you copy paste the entire section to a search window? are you getting any error?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2016 02:22:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Simple-Json-formatting-into-table/m-p/236267#M70169</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2016-07-07T02:22:16Z</dc:date>
    </item>
  </channel>
</rss>

