<?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: Array extraction with optional elements in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Array-extraction-with-optional-elements/m-p/237003#M46046</link>
    <description>&lt;P&gt;Thank you !&lt;/P&gt;</description>
    <pubDate>Tue, 05 Jul 2016 17:56:49 GMT</pubDate>
    <dc:creator>psable</dc:creator>
    <dc:date>2016-07-05T17:56:49Z</dc:date>
    <item>
      <title>Array extraction with optional elements</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Array-extraction-with-optional-elements/m-p/237001#M46044</link>
      <description>&lt;P&gt;{&lt;BR /&gt;
"Version" :  2&lt;BR /&gt;
Diagnostic: [&lt;BR /&gt;
{ Name: "Brian", School :"KVG" },&lt;BR /&gt;
{ Name: "Steve", School :"MKG" },&lt;BR /&gt;
{ Name: "Gerry"  },&lt;BR /&gt;
{LastName: "Todd", School :"HVD" }&lt;BR /&gt;
]&lt;/P&gt;

&lt;P&gt;How can I get these fields extracted  so that it looks like this:&lt;/P&gt;

&lt;P&gt;Name    Last Name   School&lt;BR /&gt;&lt;BR /&gt;
Brian                -             KVG&lt;BR /&gt;
Steve                 -            MKG &lt;BR /&gt;
Gerry                 -            - &lt;BR /&gt;
       -           Obama       HVD&lt;/P&gt;

&lt;P&gt;Thanks !&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jul 2016 13:14:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Array-extraction-with-optional-elements/m-p/237001#M46044</guid>
      <dc:creator>psable</dc:creator>
      <dc:date>2016-07-03T13:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: Array extraction with optional elements</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Array-extraction-with-optional-elements/m-p/237002#M46045</link>
      <description>&lt;P&gt;Similar to this: &lt;A href="https://answers.splunk.com/answers/424422/referring-to-array-elements-by-index.html#answer-424424"&gt;https://answers.splunk.com/answers/424422/referring-to-array-elements-by-index.html#answer-424424&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | fields - count
| eval _raw = " {
    \"Version\" : 2
    Diagnostic: [
        { Name: \"Brian\", School :\"KVG\" },
        { Name: \"Steve\", School :\"MKG\" },
        { Name: \"Gerry\" },
        { LastName: \"Todd\", School :\"HVD\" }
    ]
}
"
| rex field=_raw max_match=0 "(?mi)\{\s*(?&amp;lt;keyvalue&amp;gt;.+)\s*\}\,?\n"
| mvexpand keyvalue
| streamstats count as N
| eval keyvalue = split(keyvalue, ",")
| mvexpand keyvalue
| rex field=keyvalue max_match=0 "(?msi)(?&amp;lt;key&amp;gt;\w+)[\s:\"]+(?&amp;lt;value&amp;gt;[^\"]+)"
| eval {key} = value
| fields - keyvalue, key, value
| stats first(*) as * by N, _raw
| fillnull value="-"
| table Name, LastName, School
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Output:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/1536iA9828E8283D6A2DE/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jul 2016 07:22:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Array-extraction-with-optional-elements/m-p/237002#M46045</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-07-04T07:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: Array extraction with optional elements</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Array-extraction-with-optional-elements/m-p/237003#M46046</link>
      <description>&lt;P&gt;Thank you !&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2016 17:56:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Array-extraction-with-optional-elements/m-p/237003#M46046</guid>
      <dc:creator>psable</dc:creator>
      <dc:date>2016-07-05T17:56:49Z</dc:date>
    </item>
  </channel>
</rss>

