tracker issue : CF-3219537

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

Calling serializeJSON on a string of zeros (e.g. "000") doesn't string-encode the output.

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/

Reporter/Name(from Bugbase): Tim Blair / Tim Blair (Psionix)

Created: 06/20/2012

Components: AJAX, Plumbing

Versions: 9.0.1

Failure Type:

Found In Build/Fixed In Build: 9.0.1 /

Priority/Frequency: Major / Some users will encounter

Locale/System: English / Mac All

Vote Count: 1

Duplicate ID:	CF-3321476

Problem Description:

Calling serializeJSON on a string containing just zeros (e.g. "000") will result in a non-string output of 000.

The JSON specification (see: http://json.org/) specifies that a number value must only start with a single zero, and then only if it is directly followed by a period (.) or exponent (e).  ColdFusion's serialisation of "000" to a number value 000 does not conform to the JSON specification, which means that parsers which expect conformity will fail to parse the JSON string.  This issue therefore affects interoperability between ColdFusion and system components written in other languages, as well as JSON-based data stores like MongoDB.

Note also that CF's deserializeJSON function will parse the JSON output from serializeJSON("000") but will result in the (incorrect) output of "0" (i.e. the string of zeros has been truncated).


Steps to Reproduce:

<cfoutput>#serializejson("000")#</cfoutput>


Actual Result:

000


Expected Result:

"000"


Any Workarounds:

None known.

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

Watson Bug ID:	3219537

External Customer Info:
External Company:  
External Customer Name: Psionix
External Customer Email:  
External Test Config: My Hardware and Environment details:



OS X Lion, running CF 9,0,2,282541.

Attachments:

Comments:

In addition to the above, it appears that any floating-point number (x) where (-1 >= x < 1) fails serialisation in the same manner as above when prefixed by multiple zeros. Example values: * -0001.0 * -000.123 * 000.123
Comment by External U.
18961 | August 08, 2012 08:38:32 AM GMT
I keep running into this bug when pulling JSON data from CF using jQuery. Values such as "0000" are incorrectly sent as numeric, which causes a "parsererror" on the jQuery side. Workarounds are hacky at best.
Vote by External U.
18963 | August 31, 2012 11:43:08 AM GMT
The scenario mentioned in the bug, ("000") has been fixed. Closing as duplicate of bug CF-3321476. The scenarios mentioned in the comments, ("-0001.0" , "-000.123", "000.123"), are tracked in an other bug, CF-3706077
Comment by Immanuel N.
18962 | February 11, 2014 07:12:47 AM GMT