backbone-nestedjson

0.1.1 • Public • Published

build status

Backbone-NestedJSON

A simple replacement for #toJSON that can handle nested Backbone models.

Usage

npm install -S backbone-nestedjson

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

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i backbone-nestedjson

    Weekly Downloads

    7

    Version

    0.1.1

    License

    MIT

    Last publish

    Collaborators

    • toddself