Skip to content

Commit 9f77186

Browse files
committed
Documentation improvements to jsonpath
Besides cosmetic improvements it removes statement that operators necessary need to be separated from operands with spaces, which is not really true. Discussion: https://postgr.es/m/CAEkD-mDUZrRE%3Dk-FznEg4Ed2VdjpZCyHoyo%2Bp0%2B8KvHqR%3DpNVQ%40mail.gmail.com Author: Liudmila Mantrova, Alexander Lakhin Reviewed-by: Alexander Korotkov, Alvaro Herrera Backpatch-through: 12
1 parent 3097a0d commit 9f77186

File tree

2 files changed

+24
-27
lines changed

2 files changed

+24
-27
lines changed

doc/src/sgml/func.sgml

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11544,7 +11544,7 @@ table2-mapping
1154411544

1154511545
<para>JSON query functions and operators
1154611546
pass the provided path expression to the <firstterm>path engine</firstterm>
11547-
for evaluation. If the expression matches the JSON data to be queried,
11547+
for evaluation. If the expression matches the queried JSON data,
1154811548
the corresponding SQL/JSON item is returned.
1154911549
Path expressions are written in the SQL/JSON path language
1155011550
and can also include arithmetic expressions and functions.
@@ -11604,7 +11604,7 @@ table2-mapping
1160411604

1160511605
<para>
1160611606
If the item to retrieve is an element of an array, you have
11607-
to unnest this array using the [*] operator. For example,
11607+
to unnest this array using the <literal>[*]</literal> operator. For example,
1160811608
the following path will return location coordinates for all
1160911609
the available track segments:
1161011610
<programlisting>
@@ -11625,8 +11625,7 @@ table2-mapping
1162511625
The result of each path evaluation step can be processed
1162611626
by one or more <type>jsonpath</type> operators and methods
1162711627
listed in <xref linkend="functions-sqljson-path-operators"/>.
11628-
Each method must be preceded by a dot, while arithmetic and Boolean
11629-
operators are separated from the operands by spaces. For example,
11628+
Each method name must be preceded by a dot. For example,
1163011629
you can get an array size:
1163111630
<programlisting>
1163211631
'$.track.segments.size()'
@@ -11907,7 +11906,7 @@ table2-mapping
1190711906
</row>
1190811907
<row>
1190911908
<entry><literal>double()</literal></entry>
11910-
<entry>Approximate numeric value converted from a string</entry>
11909+
<entry>Approximate floating-point number converted from an SQL/JSON number or a string</entry>
1191111910
<entry><literal>{"len": "1.9"}</literal></entry>
1191211911
<entry><literal>$.len.double() * 2</literal></entry>
1191311912
<entry><literal>3.8</literal></entry>
@@ -11936,10 +11935,10 @@ table2-mapping
1193611935
<row>
1193711936
<entry><literal>keyvalue()</literal></entry>
1193811937
<entry>
11939-
Sequence of object's key-value pairs represented as array of objects
11938+
Sequence of object's key-value pairs represented as array of items
1194011939
containing three fields (<literal>"key"</literal>,
1194111940
<literal>"value"</literal>, and <literal>"id"</literal>).
11942-
<literal>"id"</literal> is an unique identifier of the object
11941+
<literal>"id"</literal> is a unique identifier of the object
1194311942
key-value pair belongs to.
1194411943
</entry>
1194511944
<entry><literal>{"x": "20", "y": 32}</literal></entry>
@@ -12061,9 +12060,9 @@ table2-mapping
1206112060
<entry><literal>like_regex</literal></entry>
1206212061
<entry>
1206312062
Tests pattern matching with POSIX regular expressions
12064-
(<xref linkend="functions-posix-regexp"/>). Supported flags
12063+
(see <xref linkend="functions-posix-regexp"/>). Supported flags
1206512064
are <literal>i</literal>, <literal>s</literal>, <literal>m</literal>,
12066-
<literal>x</literal> and <literal>q</literal>.</entry>
12065+
<literal>x</literal>, and <literal>q</literal>.</entry>
1206712066
<entry><literal>["abc", "abd", "aBdC", "abdacb", "babc"]</literal></entry>
1206812067
<entry><literal>$[*] ? (@ like_regex "^ab.*c" flag "i")</literal></entry>
1206912068
<entry><literal>"abc", "aBdC", "abdacb"</literal></entry>
@@ -12077,7 +12076,7 @@ table2-mapping
1207712076
</row>
1207812077
<row>
1207912078
<entry><literal>exists</literal></entry>
12080-
<entry>Tests whether a path expression has at least one SQL/JSON item</entry>
12079+
<entry>Tests whether a path expression matches at least one SQL/JSON item</entry>
1208112080
<entry><literal>{"x": [1, 2], "y": [2, 4]}</literal></entry>
1208212081
<entry><literal>strict $.* ? (exists (@ ? (@[*] > 2)))</literal></entry>
1208312082
<entry><literal>2, 4</literal></entry>
@@ -12302,10 +12301,9 @@ table2-mapping
1230212301
<row>
1230312302
<entry><literal>@@</literal></entry>
1230412303
<entry><type>jsonpath</type></entry>
12305-
<entry>JSON path predicate check result for the specified JSON value.
12306-
Only first result item is taken into account. If there are no results
12307-
or the first result item is not Boolean, then null
12308-
is returned.</entry>
12304+
<entry>Returns the result of JSON path predicate check for the specified JSON value.
12305+
Only the first item of the result is taken into account. If the
12306+
result is not Boolean, then <literal>null</literal> is returned.</entry>
1230912307
<entry><literal>'{"a":[1,2,3,4,5]}'::jsonb @@ '$.a[*] > 2'</literal></entry>
1231012308
</row>
1231112309
</tbody>
@@ -12943,7 +12941,7 @@ table2-mapping
1294312941
<row>
1294412942
<entry>
1294512943
<para><literal>
12946-
jsonb_path_exists(target jsonb, path jsonpath [, vars jsonb, silent bool])
12944+
jsonb_path_exists(target jsonb, path jsonpath [, vars jsonb [, silent bool]])
1294712945
</literal></para>
1294812946
</entry>
1294912947
<entry><type>boolean</type></entry>
@@ -12968,10 +12966,9 @@ table2-mapping
1296812966
</entry>
1296912967
<entry><type>boolean</type></entry>
1297012968
<entry>
12971-
Returns JSON path predicate result for the specified JSON value.
12972-
Only first result item is taken into account. If there are no results
12973-
or the first result item is not Boolean, then null
12974-
is returned.
12969+
Returns the result of JSON path predicate check for the specified JSON value.
12970+
Only the first item of the result is taken into account. If the
12971+
result is not Boolean, then <literal>null</literal> is returned.
1297512972
</entry>
1297612973
<entry>
1297712974
<para><literal>
@@ -13178,18 +13175,18 @@ table2-mapping
1317813175
<note>
1317913176
<para>
1318013177
The <literal>jsonb_path_exists</literal>, <literal>jsonb_path_match</literal>,
13181-
<literal>jsonb_path_query</literal>, <literal>jsonb_path_query_array</literal> and
13178+
<literal>jsonb_path_query</literal>, <literal>jsonb_path_query_array</literal>, and
1318213179
<literal>jsonb_path_query_first</literal>
1318313180
functions have optional <literal>vars</literal> and <literal>silent</literal>
1318413181
arguments.
1318513182
</para>
1318613183
<para>
13187-
If the <literal>vars</literal> argument is specified, it provides an
13184+
If the <parameter>vars</parameter> argument is specified, it provides an
1318813185
object containing named variables to be substituted into a
1318913186
<literal>jsonpath</literal> expression.
1319013187
</para>
1319113188
<para>
13192-
If the <literal>silent</literal> argument is specified and has the
13189+
If the <parameter>silent</parameter> argument is specified and has the
1319313190
<literal>true</literal> value, these functions suppress the same errors
1319413191
as the <literal>@?</literal> and <literal>@@</literal> operators.
1319513192
</para>

