<?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 Unable to parse nested json in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Unable-to-parse-nested-json/m-p/456384#M99433</link>
    <description>&lt;P&gt;Hello All,&lt;/P&gt;

&lt;P&gt;I am facing issues parsing the json data to form the required table. &lt;BR /&gt;
The json file is being pulled in the splunk as a single event. I am able to fetch the fields separately but unable to correlate them as illustrated in json. &lt;BR /&gt;
Please let me know if it is doable. if yes, then how ?&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Query&lt;/STRONG&gt;: &lt;BR /&gt;
&lt;EM&gt;source=source1 host=host1 index=index1 sourcetype=_json1 &lt;BR /&gt;
| head 1 &lt;BR /&gt;
| table issues{}.fields{}.project, issues{}.changelog.histories{}.author, issues{}.changelog.histories{}.created&lt;/EM&gt; &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Input json:&lt;/STRONG&gt;&lt;BR /&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/7548i0BD7F8753AA389C3/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;&lt;STRONG&gt;The required output table:&lt;/STRONG&gt;&lt;BR /&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/7549i417F0954164F571D/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>Mon, 19 Aug 2019 10:47:04 GMT</pubDate>
    <dc:creator>aayushisplunk1</dc:creator>
    <dc:date>2019-08-19T10:47:04Z</dc:date>
    <item>
      <title>Unable to parse nested json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Unable-to-parse-nested-json/m-p/456384#M99433</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;

&lt;P&gt;I am facing issues parsing the json data to form the required table. &lt;BR /&gt;
The json file is being pulled in the splunk as a single event. I am able to fetch the fields separately but unable to correlate them as illustrated in json. &lt;BR /&gt;
Please let me know if it is doable. if yes, then how ?&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Query&lt;/STRONG&gt;: &lt;BR /&gt;
&lt;EM&gt;source=source1 host=host1 index=index1 sourcetype=_json1 &lt;BR /&gt;
| head 1 &lt;BR /&gt;
| table issues{}.fields{}.project, issues{}.changelog.histories{}.author, issues{}.changelog.histories{}.created&lt;/EM&gt; &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Input json:&lt;/STRONG&gt;&lt;BR /&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/7548i0BD7F8753AA389C3/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;&lt;STRONG&gt;The required output table:&lt;/STRONG&gt;&lt;BR /&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/7549i417F0954164F571D/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>Mon, 19 Aug 2019 10:47:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Unable-to-parse-nested-json/m-p/456384#M99433</guid>
      <dc:creator>aayushisplunk1</dc:creator>
      <dc:date>2019-08-19T10:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to parse nested json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Unable-to-parse-nested-json/m-p/456385#M99434</link>
      <description>&lt;P&gt;what kind of default fields are you getting under interesting fields and have you tried spath?&lt;BR /&gt;
If you want more precise help, can you please post your event sample as text so that we can re-use it ?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 10:52:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Unable-to-parse-nested-json/m-p/456385#M99434</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-19T10:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to parse nested json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Unable-to-parse-nested-json/m-p/456386#M99435</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;Thank you for your quick response!&lt;BR /&gt;
As for your queries: &lt;/P&gt;

&lt;P&gt;The default fields i am getting are given as below: &lt;BR /&gt;
&lt;EM&gt;issues{}.fields{}.project, &lt;BR /&gt;
issues{}.changelog.histories{}.author, &lt;BR /&gt;
issues{}.changelog.histories{}.created,&lt;BR /&gt;
issues{}.id&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;i tried using spath but i guess it will not be able to help much as i already have the required fields. It is just that that i am unable to correlate these field values as per the json.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;json in text:&lt;/STRONG&gt; &lt;/P&gt;

