<?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: How to convert JSON array of Name/Value pairs to field/value for event in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374337#M67844</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/178243"&gt;@dubiza&lt;/a&gt;, sorry for the delay.&lt;/P&gt;

&lt;P&gt;Spath can work as a function (within eval): &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.2.6/SearchReference/TextFunctions#spath.28X.2CY.29" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/7.2.6/SearchReference/TextFunctions#spath.28X.2CY.29&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Or as a command: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;But the behaviour is pretty much the same. &lt;/P&gt;

&lt;P&gt;myJSON is just a random variable name I chose to test the raw json data provided in the question, but this could be your actual event, in which case you would just need to change that in the first spath. Now, that first spath extracts from your raw json (myJSON), based on the path &lt;BR /&gt;
"Request.capability.Attributes{}" into the new variable req_cap_attr.&lt;/P&gt;

&lt;P&gt;The second spath extracts everything from myJSON automatically, creating field names based on the JSON hierarchy. The reason req_cap_attr is extracted separately is because we would like to create new field names based on the values inside the "Request.capability.Attributes{}" branch in a dynamic way by first extracting them with regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | rex field=req_cap_attr "\"[^\"]+\"\s*:\s*\"(?&amp;lt;key&amp;gt;[^\"]+)\"\s*\,\s*\"[^\"]+\"\s*:\s*\"(?&amp;lt;value&amp;gt;[^\"]+)\""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And then dynamically generating those field names with the following syntax:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval {key} = value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That syntax above is the one responsible for the field names in the attached screenshot above.&lt;/P&gt;

&lt;P&gt;Hope that clarifies a little. It's been more than 1 year since I answered this.&lt;/P&gt;

&lt;P&gt;By the way, if you like my answer don't forget to upvote it so that others can find it quicker too.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Javier&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 00:35:06 GMT</pubDate>
    <dc:creator>javiergn</dc:creator>
    <dc:date>2020-09-30T00:35:06Z</dc:date>
    <item>
      <title>How to convert JSON array of Name/Value pairs to field/value for event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374327#M67834</link>
      <description>&lt;P&gt;I am working with JSON data... which looks like this:&lt;/P&gt;

&lt;P&gt;{"DN" : "CN=Test Group, OU=Test OU, O=\"Corp.com\"", "sourceId" : "TEST Image", "sequenceId" : 1, "description" : "doing work", "Request" : {"capability" : {"name" : "prod02", "Attributes" : [{"name" : "Model", "value" : "ea123"}, {"name" : "Verson", "value" : "1.2.3"}, {"name" : "Debug_ENABLE", "value" : "FALSE"}, {"name" : "RAM_ENABLE", "value" : "True"}, {"name" : "SW_ID", "value" : "0x0003ed"}]}}, "signatureResponse" : {"statusCode" : "1"}}&lt;/P&gt;

&lt;P&gt;same data easier to read:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
"DN":"CN=Test Group, OU=Test OU, O="Corp.com"",
"sourceId":"TEST Image",
"sequenceId":1,
"description":"doing work",
"Request":{
   "capability":{
       "name":"prod02",
       "Attributes":[
              {
                   "name":"Model",
                   "value":"ea123"
            },
               {
                   "name":"Version",
                   "value":"1.2.3"
            },
               {
                    "name":"Debug_ENABLE",
                    "value":"FALSE"
             },
                {
                    "name":"RAM_ENABLE",
                    "value":"True"
             },
                {
                     "name":"SW_ID",
                     "value":"0x0003ed"
             }
         ]
     }
  },
"signatureResponse":{
"statusCode":"1"
  }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When run through spath all the fields get parsed out as expected... except I want the array contents to be individual fields for the event.... right now the array fields have multiple values.  So for the event in the image I want/need fields called "Model" "Verson" "RAM_Enabled" etc  &lt;/P&gt;

&lt;P&gt;Instead of just Request.capability.Attributes{}.name and Request.capability.Attributes{}.value which contain the multiple values.&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://community.splunk.com/storage/temp/229825-json.png" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:38:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374327#M67834</guid>
      <dc:creator>jordomo</dc:creator>
      <dc:date>2020-09-29T18:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert JSON array of Name/Value pairs to field/value for event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374328#M67835</link>
      <description>&lt;P&gt;&lt;STRONG&gt;[UPDATED ANSWER]&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;@jordomo, try the following updated answer (hopefully the &lt;CODE&gt;sequenceId&lt;/CODE&gt; is the unique key for name and value to be correlated):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourBaseSearch&amp;gt;
| spath 
| rename Request.capability.Attributes{}.* as * 
| eval kvdata=mvzip(name,value) 
| fields - name value _* 
| mvexpand kvdata 
| eval kvdata=split(kvdata,",") 
| eval name=mvindex(kvdata,0),value=mvindex(kvdata,1) 
| fields - kvdata
| table sequenceId name value
| xyseries sequenceId name value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is a run anywhere search example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="{\"DN\" : \"CN=Test Group, OU=Test OU, O=\\\"Corp.com\\\"\", \"sourceId\" : \"TEST Image\", \"sequenceId\" : 1, \"description\" : \"doing work\", \"Request\" : {\"capability\" : {\"name\" : \"prod02\", \"Attributes\" : [{\"name\" : \"Model\", \"value\" : \"ea123\"}, {\"name\" : \"Verson\", \"value\" : \"1.2.3\"}, {\"name\" : \"Debug_ENABLE\", \"value\" : \"FALSE\"}, {\"name\" : \"RAM_ENABLE\", \"value\" : \"True\"}, {\"name\" : \"SW_ID\", \"value\" : \"0x0003ed\"}]}}, \"signatureResponse\" : {\"statusCode\" : \"1\"}}" 
| append 
    [| makeresults 
    | eval _raw="{\"DN\" : \"CN=Test Group, OU=Test OU, O=\\\"Corp.com\\\"\", \"sourceId\" : \"TEST Image\", \"sequenceId\" : 2, \"description\" : \"doing work\", \"Request\" : {\"capability\" : {\"name\" : \"prod02\", \"Attributes\" : [{\"name\" : \"Model\", \"value\" : \"ea234\"}, {\"name\" : \"Verson\", \"value\" : \"1.2.1\"}, {\"name\" : \"Debug_ENABLE\", \"value\" : \"TRUE\"}, {\"name\" : \"RAM_ENABLE\", \"value\" : \"False\"}, {\"name\" : \"SW_ID\", \"value\" : \"0x0003ab\"}]}}, \"signatureResponse\" : {\"statusCode\" : \"0\"}}"] 
| spath 
| rename Request.capability.Attributes{}.* as * 
| eval kvdata=mvzip(name,value) 
| fields - name value _* 
| mvexpand kvdata 
| eval kvdata=split(kvdata,",") 
| eval name=mvindex(kvdata,0),value=mvindex(kvdata,1) 
| fields - kvdata
| table sequenceId name value
| xyseries sequenceId name value
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 24 Mar 2018 04:11:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374328#M67835</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-03-24T04:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert JSON array of Name/Value pairs to field/value for event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374329#M67836</link>
      <description>&lt;P&gt;This doesn't do what I was hoping for... it seems to be separating out the "Name" and "Value" and creating additional events.  I need the names in the Attributes array to become new fields/columns of this one event.  And the values of the Attributes array to be the contents of the new names fields.  In the JSON data the attributes are in pairs of name/value.  &lt;/P&gt;</description>
      <pubDate>Sat, 24 Mar 2018 14:57:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374329#M67836</guid>
      <dc:creator>jordomo</dc:creator>
      <dc:date>2018-03-24T14:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert JSON array of Name/Value pairs to field/value for event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374330#M67837</link>
      <description>&lt;P&gt;Here is another picture with what I am hoping for...&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/4602iA21E45CD6DE05EF9/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>Sat, 24 Mar 2018 14:58:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374330#M67837</guid>
      <dc:creator>jordomo</dc:creator>
      <dc:date>2018-03-24T14:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert JSON array of Name/Value pairs to field/value for event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374331#M67838</link>
      <description>&lt;P&gt;Hi, let me know if this helps:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| your generating search here
| eval req_cap_attr = spath(myJSON, "Request.capability.Attributes{}")
| spath input=myJSON
| fields - Request.capability.Attributes*
| mvexpand req_cap_attr
| rex field=req_cap_attr "\"[^\"]+\"\s*:\s*\"(?&amp;lt;key&amp;gt;[^\"]+)\"\s*\,\s*\"[^\"]+\"\s*:\s*\"(?&amp;lt;value&amp;gt;[^\"]+)\""
| eval {key} = value
 | stats values(*) as * by myJSON
 | fields - myJSON, key, value, req_cap_attr
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For instance:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count
| eval myJSON = "
{
 \"DN\":\"CN=Test Group, OU=Test OU, O=Corp.com\",
 \"sourceId\":\"TEST Image\",
 \"sequenceId\":1,
 \"description\":\"doing work\",
 \"Request\":{
    \"capability\":{
        \"name\":\"prod02\",
        \"Attributes\":[
               {
                    \"name\":\"Model\",
                    \"value\":\"ea123\"
             },
                {
                    \"name\":\"Version\",
                    \"value\":\"1.2.3\"
             },
                {
                     \"name\":\"Debug_ENABLE\",
                     \"value\":\"FALSE\"
              },
                 {
                     \"name\":\"RAM_ENABLE\",
                     \"value\":\"True\"
              },
                 {
                      \"name\":\"SW_ID\",
                      \"value\":\"0x0003ed\"
              }
          ]
      }
   },
 \"signatureResponse\":{
 \"statusCode\":\"1\"
   }
 }
"
| eval req_cap_attr = spath(myJSON, "Request.capability.Attributes{}")
| spath input=myJSON
| fields - Request.capability.Attributes*
| mvexpand req_cap_attr
| rex field=req_cap_attr "\"[^\"]+\"\s*:\s*\"(?&amp;lt;key&amp;gt;[^\"]+)\"\s*\,\s*\"[^\"]+\"\s*:\s*\"(?&amp;lt;value&amp;gt;[^\"]+)\""
| eval {key} = value
 | stats values(*) as * by myJSON
 | fields - myJSON, key, value, req_cap_attr
&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/4604i670089F6C700C5EF/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
J&lt;/P&gt;</description>
      <pubDate>Sat, 24 Mar 2018 15:53:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374331#M67838</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2018-03-24T15:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert JSON array of Name/Value pairs to field/value for event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374332#M67839</link>
      <description>&lt;P&gt;@jordomom, sorry I missed that in the question, I have updated my answer above. If sequenceId  is not unique you can use streamstats to generate sequence number:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourBaseSearch&amp;gt;
| spath 
| streamstats count as sequneceId
 &amp;lt;remainingSearchAsAbove&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 24 Mar 2018 16:05:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374332#M67839</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-03-24T16:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert JSON array of Name/Value pairs to field/value for event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374333#M67840</link>
      <description>&lt;P&gt;Thanks @javiergn.  This is doing what I hoped but I am having a hard time following exactly what is happening here.  Any chance you could walk me through each line?  &lt;/P&gt;

&lt;P&gt;Regardless nice work! Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 26 Mar 2018 16:18:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374333#M67840</guid>
      <dc:creator>jordomo</dc:creator>
      <dc:date>2018-03-26T16:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert JSON array of Name/Value pairs to field/value for event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374334#M67841</link>
      <description>&lt;P&gt;Sure thing.&lt;BR /&gt;
