Shorthand ColdFusion Structs and Reserved Keywords

Today I attempted to create a struct in ColdFusion 8 via shorthand using the syntax:

<cfscript>
struct = {key1=val1,key2=val2};
</cfscript>

My case was creating a state list with abbreviation for keys and the state name as the value. However I have determined that not all key names can be used. If it is a reserved ColdFusion word, it may not work. For example "IN" and "OR".

What I want:

<cfscript>
var strStates = {IN="Indiana",OR="Oregon",UT="Utah"};
</cfscript>

But that leaves me with an "Invalid CFML construct found...".

So as a workaround I did this:

<cfscript>
var strStates = {UT="Utah"};
strStates["IN"] = "Indiana";
strStates["OR"] = "Oregon";
</cfscript>

So much for shorthand. Has anyone found a better solution for this?

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Henry Ho's Gravatar Does this work?

<cfscript>
var strStates = {"IN"="Indiana","OR"="Oregon",UT="Utah"};
</cfscript>
# Posted By Henry Ho | 8/5/09 6:40 PM
Chris's Gravatar @Henry - thanks for your suggestion. I did try this and it still failed.
# Posted By Chris | 8/5/09 6:45 PM
Henry Ho's Gravatar oh, you're right... just tested.
# Posted By Henry Ho | 8/5/09 7:48 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1. Contact Blog Owner