<?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 How do you extract dynamic nested array coordinates from JSON? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-dynamic-nested-array-coordinates-from-JSON/m-p/442931#M125703</link>
    <description>&lt;P&gt;I need help in extracting fields from the dynamically nested array coordinates from JSON. &lt;/P&gt;

&lt;P&gt;Here is the example data.&lt;/P&gt;

&lt;P&gt;thirdParty: {   [-] &lt;BR /&gt;
             Adobe Analytics:   {   [-] &lt;BR /&gt;
                 bytes:  3182&lt;BR /&gt;&lt;BR /&gt;
                 end_time:   1726&lt;BR /&gt;&lt;BR /&gt;
                 requests:   4&lt;BR /&gt;&lt;BR /&gt;
                 serial_time:    212&lt;BR /&gt;&lt;BR /&gt;
                 start_time:     773&lt;BR /&gt;&lt;BR /&gt;
                 total_user_time:    953&lt;BR /&gt;&lt;BR /&gt;
            }&lt;BR /&gt;&lt;BR /&gt;
             Adobe TypeKit: {   [-] &lt;BR /&gt;
                 bytes:  162558 &lt;BR /&gt;
                 end_time:   895&lt;BR /&gt;&lt;BR /&gt;
                 requests:   4&lt;BR /&gt;&lt;BR /&gt;
                 serial_time:    38 &lt;BR /&gt;
                 start_time:     446&lt;BR /&gt;&lt;BR /&gt;
                 total_user_time:    449&lt;BR /&gt;&lt;BR /&gt;
            }&lt;BR /&gt;&lt;BR /&gt;
             Cloudfront:    {   [-] &lt;BR /&gt;
                 bytes:  21578&lt;BR /&gt;&lt;BR /&gt;
                 end_time:   2241&lt;BR /&gt;&lt;BR /&gt;
                 requests:   1&lt;BR /&gt;&lt;BR /&gt;
                 serial_time:    26 &lt;BR /&gt;
                 start_time:     2215&lt;BR /&gt;&lt;BR /&gt;
                 total_user_time:    26 &lt;BR /&gt;
            }   &lt;/P&gt;

&lt;P&gt;The number of arrays within the ThirdParty array is dynamic. And I need to create a table like this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Site    total_user_time
Adobe Analytics 953
Adobe TypeKit   449
Cloudfront  26
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 29 Sep 2020 22:27:03 GMT</pubDate>
    <dc:creator>aravindhan_padm</dc:creator>
    <dc:date>2020-09-29T22:27:03Z</dc:date>
    <item>
      <title>How do you extract dynamic nested array coordinates from JSON?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-dynamic-nested-array-coordinates-from-JSON/m-p/442931#M125703</link>
      <description>&lt;P&gt;I need help in extracting fields from the dynamically nested array coordinates from JSON. &lt;/P&gt;

&lt;P&gt;Here is the example data.&lt;/P&gt;

&lt;P&gt;thirdParty: {   [-] &lt;BR /&gt;
             Adobe Analytics:   {   [-] &lt;BR /&gt;
                 bytes:  3182&lt;BR /&gt;&lt;BR /&gt;
                 end_time:   1726&lt;BR /&gt;&lt;BR /&gt;
                 requests:   4&lt;BR /&gt;&lt;BR /&gt;
                 serial_time:    212&lt;BR /&gt;&lt;BR /&gt;
                 start_time:     773&lt;BR /&gt;&lt;BR /&gt;
                 total_user_time:    953&lt;BR /&gt;&lt;BR /&gt;
            }&lt;BR /&gt;&lt;BR /&gt;
             Adobe TypeKit: {   [-] &lt;BR /&gt;
                 bytes:  162558 &lt;BR /&gt;
                 end_time:   895&lt;BR /&gt;&lt;BR /&gt;
                 requests:   4&lt;BR /&gt;&lt;BR /&gt;
                 serial_time:    38 &lt;BR /&gt;
                 start_time:     446&lt;BR /&gt;&lt;BR /&gt;
                 total_user_time:    449&lt;BR /&gt;&lt;BR /&gt;
            }&lt;BR /&gt;&lt;BR /&gt;
             Cloudfront:    {   [-] &lt;BR /&gt;
                 bytes:  21578&lt;BR /&gt;&lt;BR /&gt;
                 end_time:   2241&lt;BR /&gt;&lt;BR /&gt;
                 requests:   1&lt;BR /&gt;&lt;BR /&gt;
                 serial_time:    26 &lt;BR /&gt;
                 start_time:     2215&lt;BR /&gt;&lt;BR /&gt;
                 total_user_time:    26 &lt;BR /&gt;
            }   &lt;/P&gt;

&lt;P&gt;The number of arrays within the ThirdParty array is dynamic. And I need to create a table like this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Site    total_user_time
Adobe Analytics 953
Adobe TypeKit   449
Cloudfront  26
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:27:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-dynamic-nested-array-coordinates-from-JSON/m-p/442931#M125703</guid>
      <dc:creator>aravindhan_padm</dc:creator>
      <dc:date>2020-09-29T22:27:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do you extract dynamic nested array coordinates from JSON?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-dynamic-nested-array-coordinates-from-JSON/m-p/442932#M125704</link>
      <description>&lt;P&gt;@aravindhan_padmanabhan &lt;/P&gt;

&lt;P&gt;Can you please try below search?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH | spath thirdParty output=_raw | kv | fields *.total_user_time, | fields - thirdParty.* _raw, _time | rename *.total_user_time as * | transpose column_name=Site | rename "row 1" as total_user_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My Sample Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval _raw="{\"thirdParty\": {\"Adobe Analytics\": {\"bytes\": \"3182\",\"end_time\": \"1726\",\"requests\": \"4\",\"serial_time\": \"212\",\"start_time\": \"773\",\"total_user_time\": \"953\"},\"Adobe TypeKit\": {\"bytes\": \"162558\",\"end_time\": \"895\",\"requests\": \"4\",\"serial_time\": \"38\",\"start_time\": \"446\",\"total_user_time\": \"449\"},\"Cloudfront\": {\"bytes\": \"21578\",\"end_time\": \"2241\",\"requests\": \"1\",\"serial_time\": \"26\",\"start_time\": \"2215\",\"total_user_time\": \"26\"}}}" | kv | spath thirdParty output=_raw | kv | fields *.total_user_time, | fields - thirdParty.* _raw, _time
| rename *.total_user_time as * | transpose column_name=Site | rename "row 1" as total_user_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 09:55:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-dynamic-nested-array-coordinates-from-JSON/m-p/442932#M125704</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2018-12-21T09:55:14Z</dc:date>
    </item>
  </channel>
</rss>

