Select keys in Json

../../../../_images/select_json.svg

Filter a Json structure, keeping/removing keys in selected dictionaries.

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.

If the query matches anythin other than a dictionary, that entry is kept as is in the output.

Modes

By using different modes for the Keys parameter you can achieve different behaviors. With Use selected only selected keys are kept in the output. With Use and require selected the same keys are kept in the output, but it becomes an error if any selected key is missing from any of the dictionaries. With Use unselected only keys that are not selected are kept in the output. Finally, with Use all all the keys are kept in the output.

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.

Select keys (keys)

Select keys to keep in the selected dictionaries.

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.

Examples

Implementation

class node_filterjson.SelectKeysInJson[source]