tracker issue : CF-3322342

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

serializeJSON not perserving case when using a mix of array notation and dot notation

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Robert Makowski / Robert Makowski (rob.makowski)

Created: 08/31/2012

Components: AJAX, Plumbing

Versions: 10.0

Failure Type: Incorrect w/Workaround

Found In Build/Fixed In Build: Final / 284663

Priority/Frequency: Major / All users will encounter

Locale/System: English / Windows 7

Vote Count: 0

Problem Description:In previous version of Coldfusion, you could preserve the case of struct keys when converting the struct to a JSON.  This functionality doesn't appear to work in CF10.  When you would create the struct keys using array notation, the case of the keys would be preserved once the struct was run through the serializeJSON function.  Please refer to http://www.bennadel.com/blog/2162-Maintaining-Key-Case-During-JSON-Serialization-In-ColdFusion.htm, for an example.

Steps to Reproduce:Try the following code: 
<cfset var response = structnew()>
<cfset response[ "error" ] = 0>
<cfset response[ "message" ] = "">

<cfset response.error = 1>
<cfset response.message = "some text">
<cfset serializedReponse1 = serializeJSON(response)>

<cfdump var="#serializedResponse1#">
<!--- key case not preserved --->

Actual Result:
{"MESSAGE":"There was an error inserting the record...","ERROR":1}

Expected Result:
{"message":"There was an error inserting the record...","error":1}

Any Workarounds:
<cfset response["error"] = 1>
<cfset response.message = "some text">
<cfset serializedReponse2 = serializeJSON(response)>
<cfdump var="#serializedResponse1#">
<!--- key case  preserved --->

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

Watson Bug ID:	3322342

Keywords:
FixTested


External Customer Info:
External Company:  
External Customer Name: rob.makowski
External Customer Email:  
External Test Config: My Hardware and Environment details: coldfusion 10

Attachments:

Comments: