tracker issue : CF-3617509

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

serializeJSON() is converting ints to floats

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): John Pansewicz / John Pansewicz (John Pansewicz)

Created: 08/23/2013

Components: AJAX, Plumbing

Versions: 10.0

Failure Type:

Found In Build/Fixed In Build: Final / 286322

Priority/Frequency: Major / All users will encounter

Locale/System: English / Windows 7 SP1 64-bit

Vote Count: 0

Problem Description:

serializeJSON() is converting ints to floats when the number is calculated using the functions: val(), int() or ceiling(). I always assumed val() returned an int, but int() and ceiling() are supposed to return ints.



Steps to Reproduce:

Run the following code:

<cfset r = {
    "x": 0,
    "y": 1
}>

<cfoutput><pre>#serializeJSON(r)#</pre></cfoutput>

<cfset r.x = int(Val("1"))>

<cfset r.y = ceiling(100/10)>

<cfoutput><pre>#serializeJSON(r)#</pre></cfoutput>



Actual Result:

{"y":1,"x":0}

{"y":10.0,"x":1.0}



Expected Result:

{"y":1,"x":0}

{"y":10,"x":1}



Any Workarounds:

None

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

Watson Bug ID:	3617509

External Customer Info:
External Company:  
External Customer Name: redtopia-dev
External Customer Email:  
External Test Config: My Hardware and Environment details:



CF10 update 11 Win7 x64

Attachments:

Comments:

Here's a workaround: <cfset r.x = JavaCast("int", Val("1"))> <cfset r.y = JavaCast("int", ceiling(100/10))>
Comment by External U.
14627 | August 23, 2013 12:23:29 PM GMT
Even simple addition causes the number to be output as a float. For example, r["z"] = 1 + 2 will output a value of 3.0
Comment by External U.
14628 | August 23, 2013 12:28:33 PM GMT
With the fix it works as expected.
Comment by Suchika S.
14629 | September 25, 2013 02:48:29 AM GMT