On CanJS.com,it says not to return an array from a JSON service by itself。相反,它應該是這樣的:爲什麼我應該在can.Model的`data`字段下放置JSON服務器響應?
{
"data": [
{"id":1, "description":"Do the dishes."},
{"id":2, "description":"Mow the lawn."},
{"id":3, "description":"Finish the laundry."}
]
}
爲什麼這是必要的,而且它僅適用於數組或它適用於所有對象?例如,單個對象響應應該是這樣嗎?
{
data: {"id": 5, "createdAt": 2234234329}
}
或者,如果只有一個數據項,是data
場不再有必要嗎?例如:
{
"id": 5, "createdAt": 2234234329
}