WARNING: This server provides a static reference view of the NetKernel documentation. Links to dynamic content do not work. For the best experience we recommend you install NetKernel and view the documentation in the live system .

Endpoint
Name:active:jsonpath
Description:
Id:active:jsonpath
Category:accessor
Identifier Syntax

active:jsonpath is an accessor using Active URI syntax with the following base identifiers:

Base
active:jsonPath

and the following arguments: (for more details on argument passing details see here)

ArgumentRulesTypingDescription
operand
Mandatory
Representation (java.lang.Object)JSON to apply path expression to
operator
Mandatory
Representation (java.lang.Object)JSONPath expression
Request Verbs

The following verb is supported:

Verb
SOURCE
Response

The response representation of this accessor for SOURCE requests is unknown.

This accessor throws no documented exceptions.

Import Requirements

To use active:jsonpath accessor you must import the module urn:org:netkernel:json:extra:

<import>
  <uri>urn:org:netkernel:json:extra</uri>
</import>

This endpoint enables JSONPath expressions to be applied to a JSON resource.

JSONPath is similar to XPath in that it allows for simple path expressions to determine specific locations in a JSON structure.

The power of path expressions are that they allow you to subset a given structure and extract it (or simply assert that it is present).

Example

There are many examples for JSONpath expressions on the JSONPath home page. Here is a simple example of how we can use the active:jsonpath service to extract a part of a JSON structure...

Say we have a resource called res:/transport.json that looks like...

{
        "car": [
            {"id": 10, "color": "silver", "name": "Volvo"},
            {"id": 11, "color": "red",    "name": "Saab"},
            {"id": 12, "color": "red",    "name": "Peugeot"},
            {"id": 13, "color": "yellow", "name": "Porsche"}
        ],
        "bike": [
            {"id": 20, "color": "black", "name": "Cannondale"},
            {"id": 21, "color": "red",   "name": "Shimano"}
        ]
}

The following would extract only the bike data...

req=context.createRequest("active:jsonpath")
req.addArgument("operand", "res:/transport.json")
req.addArgumentByValue("operator", "$.bike")
rep=context.issueRequest(req)

The resulting representation would be...

{
        "bike": [
            {"id": 20, "color": "black", "name": "Cannondale"},
            {"id": 21, "color": "red",   "name": "Shimano"}
        ]
}