in our JS that consumes JSON responses, we've reli...
# adobe
m
in our JS that consumes JSON responses, we've relied on all keys being upper-cased. For some reason, even though CF identifiers are case-insensitive and, in the past if you wanted case sensitive keys in structs you had to do something like
a["b"]
, the implicitly created
b
struct is now being created w/ a case-sensitive key instead. 🤷
b
@mithlond I'm not quite clear what your question is here. Are you saying that the behavior changed between versions? There is a setting now in the CF admin to change how struct keys are serialized. If you're seeing a change in behavior, you may have changed that setting
As you an see here, struct keys are still upper case by default in 2021 https://trycf.com/gist/91e9dcafb753a0c681108fe7fb2b984a/acf2021?theme=monokai
m
with that cf admin setting unchecked in both 2018 and 2021, the bug shows up only in 2018. It's only an implicitly created struct that has the issue; keys in the final struct off the end turn out upper-case as expected. That is,
Copy code
a = {}
a.b = 1
writedump(serializeJSON(a))
works just fine. But if you do
Copy code
a = {}
a.b.c = 1
writedump(serializeJSON(a))
you can see that
b
is lower-case, while
C
correctly gets upper-cased. It's the
b
that broke our code 🙁
b
Yep, I see what you're saying now. That's a tricky find
m
yeah - it took a few minutes of head-scratching to see why it was off the rails in our app