<?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 to extract Json array of objects data into table format in  Splunk ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Json-array-of-objects-data-into-table-format-in/m-p/494134#M137775</link>
    <description>&lt;P&gt;Example data : &lt;BR /&gt;
We need to  extract  below json data into table format in  Splunk ?&lt;A href="https://answers.splunk.comstorage/temp/287582-json.txt"&gt;link text&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;"assets": [&lt;BR /&gt;
        {&lt;BR /&gt;
            "id": 1,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        "last_seen_time": "2020-02-26T16:23:06Z",
        "network_ports": [
            {
                "id": 100,
                "port_number": 111,
                "extra_info": "",
                "hostname": null,
                "name": "unknown",
                "ostype": "",
                "product": null,
                "protocol": "tcp",
                "state": "open",
                "version": null
            },
            {
                "id": 343,
                "port_number": 444,
                "extra_info": "",
                "hostname": null,
                "name": "unknown",
                "ostype": "",
                "product": null,
                "protocol": "tcp",
                "state": "open",
                "version": null
            },

        ],
        "tags": [
            "Loc: Ajay"
        ],
        "owner": null,
        "urls": {
            "vulnerabilities": "google.com/examples/1012/tests"
        },
        "ip_address": "1.1.0.91",
        "database": null,
        "hostname": "swetha",
        "asset_groups": [
            {
                "id": 191300,
                "name": "All examples"
            }
        ]
    },
    {
        "id": 1012,

        "last_seen_time": "2020-02-26T16:23:06Z",
        "network_ports": [
            {
                "id": 331,
                "port_number": 135,
                "extra_info": "",
                "hostname": null,
                "name": "unknown",
                "ostype": "",
                "product": null,
                "protocol": "tcp",
                "state": "open",
                "version": null
            },
            {
                "id": 343,
                "port_number": 444,
                "extra_info": "",
                "hostname": null,
                "name": "unknown",
                "ostype": "",
                "product": null,
                "protocol": "tcp",
                "state": "open",
                "version": null
            },

        ],
        "tags": [
            "Loc: NorthCEE"
        ],
        "owner": null,
        "urls": {
            "vulnerabilities": "google.com/examples/2/tests"
        },
        "ip_address": "1.1.0.92",
        "database": null,
        "hostname": "sweety",
        "asset_groups": [
            {
                "id": 191300,
                "name": "All exs"
            }
        ]
    },
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;]&lt;/P&gt;</description>
    <pubDate>Wed, 11 Mar 2020 08:00:40 GMT</pubDate>
    <dc:creator>harishalipaka</dc:creator>
    <dc:date>2020-03-11T08:00:40Z</dc:date>
    <item>
      <title>How to extract Json array of objects data into table format in  Splunk ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Json-array-of-objects-data-into-table-format-in/m-p/494134#M137775</link>
      <description>&lt;P&gt;Example data : &lt;BR /&gt;
