ok, so i say screw it, and add this to app.cfc: t...
# adobe
r
ok, so i say screw it, and add this to app.cfc: this.serialization = { preserveCaseForStructKey: true }; And... it works in a CFM, not in a CFC. Any reason why it would do that?
s
docs (https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-s/serializejson.html) say "*Note:* Key preservation do not work on keys in application, session, or request scopes."
r
nope, i mean a regular cfc
in a method ive got: var something = {};
s
ah.. you said app.cfc and I assumed you were abbreviating application.cfc and then maybe doing something in one of those scopes
r
no, i meant, i set the setting there. although from the docs, i think its supposed to default to preserving case
s
all I know is that when case matters anywhere I always set my struct keys like {'myKey' = 'somevalue'}
r
yeah, i guess ill have to
r
My test indicates otherwise Scott. They will be uppercase for anything CF creates for those scope but anything you put in those scope will keep their casing.
🤯 1
s
I have never trusted CF to preserve the case of struct keys any other way
r
i wonder if the CFC is caching somehow. trusted cache is off
r
FYI, I have Enabled Per Application Settings and Preserve case for stuct key Serialization checked in my admin and this.serialization.preserveCaseForStructKey = true set in Application.cfc for good measure.
r
same
r
Is Save class files unchecked in the Admin?
s
maybe try clearing the template cache? is that still a thing? I haven't actually had to do that in many moons
looks like the button is still there
r
ive already modified the CFC to use quotes 😉
s
and there's a clear component cahce button too
r
When all else fails, smacking CF upside the head works.
s
yes, there's always the old turn it off and on again trick
r
That's when using CommandBox is great. Just
server forget
and then
server start
.
👍 1
s
Quotes is always reliable for preserving the case of struct keys... I've literally never even tried the preserveCaseForStructKey setting
would be nice to know that would actually work though
r
I've never had an issue with using the preserveCaseForStructKey setting. Well, except when testing CF 2023.
🤣 1
I also use the preseverCaseForQueryColumns without issue since we have a large database that's case sensitive (ugh).
What version of CF are you using Ray?
r
2023
r
Uh, that has a known bug with ignoring the perserveCaseForStruct in Applicaiton.cfc.
r
to be clear 🙂 im seeing it in a cfc, not app.cfc
i mentioned app.cfc to say that i added the setting there
then in a CFC i was building, i noticed it wasnt working
r
It also affects local and possibly other scopes. https://tracker.adobe.com/#/view/CF-4218099
r
oh well shit
happy to know its known
r
Sorry. I saw 2021 in the Ben Nadel link you posted and my brain was stuck on that.
r
no, i appreciate it
and now i get to write a quick CF blog post. first since... wow i wrote one in april1??!? https://www.raymondcamden.com/categories/coldfusion
👍 1
s
I've written like 2 blog posts since 2008
😉