Is there a way or planned to support case sensitive struct keys? Like Adobe introduced with acf2021 using structNew(“casesensitive”)? Unfortunately, struct type “casesensitive” does not (yet) work with lucee…
I’ve just stumbled over a case where I read IDs from an API-call. I fill up the resulting records into a struct using the id from the json-data I got back from the API as key. In that result there are keys like ‘e3b’ and also ‘e3B’. Didn’t work with lucee because ‘e3b’ and ‘e3B’ are treated as the same. Lucee’s setting “Key case” in the admin panel has no impact to this…
Yes, already have a ticket for Case Sensitive structs [LDEV-3133] - Lucee
Looking further, I found a solution that also works in Lucee…
To create a struct that uses case sensitive keys, I use
myStruct = createObject(“java”,“java.util.LinkedHashMap”).init();
After that init command, the commands
myStruct[‘E3b’] = ‘value 1’;
myStruct[‘E3B’] = ‘value 2’;
actually will create TWO keys in the struct.
2 Likes
While LinkedHashMap does provide a mechanism for case-sensitive keys, simple bracket notation like what you used results in case-sensitive keys also. I can do the same with vanilla CF like so:
myStruct[key] = "myValue"
I’ve added a new recipe documenting this
3 Likes
Great job Zac! Easy to read. Easy to follow. Clear and concise. Thank you!