Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing json keys with special characters in javascript [duplicate]

Tags:

javascript

I have an object which looks like this:

{"response":{"mydata":[{"xxx:id":"8c8b9703-bc87-40d8-b8d7-f71ebff4002a","Description":"Tsameple desc"].....

Now, my question is, How do I access the Id field?

I have tried

$.response.mydata[i].xxx:id

However, this is resulting in an error thanks to the ":" in the key value. Any tips on how I can get the value?

like image 968
Sathya Nagarjun Avatar asked Jul 18 '14 06:07

Sathya Nagarjun


1 Answers

Use the bracket notation :

response.mydata[i]['xxx:id']
like image 161
Denys Séguret Avatar answered Oct 02 '22 18:10

Denys Séguret