James moore
James moore

Reputation: 1255

Jquery JSON parsing with @id:

I have the following JSON:

{
    "@id": "hey there",
    "id": "hey there 2"
}

I can easily parse "id" with json.id but how can I get the value of "@id" using jquery's inbuilt JSON parser?

As calling "json.@id" is not correct.

Thanks

Upvotes: 2

Views: 1695

Answers (2)

redsquare
redsquare

Reputation: 78667

In addition to above answer, you can use http://jsonlint.com to validate your json

Upvotes: 2

Darin Dimitrov
Darin Dimitrov

Reputation: 1038930

Try:

json['@id']

Also note that the JSON object you've posted is not valid: you are missing a , between the two properties.

Upvotes: 4

Related Questions