tracker issue : CF-3720137

select a category, or use search below
(searches all categories and all time range)
Title:

JSON deserialisation does not deal with keys which only differ in case

| View in Tracker

Status/Resolution/Reason: Closed/Won't Fix/

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)

Created: 03/09/2014

Components: Language

Versions: 11.0

Failure Type: Data Loss

Found In Build/Fixed In Build: PublicBeta /

Priority/Frequency: Critical / Some users will encounter

Locale/System: English / Platforms All

Vote Count: 2

See code:

// inbound.cfm
json = '{"a":"a","A":"A"}';
cfml = deserializeJSON(json);
writeDump([{json=json},{cfml=cfml}]);

The "a" and "A" keys are two different things, however when CF deserialised this JSON, it simply overwrites one of them. ColdFusion should not simply overwrite data due to its internal limitations: in this case it should raise an exception.

-- 
Adam

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3720137

External Customer Info:
External Company:  
External Customer Name: Adam Cameron.
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

Since ColdFusion is case-insensitive, it will hard to accommodate this change. It would require a major revamp.
Comment by Vamseekrishna N.
13101 | March 21, 2014 03:20:30 AM GMT
Precisely. Hence "in this case it should raise an exception." I'm not suggesting making CF case-sensitive, I'm suggesting that you don't silently lose data. -- Adam
Comment by External U.
13102 | March 21, 2014 03:30:20 AM GMT
+1 - How about something like DeserializeJSON(JSONVar[, strictMapping[, useCustomSerializer[, allowSameNamedKeys]]])? allowSameNamedKeys would default to true for backward-compat. If false, then an exception is thrown if multiple keys have the same name.
Vote by External U.
13104 | February 11, 2016 11:28:50 AM GMT
Regarding the comment in my vote, here's another idea: THIS.deserialization.allowSameNamedKeys = true|false; (default true, otherwise error thrown if multiple keys have same name) Thanks!, -Aaron
Comment by External U.
13103 | February 11, 2016 11:33:00 AM GMT