我将json加载到我的模型中但它只识别父模型类而不识别子模型。
这是json:
{
"Feedback": {
"id": 101,
"title": "asdsadsa",
"description": "sadasds",
"comments": [
{
"id": 43,
"feedbackFk": 101,
"comment": "Hi John , we are glad to receive feedback from you :) \\nOne of our technicians will reach back to you shortly.",
"commentDate": 1431488907881,
"owner": {
"id": 4,
"firstName": "Arnold",
"lastName": "Smoth",
"type": "3",
"email": "fzegarra@XXXX.com"
},
"responses": null,
"likes": null
}
],
"attachments": null,
"createdDate": 1431488906273,
"lastUpdateDate": 1431488906273,
"status": "OPEN",
"source": "ETMS",
"user": {
"id": 6,
"firstName": "John ",
"lastName": "Travolta",
"type": "1",
"email": "john.travolta@XXXXX.com"
}
}
}
这是父代码:
Ext.define('FBT.model.data.Feedback', {
extend: 'FBT.model.data.MappedModel',
fields: [ {
name: 'id',
type: 'auto'
}, {
name: 'title',
type: 'string'
}, {
name: 'description',
type: 'string'
}, {
name: 'createdDate',
type: 'date',
dateFormat: 'time'
}, {
name: 'lastUpdateDate',
type: 'date',
dateFormat: 'time'
}, {
name: 'status',
type: 'string'
}, {
name: 'source',
type: 'string'
} ],
belongsTo: [ {
name: 'reporter',
associationKey: 'user',
model: 'FBT.model.data.User'
} ],
hasMany: [ {
model: 'FBT.model.data.Comment',
name: 'comments',
associationKey: 'comments',
foreignKey: 'feedbackFk'
}, {
model: 'FBT.model.data.Attachment',
name: 'attachments',
associationKey: 'attachments'
} ],
getModelName: function() {
return 'Feedback';
}
});
这是其中一个孩子
Ext.define('FBT.model.data.Comment', {
extend: 'FBT.model.data.MappedModel',
fields: [ {
name: 'id',
type: 'auto'
}, {
name: 'feedbackFk',
type: 'int'
}, {
name: 'comment',
type: 'string'
}, {
name: 'commentDate',
type: 'date',
dateFormat: 'time'
} ],
belongsTo: [ 'Feedback', 'User' ],
hasMany: [ {
model: 'FBT.model.data.Comment',
name: 'responses',
associationKey: 'responses',
}, {
model: 'FBT.model.data.User',
name: 'likes'
} ]
});
但是当我解析它时,注释不会被识别为模型