Parsing json using model - Sencha -
i trying parse json having problem create model how can create effiecient model json below can access def-id doing record.get('def_id'):
i creating model as:
ext.define('myapp.model.todaysword', { extend: 'ext.data.model', requires: ['myapp.model.todayswordmenu'], config: { fields: [ {name: 'status', mapping: 'status'}, {name: 'message', mapping: 'message'}, {name:'data', mapping: 'data'}, {name: 'definitions', mapping: 'definitions.defintion'}, {name: 'ratings', mapping: 'definitions.rating'}, ], } }); ext.define('myapp.model.todayswordmenu', { extend: 'ext.data.model', config: { fields: [ 'name', 'author', 'word_id', 'category', 'definitions', 'rating', 'def_id', 'example', 'author', 'is_favourite' ], belongsto: "myapp.model.todaysword" } });
i getting response above model incorrect , having hard time solve it.
my json:
({ "accountinfo":{ "expire_date":"2014-07-24 22:44:14", "subscribe_date":"2013-07-24 22:44:14", "time_remain":" 323 days 22 hours 2 minutes", "status":"not expired" }, "status":"true", "message":"todays word", "data":[ { "name":"paint", "author":"admin", "word_id":"1", "category":"business", "definitions":[ { "rating":"green", "defintion":"to put color in something", "def_id":"1", "example":null, "author":"admin", "is_favourite":"yesstar" }, { "rating":"red", "defintion":"this new definition of word paint.", "def_id":"42", "example":null, "author":"admin", "is_favourite":"nostar" } ] } ] })
any appreciated.
you use ext.json.decode() , pass function responsetext. create needed object.
Comments
Post a Comment