Can I not ignore nested properties when using toJS in KnockoutJS' mapping plugin?
Example:
var obj = {
"akey": {
"anestedkey": "ignore",
"anotherkey": "value"
}
};
console.log(ko.mapping.toJS(obj, {
"ignore": ["akey.anestedkey"],
}));
Expected output is
{
akey: {
anotherkey: "value"
}
}
Actual output is
{
akey: {
anestedkey: "ignore"
anotherkey: "value"
}
}
JSFiddle: http://jsfiddle.net/48KVU/
It works if you remove the parent (if you know your key is unique in obj or if you want to remove all occurences):
var obj = {
"akey": {
"anestedkey": "ignore",
"anotherkey": "value"
}
};
console.log(ko.mapping.toJS(obj, {
"ignore": ["anestedkey"], //here
}));