tracker issue : CF-3044043

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

Bug 87118:-(Watson Migration Closure)serialiseJSON('{"key":"000"}') produces: {"key:000} which javascript is unable to interpret

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Mike Causer / Mike Causer (mike causer)

Created: 09/25/2011

Components: Language

Versions: 9.0.1

Failure Type: Unspecified

Found In Build/Fixed In Build: 9,0,1,274733 / CF10_Update14

Priority/Frequency: Trivial / Unknown

Locale/System: English / Platforms All

Vote Count: 0

Duplicate ID:	CF-3321476

Problem:

serialiseJSON('{"key":"000"}') produces: {"key:000} which javascript is unable to interpret.
The bug occurs when you try to serialise any numeric string with leading zeros.
If you serialise and deserialise again it becomes {"key":0} which javascript can understand - but is still wrong as your original value was a string with 3x zeros.

serialiseJSON('{"key":"4D "}') also throws:
coldfusion.runtime.JSONUtils$JSONParseException: JSON parsing failure at character 9:'D' in {"key":4D }
This is because coldfusion.runtime.CFDouble parseDouble() checks if the last character is "F" or "D"
The custom parseDouble() method should trim the string before checking it for a float/double.
Otherwise a NumberFormatException is not thrown and Double.parseDouble("4D ") produces the double value 4.
Method:

serialiseJSON('{"key":"000"}');
serialiseJSON('{"key":"4D "}');
(note serialiseJSON('{"key":"4D"}'); works fine - the trailing space breaks it)
Result:

serialiseJSON() incorrectly parses numeric strings with leading zeros

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

Watson Bug ID:	3044043

Keywords:
FixTested


External Customer Info:
External Company:  
External Customer Name: Mike Causer
External Customer Email: 5E3754C04462CDFF992016B6
External Test Config: 09/25/2011

Attachments:

Comments:

Fix verified on build, 287459
Comment by Immanuel N.
20922 | December 19, 2013 05:23:43 AM GMT