Title:
Bug 83937:serializeJSON() converting all numbers into strings, with added decimal point
| View in TrackerStatus/Resolution/Reason: Closed/Withdrawn/
Reporter/Name(from Bugbase): Gregory Jacobs / Gregory Jacobs (Gjake6)
Created: 08/24/2010
Components: Language, Functions
Versions: 9.0.1
Failure Type: Unspecified
Found In Build/Fixed In Build: 9,0,1,274733 /
Priority/Frequency: Trivial / Unknown
Locale/System: English / Win All
Vote Count: 0
Duplicate ID: CF-3041793
Problem:
serializeJSON() converting all numbers into strings, with 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”]). 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:
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3041939
External Customer Info:
External Company:
External Customer Name: Gregory Jacobs
External Customer Email: 3C41504F4BF9A62E0A04B833
External Test Config: 08/24/2010
Attachments:
Comments: