<?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: Splunk table with nested JSON - print parent item with each child item in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-table-with-nested-JSON-print-parent-item-with-each-child/m-p/399044#M71121</link>
    <description>&lt;P&gt;@kamlesh_vaghela  I did find a problem with this solution when I try to extract the task due date (1:1 with task name) as well.   Is there a way to make it mvexpand on the Task object rather than a specific attribute?  I tried this but then I was only getting 1 ProjectName with 2 task names/dates which won't work -- I need a full row for each task.&lt;/P&gt;

&lt;P&gt;Example: &lt;BR /&gt;
| makeresults &lt;BR /&gt;
 | eval _raw="{\"FirstName\":\"John\",\"LastName\":\"Doe\",\"Projects\":[{\"ProjectName\":\"Build Computer\",\"Tasks\":[{\"TaskName\":\"Order hardware\",\"TaskDueDate\":\"1/1/2018\"},{\"TaskName\":\"Install software\",\"TaskDueDate\":\"1/2/2018\"}]},{\"ProjectName\":\"Submit Timesheet\",\"Tasks\":[{\"TaskName\":\"Fill out Timesheet\",\"TaskDueDate\":\"2/1/2018\"},{\"TaskName\":\"Email Timesheet\",\"TaskDueDate\":\"2/2/2018\"}]}]}" &lt;BR /&gt;
 | spath path=Projects{} output=Projects | mvexpand Projects | rename Projects as _raw | kv | rename Tasks{}.TaskName as TaskName Tasks{}.TaskDueDate as TaskDueDate | mvexpand TaskName | table ProjectName TaskName TaskDueDate&lt;/P&gt;</description>
    <pubDate>Mon, 26 Nov 2018 13:21:00 GMT</pubDate>
    <dc:creator>ddelapasse</dc:creator>
    <dc:date>2018-11-26T13:21:00Z</dc:date>
    <item>
      <title>Splunk table with nested JSON - print parent item with each child item</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-table-with-nested-JSON-print-parent-item-with-each-child/m-p/399041#M71118</link>
      <description>&lt;P&gt;I'm a newbie and I know this should be super easy, but I can't create a table with separate rows (events) for each combination of project name + task.  Given the JSON below, I'm trying to create a table with each task in each project -- so I should have 4 entries.  Instead, I'm getting the 2 projects each with 1 task (screenshot attached).&lt;/P&gt;

&lt;P&gt;Strangely, I got this example from another forum post where people seemed to believe it was behaving correctly.  Here's what I want: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ProjectName                  TaskName
Build Computer             Order Hardware
Build Computer             Install Software
Submit Timesheet           Fill out Timesheet
Submit Timesheet           Email Timesheet
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Orig Json&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; {
   "FirstName": "John",
   "LastName": "Doe",
   "Projects": [
     {
       "ProjectName": "Build Computer",
       "Tasks": [
         {
           "TaskName": "Order hardware",
           "TaskDueDate": "1/1/2018"
         },
         {
           "TaskName": "Install software",
           "TaskDueDate": "1/2/2018"
         }
       ]
     },
     {
       "ProjectName": "Submit Timesheet",
       "Tasks": [
         {
           "TaskName": "Fill out Timesheet",
           "TaskDueDate": "2/1/2018"
         },
         {
           "TaskName": "Email Timesheet",
           "TaskDueDate": "2/2/2018"
         }
       ]
     }
   ]
 }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Here's the "answer" from the original post:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
 | eval _raw="{\"FirstName\":\"John\",\"LastName\":\"Doe\",\"Projects\":[{\"ProjectName\":\"Build Computer\",\"Tasks\":[{\"TaskName\":\"Order hardware\",\"TaskDueDate\":\"1/1/2018\"},{\"TaskName\":\"Install software\",\"TaskDueDate\":\"1/2/2018\"}]},{\"ProjectName\":\"Submit Timesheet\",\"Tasks\":[{\"TaskName\":\"Fill out Timesheet\",\"TaskDueDate\":\"2/1/2018\"},{\"TaskName\":\"Email Timesheet\",\"TaskDueDate\":\"2/2/2018\"}]}]}" | spath |rename Projects{}.Tasks{}.TaskDueDate AS x, 
Projects{}.ProjectName AS y, 
Projects{}.Tasks{}.TaskName AS z | eval joinfield = mvzip(x,mvzip(y,z)) |mvexpand joinfield |eval Name=mvindex(FirstName,0) +" "+mvindex(LastName,0) | eval spjoinfield = split(joinfield,",") | eval Date=mvindex(spjoinfield ,0) | eval ProjectName=mvindex(spjoinfield ,1)| eval TaskName=mvindex(spjoinfield ,2)|table Name ProjectName TaskName Date
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;^which returns the wrong answer (but closer than I was getting with spath):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    Build Computer             Order Hardware
    Submit Timesheet          Install Software
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Nov 2018 18:59:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-table-with-nested-JSON-print-parent-item-with-each-child/m-p/399041#M71118</guid>
      <dc:creator>ddelapasse</dc:creator>
      <dc:date>2018-11-20T18:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk table with nested JSON - print parent item with each child item</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-table-with-nested-JSON-print-parent-item-with-each-child/m-p/399042#M71119</link>
      <description>&lt;P&gt;Hi @ddelapasse,&lt;/P&gt;

