Error while displaying json data from server to the front end using ebmer framework,


#1

[12:50:44.045] Error: assertion failed: Your server returned a hash with the key 0 but you have no mapping for it @ http://10.102.113.48:8080/Ember/assets/js/ember-1.0.0-master.js:52 Error: assertion failed: Your server returned a hash with the key 0 but you have no mapping for it


#2

It’s a bit hard to help out without posting some sort of code sample (preferably in a jsbin).


#3

Would assume your JSON is incorrect - post it?


#4
  1. My json data in below format which i am sending it from server to frontend.

{“hostCarrierCode”:“cccc”,“boardingPoint”:“aaaa”,“hostFlightNumber”:“bbbb”,“offPoint”:“ddddd”}

  1. And i am using the below tag for displaying the data which i am getting in the frontend.

{{hostCarrierCode}} , {{boardingPoint}} , {{hostFlightNumber}} , {{offPoint}}


#5

Are you using ember-data, ember-model or a custom adapter?


#7

i am using

DS.RESTAdapter.extend for getting the data from the server. &

App.Employee = DS.Model.extend for mapping the data in the front end.


#8

Ember data needs to match the json returned from your server to a particular model type (this enables sideloading etc). So you need to have a root key for the model type (also, you need to include the id), e.g.

{“employee”: {“id”: “1”,“hostCarrierCode”:“cccc”,“boardingPoint”:“aaaa”,“hostFlightNumber”:“bbbb”,“offPoint”:“ddddd”}}

And if you are returning multiple records then you need to pluralize the key, e.g {“employees”: [{“id”: “1”, “hostCarrierCode”:“cccc”,“boardingPoint”:“aaaa”,“hostFlightNumber”:“bbbb”,“offPoint”:“ddddd”},{“id”: “2”, “hostCarrierCode”:“bbb”,“boardingPoint”:“sss”,“hostFlightNumber”:“bbbb”,“offPoint”:“ddddd”}]}