Table of Contents

JSONPath

C10 - initial

jsonpath (Sifts)
TypeCorrade progressive sift
Siftjsonpath
Parametersa string representing a JSON path
DescriptionThe jsonpath sift will extract JSON elements matching the provided JSON path.
Last ChangesNone

The jsonpath sift will extract JSON elements matching the provided JSON path.

Arguments

Position Type Description Example
0 a string representing a JSON path return all JSON elements that the path resolves to $.query.pages.*.extract

Example

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.

Notes