0
我使用RESTAdapter和RESTSerializer來解析帶有關係的json負載(sideloaded)。對於DS.RESTAdapter狀態的文檔,該側載相關數據應該自己類型的鍵下被退回,如Ember RESTSerializer,關係不像預期的那樣
{
"posts": {
"id": 5,
"title": "I'm Running to Reform the W3C's Tag",
"author": "Yehuda Katz",
"comments": [1, 2]
},
"comments": [{
"id": 1,
"author": "User 1",
"message": "First!",
}, {
"id": 2,
"author": "User 2",
"message": "Good Luck!",
}]
}
當使用我自己的有效載荷,除非我添加一個類型字段,以每一個相關項目,我得到解析錯誤:'無法讀取屬性'替換'未定義'。
這是我的有效載荷:
{
"practice-items": [
{
id: 1,
title: 'Major Scales',
discipline: 1
},
{
id: 2,
title: 'Minor Scales',
total_issues_count: 5,
discipline: 1
}
],
"disciplines": [
{
id: 1,
title: 'Scales',
type: 'discipline'
},
{
id: 2,
title: 'Pieces',
type: 'discipline'
}
]
}
這工作 - 但如果我省略,在每個相關記錄中的「類型」字段。任何想法,爲什麼這是 - 我錯過了明顯的東西?