我正在與Ext JS & Rails作爲後端..我有myysql數據庫有父子關係,即一對多的關係......我想要一個「單一」JSON存儲可以用來加載「GRID」數據與家長&子記錄。 也有任何方式綁定兩個 - 表單以及網格到同一商店,但有不同的jsonreaders?即表單的數據讀取器將讀取字符串root:'customers'並且網格將讀取字符串root:'products'? 的JSON看起來是這樣的:extjs nested json store rails
{
"customers": [{
"amt": 8000,
"custnm": "rashmi",
"id": 2,
"purdt": "2011-04-27",
"products": [{
"amt": 40,
"customer_id": 2,
"id": 3,
"prodnm": "oil",
"qty": 1,
"rate": 40
}]
}, {
"amt": 300000,
"custnm": "bhumika",
"id": 3,
"purdt": "2011-04-14",
"products": [{
"amt": 40,
"customer_id": 3,
"id": 1,
"prodnm": "soap",
"qty": 20000,
"rate": 20
}, {
"amt": 150,
"customer_id": 3,
"id": 2,
"prodnm": "shampoo",
"qty": 3000,
"rate": 50
}, {
"amt": null,
"customer_id": 3,
"id": 14,
"prodnm": "aa",
"qty": 2,
"rate": null
}]
}, {
"amt": 15000,
"custnm": "Shruti",
"id": 13,
"purdt": "2011-04-08",
"products": []
}, {
"amt": 200000,
"custnm": "Jayesh",
"id": 14,
"purdt": "2011-03-31",
"products": []
}, {
"amt": 220000,
"custnm": "SHRUTI",
"id": 15,
"purdt": "2011-04-06",
"products": []
}, {
"amt": 10000,
"custnm": "RASHMI",
"id": 24,
"purdt": "2011-04-06",
"products": []
}],
"results": 6
}
如果您嘗試顯示json,請使其可讀。這裏試試這個:http://jsbeautifier.org/。在你的json中,你忘了添加最後一個「}」 – 2011-04-21 07:10:33