...
# | Issue | Notes | Decision |
---|---|---|---|
1 | Add or Delete leaves (optional leaves) handle as UPDATE or ADD/DELETE ? | The delta report proposed follows the Json Patch format of representing the differences between 2 json. Going by the general convention, referring RFC-6902:
| Add/Delete as per notes on the left |
2 | How to handle multiple changes at different levels? | Example:
There could be Many more complex scenarios.... Replied below | |
3 | More scenarios need to be explored and documented in detail. Such as handling arrays within a json, handling child/grandchild changes. |
CPS Delta feature Exceptions
...
Anchor | ||||
---|---|---|---|---|
|
Format/Conventions to be used for Delta Report
...
There are several ways of representing the differences between JSON but here we discuss the JSON Patch format of representing these differences because the proposed Delta report closely represents JSON patch with a few differences. This approach focuses in producing another JSON document that represents the differences between the two JSON's that have been compared.
...
Code Block | ||||
---|---|---|---|---|
| ||||
[ { "op": "test", "path": "/a/b/c", "value": "foo" }, { "op": "remove", "path": "/a/b/c" }, { "op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ] }, { "op": "replace", "path": "/a/b/c", "value": 42 }, { "op": "move", "from": "/a/b/c", "path": "/a/b/d" }, { "op": "copy", "from": "/a/b/d", "path": "/a/b/e" } ] |
...
Let's assume we have a data node having some leaf data, and this particular node happens to have multiple child nodes as well.
Now we have two basic scenarios here:
- Add/Delete/Update of leaves
- Add/Delete/Update of child nodes
Add/Delete/Update of leaves
if the leaves of a particular data node, having a unique xpath, are added/deleted/updated then it will be considered as an Update of the particular Data Node.
Add/Delete/Update of child/grandchild nodes
Now in this scenario we assume that a child/grandchild data node, having its unique xpath, has been added/deleted/updated. Then this operation should be considered as an addition/deletion/update of the particular child/grandchild data node at its particular level, rather than an update of parent node,
...
Proposed Algorithm
The JSON data stored in CPS can be retrieved as Maps, And using this we can find the delta between two anchors retrieved as two separate Maps. The result can be stored in an JSON array with appropriate notations for action, xpath and payload. The following algorithm can be used to find the difference between the two maps and also recursively finds the difference between the child data nodes. The response is in form of a JSON Array which closely represents the JSON Patch format as described above.
...