&lt;P&gt;Can you please try this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH | spath path=Projects{} output=Projects | mvexpand Projects | rename Projects as _raw | kv | rename Tasks{}.TaskName as TaskName | mvexpand TaskName | table ProjectName TaskName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Sample Search:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="{\"FirstName\":\"John\",\"LastName\":\"Doe\",\"Projects\":[{\"ProjectName\":\"Build Computer\",\"Tasks\":[{\"TaskName\":\"Order hardware\",\"TaskDueDate\":\"1/1/2018\"},{\"TaskName\":\"Install software\",\"TaskDueDate\":\"1/2/2018\"}]},{\"ProjectName\":\"Submit Timesheet\",\"Tasks\":[{\"TaskName\":\"Fill out Timesheet\",\"TaskDueDate\":\"2/1/2018\"},{\"TaskName\":\"Email Timesheet\",\"TaskDueDate\":\"2/2/2018\"}]}]}" 
| spath path=Projects{} output=Projects | mvexpand Projects | rename Projects as _raw | kv | rename Tasks{}.TaskName as TaskName | mvexpand TaskName | table ProjectName TaskName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 22 Nov 2018 17:07:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-table-with-nested-JSON-print-parent-item-with-each-child/m-p/399042#M71119</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2018-11-22T17:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk table with nested JSON - print parent item with each child item</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-table-with-nested-JSON-print-parent-item-with-each-child/m-p/399043#M71120</link>
      <description>&lt;P&gt;@kamlesh_vaghela, thank you SO much!  I found 3 different examples similar to the one I posted but none of them worked for me.  I guess maybe something changed between v6 and v7?  I had not seen the kv command.  Heading to read the docs right now.&lt;/P&gt;

&lt;P&gt;thanks again!&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 02:03:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-table-with-nested-JSON-print-parent-item-with-each-child/m-p/399043#M71120</guid>
      <dc:creator>ddelapasse</dc:creator>
      <dc:date>2018-11-23T02:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk table with nested JSON - print parent item with each child item</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-table-with-nested-JSON-print-parent-item-with-each-child/m-p/399044#M71121</link>
      <description>&lt;P&gt;@kamlesh_vaghela  I did find a problem with this solution when I try to extract the task due date (1:1 with task name) as well.   Is there a way to make it mvexpand on the Task object rather than a specific attribute?  I tried this but then I was only getting 1 ProjectName with 2 task names/dates which won't work -- I need a full row for each task.&lt;/P&gt;

&lt;P&gt;Example: &lt;BR /&gt;
| makeresults &lt;BR /&gt;
 | eval _raw="{\"FirstName\":\"John\",\"LastName\":\"Doe\",\"Projects\":[{\"ProjectName\":\"Build Computer\",\"Tasks\":[{\"TaskName\":\"Order hardware\",\"TaskDueDate\":\"1/1/2018\"},{\"TaskName\":\"Install software\",\"TaskDueDate\":\"1/2/2018\"}]},{\"ProjectName\":\"Submit Timesheet\",\"Tasks\":[{\"TaskName\":\"Fill out Timesheet\",\"TaskDueDate\":\"2/1/2018\"},{\"TaskName\":\"Email Timesheet\",\"TaskDueDate\":\"2/2/2018\"}]}]}" &lt;BR /&gt;
 | spath path=Projects{} output=Projects | mvexpand Projects | rename Projects as _raw | kv | rename Tasks{}.TaskName as TaskName Tasks{}.TaskDueDate as TaskDueDate | mvexpand TaskName | table ProjectName TaskName TaskDueDate&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 13:21:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-table-with-nested-JSON-print-parent-item-with-each-child/m-p/399044#M71121</guid>
      <dc:creator>ddelapasse</dc:creator>
      <dc:date>2018-11-26T13:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk table with nested JSON - print parent item with each child item</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-table-with-nested-JSON-print-parent-item-with-each-child/m-p/399045#M71122</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/150956"&gt;@ddelapasse&lt;/a&gt; &lt;/P&gt;

&lt;P&gt;were you able to get a solution to this problem? I am breaking my head with a similar issue.&lt;/P&gt;

