我有我的JSON值从Java来解析JSON字符串,如需要使用JavaScript
var obj = "[{"id":"58","str":"sd <p/> Comment By Smith John on 2012-10-30"},{"id":"58","str":"sd <p/> Comment By Smith John on 2012-10-30"},{"id":"58","str":"sd <p/> Comment By Smith John on 2012-10-30"},{"id":"58","str":"sd <p/> Comment By Smith John on 2012-10-30"},{"id":"58","str":"sd <p/> Comment By Smith John on 2012-10-30"},{"id":"58","str":"sd <p/> Comment By Smith John on 2012-10-30"},{"id":"58","str":"sd <p/> Comment By Smith John on 2012-10-30"},{"id":"58","str":"sd <p/> Comment By Smith John on 2012-10-30"}] ".
我想使用jQuery为$ .parseJSON(OBJ)来分析;
我收到错误为未定义。我想获得id值。
我收录了jquery-ui.js和jquery.js。
我检查了jsonlint并将其作为有效的json。含有"
字符
你是如何访问它的ID ...这是一个对象数组,你可以通过你如何试图访问ID。 –
你试过了什么请发表呢? – sunleo
请显示您的JS代码。如果您正在使用jQuery的Ajax函数来检索此对象(如问题中的“jquery-ajax”标记所暗示的那样),那么您不应该使用'$ .parseJSON()',因为jQuery将解析字符串为你,并将所得到的对象(本例中是一个数组)传递给你提供的回调函数。 – nnnnnn