0 ×

JSON Path

StreamableJSON related functionality for KNIME version 3.6.1.v201808311614 by KNIME AG, Zurich, Switzerland

JSONPath is a similar to XPath alternative for JSON.

The result can be a single value or a list of multiple values (when the path is indefinite). In case there are multiple results and the selected output type cannot handle it (not a list of the selected type, or a JSON) the execution will fail. If the result cannot be represented in the selected type, missing value will be returned.

There are two notations, dot-notation:$.book[1].title and bracket-notation: $['book'][1]['title'] (indexing starts from 0, negative indices are relative to the last element).

Example input:
{"book": [
  {"year": 1999,
   "title": "Timeline",
   "author": "Michael Crichton"},
  {"year": 2000,
   "title": "Plain Truth",
   "author": "Jodi Picoult"}
]}

Example results:
$.book[0]
{"year": 1999, "title": "Timeline", "author": "Michael Crichton"} (JSON or String single value)
$.book[*].year
[1999,2000] (JSON, Int or Real list)
$.book[2].year
? (no such part)
$.book[?(@.year==1999)].title
Timeline (String) or "Timeline" (JSON)

The default path ($..*) will select all possible subparts (excluding the whole JSON value).

When you request the paths instead of values for the $.book[0].* JSONPath, you will get the paths -in bracket notation- as a list of Strings:

  • $['book'][0]['year']
  • $['book'][0]['title']
  • $['book'][0]['author']
which are valid JSONPaths for the input JSON value.

The filters ?(expr)can be used to select contents with specific properties, for example $..book[?(@.publisher)] selects the books that specify their publisher (@ refers to the actual element).

It uses the jayway/JsonPath implementation.

Options

Settings

Input
The JSON column to select the paths from.
Remove source column
When checked, the source column will be removed.
Outputs
A summary of the paths to select from the input column. The selected row can be customized with the Edit JSONPath button below or by editing the cells within the table, double-clicking on a row.
Add single query
Adds the (specific: only the selected) path for the cursor in Preview to the output columns table.
Add collection query
Adds the (generic: the selected and the siblings within arrays) path for the cursor in Preview to the output columns table.
Add JSONPath
Adds a new row to the Outputs table. This new entry selects all available paths in the JSON, regardless of current selection in Preview. This generic entry can then be manually edited to point to a specific path. To add a path to a value selected in Preview, use Add single query or Add collection query instead.
Edit JSONPath
Allows to edit the selected row using a popup dialog.
Remove JSONPath
Removes the selected row from the Outputs table.
JSON-Cell Preview
The content of the first JSON value if available (helps in writing the JSONPath expressions, you can add new rows based on the location of the cursor, move it to the value you want to select and click Add single query or Add collection query). When a row is selected in Outputs, the expected results are highlighted.

Input Ports

A table with JSON column

Output Ports

Table with the found parts

Best Friends (Incoming)

Best Friends (Outgoing)

Workflows

Update Site

To use this node in KNIME, install JSON related functionality for KNIME from the following update site:

Wait a sec! You want to explore and install nodes even faster? We highly recommend our NodePit for KNIME extension for your KNIME Analytics Platform.