Skip to main content
Participant
July 28, 2014
Answered

Case preservation for struct keys not working

  • July 28, 2014
  • 1 reply
  • 3830 views

ColdFusion 11 offers a new feature to preserve the case of struct keys during JSON serialization. Trouble is it does not work for me (OSX 10.9.4).

The documentation mentions 2 ways to get this working (although it is supposed to be on by default).

  1. In application.cfc, set this.serialization.preservecaseforstructkey = true
  2. In the ColdFusion administrator settings page, check 'Preserve case for Struct keys for Serialization'

Neither of these work. Stopping and Starting ColdFusion does not help.

No matter what, I always get the keys converted to UPPERCASE, just like in CF10 and earlier.

This would be a great feature to have working. Is it a bug? Has anyone else got it working?

Andrew Culver

This topic has been closed for replies.
Correct answer Michael Elias Paul

Was the cache cleared? Can you try providing true in quotes ("true")


I found the problem.

I had an extra line that I guess was causing an error sometimes so something anyway I removed that line of code from the application.cfc and its working perfectly now.

That line was before THIS.serialization.preserveCaseForQueryColumn= true so I think it was bombing before it got to that line what is weird is that it sometimes worked.

1 reply

Participating Frequently
May 22, 2018

I have the same issue but for me sometimes it is converted to upper case and sometimes not.

so my code sometimes works and sometimes doesn't.

Participating Frequently
May 23, 2018

Hi Michael.

Could you post the snippet that works intermittently for you?

There have been issues reported with the flag in the past, but with the latest updates applied, you should not be seeing an issue.

Participating Frequently
May 23, 2018

My CFC:

component {

    remote function getEmployeeList( ) returnFormat="JSON"{

        var queryObj1 = new query(datasource="MyDataSource");

        var Obj1Result = queryObj1.execute(

            sql="SELECT   id, firstName, lastName, gender, isActive, address1, address2

                FROM Employee

                ORDER BY firstName ASC");

        var Obj1QueryResult = Obj1Result.getResult();

        var theJSON = {};

        theJSON = SerializeJSON(Obj1QueryResult,'struct');

        return theJSON;

    }

}

And in the Application.cfc I added these tags and also I enabled it in the cold fusion administrator :

<cfset THIS.serialization.preserveCaseForStructKey = true />

<cfset THIS.serialization.preserveCaseForQueryColumn= true />

I am running cold fusion 2016 with the latest update.