Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Merged
merged 6 commits into from
Dec 20, 2023
Merged

Conversation

dafeder
Copy link
Member

@dafeder dafeder commented Dec 18, 2023

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.

@paul-m paul-m merged commit 10eccf1 into master Dec 20, 2023
@paul-m paul-m deleted the json-path-update branch December 20, 2023 20:51
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants