<?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: Parse json into rows in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-json-into-rows/m-p/641847#M222342</link>
    <description>&lt;P&gt;It's great that you not only illustrate data, but offer makeresults emulation. &amp;nbsp;This helps a lot. &amp;nbsp;Let me first point to the solution:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath path=Payloads{}.Payload
| mvexpand Payloads{}.Payload
``` | rename Payload{}.Payload Payload ```&lt;/LI-CODE&gt;&lt;P&gt;(I added a rename in comment in case you want to use a field name without citing the full path.)&lt;/P&gt;&lt;P&gt;I want to circle back to the data illustration. &amp;nbsp;The sample makeresults unfortunately did not produce valid JSON. &amp;nbsp;This is what I suspected is a valid emulation of your real data:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="{ \"MetaData\": { \"Host Name\": \"maya-MOBL\", \"Driver Version\": \"99.0.100.4\" }, \"Payloads\": [ { \"Header\": { \"Type\": \"Event\", \"Name\": \"IP Disconnection\", \"TimeStamp\": 133265876804261336 }, \"Payload\": { \"MAC Address\": \"00:00:00:00:00:00\", \"Adapter Type\": 140 } }, { \"Header\": { \"Type\": \"Event\", \"Name\": \"Connection success\", \"TimeStamp\": 133265877087374706 }, \"Payload\": { \"MAC Address\": \"00:00:00:00:00:00\", \"Network Adapter Type\": 131} }], \"Address\": \"0000:0:0000:000:000:df:0000:0000\", \"Prefix Length\": 64, \"Is Local Address\": false, \"Gateway IP Address\": \"::\", \"DNS Server\": [], \"DHCP Server\": null, \"DHCP Lease Duration\": 0, \"DHCP Retrieval Time\": 0 }"
```| eval valid = if(json_valid(_raw), "true", "false")```&lt;/LI-CODE&gt;&lt;P&gt;The emulation gives this:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="100%"&gt;&lt;SPAN&gt;{ "MetaData": { "Host Name": "maya-MOBL", "Driver Version": "99.0.100.4" }, "Payloads": [ { "Header": { "Type": "Event", "Name": "IP Disconnection", "TimeStamp": 133265876804261336 }, "Payload": { "MAC Address": "00:00:00:00:00:00", "Adapter Type": 140 } }, { "Header": { "Type": "Event", "Name": "Connection success", "TimeStamp": 133265877087374706 }, "Payload": { "MAC Address": "00:00:00:00:00:00", "Network Adapter Type": 131} }], "Address": "0000:0:0000:000:000:df:0000:0000", "Prefix Length": 64, "Is Local Address": false, "Gateway IP Address": "::", "DNS Server": [], "DHCP Server": null, "DHCP Lease Duration": 0, "DHCP Retrieval Time": 0 }&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Hope this helps&lt;/P&gt;</description>
    <pubDate>Sun, 30 Apr 2023 21:54:02 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2023-04-30T21:54:02Z</dc:date>
    <item>
      <title>How to parse json into rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-json-into-rows/m-p/641838#M222337</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have issue similar to:&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Getting-Data-In/how-to-split-the-json-array-into-multiple-new-events/m-p/122265" target="_blank" rel="noopener"&gt;https://community.splunk.com/t5/Getting-Data-In/how-to-split-the-json-array-into-multiple-new-events/m-p/122265&lt;/A&gt;&lt;BR /&gt;But my case is a bit different.&lt;/P&gt;
&lt;P&gt;json structure:&lt;BR /&gt;{&lt;BR /&gt;"&lt;STRONG&gt;MetaData&lt;/STRONG&gt;": {&lt;BR /&gt;"&lt;STRONG&gt;Host Name&lt;/STRONG&gt;": "....",&lt;BR /&gt;"&lt;STRONG&gt;Wi-Fi Driver Version&lt;/STRONG&gt;": "..."&lt;BR /&gt;},&lt;BR /&gt;"&lt;STRONG&gt;Payloads&lt;/STRONG&gt;": [&lt;BR /&gt;{&lt;BR /&gt;"&lt;STRONG&gt;Header&lt;/STRONG&gt;": {&lt;BR /&gt;"&lt;STRONG&gt;Type&lt;/STRONG&gt;": "Event",&lt;BR /&gt;"&lt;STRONG&gt;Name&lt;/STRONG&gt;": "...",&lt;BR /&gt;"&lt;STRONG&gt;TimeStamp&lt;/STRONG&gt;": ...&lt;BR /&gt;},&lt;BR /&gt;"&lt;STRONG&gt;Payload&lt;/STRONG&gt;": {&lt;BR /&gt;"&lt;STRONG&gt;MAC Address&lt;/STRONG&gt;": "00:00:00:00:00:00",&lt;BR /&gt;"&lt;STRONG&gt;Network Adapter Type&lt;/STRONG&gt;": ...&lt;BR /&gt;}&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;]&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;i need to:&lt;BR /&gt;1. extract table contain the following columns : MetaData.host name,MetaData.Wi-Fi Driver Version,Header.Type, Header.Name,Payload.MAC Address,Payload.Network Adapter Type&lt;BR /&gt;&lt;BR /&gt;2. i expected to see 2 rows in this case&lt;BR /&gt;&lt;BR /&gt;3. the fields name under&amp;nbsp;MetaData,Header and&amp;nbsp;Payload can changed, so it's should be generic.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I have started to write something like that- but it's not generic (type,name,..) and it doesn't extract the meta data:&lt;BR /&gt;| spath input=json output=payloadsObjects path=Payloads{}&lt;BR /&gt;| mvexpand payloadsObjects&lt;BR /&gt;| spath input=payloadsObjects output=Type path=Header.Type&lt;BR /&gt;| spath input=payloadsObjects output=Name path=Header.Name&lt;BR /&gt;| table *&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;json as example to use:&lt;BR /&gt;| makeresults&lt;BR /&gt;| eval _raw="{ \"MetaData\": { \"Host Name\": \"maya-MOBL\", \"Driver Version\": \"99.0.100.4\" }, \"Payloads\": [ { \"Header\": { \"Type\": \"Event\", \"Name\": \"IP Disconnection\", \"TimeStamp\": 133265876804261336 }, \"Payload\": { \"MAC Address\": \"00:00:00:00:00:00\", \"Adapter Type\": 140 } }, { \"Header\": { \"Type\": \"Event\", \"Name\": \"Connection success\", \"TimeStamp\": 133265877087374706 }, \"Payload\": { \"MAC Address\": \"00:00:00:00:00:00\", \"Network Adapter Type\": 131, \"Address\": \"0000:0:0000:000:000:df:0000:0000\", \"Prefix Length\": 64, \"Is Local Address\": false, \"Gateway IP Address\": \"::\", \"DNS Server\": [], \"DHCP Server\": null, \"DHCP Lease Duration\": 000000000, \"DHCP Retrieval Time\": 0 } } ] }"&lt;BR /&gt;&lt;BR /&gt;May I get your help please?&lt;BR /&gt;&lt;BR /&gt;*note- nice to have also solution that doesn't use makeresult because it made me problem to find Payloads{} field when i used real json file in my report and not makeresult.&lt;BR /&gt;*note 2- need to take time performance into consideration&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2023 11:26:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-json-into-rows/m-p/641838#M222337</guid>
      <dc:creator>maayan</dc:creator>
      <dc:date>2023-05-01T11:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: Parse json into rows</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-json-into-rows/m-p/641839#M222338</link>
      <description>&lt;P&gt;*I would explain that: Payloads is an array of Events.&lt;BR /&gt;Each Event is divided to Header and Payload. Fields under Payload and Header can be changed (therefore it should be generic).&lt;BR /&gt;As i said- Meta data fields also need to be extracted. they are also generic.&lt;/P&gt;</description>
      <pubDate>Sun, 30 Apr 2023 13:18:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-json-into-rows/m-p/641839#M222338</guid>
      <dc:creator>maayan</dc:creator>
      <dc:date>2023-04-30T13:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: Parse json into rows</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-json-into-rows/m-p/641847#M222342</link>
      <description>&lt;P&gt;It's great that you not only illustrate data, but offer makeresults emulation. &amp;nbsp;This helps a lot. &amp;nbsp;Let me first point to the solution:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath path=Payloads{}.Payload
| mvexpand Payloads{}.Payload
``` | rename Payload{}.Payload Payload ```&lt;/LI-CODE&gt;&lt;P&gt;(I added a rename in comment in case you want to use a field name without citing the full path.)&lt;/P&gt;&lt;P&gt;I want to circle back to the data illustration. &amp;nbsp;The sample makeresults unfortunately did not produce valid JSON. &amp;nbsp;This is what I suspected is a valid emulation of your real data:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="{ \"MetaData\": { \"Host Name\": \"maya-MOBL\", \"Driver Version\": \"99.0.100.4\" }, \"Payloads\": [ { \"Header\": { \"Type\": \"Event\", \"Name\": \"IP Disconnection\", \"TimeStamp\": 133265876804261336 }, \"Payload\": { \"MAC Address\": \"00:00:00:00:00:00\", \"Adapter Type\": 140 } }, { \"Header\": { \"Type\": \"Event\", \"Name\": \"Connection success\", \"TimeStamp\": 133265877087374706 }, \"Payload\": { \"MAC Address\": \"00:00:00:00:00:00\", \"Network Adapter Type\": 131} }], \"Address\": \"0000:0:0000:000:000:df:0000:0000\", \"Prefix Length\": 64, \"Is Local Address\": false, \"Gateway IP Address\": \"::\", \"DNS Server\": [], \"DHCP Server\": null, \"DHCP Lease Duration\": 0, \"DHCP Retrieval Time\": 0 }"
```| eval valid = if(json_valid(_raw), "true", "false")```&lt;/LI-CODE&gt;&lt;P&gt;The emulation gives this:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="100%"&gt;&lt;SPAN&gt;{ "MetaData": { "Host Name": "maya-MOBL", "Driver Version": "99.0.100.4" }, "Payloads": [ { "Header": { "Type": "Event", "Name": "IP Disconnection", "TimeStamp": 133265876804261336 }, "Payload": { "MAC Address": "00:00:00:00:00:00", "Adapter Type": 140 } }, { "Header": { "Type": "Event", "Name": "Connection success", "TimeStamp": 133265877087374706 }, "Payload": { "MAC Address": "00:00:00:00:00:00", "Network Adapter Type": 131} }], "Address": "0000:0:0000:000:000:df:0000:0000", "Prefix Length": 64, "Is Local Address": false, "Gateway IP Address": "::", "DNS Server": [], "DHCP Server": null, "DHCP Lease Duration": 0, "DHCP Retrieval Time": 0 }&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Sun, 30 Apr 2023 21:54:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-json-into-rows/m-p/641847#M222342</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-04-30T21:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: Parse json into rows</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-json-into-rows/m-p/641869#M222349</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for your help. Regarding the invalid json- it's ChatGPT fault, not mine sorry &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is an updated json:&lt;BR /&gt;{ "MetaData": { "Host Name": "maya-MOBL", "Driver Version": "0.0.0.0" }, "Payloads": [ { "Header": { "Type": "Event", "Name": "IP Disconnection", "TimeStamp": 133265876804261336 }, "Payload": { "MAC Address": "00:00:00:00:00:00", "Network Adapter Type": 131 } }, { "Header": { "Type": "Event", "Name": "conn success", "TimeStamp": 133265877087374706 }, "Payload": { "MAC Address": "00:00:00:00:00:10", "Network Adapter Type": 131, "IPv6 Address": "0000:0:0000:000:000:00:0000:0000", "Prefix Length": 64, "Is Local Address": false, "Gateway IP Address": "::", "DNS Server IP Address": [ ], "DHCP Server": null, "DHCP Lease Duration": 4294967295, "DHCP Retrieval Time": 0 } } ] }&lt;BR /&gt;&lt;BR /&gt;makeresult format:&lt;BR /&gt;_raw="{ \"MetaData\": { \"Host Name\": \"maya-MOBL\", \"Driver Version\": \"0.0.0.0\" }, \"Payloads\": [ { \"Header\": { \"Type\": \"Event\", \"Name\": \"IP Disconnection\", \"TimeStamp\": 133265876804261336 }, \"Payload\": { \"MAC Address\": \"00:00:00:00:00:00\", \"Network Adapter Type\": 131 } }, { \"Header\": { \"Type\": \"Event\", \"Name\": \"conn success\", \"TimeStamp\": 133265877087374706 }, \"Payload\": { \"MAC Address\": \"00:00:00:00:00:10\", \"Network Adapter Type\": 131, \"IPv6 Address\": \"0000:0:0000:000:000:00:0000:0000\", \"Prefix Length\": 64, \"Is Local Address\": false, \"Gateway IP Address\": \"::\", \"DNS Server IP Address\": [ ], \"DHCP Server\": null, \"DHCP Lease Duration\": 4294967295, \"DHCP Retrieval Time\": 0 } } ] }"&lt;BR /&gt;&lt;BR /&gt;I expect to see the result like this(contained all the columns of Payload, MetaData and Header),I haven't succeed yet:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mph_2-1682932542768.png" style="width: 798px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/25150iD9B12A5D4DB90DB2/image-dimensions/798x42?v=v2" width="798" height="42" role="button" title="mph_2-1682932542768.png" alt="mph_2-1682932542768.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot,&lt;/P&gt;&lt;P&gt;Maayan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2023 09:17:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-json-into-rows/m-p/641869#M222349</guid>
      <dc:creator>mph</dc:creator>
      <dc:date>2023-05-01T09:17:28Z</dc:date>
    </item>
  </channel>
</rss>

