I am new with loash and need help on this.
i have 2 objects:
{
"data": [
{
"RHID": "2",
"NOME": "Leonor",
},
{
"RHID": "3",
"NOME": "José",
}
]
}
and
{
"data": [
{
"RHID": "2",
"NOME": "Leonor maria",
},
{
"RHID": "3",
"NOME": "José Leo",
}
]
}
How can i replace inner objects with same RHID if they are diferent. Keep the second. I remove duplicates with
Form.myData[Form.arrData] = _.map(
_.uniq(
_.map(Form.myData[Form.arrData], function (obj) {
return JSON.stringify(obj);
})
), function (obj) {
return JSON.parse(obj);
}
);
i want to replace if diferent. Thanks a lot .
solved with merge the oposite way
$.merge( newData[Form.arrData],Form.myData[Form.arrData]);
instead of
$.merge( Form.myData[Form.arrData],newData[Form.arrData]);
and then
Form.myData[Form.arrData] = _.map(
_.uniq(
_.map( newData[Form.arrData], function (obj) {
return JSON.stringify(obj);
})
), function (obj) {
return JSON.parse(obj);
}
);
instead of
Form.myData[Form.arrData] = _.map(
_.uniq(
_.map(Form.myData[Form.arrData], function (obj) {
return JSON.stringify(obj);
})
), function (obj) {
return JSON.parse(obj);
}
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.