From b46bcf7a4b6f161eae1cee3ed9b6c4a28d04f4d0 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Mon, 11 Apr 2022 11:48:40 -0400 Subject: [PATCH] Improve readability of SQL/JSON documentation. Per review from Justin Pryzby. Discussion: https://postgr.es/m/f50aca87-6b35-a1b0-2286-f815a589dd83@dunslane.net --- doc/src/sgml/func.sgml | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 2ecf0482d8..0a5c402640 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -17764,7 +17764,7 @@ $.* ? (@ like_regex "^\\d+$") Examples - Construct a JSON the provided strings: + Construct JSON using the provided strings: SELECT JSON('{ "a" : 123, "b": [ true, "foo" ], "a" : "bar" }'); @@ -17819,7 +17819,7 @@ ERROR: duplicate JSON object key value JSON value. For null input, SQL null (not a JSON null) value is returned. - For any scalar other than a number or a Boolean the text + For any scalar other than a number or a Boolean, the text representation will be used, with escaping as necessary to make it a valid JSON string value. For details, see @@ -17855,7 +17855,7 @@ ERROR: duplicate JSON object key value Examples - Construct a JSON from the provided values various types: + Construct JSON scalars from the provided values of various types: SELECT JSON_SCALAR(123.45); @@ -18113,9 +18113,7 @@ WHERE f.did = 103; The JSON_OBJECTAGG function aggregates the provided data into a JSON object. You can use this function to combine values - stored in different table columns into pairs. If you specify a GROUP BY - or an ORDER BY clause, this function returns a separate JSON object - for each table row. + stored in different table columns into pairs. @@ -18691,7 +18689,7 @@ INSERT INTO my_films VALUES ( Description - JSON_EXISTS function checks whether the provided + The JSON_EXISTS function checks whether the provided JSON path expression can return any SQL/JSON items. @@ -18804,7 +18802,7 @@ SELECT JSON_EXISTS(jsonb '{"a": [1,2,3]}', 'strict $.a[5]'); Description - JSON_VALUE function extracts a value from the provided + The JSON_VALUE function extracts a value from the provided JSON data and converts it to an SQL scalar. If the specified JSON path expression returns more than one SQL/JSON item, an error occurs. To extract @@ -18963,7 +18961,7 @@ SELECT JSON_VALUE(jsonb '[1,2]', 'strict $[*]' DEFAULT 1 ON ERROR); Description - JSON_QUERY function extracts an SQL/JSON + The JSON_QUERY function extracts an SQL/JSON array or object from JSON data. This function must return a JSON string, so if the path expression returns a scalar or multiple SQL/JSON items, you must wrap the result using the WITH WRAPPER clause. @@ -19366,7 +19364,7 @@ where json_table_column is: Description - JSON_TABLE function queries JSON data + The JSON_TABLE function queries JSON data and presents the results as a relational view, which can be accessed as a regular SQL table. You can only use JSON_TABLE inside the FROM clause of the SELECT statement @@ -19620,7 +19618,7 @@ where json_table_column is: The optional json_path_name serves as an identifier of the provided json_path_specification. - The path name must be unique and cannot coincide with column names. + The path name must be unique and distinct from the column names. When using the PLAN clause, you must specify the names for all the paths, including the row pattern. Each path name can appear in the PLAN clause only once. @@ -19820,7 +19818,7 @@ JSON_SERIALIZE ( Description - JSON_SERIALIZE function transforms a SQL/JSON value + The JSON_SERIALIZE function transforms a SQL/JSON value into a character or binary string. @@ -19872,7 +19870,7 @@ JSON_SERIALIZE ( Examples - Construct a JSON the provided strings: + Construct serialized JSON using the provided strings: SELECT JSON_SERIALIZE(JSON_SCALAR('foo')); @@ -19961,7 +19959,7 @@ SELECT JSON_SERIALIZE('{"foo": "bar", "baz": [1, 2]}' RETURNING bytea); supports the following types: json, jsonb, bytea, and character string types (text, char, varchar, and nchar). - To use other types, you must create the CAST from json for this type. + To use another type, you must create a cast from json to that type. By default, the json type is returned. @@ -22392,7 +22390,7 @@ SELECT NULLIF(value, '(none)') ... Collects all the key/value pairs into a JSON object. Key arguments are coerced to text; value arguments are converted as per to_json or to_jsonb - Values can be null, but not keys. + Values can be null, but keys cannot. No @@ -22449,7 +22447,7 @@ SELECT NULLIF(value, '(none)') ... Collects all the key/value pairs into a JSON object. Key arguments are coerced to text; value arguments are converted as per to_json or to_jsonb. - Values can be null, but not keys. + Values can be null, but keys cannot. If there is a duplicate key an error is thrown. No