Reputation: 929
I'm new to Backbone.js and working with JSON.
I'm having trouble working with the following JSON: http://pastebin.com/FFEwc0Fb
What I want to achieve is to
Could someone provide sample code of that does the above or point me in the right direction?
Possible Alternative Solutions: I'm also using Rails in my App so I could use try using Rails to turn the JSON into the JSON I want it to be ...
Upvotes: 0
Views: 212
Reputation: 1680
look at the parse method on models and collections. After you make your fetch the response is always passed through a parse function that you define on your model or collection. In there you can go through the object and build up the attributes to be set to the model how you want them. For example:
parse: function(response) {
var attrs = {
title: response.feed.title,
author: response.feed.author
};
return attrs;
}
That's a small example of how you could do it within backbone.
Upvotes: 1