Skip to content

Remove without field #39

@chrisvanpatten

Description

@chrisvanpatten

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions