<?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 json values from string json array in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-json-values-from-string-json-array/m-p/689224#M234887</link>
    <description>&lt;P&gt;Rather than pasting search results, please paste the raw event data, preferably in a code block &amp;lt;/&amp;gt; to preserve original formatting.&lt;/P&gt;</description>
    <pubDate>Fri, 31 May 2024 15:13:00 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2024-05-31T15:13:00Z</dc:date>
    <item>
      <title>Extract json values from string json array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-json-values-from-string-json-array/m-p/689192#M234877</link>
      <description>&lt;P&gt;Hi, my splunk search results in two fields - Time and Event. Inside Event field there are multiple searchable fields, one of which is json array as string like this:&lt;BR /&gt;params="[{'field1':'value1','field2':'value2','field3':'value3'}]"&lt;/P&gt;&lt;P&gt;Above json array always has one json object like in example. I need to extract values for given fields from this json object - how can i do that? I figured spath is the way to do this, but none of solutions I found so far worked - maybe because all examples were operating on json as string only and in my case it is in Event as splunk shows in search - can you help?&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2024 11:38:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-json-values-from-string-json-array/m-p/689192#M234877</guid>
      <dc:creator>mipa04</dc:creator>
      <dc:date>2024-05-31T11:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: Extract json values from string json array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-json-values-from-string-json-array/m-p/689200#M234879</link>
      <description>&lt;P&gt;This isn't JSON as JSON uses double quotes not single quotes. Please post an accurate representation of the field you want to extract the data from.&lt;/P&gt;&lt;P&gt;Having said that, you should look at the json functions new to 9.x as these would probably be the basis of a solution.&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2024 12:43:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-json-values-from-string-json-array/m-p/689200#M234879</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-05-31T12:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Extract json values from string json array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-json-values-from-string-json-array/m-p/689201#M234880</link>
      <description>&lt;P&gt;I pasted it the same as I see in splunk search results, field params is in double quotes, but inside there are single quotes. I know that json requires double quotes, but don't know if it is only matter of displaying in splunk search, or actually it is not proper json for splunk (source for this is database table, in which it is proper json array with double quotes)&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2024 12:50:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-json-values-from-string-json-array/m-p/689201#M234880</guid>
      <dc:creator>mipa04</dc:creator>
      <dc:date>2024-05-31T12:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Extract json values from string json array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-json-values-from-string-json-array/m-p/689202#M234881</link>
      <description>&lt;P&gt;I agree with&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;and your sample JSON looks like an array of objects also. So please share a masked event here.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Meanwhile, I'm sharing a sample query so that you can start on the solution.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval params="[{'field1':'value1','field2':'value2','field3':'value3','field4':'value4'}]"
| rename comment as "upto now is sample data only"
| eval params = replace(params, "'","\"")
| eval _raw = params
| spath&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have handled a single quote here.&amp;nbsp; &amp;nbsp;if you have valid JSON then just remove `| eval params = replace(params, "'","\"")` .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;BR /&gt;KV&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2024 12:53:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-json-values-from-string-json-array/m-p/689202#M234881</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2024-05-31T12:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extract json values from string json array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-json-values-from-string-json-array/m-p/689224#M234887</link>
      <description>&lt;P&gt;Rather than pasting search results, please paste the raw event data, preferably in a code block &amp;lt;/&amp;gt; to preserve original formatting.&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2024 15:13:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-json-values-from-string-json-array/m-p/689224#M234887</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-05-31T15:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Extract json values from string json array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-json-values-from-string-json-array/m-p/689233#M234890</link>
      <description>&lt;P&gt;I don't know if that it is in Event top level field matters, so I'm pasting screenshot of raw data. Field in question is tlogParameters&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-05-31 172546.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/31098i14A15C33E9BC0ADE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2024-05-31 172546.png" alt="Screenshot 2024-05-31 172546.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2024 15:32:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-json-values-from-string-json-array/m-p/689233#M234890</guid>
      <dc:creator>mipa04</dc:creator>
      <dc:date>2024-05-31T15:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: Extract json values from string json array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-json-values-from-string-json-array/m-p/689245#M234894</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/268360"&gt;@mipa04&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I assume&amp;nbsp;tlogParameters filed getting extracted properly.&lt;/P&gt;&lt;P&gt;Can you please try the below search?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;YOUR_SEARCH
| eval tlogParameters = replace(tlogParameters, "'","\"")
| eval _raw = tlogParameters
| spath 
| rename {}.* as *&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Sample Search :&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval tlogParameters="[{'triggeredEventName': 'CustomerLoggedIn', 'owner': 'communicationcenter', 'channel': 'SiteMessage', 'sentOrNotSent': 'Sent', 'reasonNotSent':null}]" | append [| makeresults 
| eval tlogParameters="[{'triggeredEventName': 'CustomerLoggedIn', 'owner': 'communicationcenter', 'channel': 'SiteMessage', 'sentOrNotSent': 'Sent', 'reasonNotSent':null}]"]
| rename comment as "upto now is sample data only"
| eval tlogParameters = replace(tlogParameters, "'","\"")
| eval _raw = tlogParameters
| spath 
| rename {}.* as *&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-05-31 at 9.52.18 PM.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/31099iBFC6E3BACB445506/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2024-05-31 at 9.52.18 PM.png" alt="Screenshot 2024-05-31 at 9.52.18 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt; I hope this will help you.&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;If any of my replies help you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2024 16:22:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-json-values-from-string-json-array/m-p/689245#M234894</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2024-05-31T16:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: Extract json values from string json array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-json-values-from-string-json-array/m-p/689374#M234921</link>
      <description>&lt;P&gt;Thanks for response, but unfortunately it doesn't work -&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;YOUR_SEARCH
| eval tlogParameters = replace(tlogParameters, "'","\"")&lt;/PRE&gt;&lt;P&gt;this doesn't change anything - ie tlogParameters is still displayed in raw as single quotes and surrounded by double quotes as original.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;YOUR_SEARCH
| eval tlogParameters = replace(tlogParameters, "'","\"")
| eval _raw = tlogParameters&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;this makes empty result (the same as full query you proposed):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-06-03 085459.png" style="width: 700px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/31112i09EB6A853A064E64/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2024-06-03 085459.png" alt="Screenshot 2024-06-03 085459.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2024 06:56:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-json-values-from-string-json-array/m-p/689374#M234921</guid>
      <dc:creator>mipa04</dc:creator>
      <dc:date>2024-06-03T06:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: Extract json values from string json array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-json-values-from-string-json-array/m-p/689378#M234922</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Please paste the raw event data, preferably in a code block &amp;lt;/&amp;gt; to preserve original formatting.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2024 07:09:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-json-values-from-string-json-array/m-p/689378#M234922</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-06-03T07:09:18Z</dc:date>
    </item>
  </channel>
</rss>