doc/src/sgml/json.sgml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -490,11 +490,11 @@ SELECT jdoc->'guid', jdoc->'name' FROM api WHERE jdoc @@ '$.tags[*] == "qui"';
490490
SELECT jdoc->'guid', jdoc->'name' FROM api WHERE jdoc @@ '$.tags[*] ? (@ == "qui")';
491491
</programlisting>
492492
GIN index extracts statements of following form out of
493-
<literal>jsonpath</literal>: <literal>accessors_chain = const</literal>.
493+
<literal>jsonpath</literal>: <replaceable>accessors_chain</replaceable> = <replaceable>const</replaceable>.
494494
Accessors chain may consist of <literal>.key</literal>,
495-
<literal>[*]</literal> and <literal>[index]</literal> accessors.
495+
<literal>[*]</literal>, and <literal>[<replaceable>index</replaceable>]</literal> accessors.
496496
<literal>jsonb_ops</literal> additionally supports <literal>.*</literal>
497-
and <literal>.**</literal> statements.
497+
and <literal>.**</literal> accessors.
498498
</para>
499499
<para>
500500
Another approach to querying is to exploit containment, for example:
@@ -650,12 +650,12 @@ SELECT jdoc-&gt;'guid', jdoc-&gt;'name' FROM api WHERE jdoc @&gt; '{"tags": ["qu
650650
<itemizedlist>
651651
<listitem>
652652
<para>
653-
Dot <literal>.</literal> is used for member access.
653+
Dot (<literal>.</literal>) is used for member access.
654654
</para>
655655
</listitem>
656656
<listitem>
657657
<para>
658-
Square brackets <literal>[]</literal> are used for array access.
658+
Square brackets (<literal>[]</literal>) are used for array access.
659659
</para>
660660
</listitem>
661661
<listitem>

0 commit comments

Comments
 (0)