<?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 parse JSON with JSON array to identify fields? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-JSON-with-JSON-array-to-identify-fields/m-p/184527#M36958</link>
    <description>&lt;P&gt;Could someone guide me through to parse JSON within JSON array? I have tried many different variations with spath command but without luck&lt;/P&gt;

&lt;H1&gt;source = connection.txt&lt;/H1&gt;

&lt;P&gt;begin: {&lt;BR /&gt;
"conn":&lt;BR /&gt;
    {&lt;BR /&gt;
    "type":"scp",&lt;BR /&gt;
    "ip":"1.1.1.1",&lt;BR /&gt;
    "userName":"tiger",&lt;BR /&gt;
    "password":"wood",&lt;BR /&gt;
    "platform":"ibm",&lt;BR /&gt;
    "retryCnt":10&lt;BR /&gt;
    },&lt;BR /&gt;
        "mainCommandsList":&lt;BR /&gt;
        [{&lt;BR /&gt;
        "commandSetId":"1234",&lt;BR /&gt;
        "commandSetName":"setName",&lt;BR /&gt;
        "commandListType":"listType",&lt;BR /&gt;
        "commandList":&lt;BR /&gt;
            [&lt;BR /&gt;
            {&lt;BR /&gt;
            "commandLineId":1,&lt;BR /&gt;
            "commandLevel":0,&lt;BR /&gt;
            "command":"sh redundancy inter-device",&lt;BR /&gt;
            "lineFeedCnt":1,&lt;BR /&gt;
            "ignoreErrors":true&lt;BR /&gt;
            }&lt;BR /&gt;
            ]&lt;BR /&gt;
        }&lt;BR /&gt;
        ],&lt;BR /&gt;
    "serialNumber":"aaaaaaaa1",&lt;BR /&gt;
    "scpHostName":"10.10.10.10",&lt;BR /&gt;
    "scpUserName":"testUser",&lt;BR /&gt;
    "scpPassword":"testPass",&lt;BR /&gt;
    "scpRoot":"downloads"&lt;BR /&gt;
}&lt;/P&gt;</description>
    <pubDate>Sat, 16 Aug 2014 02:03:06 GMT</pubDate>
    <dc:creator>ziyod2005</dc:creator>
    <dc:date>2014-08-16T02:03:06Z</dc:date>
    <item>
      <title>How to parse JSON with JSON array to identify fields?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-JSON-with-JSON-array-to-identify-fields/m-p/184527#M36958</link>
      <description>&lt;P&gt;Could someone guide me through to parse JSON within JSON array? I have tried many different variations with spath command but without luck&lt;/P&gt;

&lt;H1&gt;source = connection.txt&lt;/H1&gt;

&lt;P&gt;begin: {&lt;BR /&gt;
"conn":&lt;BR /&gt;
    {&lt;BR /&gt;
    "type":"scp",&lt;BR /&gt;
    "ip":"1.1.1.1",&lt;BR /&gt;
    "userName":"tiger",&lt;BR /&gt;
    "password":"wood",&lt;BR /&gt;
    "platform":"ibm",&lt;BR /&gt;
    "retryCnt":10&lt;BR /&gt;
    },&lt;BR /&gt;
        "mainCommandsList":&lt;BR /&gt;
        [{&lt;BR /&gt;
        "commandSetId":"1234",&lt;BR /&gt;
        "commandSetName":"setName",&lt;BR /&gt;
        "commandListType":"listType",&lt;BR /&gt;
        "commandList":&lt;BR /&gt;
            [&lt;BR /&gt;
            {&lt;BR /&gt;
            "commandLineId":1,&lt;BR /&gt;
            "commandLevel":0,&lt;BR /&gt;
            "command":"sh redundancy inter-device",&lt;BR /&gt;
            "lineFeedCnt":1,&lt;BR /&gt;
            "ignoreErrors":true&lt;BR /&gt;
            }&lt;BR /&gt;
            ]&lt;BR /&gt;
        }&lt;BR /&gt;
        ],&lt;BR /&gt;
    "serialNumber":"aaaaaaaa1",&lt;BR /&gt;
    "scpHostName":"10.10.10.10",&lt;BR /&gt;
    "scpUserName":"testUser",&lt;BR /&gt;
    "scpPassword":"testPass",&lt;BR /&gt;
    "scpRoot":"downloads"&lt;BR /&gt;
}&lt;/P&gt;</description>
      <pubDate>Sat, 16 Aug 2014 02:03:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-JSON-with-JSON-array-to-identify-fields/m-p/184527#M36958</guid>
      <dc:creator>ziyod2005</dc:creator>
      <dc:date>2014-08-16T02:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse JSON with JSON array to identify fields?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-JSON-with-JSON-array-to-identify-fields/m-p/184528#M36959</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I also had some problems getting the JSON Data into splunk. I have tried the following:&lt;/P&gt;

&lt;P&gt;Setting Sourcetype to &lt;CODE&gt;_json&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Added the following to the props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[_json]
KV_MODE = _json
LINE_BREAKER = "(^){"
SHOULD_LINEMERGE = false
MAX_EVENTS = 3000000
TRUNCATE = 3000000
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I used &lt;CODE&gt;MAX_EVENTS&lt;/CODE&gt; and &lt;CODE&gt;TRUNCATE&lt;/CODE&gt; because my JSON Events has more ore less 10000 lines.&lt;/P&gt;

&lt;P&gt;For xour JSON sample i would use:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[_json]
KV_MODE = _json
LINE_BREAKER = "(^)begin: {"
SHOULD_LINEMERGE = false
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then it should build the events for you:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;conn.type = scp
conn.ip = 1.1.1.1
conn.userName = tiger
conn.password =wood
...
...
conn.mainCommandsList.commandSetId = 1234
conn.mainCommandsList.commandSetName = setName
...
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I hope this is what you are looking for.&lt;/P&gt;

&lt;P&gt;Regards,&lt;BR /&gt;
Patrik&lt;/P&gt;</description>
      <pubDate>Sat, 16 Aug 2014 13:33:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-JSON-with-JSON-array-to-identify-fields/m-p/184528#M36959</guid>
      <dc:creator>psidler</dc:creator>
      <dc:date>2014-08-16T13:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse JSON with JSON array to identify fields?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-JSON-with-JSON-array-to-identify-fields/m-p/184529#M36960</link>
      <description>&lt;P&gt;It seems that your events don't have true json format (due to 'begin: ' in the start. In case you can't get rid of that, you can try this workaround:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex "begin:\s*(?&amp;lt;temp_raw&amp;gt;.*)"| spath input=temp_raw... rest your your search
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Aug 2014 18:36:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-parse-JSON-with-JSON-array-to-identify-fields/m-p/184529#M36960</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-08-18T18:36:18Z</dc:date>
    </item>
  </channel>
</rss>

