@JSONXPATH[["filename",]path] : JSON XPath query.

 

If filename is not specified, @JSONXPATH will use the current JSON file opened by @JSONOPEN.

 

The path is a series of one or more element accessors separated by '/'. The path can be absolute (starting with '/') or relative to the current XPath location. Note: When using XPath notation the root element is always referred to as "json". This means all paths will begin with "/json".

The following are possible values for an element accessor:

name

A particular element name.

[i]

The i-th subelement of the current element.

..

the parent of the current element.

Example:

 

For example, with this JSON file:

 

{

 "firstlevel": {

   "one": "value",

   "two": ["first", "second"],

   "three": "value three"

 }

}

 

echo %@jsonxpath["test.json",/json/firstlevel/one/]

"value"

 

echo %@jsonxpath["test.json",/json/firstlevel/two/[2]/]

"second"

JSON Errors

10231   Unbalanced element tag

10232   Invalid JSON markup

10233   Invalid XPath

10234   DOM tree unavailable

XMLp Errors

101   Invalid attribute index

102   No attributes available

103   Invalid namespace index

104   No namespaces available

105   Invalid element index

106   No elements available

107   Attribute does not exist

201   Unbalanced element tag

202   Unknown element prefix (can't find namespace)

203   Unknown attribute prefix (can't find namespace)

204   Invalid XML markup

205   Invalid end state for parser

206   Document contains unbalanced element

207   Invalid XPath

208   No such child

209   Top element does not match start of path

210   DOM tree unavailable

302   Can't open file.