by jameshart · 12y ago · 0 comments
[
{ "op": "replace", "path": "/baz", "value": "boo" },
{ "op": "add", "path": "/hello", "value": ["world"] },
{ "op": "remove", "path": "/foo"}
]
would be better described as value["baz"] = "boo";
value["hello"] = ["world"];
delete value["foo"];
Why go to the trouble of defining your grammar as a strict subset of JSON documents, which are themselves written using a strict subset of JavaScript syntax, when you could just limit yourself instead to the strict subset of JavaScript syntax that encapsulates the operations you actually want to perform?To support my approach, you need to validate that each line uses a strict subset of JavaScript, then securely evaluate each one according to the well defined rules of JavaScript.
Both have basically the same essential complexity - not sure I see why the JSON format patch is inherently 'easier' to work with.