Backbone.js model.toJSON()

The Backbone.js toJSON model returns copy of the attributes as an object for JSON stringification.

Syntax:

Parameter explanation:

options: : It defines parameters such as variable name and id used for a model when returning shallow copy of model's attributes.

Let's take an example.

See this example:

Test it Now

Output:

Save the above code in tojson.html file and open this file in a new browser.

BackboneJS tojson Model