<?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 How to parse a string with special format into objects or variables? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-string-with-special-format-into-objects-or/m-p/593789#M206681</link>
    <description>&lt;P class="lia-align-left"&gt;Hi there,&lt;/P&gt;
&lt;P class="lia-align-left"&gt;I have trying to use&amp;nbsp;&lt;STRONG&gt;spath&amp;nbsp;&lt;/STRONG&gt;to try to extract fields inside a string. Currently, the string has this format..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="ruby"&gt;stringField=["fieldOne": "fieldValue", "fieldTwo": "fieldValue", "fieldThree": "fieldValue"]&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, my string inside has some kinda of array with key value pairs. I would to be able to extract those fields and values in a way that I can use their information for my queries.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I would like to be able to get the value of &lt;STRONG&gt;fieldOne&lt;/STRONG&gt; by just calling the &lt;STRONG&gt;fieldOne&amp;nbsp;&lt;/STRONG&gt;variable/object to get it's value to perform my desire task/stats and so on..&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I was trying something like... but no luck!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="ruby"&gt;search... | spath input=stringField &lt;/LI-CODE&gt;&lt;LI-CODE lang="ruby"&gt;search... | eval newVariable=spath(_raw,'stringField')&lt;/LI-CODE&gt;&lt;LI-CODE lang="ruby"&gt;search... | spath&lt;/LI-CODE&gt;&lt;LI-CODE lang="ruby"&gt;search... | spath path=stringField output=newField&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first option of just using input with the &lt;STRONG&gt;spath&lt;/STRONG&gt; command only gave me back the first field inside my string. And it was listed as&lt;STRONG&gt; {}&lt;/STRONG&gt; field.&lt;BR /&gt;&lt;BR /&gt;I would really appreciate the help!&lt;/P&gt;</description>
    <pubDate>Thu, 14 Apr 2022 17:04:47 GMT</pubDate>
    <dc:creator>jvdev</dc:creator>
    <dc:date>2022-04-14T17:04:47Z</dc:date>
    <item>
      <title>How to parse a string with special format into objects or variables?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-string-with-special-format-into-objects-or/m-p/593789#M206681</link>
      <description>&lt;P class="lia-align-left"&gt;Hi there,&lt;/P&gt;
&lt;P class="lia-align-left"&gt;I have trying to use&amp;nbsp;&lt;STRONG&gt;spath&amp;nbsp;&lt;/STRONG&gt;to try to extract fields inside a string. Currently, the string has this format..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="ruby"&gt;stringField=["fieldOne": "fieldValue", "fieldTwo": "fieldValue", "fieldThree": "fieldValue"]&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, my string inside has some kinda of array with key value pairs. I would to be able to extract those fields and values in a way that I can use their information for my queries.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I would like to be able to get the value of &lt;STRONG&gt;fieldOne&lt;/STRONG&gt; by just calling the &lt;STRONG&gt;fieldOne&amp;nbsp;&lt;/STRONG&gt;variable/object to get it's value to perform my desire task/stats and so on..&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I was trying something like... but no luck!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="ruby"&gt;search... | spath input=stringField &lt;/LI-CODE&gt;&lt;LI-CODE lang="ruby"&gt;search... | eval newVariable=spath(_raw,'stringField')&lt;/LI-CODE&gt;&lt;LI-CODE lang="ruby"&gt;search... | spath&lt;/LI-CODE&gt;&lt;LI-CODE lang="ruby"&gt;search... | spath path=stringField output=newField&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first option of just using input with the &lt;STRONG&gt;spath&lt;/STRONG&gt; command only gave me back the first field inside my string. And it was listed as&lt;STRONG&gt; {}&lt;/STRONG&gt; field.&lt;BR /&gt;&lt;BR /&gt;I would really appreciate the help!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 17:04:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-string-with-special-format-into-objects-or/m-p/593789#M206681</guid>
      <dc:creator>jvdev</dc:creator>
      <dc:date>2022-04-14T17:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse a string with special format into objects or variables?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-string-with-special-format-into-objects-or/m-p/593880#M206712</link>
      <description>&lt;LI-CODE lang="markup"&gt;| eval stringField="{".trim(stringField,"[]")."}"
| spath input=stringField&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 15 Apr 2022 09:41:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-string-with-special-format-into-objects-or/m-p/593880#M206712</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-04-15T09:41:40Z</dc:date>
    </item>
  </channel>
</rss>

