Reputation: 1101
There is a json data:
var json = {
"entry" : [{
"category" : {
"@scheme" : "http:\/\/www.douban.com\/2007#kind",
"@term" : "http:\/\/www.douban.com\/2007#movie"
},
"title" : {
"$t" : "Real Steel"
},
"db:attribute" : [{
"$t" : "USA",
"@name" : "country"
}]
}]
}
alert(json.entry[0].title.$t)
can print "Real Steel". However,
how to get the http:\/\/www.douban.com\/2007#kind
and USA
in Javascript ?
It contains @
and :
, I don't know how to cope with it.
Upvotes: 1
Views: 126
Reputation: 78650
If I'm understanding you correctly, you can do the following:
json.entry[0].category["@scheme"]
Upvotes: 1
Reputation:
Use square brackets and a string instead of .
json.entry[0].category["@scheme"]
json.entry[0].category["@term"]
json.entry[0]["db:attribute"][0].$t
json.entry[0]["db:attribute"][0]["@name"]
Upvotes: 6