ember.js - I have a json response and my Ember model is not matching for it -
my json response
{ "object": { "assignments": [ { "assignmentid": 14706368, "sectionid": 0, "assignmenttype": "fileattach", "assignmenttitle": "file attachment a", "assignmentstartdate": "01/01/1900", "assignmentstarttime": "01:00am", "assignmentduedate": "01/01/2100", "assignmentduetime": "01:00am", "ismarathonchain": "no", "assignmenttimelimit": 0, "assignmenttimeremaining": "0", "marathonassignmentstatus": "marathon_not_associated", "showassignmentattemptsandpassworddetails": false, "assignmentattemptstaken": 0, "assignmentattemptsallowed": "1", "showpasswordform": false, "isstartassignment": true, "isresumeassignment": false, "issubmitassignment": false, "passwordrequired": false, "isconverttogeniusenabled": false, "draftnumber": 0, "studentexceptionexistsforduedate": false, "ispastuploaddate": false, "showmarathonprerequisiteinfo": false } ], "sections": [ { "sectionid": 241409387, "courseid": 241409386, "sectionname": "section01" } ], "courses": [ { "courseid": 241409386, "coursename": "tricon.connect_01", "showdiscipline": false } ], "users": [ { "userid": 1000321061, "firstname": "ragu �������&^&", "lastname": "+#@)()xyz �^^������", "usertype": "s" } ], "returnlms": [ { "returnurl": "bb" } ] } } data model var attr = ds.attr; app.about = ds.model.extend({ object: ds.hasmany('object') }); app.object = ds.model.extend({ assignments: ds.hasmany('assignments'), sections: ds.hasmany('sections'), courses: ds.hasmany('courses'), users: ds.hasmany('users'), returnlms: ds.hasmany('returnlms') }); app.assignments = ds.model.extend({ assignmentid: attr('number'), sectionid:attr('number'), assignmenttype:attr('string'), assignmenttitle:attr('string'), assignmentstartdate:attr('string'), assignmentstarttime:attr('string'), assignmentduedate:attr('string'), assignmentduetime:attr('string'), ismarathonchain:attr('boolean'), assignmenttimelimit:attr('number'), assignmenttimeremaining:attr('number'), marathonassignmentstatus:attr('string'), showassignmentattemptsandpassworddetails:attr('boolean'), assignmentattemptstaken:attr('number'), assignmentattemptsallowed:attr('number'), showpasswordform:attr('boolean'), isstartassignment:attr('boolean'), isresumeassignment:attr('boolean'), issubmitassignment:attr('boolean'), passwordrequired:attr('boolean'), isconverttogeniusenabled:attr('boolean'), draftnumber:attr('number'), studentexceptionexistsforduedate:attr('boolean'), ispastuploaddate:attr('boolean'), showmarathonprerequisiteinfo:attr('boolean') }); app.sections = ds.model.extend({ sectionid: attr('number'), courseid: attr('number'), sectionname: attr('string') }); app.courses = ds.model.extend({ courseid: attr('number'), coursename: attr('string'), showdiscipline: attr('boolean') }); app.users = ds.model.extend({ userid: attr('number'), firstname: attr('string'), lastname: attr('string'), usertype:attr('string') }); app.returnlms = ds.model.extend({ returnurl: attr('string') });
in app.about route name have created object inside , rest of follows. no getting response restadapter somehow not matching model format , model object show empty.
take @ json conventions ember data expecting.
you can input models neat tool called ember-data-model-maker, , see server responses should be.
if don't have control on server responses, you'll need extend ds.restadapter
manipulate json form ember data expects.
Comments
Post a Comment