<?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: Extracting a JSON boolean value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extracting-a-JSON-boolean-value/m-p/514974#M144557</link>
    <description>&lt;P&gt;I noticed when I tried your code - creating _raw, this worked. Note I fixed the "==" :&lt;/P&gt;&lt;P&gt;| eval _raw="{\"build\":{\"build_id\":\"bubyut7oi7xlg\",\"cache\":{\"remote_enabled\":false}}}"&lt;BR /&gt;| spath&lt;BR /&gt;| eval check = if('build.cache.remote_enabled'=="false", "boolean", "string")&lt;BR /&gt;| table check&lt;/P&gt;&lt;P&gt;However when I use the _raw value (which is much larger than my small subset, it fails). &amp;nbsp;I knew the _raw text was large, but I checked and I was surprised to see it was &amp;nbsp;&amp;gt; 5K characters. I did try using spath with an input path to try and give it a more precise starting point, but I guess it doesn't work that way. So I'm sure that is why mine was failing. &amp;nbsp;Your initial suggestion works fine by testing with quoted "false"!&lt;/P&gt;&lt;P&gt;To work around my problem, &amp;nbsp;I use this to extract the (fortunately unique) named value:&lt;/P&gt;&lt;P&gt;index=gradle_enterprise_export sourcetype="gradle-export-app" message=build_saved env="prod" build.build_id="bubyut7oi7xlg"&lt;BR /&gt;| rex field=_raw "\"remote_enabled\":(?P&amp;lt;remote_enabled&amp;gt;[^,]*)"&lt;BR /&gt;| table remote_enabled&lt;/P&gt;&lt;P&gt;Thanks for your suggestions. It helped!&lt;/P&gt;</description>
    <pubDate>Wed, 19 Aug 2020 14:58:56 GMT</pubDate>
    <dc:creator>danl</dc:creator>
    <dc:date>2020-08-19T14:58:56Z</dc:date>
    <item>
      <title>Extracting a JSON boolean value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-a-JSON-boolean-value/m-p/514786#M144500</link>
      <description>&lt;P&gt;I've been unable to get a boolean value extracted from JSON written to Splunk. The data looks like this:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;build&lt;/SPAN&gt;: {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-2"&gt;&lt;SPAN class="key-name"&gt;build_id&lt;/SPAN&gt;: &lt;SPAN class="t string"&gt;bubyut7oi7xlg&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-2"&gt;&lt;SPAN class="key-name"&gt;cache&lt;/SPAN&gt;: {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN class="key level-3"&gt;&lt;SPAN class="key-name"&gt;remote_enabled&lt;/SPAN&gt;: &lt;SPAN class="t boolean"&gt;false&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Here's my search:&lt;/P&gt;&lt;P&gt;index=gradle_enterprise_export sourcetype="gradle-export-app" message=build_saved env="prod" build.build_id="bubyut7oi7xlg"&lt;BR /&gt;| spath&lt;BR /&gt;| rename build.cache.remote_enabled as remote&lt;BR /&gt;| eval remote_cache = if(remote=="false", "false", "true")&lt;BR /&gt;| table build.build_id remote_cache&lt;/P&gt;&lt;P&gt;I've tried a number of different combinations for remote=="false" using no quotes, single quotes, different cases. I've also tried directly using&amp;nbsp;build.cache.remote_enabled == "false". (though another another post says eval will concatenate fields. Even quoted, it makes no difference). &amp;nbsp;The result should be "false" and &amp;nbsp;is always "true":&lt;/P&gt;&lt;P&gt;build.build_id &amp;nbsp; &amp;nbsp; remote_cache&lt;BR /&gt;bubyut7oi7xlg &amp;nbsp; true&lt;/P&gt;&lt;P&gt;I've also used tostring() to show the remote_enabled value and it shows NULL.&lt;/P&gt;&lt;P&gt;Any ideas? Are JSON boolean values supported?&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2020 22:30:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-a-JSON-boolean-value/m-p/514786#M144500</guid>
      <dc:creator>danl</dc:creator>
      <dc:date>2020-08-18T22:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a JSON boolean value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-a-JSON-boolean-value/m-p/514798#M144505</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=_internal | head 1 | fields _raw
