【发布时间】:2014-01-09 16:15:18
【问题描述】:
我正在 Django 框架上开发一个站点,它返回一个 json 响应以用于 jquery 数据表。 Datatable 要求输入是 javascript 对象或数组,因此我需要在服务器端或客户端将其转换为 javascript 对象或数组。
这是数据表的相关文档。
DataTables AJAX source example DataTables AJAX source example - array of objects as a data source
[
{
"pk": 7,
"model": "softwareapp.software",
"fields": {
"city": "miami",
"submitted_by": [],
"description": "test",
"title": "test",
"zipcode": "test",
"rating_votes": 0,
"state": "fl",
"address": "test",
"rating_score": 0,
"business_size": [
5
],
"slug": "test",
"developer": "test"
}
},
{
"pk": 8,
"model": "softwareapp.software",
"fields": {
"city": "",
"submitted_by": [],
"description": "",
"title": "test2",
"zipcode": "",
"rating_votes": 0,
"state": "",
"address": "",
"rating_score": 0,
"business_size": [
5
],
"slug": "test2",
"developer": ""
}
},
{
"pk": 10,
"model": "softwareapp.software",
"fields": {
"city": "",
"submitted_by": [],
"description": "",
"title": "test3",
"zipcode": "",
"rating_votes": 0,
"state": "",
"address": "",
"rating_score": 0,
"business_size": [
6
],
"slug": "test3",
"developer": ""
}
}
]
【问题讨论】:
-
Google "Json to Javascript object" 点击第一个链接。
标签: javascript django json jquery-datatables