Closed RobinsonSir closed 6 years ago
Hello :)
Could you please provide more details?
@RobinsonSir 请您说清楚一点,您的问题是什么?
Nobody.......
@RobinsonSir please help us help you:
I assume you're using this with Angular. You see Angular adds these props to the object for internal diffing. JSON-Patch itself isn't resposible for these.
I can think of two choices, either use Angular's toJson
to get your JSON instead of JSON.stringify. More details on this here.
Another solution is to filter patches and remove Angular-added props. Like this:
const patches = [{
"op": "add",
"path": "/dtTypeEpTypes/1/$$hashKey",
"value": "object:231"
}, {
"op": "add",
"path": "/dtTypeEpTypes/0/$$hashKey",
"value": "object:230"
}, {
"op": "add",
"path": "/dtTypeEpTypes/2",
"value": {
"epTypeID": 1,
"channelNo": 2
}
}]
const filterdPatches = patches.filter(p => !p.path.includes('$$hashKey'));
console.log(filterdPatches);
// filterdPatches
[{"op":"add","path":"/dtTypeEpTypes/2","value":{"epTypeID":1,"channelNo":2}}]
But I personally prefer the first one.
Yes, you are right. I use Angularjs ng-repeat with jsonObj. Now, i remove $$hashkey by myself. Another solution i will try, thanks very much.
Great. Closing as answered :)
I use jsonpatch observer to watch the above
jsonObj
, then i add one obj tojsonObj.dtTypeEpTypes
,jsonObj
like thisThen I use jsonPatch generate function, get patch operation array below:
As u can see, it contains $$hashKey, i don't know why contains that