Reputation: 1340
Given a JSON object such as:
{
"@abc.def":"foo"
}
How do you address a property named like that?
e.g. this doesn't work
var x = [email protected]
Upvotes: 1
Views: 237
Reputation: 2302
As @abc.def
is not a valid JavaScript identifier, accessing a property with this name must use bracket notation.
The working code would be:
var x = obj['@abc.def']
Upvotes: 3
Reputation: 50550
You can use: var x = obj["@abc.def"]
.
Of course, I suppose that obj
is defined as: var obj = { "@abc.def":"foo" }
.
Upvotes: 0