我正在Django框架上開發一個網站,它返回一個使用jQuery數據表的json響應。 Datatable需要輸入爲javascript對象或arrys數組,所以我需要將其在服務器端或客戶端轉換爲javascript對象或數組。Json to 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": ""
}
}
]
谷歌「Json to Javascript對象」點擊第一個鏈接。 – Blender