0

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.urlvalue but i can't access to foo:bar because of the colon in it.

outis
  • 75,655
  • 22
  • 151
  • 221
Danny
  • 682
  • 1
  • 11
  • 21

1 Answers1

2

You could use bracket notation to access that value,

console.log(myJson["foo:bar"]);

And your object is perfectly valid.

Rajaprabhu Aravindasamy
  • 66,513
  • 17
  • 101
  • 130