C10 - initial
jsonpath (Sifts) | |
---|---|
Type | Corrade progressive sift |
Sift | jsonpath |
Parameters | a string representing a JSON path |
Description | The jsonpath sift will extract JSON elements matching the provided JSON path. |
Last Changes | None |
The jsonpath
sift will extract JSON elements matching the provided JSON path.
Position | Type | Description | Example |
---|---|---|---|
0 | a string representing a JSON path | return all JSON elements that the path resolves to | $.query.pages.*.extract |
In case the returned data is expected to return JSON, then the JSONPath
sift can be used to extract a subtree or a single value. For example, suppose we would like to retrieve the value of the extract
key in the Wikipedia query https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro&explaintext&redirects=1&titles=Homie
.
Were we to issue the HTTP
command in order to retrieve a summary of the article named Homie
:
llInstantMessage(CORRADE, wasKeyValueEncode( [ "command", "HTTP", "group", wasURLEscape(GROUP), "password", wasURLEscape(PASSWORD), "action", "get", "type", "text", "URL", wasURLEscape("https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro&explaintext&redirects=1&titles=Homie"), "sift", wasListToCSV([ "JSONPath", wasURLEscape("$.query.pages.*.extract") ]), "callback", wasURLEscape(URL) ] ) );
then the sift JSONPath
with the value $.query.pages.*.extract
would return the page extract in the data
key.
For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.