woob.browser.filters.json
¶
- class Dict(selector=None, default=_NO_DEFAULT)[source]¶
Bases:
Filter
Filter to find elements in a dictionary or list.
Note that a selector defined as None or an empty string will be equivalent to selecting the root of the provided document, as for None.
- Parameters:
>>> d = {'a': {'b': 'c', 'd': None}} >>> Dict('')(d) {'a': {'b': 'c', 'd': None}} >>> Dict()(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) >>>