Ember.js REST适配器期望JSON返回为:
{
"person": {
"first_name": "Barack",
"last_name": "Obama",
"is_person_of_the_year": true
}
}
Run Code Online (Sandbox Code Playgroud)
但我的API返回没有根元素的数据:
{
"first_name": "Barack",
"last_name": "Obama",
"is_person_of_the_year": true
}
Run Code Online (Sandbox Code Playgroud)
是否可以自定义REST适配器以使其接受我的JSON数据?现在它显示" 断言失败:你的服务器返回一个带有键0的哈希,但你没有映射它 "
更新: 基于Sherwin Yu的回答,这是我想出的,似乎到目前为止工作:https://gist.github.com/richardkall/5910875