Quantcast
Channel: Adobe Community: Message List - ColdFusion
Viewing all articles
Browse latest Browse all 21760

Re: Does cf10 change the way deserializejson handles null?

$
0
0

Resurrecting a dead thread, but I thought it better than creating a new one. Shouldn't this behaviour be considered a bug in CF10.

  1. Deserialize a JSON structure that has null values
  2. If I perform the comparison IsNull(foo) it returns true as it should because that field is null. Now, IsNull is a type check.
  3. But, if I perform another type check such as IsDate(foo) I now get an error because ColdFusion is now saying that foo is undefined instead of null. This should be a bug. A type check is a type check, if the variable was null, its state shouldn't magically change to undefined when performing a different type check. And undefined does not equal null. Those are 2 different variable states.

 

If this is not a bug, then please explain why this should be failiing? And once again, this is for CF10.

<cfsetfoo = {string = "", mynull = ""}>

<cfsetfoo.mynull = javaCast("null", "")>

<cfsetbar = SerializeJSON(foo)>

<cfsetfoobar = DeSerializeJSON(bar) />

<cfdumpvar="#foobar#">

<cfoutput>

       isNull = #isNull(foobar.mynull)#<br/>

       <cftry>

        isSimpleValue = #isSimpleValue(foobar.mynull)#<br/>

              isDate = #isDate(foobar.mynull)#<br/>

              isQuery = #isQuery(foobar.mynull)#<br/>

              isArray = #isArray(foobar.mynull)#<br/>

              isStruct = #isStruct(foobar.mynull)#<br/>

    <cfcatchtype="Any">

              <cfdumpvar="#cfcatch#">

    </cfcatch>

    </cftry>

</cfoutput>


Viewing all articles
Browse latest Browse all 21760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>