You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I did a bit of experimentation with a PR but wasn't quite able to get it to work, so I thought I'd take this to an issue to look for some ideas on how to implement :)
Given the sample document, I'm interested in being able to use remove() without providing a field, e.g. removing all matching paths.
Essentially supporting something like this:
$jsonObject = new JsonObject($json);
$jsonObject->remove("$..book[?(@.category == 'fiction')]");
$results = $jsonObject->toValue();
// $results with all fiction books removed.
I tried a simple unset($element); in the remove code but PHP's unset only unsets the reference, not the original value, so it doesn't quite work.
The text was updated successfully, but these errors were encountered:
Have you tried passing an optional parameter to getReal() stating the action, ie.remove, and have the remove logic happen when traversing the internal array? Instead of appending the match to $selection you could unset it from its parent.
I did a bit of experimentation with a PR but wasn't quite able to get it to work, so I thought I'd take this to an issue to look for some ideas on how to implement :)
Given the sample document, I'm interested in being able to use
remove()
without providing a field, e.g. removing all matching paths.Essentially supporting something like this:
I tried a simple
unset($element);
in theremove
code but PHP's unset only unsets the reference, not the original value, so it doesn't quite work.The text was updated successfully, but these errors were encountered: