Creating Backbone Model using received JSON data

backbone.js, javascript, json

Solution

MyModel = Backbone.Model.extend({});

var data = { /* some data you got from the ajax call */};

var m = new MyModel(data);

Or if you don't need a specific type of model, you can just use a generic Backbone.Model

var data = { /* some data you got from the ajax call */};

var m = new Backbone.Model(data);

Problem

I know how to create a new backbone model. But how I can create a backbone model with the data which is received from a web service? For example, you are receiving a JSON data from a webservice. I want to use this JSON as backbone model. How I can do that? Thanks.

Original source