jsonyx.apply_filter¶
- jsonyx.apply_filter(nodes, query, *, allow=NOTHING, use_decimal=False)[source]¶
Apply a JSON filter query to a node or a list of nodes.
Added in version 2.0.
- Parameters:
nodes (_Node |
list[_Node]) – a node or a list of nodesquery (
str) – a JSON filter queryallow (
Container[str], default:NOTHING) – the JSON deviations fromjsonyx.allowuse_decimal (
bool, default:False) – usedecimal.Decimalinstead offloat
- Raises:
IndexError – if an index is out of range
JSONSyntaxError – if the filter query is invalid
KeyError – if a key is not found
TypeError – if a value has the wrong type
- Returns:
list[_Node] – the filtered list of nodes
- Example:
>>> import jsonyx as json >>> obj = None >>> root = [obj] >>> node = root, 0 # pointer to obj >>> assert json.apply_filter(node, "@ == null")