<?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: Adding and sorting key, value pairs in JSON array in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Adding-and-sorting-key-value-pairs-in-JSON-array/m-p/352311#M64587</link>
    <description>&lt;P&gt;This is a general approach to demonstrate:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | makeresults count=3
 | streamstats count AS serial
 | eval ExtendedProperties.Name="DisplayName IsPublic Mail"
 | makemv ExtendedProperties.Name
 | eval ExtendedProperties.Value=case(
    (serial=1), "Test Group::False::testgroup@microsoft.com",
    (serial=2), "Group1::True::group1@microsoft.com",
    (serial=3), "Group2::True::group2@microsoft.com")
 | makemv delim="::" ExtendedProperties.Value
 | fields - _time

 | rename COMMENT AS "Everything above generates contrived example data; everytinng below is the general solution"

 | eval KVP=mvzip('ExtendedProperties.Name', 'ExtendedProperties.Value', "=")
 | table KVP serial
 | mvexpand KVP
 | rex field=KVP "^(?&amp;lt;KVP_key&amp;gt;[^=]+)=(?&amp;lt;KVP_value&amp;gt;[^=]+)$"
 | eval {KVP_key}=KVP_value
 | fields - KVP* 
 | stats values(*) AS * BY serial
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 14 Jun 2017 14:42:56 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-06-14T14:42:56Z</dc:date>
    <item>
      <title>Adding and sorting key, value pairs in JSON array</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Adding-and-sorting-key-value-pairs-in-JSON-array/m-p/352310#M64586</link>
      <description>&lt;P&gt;This is the way my data looks:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{  
   "NODE-A":{  
      "DATA":{  
         "SNR_DATA":{  
            "Cable3/0/3-upstream2":38.1,
            "Cable3/0/3-upstream0":38.3
         },
         "MODEM_DATA":{  
            "Cable3/0/3-upstream2":14,
            "Cable3/0/3-upstream0":32
         }
      }
   }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am trying to figure out how to add the values of each Cable interface under "MODEM_DATA" and present it in a table so that it can be graphed. &lt;/P&gt;

&lt;P&gt;The farthest I have been able to get is to use &lt;CODE&gt;spath&lt;/CODE&gt; like so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| spath path=DATA.MODEM_DATA output=test | table test
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This does not exactly break apart the key, value pairs so they can be manipulated. How to do this?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 19:26:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Adding-and-sorting-key-value-pairs-in-JSON-array/m-p/352310#M64586</guid>
      <dc:creator>evan_roggenkamp</dc:creator>
      <dc:date>2017-06-13T19:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: Adding and sorting key, value pairs in JSON array</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Adding-and-sorting-key-value-pairs-in-JSON-array/m-p/352311#M64587</link>
      <description>&lt;P&gt;This is a general approach to demonstrate:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | makeresults count=3
 | streamstats count AS serial
 | eval ExtendedProperties.Name="DisplayName IsPublic Mail"
 | makemv ExtendedProperties.Name
 | eval ExtendedProperties.Value=case(
    (serial=1), "Test Group::False::testgroup@microsoft.com",
    (serial=2), "Group1::True::group1@microsoft.com",
    (serial=3), "Group2::True::group2@microsoft.com")
 | makemv delim="::" ExtendedProperties.Value
 | fields - _time

 | rename COMMENT AS "Everything above generates contrived example data; everytinng below is the general solution"

 | eval KVP=mvzip('ExtendedProperties.Name', 'ExtendedProperties.Value', "=")
 | table KVP serial
 | mvexpand KVP
 | rex field=KVP "^(?&amp;lt;KVP_key&amp;gt;[^=]+)=(?&amp;lt;KVP_value&amp;gt;[^=]+)$"
 | eval {KVP_key}=KVP_value
 | fields - KVP* 
 | stats values(*) AS * BY serial
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Jun 2017 14:42:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Adding-and-sorting-key-value-pairs-in-JSON-array/m-p/352311#M64587</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-14T14:42:56Z</dc:date>
    </item>
  </channel>
</rss>

