Presumably you don't know what the key-casing is because you're getting the objects from a 3rd party source, such as an AJAX call or other script resource load. You can interject a normalization method at that point and only have to loop once per object, making it a static overhead cost.
For example, define a method
function normalizeObjectKeys(obj) {
for (key in obj) {
obj[key.toUpperCase()] = foo[key];
delete obj[key];
}
}
Calling it like this in my Chrome javascript console seems to prove it works.
> var foo = { bar: "bar", baZ: "baZ" }
undefined
> foo
Object {bar: "bar", baZ: "baZ"}
> normalizeObjectKeys(foo)
undefined
> foo
Object {BAR: "bar", BAZ: "baZ"}
Then you always check for the uppercase version of the key. It's not pretty, and will collide if there are different cases of the same key (e.g. foo = {bar : "bar", Bar : "baz" }
could wind up with either value of BAR
), but it might suit your purposes. If you really need to know, you could check whether obj[key.toUpperCase] == undefined
before setting the value and log an error or throw an exception.