Title:
ColdFusion 10, 11 (11,0,13,303668) and 2016: JSON Serialization Still Broken - String values in numeric format being interpreted as numeric (ie, "1.1.10")
| View in TrackerStatus/Resolution/Reason: Closed/Won't Fix/Workaround
Reporter/Name(from Bugbase): Phill Nacelli / ()
Created: 04/09/2018
Components: AJAX
Versions: 2016,11.0
Failure Type: Data Corruption
Found In Build/Fixed In Build: 11,0,13,303668 /
Priority/Frequency: Normal / All users will encounter
Locale/System: / Platforms All
Vote Count: 0
Problem Description:
Steps to Reproduce:
------------------------ BEGIN CODE -----------------------
<cfscript>
// tree outline
arbitraryTreeData = {
"one":"1",
"one_one":"1.1",
"one_two":"1.2",
"one_three":"1.3",
"one_four":"1.4",
"one_five":"1.5",
"one_six":"1.6",
"one_seven":"1.7",
"one_eight":"1.8",
"one_nine":"1.9",
"one_ten":"1.10"
};
writeDump(serializeJSON(arbitraryTreeData));
</cfscript>
------------------------ END CODE -----------------------
Actual Result:
// actual result:
// values are now numeric, causing client side JavaScript to
// interpret and render values as numeric removing trailing zero
/*
{
"one":1,
"one_one":1.1,
"one_two":1.2,
"one_three":1.3,
"one_four":1.4,
"one_five":1.5,
"one_six":1.6,
"one_seven":1.7,
"one_eight":1.8,
"one_nine":1.9,
"one_ten":1.10
}
*/
Expected Result:
// expected result:
// values are preserved as string, causing client side JavaScript to
// interpret and render values as numeric removing trailing zero
/*
{
"one":"1",
"one_one":"1.1",
"one_two":"1.2",
"one_three":"1.3",
"one_four":"1.4",
"one_five":"1.5",
"one_six":"1.6",
"one_seven":"1.7",
"one_eight":"1.8",
"one_nine":"1.9",
"one_ten":"1.10"
}
*/
Any Workarounds:
Painfully manually create JSON String by appending strings, it's 2018 that should not be an option!
Attachments:
Comments: