I have this JSON:
{
"foo:bar":"value",
"key:id":"1234",
"url":"www.google.com"},
How can I get foo:bar
value in Javascript ?
I can get myJson.url
value but i can't access to foo:bar
because of the colon in it.
I have this JSON:
{
"foo:bar":"value",
"key:id":"1234",
"url":"www.google.com"},
How can I get foo:bar
value in Javascript ?
I can get myJson.url
value but i can't access to foo:bar
because of the colon in it.
You could use bracket notation
to access that value,
console.log(myJson["foo:bar"]);
And your object is perfectly valid.