&lt;P&gt;My json output looks like this:&lt;BR /&gt;
 {&lt;BR /&gt;
    "plugins": [&lt;BR /&gt;
        {&lt;BR /&gt;
            "key": "aemrules",&lt;BR /&gt;
            "name": "AEM Rules for SonarQube",&lt;BR /&gt;
            "category": "External Analysers",&lt;BR /&gt;
            "description": "Adds rules for AEM Java development",&lt;BR /&gt;
            "license": "The Apache Software License, Version 2.0",&lt;BR /&gt;
            "organizationName": "Cognifide Limited",&lt;BR /&gt;
            "organizationUrl": "&lt;A href="http://www.cognifide.com" target="_blank"&gt;http://www.cognifide.com&lt;/A&gt;",&lt;BR /&gt;
            "homepageUrl": "&lt;A href="https://github.com/Cognifide/AEM-Rules-for-SonarQube" target="_blank"&gt;https://github.com/Cognifide/AEM-Rules-for-SonarQube&lt;/A&gt;",&lt;BR /&gt;
            "issueTrackerUrl": "&lt;A href="https://github.com/Cognifide/AEM-Rules-for-SonarQube/issues" target="_blank"&gt;https://github.com/Cognifide/AEM-Rules-for-SonarQube/issues&lt;/A&gt;",&lt;BR /&gt;
            "editionBundled": false,&lt;BR /&gt;
            "updates": [&lt;BR /&gt;
                {&lt;BR /&gt;
                    "release": {&lt;BR /&gt;
                        "version": "1.0",&lt;BR /&gt;
                        "date": "2020-02-07",&lt;BR /&gt;
                        "description": "HTL Support",&lt;BR /&gt;
                        "changeLogUrl": "&lt;A href="https://github.com/Cognifide/AEM-Rules-for-SonarQube/releases/tag/v1.0" target="_blank"&gt;https://github.com/Cognifide/AEM-Rules-for-SonarQube/releases/tag/v1.0&lt;/A&gt;"&lt;BR /&gt;
                    },&lt;BR /&gt;
                    "status": "COMPATIBLE",&lt;BR /&gt;
                    "requires": [&lt;BR /&gt;
                        {&lt;BR /&gt;
                            "key": "java",&lt;BR /&gt;
                            "name": "Java Code Quality and Security",&lt;BR /&gt;
                            "description": "Code Analyzer for Java"&lt;BR /&gt;
                        }&lt;BR /&gt;
                    ]&lt;BR /&gt;
                },&lt;BR /&gt;
                {&lt;BR /&gt;
                    "release": {&lt;BR /&gt;
                        "version": "1.1",&lt;BR /&gt;
                        "date": "2020-04-02",&lt;BR /&gt;
                        "description": "Java Plugin 6.2 support",&lt;BR /&gt;
                        "changeLogUrl": "&lt;A href="https://github.com/Cognifide/AEM-Rules-for-SonarQube/releases/tag/v1.1" target="_blank"&gt;https://github.com/Cognifide/AEM-Rules-for-SonarQube/releases/tag/v1.1&lt;/A&gt;"&lt;BR /&gt;
                    },&lt;BR /&gt;
                    "status": "COMPATIBLE",&lt;BR /&gt;
                    "requires": [&lt;BR /&gt;
                        {&lt;BR /&gt;
                            "key": "java",&lt;BR /&gt;
                            "name": "Java Code Quality and Security",&lt;BR /&gt;
                            "description": "Code Analyzer for Java"&lt;BR /&gt;
                        }&lt;BR /&gt;
                    ]&lt;BR /&gt;
                }&lt;BR /&gt;
            ]&lt;BR /&gt;
        }&lt;/P&gt;

&lt;P&gt;each parent "key" has multiple child "releases" for which i need the corresponding "version" and "date"&lt;/P&gt;

&lt;P&gt;output format: key version date&lt;/P&gt;

&lt;P&gt;No matter what i do, i am unable  to print the key (repeatedly for each release/version) in a table .The results get truncated to the exact number of keys. However when i print just version and date, all versions and dates get printed. Seems like i am unable to pair the "key" with multiple  "versions" and "dates". Please help.&lt;/P&gt;

&lt;P&gt;I am trying to use the query:&lt;/P&gt;

&lt;P&gt;index=edot_sonarqube_prod sourcetype="sonarqube-ceLogs-splunk" "/api/plugins/updates"|head 1&lt;BR /&gt;
|eval json_field = _raw&lt;BR /&gt;
 | spath input=json_field path=data.plugins{}.key output=key | spath input=json_field path=data.plugins{}.updates{}.release{}.version output=version|spath input=json_field path=data.plugins{}.updates{}.release{}.date output=date&lt;BR /&gt;
   | eval test=mvzip(key,version)|mvexpand test|eval test1=mvzip(test,date)&lt;BR /&gt;
   | mvexpand test1 &lt;BR /&gt;
 | eval test1 = split(test1,",") | eval key=mvindex(test1,0) | eval version=mvindex(test1,1) | eval date=mvindex(test1,2) | table key version date|sort key&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:23:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-table-with-nested-JSON-print-parent-item-with-each-child/m-p/399045#M71122</guid>
      <dc:creator>rsantkumar</dc:creator>
      <dc:date>2020-09-30T05:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk table with nested JSON - print parent item with each child item</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-table-with-nested-JSON-print-parent-item-with-each-child/m-p/399046#M71123</link>
      <description>&lt;P&gt;@rsantkumar This question has an accepted answer.  If the solution does not work for you then please post a new question.&lt;/P&gt;</description>
      <pubDate>Sun, 10 May 2020 18:55:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-table-with-nested-JSON-print-parent-item-with-each-child/m-p/399046#M71123</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-05-10T18:55:50Z</dc:date>
    </item>
  </channel>
</rss>

