Title:
Bug 83986:serializeJSON() converting all numbers into strings, sometimes with an added decimal point
| View in TrackerStatus/Resolution/Reason: Closed/Withdrawn/
Reporter/Name(from Bugbase): Gjslick Gjslick / Gjslick Gjslick (Greg_J2)
Created: 08/30/2010
Components: Language, Functions
Versions: 9.0.1
Failure Type: Unspecified
Found In Build/Fixed In Build: 274733 /
Priority/Frequency: Trivial / Unknown
Locale/System: English / Win All
Vote Count: 0
Duplicate ID: CF-3041793
Problem:
serializeJSON() converting all numbers into strings, sometimes with an added decimal point.The move to change the behavior of serializeJSON() to return all variables as strings (including actual numbers) has been disastrous for my application. This is especially so with the added “.0” that ColdFusion seems to add to values in some cases. Not only is every calculation using the returned data now broken (2+"5.0"="25.0", instead of what it should be, 7) but this also breaks any lookups for JS array/object keys (i.e. myArr[2] != myArr[“2.0”]). Even when the .0 is not added though, it is still a problem (2+"5" = "25") and any boolean value returning from a database breaks JavaScript code as well. We can no longer return 0 from a database because it is serialized as "0". if("0") passes as *true*, whereas if(0) does not.This convert-to-string issue is also causing problems in JavaScript library code, namely ExtJS’s “Direct” functionality, which uses ajax and numeric metadata for its processing.I see why you made the change to serializeJSON (to allow strings like "000001" to be sent as-is, as per bug #82706), but a better solution needs to be found, even if it’s just making serializeJSON() check for any prefixed 0’s on a variable’s value first, and leaving those variables as strings. This would be worlds better than just making absolutely everything be converted into a string, and developers who come across the very rare case of needing prefixed 0’s removed from a value will then have the workaround of using int() or numberFormat() on the value first. Right now, there is no workaround for everything being converted into strings, except to update every piece of JavaScript code in an entire system, which in this case includes library code that we have no control over. Not to mention, this kind of problem with the concatenation of numbers+strings in JavaScript code is exceedingly difficult, and very time consuming to diagnose and fix.
Method:
Result:
None
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3041967
External Customer Info:
External Company:
External Customer Name: Gjslick Gjslick
External Customer Email: 11CE679F445E352D9920157F
External Test Config: 08/30/2010
Attachments:
Comments: