jmespath / jmespath/jmespath.py

Custom "None" value when search fails

Open
#186 10 comments 3 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2.4k
Forks
212
PR merge metrics
No merged PRs in 30d

Description

Hi, thanks for this awesome lib!
One question: it seems to be impossible to set a custom return in case the search fails.

E.g.
```
not_found = object()
jmespath.search('foo.aaa', {'foo': {'bar': 'baz'}}) # I need `not_found`, not `None`
```

Is this by design or are you open to supporting that?
I see this was discussed at https://github.com/jmespath/jmespath.py/issues/113
But the proposed solution of `contains` isn't great, as it requires 2 searches.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.