&lt;P&gt;*{&lt;BR /&gt;&lt;BR /&gt;
     issues:    [&lt;BR /&gt;
        {&lt;BR /&gt;
         changelog: {&lt;BR /&gt;&lt;BR /&gt;
             histories: [&lt;BR /&gt;&lt;BR /&gt;
            {&lt;BR /&gt;&lt;BR /&gt;
                 author:    ABC&lt;BR /&gt;
                 created:   123 &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        }   
        {   
             author:    XYZ
             created:    456

        }   
        ]   
    }   
     fields:    {
         project: test1
    }   
     id: 1
    }
    {
     changelog: {   
         histories: [   
        {   
             author:    ABC
             created:   1234    

        }   
        {   
             author:    XYZ4
             created:    456

        }   
        ]   
    }   
     fields:    {
         project: test1
    }   
      id : 2
    }
    {
     changelog: {   
         histories: [   
        {   
             author:    ABC2
             created:   1232    

        }   
        {   
             author:    XYZ2
             created:    4562

        }   
        ]   
    }   
     fields:    {
         project: test12 
    }   
     id: 3
    }
            ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;}*      &lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 11:12:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Unable-to-parse-nested-json/m-p/456386#M99435</guid>
      <dc:creator>aayushisplunk1</dc:creator>
      <dc:date>2019-08-19T11:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to parse nested json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Unable-to-parse-nested-json/m-p/456387#M99436</link>
      <description>&lt;P&gt;@aayushisplunk1 &lt;/P&gt;

&lt;P&gt;Can you please share &lt;CODE&gt;raw&lt;/CODE&gt; event?  Your provided event is not valid JSON.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 11:14:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Unable-to-parse-nested-json/m-p/456387#M99436</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-08-19T11:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to parse nested json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Unable-to-parse-nested-json/m-p/456388#M99437</link>
      <description>&lt;P&gt;Hello @aayushisplunk1 , &lt;/P&gt;

&lt;P&gt;See this: &lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/366957/how-do-i-get-splunk-to-extract-nested-json-arrays.html"&gt;https://answers.splunk.com/answers/366957/how-do-i-get-splunk-to-extract-nested-json-arrays.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;And this link too: &lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/762294/parse-nested-json-array-into-splunk-table.html"&gt;https://answers.splunk.com/answers/762294/parse-nested-json-array-into-splunk-table.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 11:21:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Unable-to-parse-nested-json/m-p/456388#M99437</guid>
      <dc:creator>Kawtar</dc:creator>
      <dc:date>2019-08-19T11:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to parse nested json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Unable-to-parse-nested-json/m-p/456389#M99438</link>
      <description>&lt;P&gt;@kamlesh_vaghela &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Raw event:&lt;/STRONG&gt; &lt;/P&gt;

&lt;P&gt;{"issues":[{"changelog":{"histories":[{"author":"ABC","created":"123"},{"author":"XYZ","created":"456"}]},"fields":{"project":"test1"},"id":"1"},{"changelog":{"histories":[{"author":"ABC","created":"1234"},{"author":"XYZ4","created":"456"}]},"fields":{"project":"test1"},"id":"2"},{"changelog":{"histories":[{"author":"ABC2","created":"1232"},{"author":"XYZ2","created":"4562"}]},"fields":{"project":"test12"},"id":"3"}]}&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 11:27:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Unable-to-parse-nested-json/m-p/456389#M99438</guid>
      <dc:creator>aayushisplunk1</dc:creator>
      <dc:date>2019-08-19T11:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to parse nested json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Unable-to-parse-nested-json/m-p/456390#M99439</link>
      <description>&lt;P&gt;@aayushisplunk1 &lt;/P&gt;

&lt;P&gt;Can you please try this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH 
| spath path=issues{} output=issues 
| mvexpand issues 
| fields issues 
| eval _raw=issues 
| extract 
| rename changelog.histories{}.* as * ,fields.* as *
| eval temp = mvzip(author,created) | mvexpand temp | eval author=mvindex(split(temp,","),0), created=mvindex(split(temp,","),1) | table project author created
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sample Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="{\"issues\":[{\"changelog\":{\"histories\":[{\"author\":\"ABC\",\"created\":\"123\"},{\"author\":\"XYZ\",\"created\":\"456\"}]},\"fields\":{\"project\":\"test1\"},\"id\":\"1\"},{\"changelog\":{\"histories\":[{\"author\":\"ABC\",\"created\":\"1234\"},{\"author\":\"XYZ4\",\"created\":\"456\"}]},\"fields\":{\"project\":\"test1\"},\"id\":\"2\"},{\"changelog\":{\"histories\":[{\"author\":\"ABC2\",\"created\":\"1232\"},{\"author\":\"XYZ2\",\"created\":\"4562\"}]},\"fields\":{\"project\":\"test12\"},\"id\":\"3\"}]}" 
| extract 
| spath path=issues{} output=issues 
| mvexpand issues 
| fields issues 
| eval _raw=issues 
| extract 
| rename changelog.histories{}.* as * ,fields.* as *
| eval temp = mvzip(author,created) | mvexpand temp | eval author=mvindex(split(temp,","),0), created=mvindex(split(temp,","),1) | table project author created
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 11:38:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Unable-to-parse-nested-json/m-p/456390#M99439</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-08-19T11:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to parse nested json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Unable-to-parse-nested-json/m-p/456391#M99440</link>
      <description>&lt;P&gt;try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
 | eval raw="issues:    [
     {
        changelog:    {    
          histories:    [    
           {    
              author:    ABC
              created:    123    

           }    
           {    
              author:    XYZ
              created:     456

           }    
         ]    
       }    
        fields:    {
          project: test1
       }    
      id: 1
     }
     {
        changelog:    {    
          histories:    [    
           {    
              author:    ABC
              created:    1234    

           }    
           {    
              author:    XYZ4
              created:     456

           }    
         ]    
       }    
        fields:    {
          project: test1
       }    
       id : 2
     }
     {
        changelog:    {    
          histories:    [    
           {    
              author:    ABC2
              created:    1232    

           }    
           {    
              author:    XYZ2
              created:     4562

           }    
         ]    
       }    
        fields:    {
          project: test12 
       }    
      id: 3
     }
             ]"
| eval raw=split(raw,"id")
| mvexpand raw
|rex field=raw "author:(?&amp;lt;author&amp;gt;.*)" max_match=0 
| rex field=raw "created:(?&amp;lt;created&amp;gt;.*)" max_match=0
|eval x=mvzip(author,created)
| rex field=raw "project:(?&amp;lt;project&amp;gt;.*)" max_match=0

|  fields - _time
| fields project,x
| mvexpand x
| rex field=x "(?&amp;lt;author&amp;gt;.*?)," max_match=0| rex field=x ",(?&amp;lt;created&amp;gt;.*)" max_match=0
| fields project,author,created
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Aug 2019 12:04:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Unable-to-parse-nested-json/m-p/456391#M99440</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-19T12:04:48Z</dc:date>
    </item>
  </channel>
</rss>

