Backbone.JS Parse()

The Backbone.JS Parse() model is used to get the model’s data (in the JSON format) by passing through the response object.

Syntax:

Model.Parse (response, options)   

Parameters:
response: This parameter is passed using response raw object in order to get the attributes to be set on the model.
options: This parameter is used to specify the options like id, name etc. for a model.

Example:

<!DOCTYPE html>  
<html>  
<head>  
<title>Example</title>  
<script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>  
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js" 
type="text/javascript"></script>  
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js" 
type="text/javascript"></script>  
</head>  
<body>  
<script type="text/javascript">  
var X ={  
"Messages": {  
"msg1": "Hello",  
"msg2": "Hi",  
"msg3": "Hey"  
}  };  
var Y  = Backbone.Model.extend({  
parse : function(response, options){  
document.write(JSON.stringify(response));  
}  });  
var Z = new Y(X, {parse: true});  
</script>  
</body>  
</html>

Output:

{"Messages":{"msg1":"Hello","msg2":"Hi","msg3":"Hey"}}

Explanation:
In the above example, the output is the model’s data in the JSON format.

Please Share