Reputation: 14333
I'm working with data via an IBM MQ call where a 0 is returned as +0.0
when this is serialized by ColdFusion 10 (10,0,11,285437) it results in invalid JSON and cannot be deserialized.
stPolicy = { "prem": "+0.0" };
serializedData = serializeJSON(stPolicy);
writeDump(isJSON(serializedData));
writeDump(deserializeJSON(serializedData));
This outputs NO
for isJSON
and an error when trying to deserialize JSON parsing failure at character 9:'+' in {"prem":+0.0}
.
I'm able to work around this by replacing all +0
to 0
, but I'm guessing this is a bug in ColdFusion. Has anyone else had this issue and implemented a better fix?
Bug report filed: Bug #3632972
Upvotes: 14
Views: 1847
Reputation: 14333
Adobe has the bug listed as fixed in their bug database, but it has not yet been released. Here's the fix I came up with. Simply replace the +0
with 0
private string function serializeJSONFixCF10(required string serializedData) {
return replace(arguments.serializedData,'+0','0','all');
}
Upvotes: 1