Here we go:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval req_cap_attr = spath(myJSON, "Request.capability.Attributes{}")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Parse all the attributes in the Request.capability.Attributes and store that in the variable req_cap_attr.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| spath input=myJSON
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now parse the whole JSON file using spath in order to extract the key value pairs automatically.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | fields - Request.capability.Attributes*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Remove the fields we don't need because we already have their info the req_cap_attr variable.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | mvexpand req_cap_attr
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;req_cap_attr is a multivalued variable, therefore we want to expand it into individual events so that we can perform operations against them&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | rex field=req_cap_attr "\"[^\"]+\"\s*:\s*\"(?&amp;lt;key&amp;gt;[^\"]+)\"\s*\,\s*\"[^\"]+\"\s*:\s*\"(?&amp;lt;value&amp;gt;[^\"]+)\""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now that we have individual events, go an extract the key value pairs from your attributes.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval {key} = value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What this syntax here does is to basically create dynamic field names based on the content of the key field, for instance, if key=Model, the new field will be named "Model" and the value is the content of the value field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | stats values(*) as * by myJSON
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now that you have all the data you need in the relevant fields, you can use stats to summarise it in a tabular format, where all the fields and their values are presented in one header row and one values row.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | fields - myJSON, key, value, req_cap_attr
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Do some cleanup and show only the fields you really care about.&lt;/P&gt;

&lt;P&gt;Hope that helps. If you want me to elaborate more any particular line let me know.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
J&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:42:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374334#M67841</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2020-09-29T18:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert JSON array of Name/Value pairs to field/value for event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374335#M67842</link>
      <description>&lt;P&gt;Rockstar! Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 16:02:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374335#M67842</guid>
      <dc:creator>jordomo</dc:creator>
      <dc:date>2018-03-27T16:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert JSON array of Name/Value pairs to field/value for event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374336#M67843</link>
      <description>&lt;P&gt;@javiergn - This looks almost exactly like what I'm trying to do with some JSON data. I'm trying to understand what you're doing with the search, however, I'm not sure my skills in Splunk are up to the higher level explanation you've given.&lt;/P&gt;

&lt;P&gt;I'm trying to go through the Splunk docs on spath to gain a better understanding but not having a great time of it. Can you maybe explain a bit more in detail how spath() is used with eval? What does "myJSON" represent as the first parameter in that first line? How does that related to | spath input=myJSON?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2019 20:20:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374336#M67843</guid>
      <dc:creator>dubiza</dc:creator>
      <dc:date>2019-05-13T20:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert JSON array of Name/Value pairs to field/value for event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374337#M67844</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/178243"&gt;@dubiza&lt;/a&gt;, sorry for the delay.&lt;/P&gt;

&lt;P&gt;Spath can work as a function (within eval): &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.2.6/SearchReference/TextFunctions#spath.28X.2CY.29" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/7.2.6/SearchReference/TextFunctions#spath.28X.2CY.29&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Or as a command: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;But the behaviour is pretty much the same. &lt;/P&gt;

&lt;P&gt;myJSON is just a random variable name I chose to test the raw json data provided in the question, but this could be your actual event, in which case you would just need to change that in the first spath. Now, that first spath extracts from your raw json (myJSON), based on the path &lt;BR /&gt;
"Request.capability.Attributes{}" into the new variable req_cap_attr.&lt;/P&gt;

&lt;P&gt;The second spath extracts everything from myJSON automatically, creating field names based on the JSON hierarchy. The reason req_cap_attr is extracted separately is because we would like to create new field names based on the values inside the "Request.capability.Attributes{}" branch in a dynamic way by first extracting them with regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | rex field=req_cap_attr "\"[^\"]+\"\s*:\s*\"(?&amp;lt;key&amp;gt;[^\"]+)\"\s*\,\s*\"[^\"]+\"\s*:\s*\"(?&amp;lt;value&amp;gt;[^\"]+)\""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And then dynamically generating those field names with the following syntax:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval {key} = value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That syntax above is the one responsible for the field names in the attached screenshot above.&lt;/P&gt;

&lt;P&gt;Hope that clarifies a little. It's been more than 1 year since I answered this.&lt;/P&gt;

&lt;P&gt;By the way, if you like my answer don't forget to upvote it so that others can find it quicker too.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Javier&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:35:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-JSON-array-of-Name-Value-pairs-to-field-value-for/m-p/374337#M67844</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2020-09-30T00:35:06Z</dc:date>
    </item>
  </channel>
</rss>

