JSONPath is a query language for JSON, similar to XPath for XML.
The result of a simple query (also called definite JSONPath) is a single value. The result of a collection query (also called indefinite JSONPath) is a list of multiple values. Results of JSONPath queries are converted to the selected KNIME type. If the result is a list and the selected KNIME type is not compatible, the execution will fail. If the result cannot be converted to the selected KNIME type, a missing value will be returned.
JSONPath queries can be automatically generated via the node configuration dialog. To create a simple query, select a single value from the JSON-Cell Preview window and click "Add single query". To create a collection query, select a value that is part of a list of values from the JSON-Cell Preview window and click "Add collection query". Alternatively, you can write your own JSONPath query by clicking the "Add JSONPath" button.
Example input:{"book": [ {"year": 1999, "title": "Timeline", "author": "Michael Crichton"}, {"year": 2000, "title": "Plain Truth", "author": "Jodi Picoult"} ]}
Example JSONPath queries and evaluation 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)].titleTimeline
(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:
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).
The JSON Path node uses the Jayway JSONPath implementation.
You want to see the source code for this node? Click the following button and we’ll use our super-powers to find it for you.
To use this node in KNIME, install the extension KNIME JSON-Processing from the below update site following our NodePit Product and Node Installation Guide:
A zipped version of the software site can be downloaded here.
Deploy, schedule, execute, and monitor your KNIME workflows locally, in the cloud or on-premises – with our brand new NodePit Runner.
Try NodePit Runner!Do you have feedback, questions, comments about NodePit, want to support this platform, or want your own nodes or workflows listed here as well? Do you think, the search results could be improved or something is missing? Then please get in touch! Alternatively, you can send us an email to mail@nodepit.com.
Please note that this is only about NodePit. We do not provide general support for KNIME — please use the KNIME forums instead.