我正在尝试查看一个对象,但基于结构我不知道如何获取数据。在javascript中循环浏览json对象
对象:
{
"177":{
"text":"test text",
"user_name":"Admin",
"date":"1385494358",
"docs":{
"document_name": [
"marketing_service",
"maintenance_service",
"development_service"],
"document_type":[
"png",
"png",
"png"]
}
},
"174":{
"text":"Some more images",
"user_name":"Admin",
"date":"1385493618",
"docs":{
"document_name": [
"marketing_service16",
"maintenance_service53"],
"document_type":[
"png","png"]
}
}
}
循环,我试图在jQuery的
var obj = $.parseJSON(data);
$(obj).each(function(index, note) {
console.log(note.text + note.user_name + note.date_created);
});
它返回undefined。我究竟做错了什么?
什么是'data'是一个字符串? – qwertynl
'obj [index] .text'? – Krishna
数据是上述代码中显示的对象 – steeped