title: How to build a Collection/Model from nested JSON with Backbone.js
body: <p>I'm relativly new to Backbone.js</p>
  
  <p>I have a <strong>JSON</strong> like the picture shows ! 
  I saw some Answers in relation with Backbone-relational, but still dont get the point!</p>
  
  <p>How can i convert this <strong>JSON</strong> to Backbone.js Collections/Models?? </p>
  
  <p>I update with a code but it dont work like expected! i can't see an model when i do :</p>
  
  <p>My Structure is :</p>
  
  <p>[0] : is a collection of models</p>
  
  <p>[clefs] + ... + [Rest] : are collection of models</p>
  
  <p>(clefs) => [0] + ... + [9] : are Models(title contains a string, path too)</p>
  
  <p>Thanks a lot!!</p>
  
  <p><strong>EDIT(10.01.12) :</strong></p>
  
  <p><strong>My Solution :</strong></p>
  
  <pre><code>window.initModel = Backbone.Model.extend({
    defaults: {
      "title": "",
      "path": ""
    }
  });
  window.CustomCollection = Backbone.Collection.extend({
    model: initModel
  });
  window.Init = Backbone.Model.extend({
    url : function(){
      return  "/api/data.json"      
    },
  
    parse: function(response) {
  
      clefs = new CustomCollection();
      clefs.add(response.clefs);        
      this.set({clefs: clefs});
  
      .....
  
      rests = new CustomCollection();
      rests.add(response.rests);        
      this.set({rests: rests});
  } 
  });
  </code></pre>
  
  <p><a href="http://www.deploymentzone.com/2011/08/10/backbone-js-collections-of-models-within-models/" rel="noreferrer">this</a> helped me out too!</p>
  
  <p><img src="https://i.stack.imgur.com/nLDNF.png" alt="Nested Array"></p>