We need to  extract  below json data into table format in  Splunk ?&lt;A href="https://answers.splunk.comstorage/temp/287582-json.txt"&gt;link text&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;"assets": [&lt;BR /&gt;
        {&lt;BR /&gt;
            "id": 1,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        "last_seen_time": "2020-02-26T16:23:06Z",
        "network_ports": [
            {
                "id": 100,
                "port_number": 111,
                "extra_info": "",
                "hostname": null,
                "name": "unknown",
                "ostype": "",
                "product": null,
                "protocol": "tcp",
                "state": "open",
                "version": null
            },
            {
                "id": 343,
                "port_number": 444,
                "extra_info": "",
                "hostname": null,
                "name": "unknown",
                "ostype": "",
                "product": null,
                "protocol": "tcp",
                "state": "open",
                "version": null
            },

        ],
        "tags": [
            "Loc: Ajay"
        ],
        "owner": null,
        "urls": {
            "vulnerabilities": "google.com/examples/1012/tests"
        },
        "ip_address": "1.1.0.91",
        "database": null,
        "hostname": "swetha",
        "asset_groups": [
            {
                "id": 191300,
                "name": "All examples"
            }
        ]
    },
    {
        "id": 1012,

        "last_seen_time": "2020-02-26T16:23:06Z",
        "network_ports": [
            {
                "id": 331,
                "port_number": 135,
                "extra_info": "",
                "hostname": null,
                "name": "unknown",
                "ostype": "",
                "product": null,
                "protocol": "tcp",
                "state": "open",
                "version": null
            },
            {
                "id": 343,
                "port_number": 444,
                "extra_info": "",
                "hostname": null,
                "name": "unknown",
                "ostype": "",
                "product": null,
                "protocol": "tcp",
                "state": "open",
                "version": null
            },

        ],
        "tags": [
            "Loc: NorthCEE"
        ],
        "owner": null,
        "urls": {
            "vulnerabilities": "google.com/examples/2/tests"
        },
        "ip_address": "1.1.0.92",
        "database": null,
        "hostname": "sweety",
        "asset_groups": [
            {
                "id": 191300,
                "name": "All exs"
            }
        ]
    },
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;]&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 08:00:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Json-array-of-objects-data-into-table-format-in/m-p/494134#M137775</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2020-03-11T08:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract Json array of objects data into table format in  Splunk ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Json-array-of-objects-data-into-table-format-in/m-p/494135#M137776</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="\"assets\":[{\"id\":1,\"last_seen_time\":\"2020-02-26T16:23:06Z\",\"network_ports\":[{\"id\":100,\"port_number\":111,\"extra_info\":\"\",\"hostname\":null,\"name\":\"unknown\",\"ostype\":\"\",\"product\":null,\"protocol\":\"tcp\",\"state\":\"open\",\"version\":null},{\"id\":343,\"port_number\":444,\"extra_info\":\"\",\"hostname\":null,\"name\":\"unknown\",\"ostype\":\"\",\"product\":null,\"protocol\":\"tcp\",\"state\":\"open\",\"version\":null}],\"tags\":[\"Loc: Ajay\"],\"owner\":null,\"urls\":{\"vulnerabilities\":\"google.com/examples/1012/tests\"},\"ip_address\":\"1.1.0.91\",\"database\":null,\"hostname\":\"swetha\",\"asset_groups\":[{\"id\":191300,\"name\":\"All examples\"}]},{\"id\":1012,\"last_seen_time\":\"2020-02-26T16:23:06Z\",\"network_ports\":[{\"id\":331,\"port_number\":135,\"extra_info\":\"\",\"hostname\":null,\"name\":\"unknown\",\"ostype\":\"\",\"product\":null,\"protocol\":\"tcp\",\"state\":\"open\",\"version\":null},{\"id\":343,\"port_number\":444,\"extra_info\":\"\",\"hostname\":null,\"name\":\"unknown\",\"ostype\":\"\",\"product\":null,\"protocol\":\"tcp\",\"state\":\"open\",\"version\":null}],\"tags\":[\"Loc: NorthCEE\"],\"owner\":null,\"urls\":{\"vulnerabilities\":\"google.com/examples/2/tests\"},\"ip_address\":\"1.1.0.92\",\"database\":null,\"hostname\":\"sweety\",\"asset_groups\":[{\"id\":191300,\"name\":\"All exs\"}]}]"
| rex mode=sed "s/(.*)/{\1}/"
| spath
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This query works. If you want only searching, try this &lt;CODE&gt;rex&lt;/CODE&gt; and &lt;CODE&gt;spath&lt;/CODE&gt;&lt;BR /&gt;
I guess your JSON is not &lt;STRONG&gt;valid&lt;/STRONG&gt;.&lt;/P&gt;

&lt;P&gt;recommed props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your sourcetype]
SEDCMD-add_header = s/(.*)/{\1}/
KV_MODE=json
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Mar 2020 12:01:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Json-array-of-objects-data-into-table-format-in/m-p/494135#M137776</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-03-11T12:01:55Z</dc:date>
    </item>
  </channel>
</rss>

