I've typed my structure key in CamelCase and you return in UPPERCASE

2010 June 07
tags: Coding · ColdFusion
by Big Mad Kev

This is something that gets everyone, when you create a new structure key it ends up in UPPERCASE when you try to use it in JSON / AMF OBJECTS etc.

For example you may have a Remote CFC that returns JSON and you set a variable like:

returnStruct.ThisShouldBeCamelCase = 'Value'

when you make the request to the CFC the returned key is returned as:

THISSHOULDBECAMELCASE 

and then breaks in a Case Sensitive Langauge like JavaScript or if you have done this in an AMF call and your returning an CFC Value Object or a Typed Structure.

This is how you force the case to be kept; you type it likes this:

returnStruct['ThisShouldBeCamelCase'] = 'Value'

This will then return your key in the case you want.

| View count: 11520
No Responses leave one →

Leave a Reply