我想从返回的数据中获取每一个数据name
,logo
但我做不到。问题可能是 JSON 的值来自数据库并且也被转义。
如何从下面发布的数据中获取每个name
数据logo
?
代码:
$.getJSON('/sms/fetch_smartpages/', function (data) {
var items = [];
$.each(data, function (key, val) {
$('#linkHolder').append('<p>' + val + '</p>');
items.push('<li id="' + key + '">' + val.fields.JASON.NAME + '</li>');
});
});
这是返回的数据:
[
{
"pk": 11,
"model": "content",
"fields": {
"logo": "",
"json": "{\"name\":\"sas\",\"logo\":\"\",\"theme\":\"a\",\"pages\":[{\"id\":\"1366993986180\",\"name\":\"Page Name\",\"type\":\"basic\",\"components\":{\"img\":\"\",\"text\":\"\"}}]}",
"link": null,
"name": "sas",
"user": 2
}
},
{
"pk": 18,
"model": "content",
"fields": {
"logo": "",
"json": "{\"name\":\"test123456789\",\"logo\":\"\",\"theme\":\"e\",\"pages\":[{\"id\":\"1366994946585\",\"name\":\"Page Name\",\"type\":\"basic\",\"components\":{\"img\":\"\",\"text\":\"\"}}]}",
"link": 18,
"name": "test123456789",
"user": 2
}
}
]