<?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 would you create a table from json array with a nested a array in each object in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-would-you-create-a-table-from-json-array-with-a-nested-a/m-p/481746#M82573</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="{ \"Items\": [ { \"CN\": \"AccountName\", \"CV\": \"AccountOne\", \"Props\": [ { \"PN\": \"PropOne\", \"PV\": \"5\" }, { \"PN\": \"PropTwo\", \"PV\": \"3\" } ] }, { \"CN\": \"AccountName\", \"CV\": \"AccountOne\", \"Props\": [ { \"PN\": \"PropOne\", \"PV\": \"5\" } ] }, { \"CN\": \"AccountName\", \"CV\": \"AccountTwo\", \"Props\": [ { \"PN\": \"PropOne\", \"PV\": \"5\" }, { \"PN\": \"PropThree\", \"PV\": \"8\" } ] }, { \"CN\": \"PersonName\", \"CV\": \"Bob\", \"Props\": [ { \"PN\": \"PropOne\", \"PV\": \"5\" }, { \"PN\": \"PropThree\", \"PV\": \"8\" } ] }, { \"CN\": \"PersonName\", \"CV\": \"Bob\", \"Props\": [ { \"PN\": \"PropThree\", \"PV\": \"8\" } ] } ] }"
| spath path=Items{} output=Items
| stats count by Items
| spath input=Items path=Props{} output=Props
| mvexpand Props
| spath input=Props
| spath input=Items
| fields - Items count Props*
| eval names=CN."_".CV
| stats sum(PV) as PV by names PN
| xyseries names PN PV
| rex field=names "AccountName_(?&amp;lt;AccountName&amp;gt;\w+)|PersonName_(?&amp;lt;PersonName&amp;gt;\w+)"
| table PersonName AccountName PropOne PropTwo PropThree
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 22 Apr 2020 01:19:45 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2020-04-22T01:19:45Z</dc:date>
    <item>
      <title>How would you create a table from json array with a nested a array in each object</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-would-you-create-a-table-from-json-array-with-a-nested-a/m-p/481745#M82572</link>
      <description>&lt;P&gt;I have tried quite a few different ways to capture data within a json object and return it as separate events, but my break-down always occurs when attempting to access the data in the nested arrays.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
    "Items": [
        {
            "CN": "AccountName",
            "CV": "AccountOne",
            "Props": [
                {
                    "PN": "PropOne",
                    "PV": "5"
                },
                {
                    "PN": "PropTwo",
                    "PV": "3"
                }
            ]
        },
        {
            "CN": "AccountName",
            "CV": "AccountOne",
            "Props": [
                {
                    "PN": "PropOne",
                    "PV": "5"
                }
            ]
        },
        {
            "CN": "AccountName",
            "CV": "AccountTwo",
            "Props": [
                {
                    "PN": "PropOne",
                    "PV": "5"
                },
                {
                    "PN": "PropThree",
                    "PV": "8"
                }
            ]
        },
        {
            "CN": "PersonName",
            "CV": "Bob",
            "Props": [
                {
                    "PN": "PropOne",
                    "PV": "5"
                },
                {
                    "PN": "PropThree",
                    "PV": "8"
                }
            ]
        },
        {
            "CN": "PersonName",
            "CV": "Bob",
            "Props": [
                {
                    "PN": "PropThree",
                    "PV": "8"
                }
            ]
        }
    ]
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;Prepared version for testing:&lt;/P&gt;

