backbone-nestedjson
v0.1.1
Published
A toJSON replacement that handles nested objects
Downloads
3
Readme
#Backbone-NestedJSON
A simple replacement for #toJSON
that can handle nested Backbone models.
#Usage
npm install -S backbone-nestedtojson
var Backbone = require('backbone');
var toJSON = require('backboned-nestedjson');
var TestModel = Backbone.Model.extend();
TestModel.prototype.toJSON = toJSON;
var tm = new TestModel();
tm.set({
foo: 'bar',
boo: ['a','b'],
baz: new TestModel({back: 'front'}),
test: {
hello: 'goodbye'
}
});
tm.toJSON()
{
foo: 'bar',
boo: ['a','b'],
baz: {
back: 'front'
},
test: {
hello: 'goodbye'
}
};