<?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 my JSON data with spath and table the data? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-my-JSON-data-with-spath-and-table-the-data/m-p/250463#M74805</link>
    <description>&lt;P&gt;Hello, &lt;/P&gt;

&lt;P&gt;This seems to work with your data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
| spath 
| rename Student{}.SubjectDetails{}.name AS name, Student{}.SubjectDetails{}.type AS type, Student{}.SubjectDetails{}.endTime as endTime, Student{}.SubjectDetails{}.startTime as startTime, Student{}.RollNo as RollNo 
| eval a=mvzip(Class,RollNo) 
| eval b=mvzip(date,RollNo) 
| eval c=mvzip(RollNo,name) 
| eval d=mvzip(name,type) 
| eval e=mvzip(name,startTime) 
| eval f=mvzip(name,endTime) 
| eval g=mvzip(a,b) 
| eval h=mvzip(c,d) 
| eval i=mvzip(e,f) 
| eval j=mvzip(g,h) 
| eval k=mvzip(g,i) 
| eval x=mvzip(j,k) 
| mvexpand x 
| eval x=split(x,",") 
| eval Class=mvindex(x,0) 
| eval RollNo=mvindex(x,1)
| eval date=mvindex(x,2)
| eval name=mvindex(x,5)
| eval type=mvindex(x,7)
| eval startTime=mvindex(x,13)
| eval endTime=mvindex(x,15)
| table  Class, RollNo, date, name, type startTime, endTime
&lt;/CODE&gt;&lt;/PRE&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/1358i85D6A5B4DBD83029/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;This was my first time successfully parsing json this way... I used this to learn how to do it: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.3/SearchReference/Spath"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.3/SearchReference/Spath&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 15 May 2016 11:46:09 GMT</pubDate>
    <dc:creator>jkat54</dc:creator>
    <dc:date>2016-05-15T11:46:09Z</dc:date>
    <item>
      <title>How to parse my JSON data with spath and table the data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-my-JSON-data-with-spath-and-table-the-data/m-p/250462#M74804</link>
      <description>&lt;P&gt;I am trying to parse this json using spath, &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
  "Class": "11",
  "date": "05/16/2016",
  "Student": [
    {
      "RollNo": "1234",
      "SubjectDetails": [
        {
          "type": "Mandatory",
          "startTime": "05/16/2016 21:30",
          "endTime": "05/16/2016 22:00",
          "name": "English"
        },
        {
          "type": "Optional",
          "startTime": "05/16/2016 20:00",
          "endTime": "05/16/2016 21:30",
          "name": "Math"
        }
      ]
    }
  ]
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am trying to plot it in a table. Any help will be appreciated. &lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2016 22:28:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-my-JSON-data-with-spath-and-table-the-data/m-p/250462#M74804</guid>
      <dc:creator>deepak312</dc:creator>
      <dc:date>2016-05-13T22:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse my JSON data with spath and table the data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-my-JSON-data-with-spath-and-table-the-data/m-p/250463#M74805</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;

&lt;P&gt;This seems to work with your data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
| spath 
| rename Student{}.SubjectDetails{}.name AS name, Student{}.SubjectDetails{}.type AS type, Student{}.SubjectDetails{}.endTime as endTime, Student{}.SubjectDetails{}.startTime as startTime, Student{}.RollNo as RollNo 
| eval a=mvzip(Class,RollNo) 
| eval b=mvzip(date,RollNo) 
| eval c=mvzip(RollNo,name) 
| eval d=mvzip(name,type) 
| eval e=mvzip(name,startTime) 
| eval f=mvzip(name,endTime) 
| eval g=mvzip(a,b) 
| eval h=mvzip(c,d) 
| eval i=mvzip(e,f) 
| eval j=mvzip(g,h) 
| eval k=mvzip(g,i) 
| eval x=mvzip(j,k) 
| mvexpand x 
| eval x=split(x,",") 
| eval Class=mvindex(x,0) 
| eval RollNo=mvindex(x,1)
| eval date=mvindex(x,2)
| eval name=mvindex(x,5)
| eval type=mvindex(x,7)
| eval startTime=mvindex(x,13)
| eval endTime=mvindex(x,15)
| table  Class, RollNo, date, name, type startTime, endTime
&lt;/CODE&gt;&lt;/PRE&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/1358i85D6A5B4DBD83029/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;This was my first time successfully parsing json this way... I used this to learn how to do it: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.3/SearchReference/Spath"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.3/SearchReference/Spath&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 15 May 2016 11:46:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-my-JSON-data-with-spath-and-table-the-data/m-p/250463#M74805</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-05-15T11:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse my JSON data with spath and table the data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-my-JSON-data-with-spath-and-table-the-data/m-p/250464#M74806</link>
      <description>&lt;P&gt;Thank You !! Worked like a charm.&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2016 19:42:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-my-JSON-data-with-spath-and-table-the-data/m-p/250464#M74806</guid>
      <dc:creator>deepak312</dc:creator>
      <dc:date>2016-05-16T19:42:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse my JSON data with spath and table the data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-my-JSON-data-with-spath-and-table-the-data/m-p/250465#M74807</link>
      <description>&lt;P&gt;Many thanks to you for the opportunity to learn how to parse json... now if only i had known this a couple years ago &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2016 19:58:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-my-JSON-data-with-spath-and-table-the-data/m-p/250465#M74807</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-05-16T19:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse my JSON data with spath and table the data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-my-JSON-data-with-spath-and-table-the-data/m-p/250466#M74808</link>
      <description>&lt;P&gt;This is a more general approach:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | makeresults count=3
 | eval ExtendedProperties.Name="DisplayName IsPublic Mail"
 | makemv ExtendedProperties.Name
 | eval ExtendedProperties.Value=case(
    (serial=1), "Test Group::False::testgroup@microsoft.com",
    (serial=2), "Group1::True::group1@microsoft.com",
    (serial=3), "Group2::True::group2@microsoft.com")
 | makemv delim="::" ExtendedProperties.Value
 | fields - _time

 | rename COMMENT AS "Everything above is faking your data; everyting below is your solution"

 | streamstats count AS serial
 | eval KVP=mvzip('ExtendedProperties.Name', 'ExtendedProperties.Value', "=")
 | table KVP serial
 | mvexpand KVP
 | rex field=KVP "^(?&amp;lt;KVP_key&amp;gt;[^=]+)=(?&amp;lt;KVP_value&amp;gt;[^=]+)$"
 | eval {KVP_key}=KVP_value
 | fields - KVP* 
 | stats values(*) AS * BY serial
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Jun 2017 14:37:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-my-JSON-data-with-spath-and-table-the-data/m-p/250466#M74808</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-14T14:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse my JSON data with spath and table the data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-my-JSON-data-with-spath-and-table-the-data/m-p/250467#M74809</link>
      <description>&lt;P&gt;I think it's a simplest answer:&lt;/P&gt;

