JSON query functions and operators
pass the provided path expression to the path engine
- for evaluation. If the expression matches the JSON data to be queried,
+ for evaluation. If the expression matches the queried JSON data,
the corresponding SQL/JSON item is returned.
Path expressions are written in the SQL/JSON path language
and can also include arithmetic expressions and functions.
If the item to retrieve is an element of an array, you have
- to unnest this array using the [*] operator. For example,
+ to unnest this array using the [*] operator. For example,
the following path will return location coordinates for all
the available track segments:
The result of each path evaluation step can be processed
by one or more jsonpath operators and methods
listed in .
- Each method must be preceded by a dot, while arithmetic and Boolean
- operators are separated from the operands by spaces. For example,
+ Each method name must be preceded by a dot. For example,
you can get an array size:
'$.track.segments.size()'
|
double()
- Approximate numeric value converted from a string
+ Approximate floating-point number converted from an SQL/JSON number or a string
{"len": "1.9"}
$.len.double() * 2
3.8
|
keyvalue()
- Sequence of object's key-value pairs represented as array of objects
+ Sequence of object's key-value pairs represented as array of items
containing three fields ("key",
"value", and "id").
- "id" is an unique identifier of the object
+ "id" is a unique identifier of the object
key-value pair belongs to.
{"x": "20", "y": 32}
like_regex
Tests pattern matching with POSIX regular expressions
- (). Supported flags
+ (see ). Supported flags
are i, s, m,
- x and q.
+ x, and q.
["abc", "abd", "aBdC", "abdacb", "babc"]
$[*] ? (@ like_regex "^ab.*c" flag "i")
"abc", "aBdC", "abdacb"
|
exists
- Tests whether a path expression has at least one SQL/JSON item
+ Tests whether a path expression matches at least one SQL/JSON item
{"x": [1, 2], "y": [2, 4]}
strict $.* ? (exists (@ ? (@[*] > 2)))
2, 4
|
@@
jsonpath
- JSON path predicate check result for the specified JSON value.
- Only first result item is taken into account. If there are no results
- or the first result item is not Boolean, then null
- is returned.
+ Returns the result of JSON path predicate check for the specified JSON value.
+ Only the first item of the result is taken into account. If the
+ result is not Boolean, then null is returned.
'{"a":[1,2,3,4,5]}'::jsonb @@ '$.a[*] > 2'
|
- jsonb_path_exists(target jsonb, path jsonpath [, vars jsonb, silent bool])
+ jsonb_path_exists(target jsonb, path jsonpath [, vars jsonb [, silent bool]])
boolean
boolean
- Returns JSON path predicate result for the specified JSON value.
- Only first result item is taken into account. If there are no results
- or the first result item is not Boolean, then null
- is returned.
+ Returns the result of JSON path predicate check for the specified JSON value.
+ Only the first item of the result is taken into account. If the
+ result is not Boolean, then null is returned.
The jsonb_path_exists, jsonb_path_match,
- jsonb_path_query, jsonb_path_query_array and
+ jsonb_path_query, jsonb_path_query_array, and
jsonb_path_query_first
functions have optional vars and silent
arguments.
- If the <literal>vars> argument is specified, it provides an
+ If the <parameter>vars> argument is specified, it provides an
object containing named variables to be substituted into a
jsonpath expression.
- If the <literal>silent> argument is specified and has the
+ If the <parameter>silent> argument is specified and has the
true value, these functions suppress the same errors
as the @? and @@ operators.