woob.browser.filters.json
¶
- class Dict(selector: Optional[Union[str, _Filter, Callable, Any]] = None, default: Any = NO_DEFAULT)[source]¶
Bases:
Filter
Filter to find elements in a dictionary
- Parameters
selector – input selector to use on the object
default – default value is the element is not found, or if the type mismatch
>>> d = {'a': {'b': 'c', 'd': None}} >>> Dict('a/b')(d) 'c' >>> Dict('a')(d) {'b': 'c', 'd': None} >>> Dict('notfound')(d) Traceback (most recent call last): ... woob.browser.filters.base.ItemNotFound: Element ['notfound'] not found >>> Dict('notfound', default=None)(d) >>>