&lt;P&gt;yoursearch | spath input=your_json_field&lt;/P&gt;

&lt;P&gt;Try it!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:09:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-my-JSON-data-with-spath-and-table-the-data/m-p/250467#M74809</guid>
      <dc:creator>chlima</dc:creator>
      <dc:date>2020-09-29T17:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse my JSON data with spath and table the data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-my-JSON-data-with-spath-and-table-the-data/m-p/250468#M74810</link>
      <description>&lt;P&gt;Can someone please tell me why this answer isn't working in my 7.1.3?   I only get one row instead of the two rows shown above.  I'm brand new to Splunk, but this is the 3rd similar example I've tried that is supposed to render multiple rows but does not for me.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
 | eval _raw="{\"Class\":\"11\",\"date\":\"05/16/2016\",\"Student\":[{\"RollNo\":\"1234\",\"SubjectDetails\":[{\"type\":\"Mandatory\",\"startTime\":\"05/16/2016 21:30\",\"endTime\":\"05/16/2016 22:00\",\"name\":\"English\"},{\"type\":\"Optional\",\"startTime\":\"05/16/2016 20:00\",\"endTime\":\"05/16/2016 21:30\",\"name\":\"Math\"}]}]}"
| spath | rename Student{}.SubjectDetails{}.name AS name, Student{}.SubjectDetails{}.type AS type, Student{}.SubjectDetails{}.endTime as endTime, Student{}.SubjectDetails{}.startTime as startTime, Student{}.RollNo as RollNo 
 | eval a=mvzip(Class,RollNo) 
 | eval b=mvzip(date,RollNo) 
 | eval c=mvzip(RollNo,name) 
 | eval d=mvzip(name,type) 
 | eval e=mvzip(name,startTime) 
 | eval f=mvzip(name,endTime) 
 | eval g=mvzip(a,b) 
 | eval h=mvzip(c,d) 
 | eval i=mvzip(e,f) 
 | eval j=mvzip(g,h) 
 | eval k=mvzip(g,i) 
 | eval x=mvzip(j,k) 
 | mvexpand x 
 | eval x=split(x,",") 
 | eval Class=mvindex(x,0) 
 | eval RollNo=mvindex(x,1)
 | eval date=mvindex(x,2)
 | eval name=mvindex(x,5)
 | eval type=mvindex(x,7)
 | eval startTime=mvindex(x,13)
 | eval endTime=mvindex(x,15)
 | table  Class, RollNo, date, name, type startTime, endTime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Nov 2018 15:15:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-my-JSON-data-with-spath-and-table-the-data/m-p/250468#M74810</guid>
      <dc:creator>ddelapasse</dc:creator>
      <dc:date>2018-11-21T15:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse my JSON data with spath and table the data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-my-JSON-data-with-spath-and-table-the-data/m-p/250469#M74811</link>
      <description>&lt;P&gt;Not sure when the behavior changed, but now i have to mvexpand twice:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | makeresults
  | eval _raw="{\"Class\":\"11\",\"date\":\"05/16/2016\",\"Student\":[{\"RollNo\":\"1234\",\"SubjectDetails\":[{\"type\":\"Mandatory\",\"startTime\":\"05/16/2016 21:30\",\"endTime\":\"05/16/2016 22:00\",\"name\":\"English\"},{\"type\":\"Optional\",\"startTime\":\"05/16/2016 20:00\",\"endTime\":\"05/16/2016 21:30\",\"name\":\"Math\"}]}]}"
  | spath 
  | rename Student{}.SubjectDetails{}.name AS name, Student{}.SubjectDetails{}.type AS type, Student{}.SubjectDetails{}.endTime as endTime, Student{}.SubjectDetails{}.startTime as startTime, Student{}.RollNo as RollNo
  | eval a=mvzip(name,type) 
  | mvexpand a
  | eval b=mvzip(startTime,RollNo) 
  | eval c=mvzip(a,b)
  | mvexpand c
  | eval x=split(c,",")
  | eval name=mvindex(x,0)
  | eval type=mvindex(x,1)
  | eval startTime=mvindex(x,2)
  | eval RollNo=mvindex(x,3)
  | table name, type, startTime, RollNo
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Apr 2019 15:27:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-my-JSON-data-with-spath-and-table-the-data/m-p/250469#M74811</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2019-04-02T15:27:39Z</dc:date>
    </item>
  </channel>
</rss>

