GetDKAN / RootedJsonData

Access and modify JSON-based data objects while enforcing JSON Schema
GNU General Public License v3.0
1 stars 0 forks source link

Add remove() and __unset(), update JsonPath #15

Closed dafeder closed 10 months ago

dafeder commented 10 months ago

This adds a remove() method, which is just a wrapper for JsonPath::remove, and also an magic __unset() method that attempts to unset a property using remove(). Both will validate before modifying the object.

So we can do on the following:

{
  "field1": "foo",
  "field2": "bar"
}
  1. $rootedDataObject->remove("$", "field2");
  2. unset($rootedDataObject->{"$.field2");

Either will result in:

{
  "field1": "foo",
}

Also updates to latest release of JsonPath library.