Status/Resolution/Reason: Closed/Fixed/
Reporter/Name(from Bugbase): John Whish / John Whish (John Whish)
Created: 09/29/2016
Components: Language, Functions
Versions: 2016
Failure Type: Data Corruption
Found In Build/Fixed In Build: CF2016_Update1 /
Priority/Frequency: Critical / Some users will encounter
Locale/System: English / Mac 10.9 64 bit
Vote Count: 0
Problem Description:
<cfscript>
x = [
{"userid":"123"},
{"userid":"ABC"}
];
</cfscript>
writeDump(SerializeJSON(x));
returns:
[{"userid":123},{"userid":"ABC"}]
Note that the first userid is numeric, the second is a string. Expected:
[{"userid":"123"},{"userid":"ABC"}]
This also happens when iterating a query.
For example:
<cfscript>
function queryToArrayOfStructs(q) {
var result = [];
for (row in q) {
var data = {};
for (var key in row) {
data[lcase(key)] = "" & row[key];
}
result.append(data);
};
return result;
}
// simulate a query
myQuery = queryNew("UserID,UserName,FirstName","varchar,varchar,varchar", [
["100", "Fred", "Bloggs"],
["ABC", "Jo", "Smith"]
]);
foo = queryToArrayOfStructs(myQuery);
writeDump(myQuery);
writeDump(serializeJSON(foo));
</cfscript>
Here it does not respect the original query column type of `varchar`. It also does not respect that the attempt to coerce it back to a string in the loop.
Any Workarounds:
None found.
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 4194160
External Customer Info:
External Company:
External Customer Name: John Whish
External Customer Email:
External Test Config: My Hardware and Environment details:
Attachments:
Comments: