通过jQuery访问JSON数据

时间:2016-09-17 14:50:26

标签: jquery

通过变量data返回以下内容。

{"success":0,"errors":[],"field_errors":{"title":"This field is required.","url_title":"This field is required.","field_id_9":"This field is required.","field_id_229":"This field is required.","testimonial_import_id":"This field is required.","testimonial_display":"This field is required."},"entry_id":null,"url_title":null,"channel_id":"4"}

我无法访问单个项目。

我试过了:

data.success
data[0]
data[0].success

有人能指出我在正确的方向吗?

1 个答案:

答案 0 :(得分:1)

您需要使用 JSON.parse 方法解析JSON字符串,以将其转换为JavaScript对象。

JSON.parse(data).success