从API获取Backbone.js集合时,Backbone需要一个JSON数组:
[
{
id: 1,
name: "whatever"
},
{
id: 2,
name: "another"
}
]
我想这是一个安全风险,请参阅:JSON security best practices?
我想让Backbone理解以下格式:
{
things: [
{
id: 1,
name: "whatever"
},
{
id: 2,
name: "another"
}
]
}
我有一个简单的方法吗?
答案 0 :(得分:0)
var Library = Backbone.Collection.extend({
parse: function(response) { // This is called after the `fetch()` got its data
return response.things;
}
});
但是我没有看到使用简单数组的任何安全威胁..