&lt;H2&gt;{ \"Items\": [ { \"CN\": \"AccountName\", \"CV\": \"AccountOne\", \"Props\": [ { \"PN\": \"PropOne\", \"PV\": \"5\" }, { \"PN\": \"PropTwo\", \"PV\": \"3\" } ] }, { \"CN\": \"AccountName\", \"CV\": \"AccountOne\", \"Props\": [ { \"PN\": \"PropOne\", \"PV\": \"5\" } ] }, { \"CN\": \"AccountName\", \"CV\": \"AccountTwo\", \"Props\": [ { \"PN\": \"PropOne\", \"PV\": \"5\" }, { \"PN\": \"PropThree\", \"PV\": \"8\" } ] }, { \"CN\": \"PersonName\", \"CV\": \"Bob\", \"Props\": [ { \"PN\": \"PropOne\", \"PV\": \"5\" }, { \"PN\": \"PropThree\", \"PV\": \"8\" } ] }, { \"CN\": \"PersonName\", \"CV\": \"Bob\", \"Props\": [ { \"PN\": \"PropThree\", \"PV\": \"8\" } ] } ] }&lt;/H2&gt;

&lt;P&gt;I would want this to result in something like:&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/8751i16A83C9FB6B8F252/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;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 23:53:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-would-you-create-a-table-from-json-array-with-a-nested-a/m-p/481745#M82572</guid>
      <dc:creator>topherbirth</dc:creator>
      <dc:date>2020-04-21T23:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: How would you create a table from json array with a nested a array in each object</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-would-you-create-a-table-from-json-array-with-a-nested-a/m-p/481746#M82573</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="{ \"Items\": [ { \"CN\": \"AccountName\", \"CV\": \"AccountOne\", \"Props\": [ { \"PN\": \"PropOne\", \"PV\": \"5\" }, { \"PN\": \"PropTwo\", \"PV\": \"3\" } ] }, { \"CN\": \"AccountName\", \"CV\": \"AccountOne\", \"Props\": [ { \"PN\": \"PropOne\", \"PV\": \"5\" } ] }, { \"CN\": \"AccountName\", \"CV\": \"AccountTwo\", \"Props\": [ { \"PN\": \"PropOne\", \"PV\": \"5\" }, { \"PN\": \"PropThree\", \"PV\": \"8\" } ] }, { \"CN\": \"PersonName\", \"CV\": \"Bob\", \"Props\": [ { \"PN\": \"PropOne\", \"PV\": \"5\" }, { \"PN\": \"PropThree\", \"PV\": \"8\" } ] }, { \"CN\": \"PersonName\", \"CV\": \"Bob\", \"Props\": [ { \"PN\": \"PropThree\", \"PV\": \"8\" } ] } ] }"
| spath path=Items{} output=Items
| stats count by Items
| spath input=Items path=Props{} output=Props
| mvexpand Props
| spath input=Props
| spath input=Items
| fields - Items count Props*
| eval names=CN."_".CV
| stats sum(PV) as PV by names PN
| xyseries names PN PV
| rex field=names "AccountName_(?&amp;lt;AccountName&amp;gt;\w+)|PersonName_(?&amp;lt;PersonName&amp;gt;\w+)"
| table PersonName AccountName PropOne PropTwo PropThree
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Apr 2020 01:19:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-would-you-create-a-table-from-json-array-with-a-nested-a/m-p/481746#M82573</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-22T01:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: How would you create a table from json array with a nested a array in each object</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-would-you-create-a-table-from-json-array-with-a-nested-a/m-p/481747#M82574</link>
      <description>&lt;P&gt;That works. Thanks!&lt;/P&gt;

&lt;P&gt;Any chance we could get an explanation for how it works? I would like to learn from it, but it's hard for me to tell exactly whats happening.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 02:04:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-would-you-create-a-table-from-json-array-with-a-nested-a/m-p/481747#M82574</guid>
      <dc:creator>topherbirth</dc:creator>
      <dc:date>2020-04-22T02:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: How would you create a table from json array with a nested a array in each object</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-would-you-create-a-table-from-json-array-with-a-nested-a/m-p/481748#M82575</link>
      <description>&lt;P&gt;Try line by line and check result. &lt;/P&gt;

&lt;P&gt;spath session: &lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;see reference: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath"&gt;spath&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;first &lt;CODE&gt;stats count by&lt;/CODE&gt; is to divide 5 &lt;EM&gt;Items&lt;/EM&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;mvexpand&lt;/CODE&gt; is to divide &lt;EM&gt;Props&lt;/EM&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;xyseries session:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;see reference: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Xyseries"&gt;xyseries&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;xyseries&lt;/CODE&gt; can have many args. but it is hard to understand and handle over 4 args.&lt;/LI&gt;
&lt;LI&gt;so, let' make only three fields(args).  &lt;CODE&gt;| eval names=CN."_".CV&lt;/CODE&gt; this is trick.&lt;/LI&gt;
&lt;LI&gt;aggregate by &lt;CODE&gt;| stats sum(PV) as PV by names PN&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;rex&lt;/CODE&gt; is to extract fields by REGEX.&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Is this enough?  happy Splunking.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 02:29:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-would-you-create-a-table-from-json-array-with-a-nested-a/m-p/481748#M82575</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-22T02:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: How would you create a table from json array with a nested a array in each object</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-would-you-create-a-table-from-json-array-with-a-nested-a/m-p/481749#M82576</link>
      <description>&lt;P&gt;Good deal! Thanks for the info and help.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 03:25:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-would-you-create-a-table-from-json-array-with-a-nested-a/m-p/481749#M82576</guid>
      <dc:creator>topherbirth</dc:creator>
      <dc:date>2020-04-22T03:25:26Z</dc:date>
    </item>
  </channel>
</rss>

