我正在尝试将 [backbone deep model] ( https://github.com/powmedia/backbone-deep-model ) 用于具有嵌套属性的 Person 模型。github 中的示例代码显示设置嵌套属性,如名称
model.set({
'user.name.first': 'Lana',
'user.name.last': 'Kang'
});
但是如何设置模型属性 otherSpies.name[0]:'Lana' ?
我的人模型的 JSON 格式如下所示。
{
"birthdate": "2005-10-26T00:00:00.000+0530",
"gender": "M",
"attributes": [
{
"value": "saagar.gugwad@gmail.com",
"attributeType": "8d6d7f78-9b9e-409a-96dc-ea8300e54175"
},
{
"value": "single",
"attributeType": "6b550dd7-ce73-4f14-af2d-35d1a37e7377"
},
{
"value": "7829730769",
"attributeType": "d1266776-7431-4fa4-9724-215c21418efb"
},
{
"value": "0",
"attributeType": "892089d1-f187-404b-89c3-96606194a05c"
},
{
"value": "AAAAAACAGwEtAAHMpTgHAAAAAElFTkSuQmCC\n",
"attributeType": "d5ac7b1d-a563-4661-9d9d-0ad6b8e346e8"
}
],
"addresses": [
{
"address1":"bla",
"address2":"bla2",
"street" :"walstreet",
"pincode" :"222FB"
}
],
"names": [
{
"familyName": "Dbh",
"givenName": "Saagar"
}
],
"age": 8
}
我想使用我的 personModel 设置属性。我怎样才能做到这一点?