Remove Json¶
Filter a Json structure, removing entries that match a query.
Documentation¶
For more information about how to write Json queries, see Json query syntax.
If Match anywhere is not checked (the default) the query must
match starting at the root of the Json structure. E.g. the query
articles
only matches if the root entry is a dictionary containing the
key “articles”. Conversely, if Match anywhere is checked the
query articles
can matches the key “articles” in any dictionary in the
whole structure. It can even match at several places despite the query just
being a simple key.
Using predicates¶
A predicate is a function that takes a Json entry as its only argument and
returns a boolean. It can be entered either as a lambda expression or as a
function definition using def
., e.g:
lambda entry: entry['score'] >= 100
or:
def filter_by_score(entry):
return entry['score'] >= 100
When predicate is used each selected entry in the Json structure is passed
to the predicate function which can then return True for entries that
should be removed from the output and False for those that should be kept.
If evaluating the predicate raises an exception this is treated the same as returning False.
Definition¶
Input ports¶
- input json
Input
Output ports¶
- output json
Output
Configuration¶
- Match anywhere (anywhere)
Match the query at any position in the Json structure.
- Predicate (predicate)
The predicate can be entered as a python function (def or lambda) which takes an entry in the Json structure as its only argument and returns either True if that entry should be removed, or False if it shouldn’t
- Query (query)
Query for selecting entries in the Json structure. The visual editor can help you create a query which selects a single entry. The query can then be edited manually to include slices (e.g. [2:4]) or patterns (e.g. some*key) which will select multiple entries. For more details see the node’s documentation.
- Filter by predicate (use_predicate)
When checked, each entry in the data selected by the query will be passed to the predicate function and will only be removed if the predicate function returns True.
Examples¶
Implementation¶
- class node_filterjson.RemoveJson[source]