<?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: extract first value from json subarray in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/extract-first-value-from-json-subarray/m-p/476104#M81708</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;...
| rex "(?ms)asset_uri\":\[\"(?&amp;lt;asset_uri&amp;gt;[^\"]+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 15 Apr 2020 09:33:03 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2020-04-15T09:33:03Z</dc:date>
    <item>
      <title>extract first value from json subarray</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/extract-first-value-from-json-subarray/m-p/476101#M81705</link>
      <description>&lt;P&gt;Hello Guys ,&lt;/P&gt;

&lt;P&gt;I have one json event in which there is subarray so i want to create one field which will have first index value of array for example&lt;/P&gt;

&lt;P&gt;{&lt;BR /&gt;
"data":&lt;BR /&gt;
{"task":"pullFrom",&lt;BR /&gt;
"from_repo":"&lt;A href="https://abc.mxz.com:8089" target="_blank"&gt;https://abc.mxz.com:8089&lt;/A&gt;",&lt;BR /&gt;
"to_repo":"&lt;A href="https://abc.mxzz.com:8089" target="_blank"&gt;https://abc.mxzz.com:8089&lt;/A&gt;",&lt;BR /&gt;
"to_repo_change_count":20008,&lt;BR /&gt;
"asset_uri":["kannu","search","ui-prefs","search"]&lt;BR /&gt;
}&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;in above event i wnat to create the field which will have value only "kannu"  from subarray "asset_uri"  .&lt;/P&gt;

&lt;P&gt;I tried doing data.asset_uri[0] as a normal json parsing but splunk is giving error while doing like this &lt;/P&gt;

&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:01:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/extract-first-value-from-json-subarray/m-p/476101#M81705</guid>
      <dc:creator>kannu</dc:creator>
      <dc:date>2020-09-30T05:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: extract first value from json subarray</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/extract-first-value-from-json-subarray/m-p/476102#M81706</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Check this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval temp="{
\"data\":
{\"task\":\"pullFrom\",
\"from_repo\":\"https://abc.mxz.com:8089\",
\"to_repo\":\"https://abc.mxzz.com:8089\",
\"to_repo_change_count\":20008,
\"asset_uri\":[\"kannu\",\"search\",\"ui-prefs\",\"search\"]
}
}" 
| spath input=temp path=data.asset_uri{} output=asset_uri 
| eval asset_uri=mvindex(asset_uri,0)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Apr 2020 08:43:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/extract-first-value-from-json-subarray/m-p/476102#M81706</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2020-04-15T08:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: extract first value from json subarray</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/extract-first-value-from-json-subarray/m-p/476103#M81707</link>
      <description>&lt;P&gt;Hi @kannu,&lt;/P&gt;

&lt;P&gt;Assuming your JSON is extracted correctly you could just do the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval first_value = mvindex('data.asset_uri{}', 0)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Regards,&lt;BR /&gt;
J&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 08:55:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/extract-first-value-from-json-subarray/m-p/476103#M81707</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2020-04-15T08:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: extract first value from json subarray</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/extract-first-value-from-json-subarray/m-p/476104#M81708</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;...
| rex "(?ms)asset_uri\":\[\"(?&amp;lt;asset_uri&amp;gt;[^\"]+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Apr 2020 09:33:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/extract-first-value-from-json-subarray/m-p/476104#M81708</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-15T09:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: extract first value from json subarray</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/extract-first-value-from-json-subarray/m-p/476105#M81709</link>
      <description>&lt;P&gt;This one is simple , i tried using the same but dont know why it doesnt work for me may be single quote i forget to add .&lt;/P&gt;

&lt;P&gt;but thanks for helping me in resolving the issue  &lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 09:34:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/extract-first-value-from-json-subarray/m-p/476105#M81709</guid>
      <dc:creator>kannu</dc:creator>
      <dc:date>2020-04-15T09:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: extract first value from json subarray</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/extract-first-value-from-json-subarray/m-p/476106#M81710</link>
      <description>&lt;P&gt;Thank you ravikumar&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 09:34:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/extract-first-value-from-json-subarray/m-p/476106#M81710</guid>
      <dc:creator>kannu</dc:creator>
      <dc:date>2020-04-15T09:34:34Z</dc:date>
    </item>
  </channel>
</rss>

