0.1.1 • Published 10 years ago

backbone-nestedjson v0.1.1

Weekly downloads
2
License
-
Repository
github
Last release
10 years ago

build status

#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'
  }
};