tracker issue : CF-3565260

select a category, or use search below
(searches all categories and all time range)
Title:

DeserializeJSON() messes up ArrayContains() With Database Ints

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Ben Nadel / Ben Nadel (Ben Nadel)

Created: 05/22/2013

Components: AJAX, Plumbing

Versions: 9.0.1

Failure Type: Non Functioning

Found In Build/Fixed In Build: 9.0.1 /

Priority/Frequency: Trivial / Unknown

Locale/System: English / Mac All

Vote Count: 0

Problem Description: 

If I am using deserializeJSON(), I cannot find a database INT (via query-loop) using arrayContains() or arrayFind(). If I remove the deserializeJson() step, it works as expected.


Steps to Reproduce:

See blog post: http://www.bennadel.com/blog/2475-Strange-Interaction-Between-DeserializeJson-ArrayContains-And-Database-Values-In-ColdFusion.htm


Any Workarounds:

Manually loop over array to check values using "==" or "eq".

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3565260

External Customer Info:
External Company:  
External Customer Name: BenNadel
External Customer Email:  
External Test Config: CF:  	9,0,1,274733  

Mac OSX: 10.6.8

Attachments:

Comments:

This has been fixed in ColdFusion 11 Here is the code I tried ----------------- <cfset users = queryNew("id, name", "Integer, Varchar")> <cfset users.addRow({id=1, name="alice"})> <cfset users.addRow({id=2, name="bob"})> <cfset users.addRow({id=3, name="charlie"})> <cfset users.addRow({id=4, name="dan"})> <cfoutput> <cfset selectedUserIDs = deserializeJson(serializeJson( [ 1, 4 ] )) /> <!--- Output the users. ---> Selected User IDs: #arrayToList( selectedUserIDs )#<br /> <br /> <cfloop query="users"> User #users.id# selected: <!--- Use database ID, as-is. ---> #arrayContains( selectedUserIDs, users.id )# - <!--- Use "stringified" user ID. ---> #arrayContains( selectedUserIDs, toString( users.id ) )# <br /> </cfloop> <br /> <!--- As a sanity check, let's try different values manually. ---> As Number: #arrayContains( selectedUserIDs, 1 )#<br /> As String: #arrayContains( selectedUserIDs, "1" )#<br /> As Java: #arrayContains( selectedUserIDs, javaCast( "int", 1 ) )#<br /> </cfoutput> --------------
Comment by Rupesh K.
15319 | May 02, 2014 07:00:02 PM GMT