| eval _raw="{\"build\":{\"build_id\":\"bubyut7oi7xlg\",\"cache\":{\"remote_enabled\":false}}}"
| spath
| eval check = if('build.cache.remote_enabled'="false","boolean","string")
| table *&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE width="751px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="115px" height="25px"&gt;build.build_id&amp;nbsp;&lt;/TD&gt;&lt;TD width="220px" height="25px"&gt;build.cache.remote_enabled&amp;nbsp;&lt;/TD&gt;&lt;TD width="70px" height="25px"&gt;check&amp;nbsp;&lt;/TD&gt;&lt;TD width="345px" height="25px"&gt;_raw&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="115px" height="47px"&gt;bubyut7oi7xlg&lt;/TD&gt;&lt;TD width="220px" height="47px"&gt;false&lt;/TD&gt;&lt;TD width="70px" height="47px"&gt;boolean&lt;/TD&gt;&lt;TD width="345px" height="47px"&gt;{"build":{"build_id":"bubyut7oi7xlg","cache":{"remote_enabled":false}}}&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;my splunk is ver 8.0.3. there is no problem.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2020 23:42:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-a-JSON-boolean-value/m-p/514798#M144505</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-08-18T23:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a JSON boolean value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-a-JSON-boolean-value/m-p/514809#M144513</link>
      <description>&lt;P&gt;thanks to4kawa. I tried your code, altering slightly for my search:&lt;/P&gt;&lt;P&gt;index=gradle_enterprise_export sourcetype="gradle-export-app" message=build_saved env="prod" build.build_id="bubyut7oi7xlg"&lt;BR /&gt;| spath&lt;BR /&gt;| eval check = if('build.cache.remote_enabled'="false", "boolean", "string")&lt;BR /&gt;| table check&lt;/P&gt;&lt;P&gt;I get "string" for the value of check. I'm running Splunk V7.2.7.3 and this is the raw text of the search result:&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"build": {&lt;BR /&gt;"build_id": "bubyut7oi7xlg",&lt;BR /&gt;"cache": {&lt;BR /&gt;"remote_enabled": false&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2020 00:25:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-a-JSON-boolean-value/m-p/514809#M144513</guid>
      <dc:creator>danl</dc:creator>
      <dc:date>2020-08-19T00:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a JSON boolean value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-a-JSON-boolean-value/m-p/514813#M144515</link>
      <description>&lt;P&gt;wow, that's interesting.&lt;BR /&gt;&lt;BR /&gt;workaround:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;index=gradle_enterprise_export sourcetype="gradle-export-app" message=build_saved env="prod" build.build_id="bubyut7oi7xlg"&lt;/SPAN&gt;&lt;BR /&gt;| rex mode=sed "s/false/\"false\"/g s/true/\"true\"/g"&lt;BR /&gt;| spath&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2020 00:34:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-a-JSON-boolean-value/m-p/514813#M144515</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-08-19T00:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a JSON boolean value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-a-JSON-boolean-value/m-p/514817#M144518</link>
      <description>&lt;P&gt;worth watching below video if you are beginner in regular expressions.&lt;/P&gt;&lt;P&gt;&lt;A title="Regular expressions in Splunk" href="https://youtu.be/LoiyiCVGLnw" target="_self"&gt;Regular expressions in Splunk&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can share _raw to give you correct regex?&lt;/P&gt;&lt;P&gt;formatted json may have special characters which will not appear here.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2020 02:41:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-a-JSON-boolean-value/m-p/514817#M144518</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2020-08-19T02:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a JSON boolean value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-a-JSON-boolean-value/m-p/514974#M144557</link>
      <description>&lt;P&gt;I noticed when I tried your code - creating _raw, this worked. Note I fixed the "==" :&lt;/P&gt;&lt;P&gt;| eval _raw="{\"build\":{\"build_id\":\"bubyut7oi7xlg\",\"cache\":{\"remote_enabled\":false}}}"&lt;BR /&gt;| spath&lt;BR /&gt;| eval check = if('build.cache.remote_enabled'=="false", "boolean", "string")&lt;BR /&gt;| table check&lt;/P&gt;&lt;P&gt;However when I use the _raw value (which is much larger than my small subset, it fails). &amp;nbsp;I knew the _raw text was large, but I checked and I was surprised to see it was &amp;nbsp;&amp;gt; 5K characters. I did try using spath with an input path to try and give it a more precise starting point, but I guess it doesn't work that way. So I'm sure that is why mine was failing. &amp;nbsp;Your initial suggestion works fine by testing with quoted "false"!&lt;/P&gt;&lt;P&gt;To work around my problem, &amp;nbsp;I use this to extract the (fortunately unique) named value:&lt;/P&gt;&lt;P&gt;index=gradle_enterprise_export sourcetype="gradle-export-app" message=build_saved env="prod" build.build_id="bubyut7oi7xlg"&lt;BR /&gt;| rex field=_raw "\"remote_enabled\":(?P&amp;lt;remote_enabled&amp;gt;[^,]*)"&lt;BR /&gt;| table remote_enabled&lt;/P&gt;&lt;P&gt;Thanks for your suggestions. It helped!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2020 14:58:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-a-JSON-boolean-value/m-p/514974#M144557</guid>
      <dc:creator>danl</dc:creator>
      <dc:date>2020-08-19T14:58:56Z</dc:date>
    </item>
  </channel>
</rss>

