<?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 Evaluate json boolean value with if statement in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Evaluate-json-boolean-value-with-if-statement/m-p/169057#M48269</link>
    <description>&lt;P&gt;Hi all, I am trying to run this simple search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SourceType=FooMonitoring |eval isSuccess=if(Test.TestIsSuccessful=="true","Yes","No") | table isSuccess Test.TestIsSuccessful
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am getting the following results:  (can't post an image...)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;isSuccess   Test.TestIsSuccessful
--------------------------------------
No          true
No          true
No          true
No          true
No          true
No          true
No          true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am expecting all the isSuccess values to be "Yes" but no matter what I do the if expression does not evaluate to true. Tried different ways, tried removing the double quotes around the "true" part with no luck.&lt;/P&gt;

&lt;P&gt;Note that the raw data is json, but I didn't encounter any problems with it so far and I don't know if it is related or not...&lt;/P&gt;

&lt;P&gt;I am using splunk 6&lt;/P&gt;

&lt;P&gt;Please help me figure out what am I doing wrong.&lt;BR /&gt;
Thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 06 Dec 2013 03:32:19 GMT</pubDate>
    <dc:creator>itaigev</dc:creator>
    <dc:date>2013-12-06T03:32:19Z</dc:date>
    <item>
      <title>Evaluate json boolean value with if statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Evaluate-json-boolean-value-with-if-statement/m-p/169057#M48269</link>
      <description>&lt;P&gt;Hi all, I am trying to run this simple search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SourceType=FooMonitoring |eval isSuccess=if(Test.TestIsSuccessful=="true","Yes","No") | table isSuccess Test.TestIsSuccessful
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am getting the following results:  (can't post an image...)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;isSuccess   Test.TestIsSuccessful
--------------------------------------
No          true
No          true
No          true
No          true
No          true
No          true
No          true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am expecting all the isSuccess values to be "Yes" but no matter what I do the if expression does not evaluate to true. Tried different ways, tried removing the double quotes around the "true" part with no luck.&lt;/P&gt;

&lt;P&gt;Note that the raw data is json, but I didn't encounter any problems with it so far and I don't know if it is related or not...&lt;/P&gt;

&lt;P&gt;I am using splunk 6&lt;/P&gt;

&lt;P&gt;Please help me figure out what am I doing wrong.&lt;BR /&gt;
Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2013 03:32:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Evaluate-json-boolean-value-with-if-statement/m-p/169057#M48269</guid>
      <dc:creator>itaigev</dc:creator>
      <dc:date>2013-12-06T03:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluate json boolean value with if statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Evaluate-json-boolean-value-with-if-statement/m-p/169058#M48270</link>
      <description>&lt;P&gt;Unfortunately, the dot (&lt;CODE&gt;.&lt;/CODE&gt;) in &lt;CODE&gt;eval&lt;/CODE&gt; expression syntax means "string concatenate". JSON kv parsing creates variables with a dot in their name, e.g., &lt;CODE&gt;Test.TestIsSuccessful&lt;/CODE&gt;. However, &lt;CODE&gt;eval&lt;/CODE&gt; parses that as a concatenation of two variables, &lt;CODE&gt;Test&lt;/CODE&gt; and &lt;CODE&gt;TestIsSuccessful&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;To get around this, quote the variable name with single-quotes, so that the dot is not interpreted as the concatenation operator:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval isSuccess=if('Test.TestIsSuccessful'=="true","Yes","No") | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Dec 2013 05:05:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Evaluate-json-boolean-value-with-if-statement/m-p/169058#M48270</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2013-12-06T05:05:11Z</dc:date>
    </item>
  </channel>
</rss>

