<?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: Extract JSON objects in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-JSON-objects/m-p/562583#M196043</link>
    <description>&lt;P&gt;Assuming columns is supposed to be an array of name/type pairs (added closing ]) and that there are supposed to be 9 of these pairs (added Comment), and that you have a properly formatted JSON string (added surrounding and closing braces), then you could do something like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="{\"properties\": {\"nextLink\": null,
\"columns\": [
{\"name\": \"Cost\", \"type\": \"Number\"},
{\"name\": \"Date\", \"type\": \"Number\"},
{\"name\": \"Charge\", \"type\": \"String\"},
{\"name\": \"Publisher\", \"type\": \"String\"},
{\"name\": \"Resource\", \"type\": \"String\"},
{\"name\": \"Resource\", \"type\": \"String\"},
{\"name\": \"Service\", \"type\": \"String\"},
{\"name\": \"Standard\", \"type\": \"String\"},
{\"name\": \"Comment\", \"type\": \"String\"}],
\"rows\": [
[2.06, 20210807, \"usage\", \"uuuu\", \"hhh\", \"gd\", \"bandwidth\", \"azy\", \"HHH\"],
[2.206, 20210807, \"usage\", \"uuuhhh\", \"ggg\", \"gd\", \"bandwidth\", \"new\", \"YYY\"]] }}"



| spath path="properties.columns{}.name" output=columnnames
| spath path="properties.rows{}{}" output=rows
| streamstats count as event 
| mvexpand rows
| streamstats count as row by event
| eval index=(row-1)%mvcount(columnnames)
| eval name=mvindex(columnnames,index)
| eval {name}=rows
| eval row=floor((row-1)/mvcount(columnnames))
| fields - columnnames name index rows
| stats values(*) as * by row event&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Aug 2021 13:16:41 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2021-08-09T13:16:41Z</dc:date>
    <item>
      <title>Extract JSON objects</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-JSON-objects/m-p/562580#M196042</link>
      <description>&lt;P&gt;How can i extract this:&lt;BR /&gt;"properties": {"nextLink": null,&lt;BR /&gt;"columns": [&lt;BR /&gt;{"name": "Cost", "type": "Number"},&lt;BR /&gt;{"name": "Date", "type": "Number"},&lt;BR /&gt;{"name": "Charge", "type": "String"},&lt;BR /&gt;{"name": "Publisher", "type": "String"},&lt;BR /&gt;{"name": "Resource", "type": "String"},&lt;BR /&gt;{"name": "Resource", "type": "String"},&lt;BR /&gt;{"name": "Service", "type": "String"},&lt;BR /&gt;{"name": "Standard", "type": "String"},&lt;BR /&gt;"rows": [&lt;BR /&gt;[2.06, 20210807, "usage", "uuuu", "hhh", "gd", "bandwidth", "azy", "HHH"],&lt;BR /&gt;[2.206, 20210807, "usage", "uuuhhh", "ggg", "gd", "bandwidth", "new", "YYY"] ]&lt;BR /&gt;&lt;BR /&gt;No of columns can be increased.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 12:40:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-JSON-objects/m-p/562580#M196042</guid>
      <dc:creator>vishaltaneja070</dc:creator>
      <dc:date>2021-08-09T12:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: Extract JSON objects</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-JSON-objects/m-p/562583#M196043</link>
      <description>&lt;P&gt;Assuming columns is supposed to be an array of name/type pairs (added closing ]) and that there are supposed to be 9 of these pairs (added Comment), and that you have a properly formatted JSON string (added surrounding and closing braces), then you could do something like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="{\"properties\": {\"nextLink\": null,
\"columns\": [
{\"name\": \"Cost\", \"type\": \"Number\"},
{\"name\": \"Date\", \"type\": \"Number\"},
{\"name\": \"Charge\", \"type\": \"String\"},
{\"name\": \"Publisher\", \"type\": \"String\"},
{\"name\": \"Resource\", \"type\": \"String\"},
{\"name\": \"Resource\", \"type\": \"String\"},
{\"name\": \"Service\", \"type\": \"String\"},
{\"name\": \"Standard\", \"type\": \"String\"},
{\"name\": \"Comment\", \"type\": \"String\"}],
\"rows\": [
[2.06, 20210807, \"usage\", \"uuuu\", \"hhh\", \"gd\", \"bandwidth\", \"azy\", \"HHH\"],
[2.206, 20210807, \"usage\", \"uuuhhh\", \"ggg\", \"gd\", \"bandwidth\", \"new\", \"YYY\"]] }}"



| spath path="properties.columns{}.name" output=columnnames
| spath path="properties.rows{}{}" output=rows
| streamstats count as event 
| mvexpand rows
| streamstats count as row by event
| eval index=(row-1)%mvcount(columnnames)
| eval name=mvindex(columnnames,index)
| eval {name}=rows
| eval row=floor((row-1)/mvcount(columnnames))
| fields - columnnames name index rows
| stats values(*) as * by row event&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 13:16:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-JSON-objects/m-p/562583#M196043</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-08-09T13:16:41Z</dc:date>
    </item>
  </channel>
</rss>

