开发者

Jquery JSON parsing with @id:

开发者 https://www.devze.com 2023-01-13 03:00 出处:网络
I have the foll开发者_JAVA百科owing 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 J

I have the foll开发者_JAVA百科owing 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


Try:

json['@id']

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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消