I really searched, and I did not find a decent example of using a serializer to get objects from a formatted JSON response. My reason for not changing the format of the JSON response is here http://flask.pocoo.org/docs/security/#json-security .
I am not very good at javascript, so it was hard for me to understand the hooks in serialize_json.js or maybe I should use matching (I just don't know). So, here is an example of my JSON response for many objects:
{ "total_pages": 1, "objects": [ { "is_completed": true, "id": 1, "title": "I need to eat" }, { "is_completed": false, "id": 2, "title": "Hey does this work" }, { "is_completed": false, "id": 3, "title": "Go to sleep" }, ], "num_results": 3, "page": 1 }
When ember-data tries to use this, I get the following error:
DEBUG: ------------------------------- DEBUG: Ember.VERSION : 1.0.0-rc.1 DEBUG: Handlebars.VERSION : 1.0.0-rc.3 DEBUG: jQuery.VERSION : 1.9.1 DEBUG: ------------------------------- Uncaught Error: assertion failed: Your server returned a hash with the key total_pages but you have no mapping for it
Which completely does when you look at my data warehouse code:
Todos.Store = DS.Store.extend({ revision: 12, adapter: DS.RESTAdapter.create({ mappings: {objects: "Todos.Todo"}, namespace: 'api' }) });
My question is: how do I work with total_pages , num_results and page ? And for the deal, I mean ignore it, so I can just map the array of objects .