Json.Path

g GObject.Object GObject.Object Json.Path Json.Path GObject.Object->Json.Path

Subclasses:None

Methods

Inherited:GObject.Object (37)
Structs:GObject.ObjectClass (5)
class new ()
class query (expression, root)
  compile (expression)
  match (root)

Virtual Methods

Inherited:GObject.Object (7)

Properties

None

Signals

Inherited:GObject.Object (1)

Fields

Inherited:GObject.Object (1)

Class Details

class Json.Path(**kwargs)
Bases:GObject.Object
Abstract:No
Structure:Json.PathClass

The JsonPath structure is an opaque object whose members cannot be directly accessed except through the provided API.

New in version 0.14.

classmethod new()
Returns:the newly created Json.Path instance. Use GObject.Object.unref() to free the allocated resources when done
Return type:Json.Path

Creates a new Json.Path instance.

Once created, the Json.Path object should be used with Json.Path.compile() and Json.Path.match().

New in version 0.14.

classmethod query(expression, root)
Parameters:
  • expression (str) – a JSONPath expression
  • root (Json.Node) – the root of a JSON tree
Raises:

GLib.Error

Returns:

a newly-created Json.Node of type Json.NodeType.ARRAY containing an array of matching Json.Nodes. Use Json.Node.unref() when done

Return type:

Json.Node

Queries a JSON tree using a JSONPath expression.

This function is a simple wrapper around Json.Path.new(), Json.Path.compile() and Json.Path.match(). It implicitly creates a Json.Path instance, compiles expression and matches it against the JSON tree pointed by root.

New in version 0.14.

compile(expression)
Parameters:expression (str) – a JSONPath expression
Raises:GLib.Error
Returns:True on success; on error, error will be set with the %JSON_PATH_ERROR domain and a code from the Json.PathError enumeration, and False will be returned
Return type:bool

Validates and decomposes expression.

A JSONPath expression must be compiled before calling Json.Path.match().

New in version 0.14.

match(root)
Parameters:root (Json.Node) – a Json.Node
Returns:a newly-created Json.Node of type Json.NodeType.ARRAY containing an array of matching Json.Nodes. Use Json.Node.unref() when done
Return type:Json.Node

Matches the JSON tree pointed by root using the expression compiled into the Json.Path.

The matching Json.Nodes will be copied into a Json.Array and returned wrapped in a Json.Node.

New in version 0.14.