<?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 Json extraction with optional embedded element in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Json-extraction-with-optional-embedded-element/m-p/236968#M46036</link>
    <description>&lt;P&gt;HI,&lt;BR /&gt;
I am tryig to get elements extracted from array which looks like this :&lt;BR /&gt;
{&lt;BR /&gt;
    "Version": 2,&lt;BR /&gt;
    "diagnostic": [&lt;BR /&gt;
      {&lt;BR /&gt;
        "name": "EMERGENCY_FUND",&lt;BR /&gt;
        "stringValue": "  6 months",&lt;BR /&gt;
        "isCohortUsed": true,&lt;BR /&gt;
        "cohortDefaultCode": "EX"&lt;BR /&gt;
      },&lt;BR /&gt;
      {&lt;BR /&gt;
        "name": "RATE",&lt;BR /&gt;
        "doubleValue": 0,&lt;BR /&gt;
        "isCohortUsed": true,&lt;BR /&gt;
        "cohortDefaultCode": "WR"&lt;BR /&gt;
      },&lt;BR /&gt;
      {&lt;BR /&gt;
        "name": "CHANCE",&lt;BR /&gt;
    "score": {&lt;BR /&gt;
              "scorevalue": 10,&lt;BR /&gt;
          "valueType": "PERCENT"&lt;BR /&gt;
        },&lt;BR /&gt;
        "stringValue": "likely",&lt;BR /&gt;
        "isCohortUsed": true,&lt;BR /&gt;
        "cohortDefaultCode": "CW"&lt;BR /&gt;
      }&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;Of alll this array, I want to extract element array score and its value for that respective Name i.e.&lt;/P&gt;

&lt;P&gt;Name         scorevalue&lt;BR /&gt;
CHANCE        10&lt;/P&gt;

&lt;P&gt;The score element may or may not be present in parent array element.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Sun, 03 Jul 2016 13:21:43 GMT</pubDate>
    <dc:creator>psable</dc:creator>
    <dc:date>2016-07-03T13:21:43Z</dc:date>
    <item>
      <title>Json extraction with optional embedded element</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Json-extraction-with-optional-embedded-element/m-p/236968#M46036</link>
      <description>&lt;P&gt;HI,&lt;BR /&gt;
I am tryig to get elements extracted from array which looks like this :&lt;BR /&gt;
{&lt;BR /&gt;
    "Version": 2,&lt;BR /&gt;
    "diagnostic": [&lt;BR /&gt;
      {&lt;BR /&gt;
        "name": "EMERGENCY_FUND",&lt;BR /&gt;
        "stringValue": "  6 months",&lt;BR /&gt;
        "isCohortUsed": true,&lt;BR /&gt;
        "cohortDefaultCode": "EX"&lt;BR /&gt;
      },&lt;BR /&gt;
      {&lt;BR /&gt;
        "name": "RATE",&lt;BR /&gt;
        "doubleValue": 0,&lt;BR /&gt;
        "isCohortUsed": true,&lt;BR /&gt;
        "cohortDefaultCode": "WR"&lt;BR /&gt;
      },&lt;BR /&gt;
      {&lt;BR /&gt;
        "name": "CHANCE",&lt;BR /&gt;
    "score": {&lt;BR /&gt;
              "scorevalue": 10,&lt;BR /&gt;
          "valueType": "PERCENT"&lt;BR /&gt;
        },&lt;BR /&gt;
        "stringValue": "likely",&lt;BR /&gt;
        "isCohortUsed": true,&lt;BR /&gt;
        "cohortDefaultCode": "CW"&lt;BR /&gt;
      }&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;Of alll this array, I want to extract element array score and its value for that respective Name i.e.&lt;/P&gt;

&lt;P&gt;Name         scorevalue&lt;BR /&gt;
CHANCE        10&lt;/P&gt;

&lt;P&gt;The score element may or may not be present in parent array element.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jul 2016 13:21:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Json-extraction-with-optional-embedded-element/m-p/236968#M46036</guid>
      <dc:creator>psable</dc:creator>
      <dc:date>2016-07-03T13:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: Json extraction with optional embedded element</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Json-extraction-with-optional-embedded-element/m-p/236969#M46037</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw mode=sed "s/\"(doubleValue)\"/\"stringValue\"/g"
| rex field=_raw mode=sed "s/\"score\": {[\r\n\s]*\"scorevalue\": (\d*),[\r\n\s]*\"valueType\": \"(\w*)\"[\r\n\s]*},[\r\n\s]*\"stringValue\": \"(\w*)\",/\"stringValue\": \"\3 \1 \2\"/g"
| spath
| rename diagnostic{}.* AS *
| eval nameValue=mvzip(name,stringValue, "=")
| mvexpand nameValue | fields - name stringValue
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 03 Jul 2016 18:43:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Json-extraction-with-optional-embedded-element/m-p/236969#M46037</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-07-03T18:43:12Z</dc:date>
    </item>
  </channel>
</rss>

