Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Allow includes prediate to check for object in collection #2232

Open
RyanEager-TensorIoT opened this issue Dec 6, 2023 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@RyanEager-TensorIoT
Copy link

Problem to solve

I have an API which returns a collection of JSON objects and I want to check their values. I can check that the values exist within the collection with:

jsonpath "$.books[*].title includes "Introduction to Algorithms"
jsonpath "$.books[*].author includes "Thomas H. Cormen"

but I can not confirm that the these values are within the same object.

Proposal

Allow the includes predicate to check for a object within a collection, i.e for the collection:

books: [
    {
        "title":  "Introduction to Algorithms",
        "author": "Thomas H. Cormen",
        "publisher": "The MIT Press"
    },
    ...
]

You can check with an object:

jsonpath "$.books includes 
{
    "title":  "Introduction to Algorithms",
    "author": "Thomas H. Cormen", 
}

or one in a variable:

jsonpath "$.books includes {{myAwesomeBook}}

This would return true even if the object in the collection has additional keys. i.e. the above examples would return True.

Additional context and resources

  • There could be a keyword instead of the newline to invoke this behavior, possibly object?
@RyanEager-TensorIoT RyanEager-TensorIoT added the enhancement New feature or request label Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant