https://github.com/toddself/backbone-nestedjson
https://github.com/toddself/backbone-nestedjson
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/toddself/backbone-nestedjson
- Owner: toddself
- Created: 2013-12-20T18:30:06.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-12-20T19:06:30.000Z (over 12 years ago)
- Last Synced: 2025-03-15T05:11:59.607Z (over 1 year ago)
- Language: JavaScript
- Size: 129 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](http://travis-ci.org/toddself/backbone-nestedjson)
#Backbone-NestedJSON
A simple replacement for `#toJSON` that can handle nested Backbone models.
#Usage
`npm install -S backbone-nestedjson`
```javascript
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'
}
};
```