json-patch / json-patch2

A possibile revision to the JSON-Patch format
44 stars 0 forks source link

Use an array to specify a property path #24

Open awwright opened 5 years ago

awwright commented 5 years ago

JSON Patch specifies that paths be specified in a string format as specified by RFC 6901. This requires additional steps to form paths, first to escape characters (in a new, invented escape not used elsewhere), then joining the segments together prepended by a "/". This seems unnecessary.

JSON Patch should accept an array path format, where each item in the array descends into an object property (if a string) or an array item (if an integer). To adapt examples from RFC 6902:

   { "op": "add", "path": ["a", "b", "c"], "value": "foo" },
   { "op": "copy", "from": ["a", "b", "c"] "path": ["a", "b", "e"]},
   { "op": "remove", "path": ["foo", 1]},
   { "op": "test", "path": ["~1"], "value": 10},

etc.

gregsdennis commented 5 years ago

Is this a duplicate of #1?

awwright commented 5 years ago

@gregsdennis This is formally stating one of the comments, but yeah nice catch