如何从嵌套的JSON密钥获取Backbone数据?

时间:2014-08-07 12:45:25

标签: javascript json backbone.js

我使用Backbone.js库,但我的服务器以格式返回数据:

{
     "status":"OK",
     "message":"",
     "data":{"table":{"id":"4","name":"\u0421\u0442\u043e\u043b 1","tableType":"0","chairNumber":"0","posX":"0","posY":"0","width":"0","height":"0","angle":"0","plan":"0"}}
}

Backbone只预计数据:

{"table":{"id":"4","name":"\u0421\u0442\u043e\u043b 1","tableType":"0","chairNumber":"0","posX":"0","posY":"0","width":"0","height":"0","angle":"0","plan":"0"}}

如何使用嵌套级别data作为主干?

1 个答案:

答案 0 :(得分:3)

parse: function (response, options) {
    return response.data;
}

http://backbonejs.org/#Model-parse