@@ -16901,11 +16901,16 @@ $ ? (@ like_regex "^\\d+$")
1690116901 <para>
1690216902 <productname>PostgreSQL</productname> provides several functions
1690316903 that generate JSON data. Taking values of SQL types as input, these
16904- functions construct JSON objects or JSON arrays represented as
16905- SQL character or binary strings.
16904+ functions construct JSON objects, JSON arrays or JSON scalars represented
16905+ as <type>json</type> or <type>jsonb</type> types, SQL character or binary strings.
1690616906 </para>
1690716907
1690816908 <itemizedlist>
16909+ <listitem>
16910+ <para>
16911+ <xref linkend="functions-jsonscalar"/>
16912+ </para>
16913+ </listitem>
1690916914 <listitem>
1691016915 <para>
1691116916 <link linkend="functions-jsonobject"><literal>JSON_OBJECT</literal></link>
@@ -16928,6 +16933,102 @@ $ ? (@ like_regex "^\\d+$")
1692816933 </listitem>
1692916934 </itemizedlist>
1693016935
16936+ <refentry id="functions-jsonscalar">
16937+ <refnamediv>
16938+ <refname>JSON_SCALAR</refname>
16939+ <refpurpose>create a JSON scalar</refpurpose>
16940+ </refnamediv>
16941+
16942+ <refsynopsisdiv>
16943+ <synopsis>
16944+ JSON_SCALAR (
16945+ <replaceable class="parameter">expression</replaceable>
16946+ [ RETURNING <replaceable class="parameter">json_data_type</replaceable> ]
16947+ )
16948+ </synopsis>
16949+ </refsynopsisdiv>
16950+
16951+ <refsect1>
16952+ <title>Description</title>
16953+
16954+ <para>
16955+ <function>JSON_SCALAR</function> function generates a scalar
16956+ <acronym>JSON</acronym> from a <acronym>SQL</acronym> data.
16957+ </para>
16958+ </refsect1>
16959+
16960+ <refsect1>
16961+ <title>Parameters</title>
16962+ <variablelist>
16963+ <varlistentry>
16964+ <term>
16965+ <literal><replaceable class="parameter">expression</replaceable></literal>
16966+ </term>
16967+ <listitem>
16968+ <para>
16969+ Expression that provides the data for constructing a
16970+ <acronym>JSON</acronym>.
16971+ For null input, <acronym>SQL</acronym> null
16972+ (not a <acronym>JSON</acronym> null) value is returned.
16973+ For any scalar other than a number, a Boolean, the text representation
16974+ will be used, with escaping as necessary to make it a valid
16975+ <acronym>JSON</acronym> string value.
16976+ For details, see
16977+ <function>to_json()</function>/<function>to_jsonb()</function>
16978+ in <xref linkend="functions-json-creation-table"/>.
16979+ </para>
16980+ </listitem>
16981+ </varlistentry>
16982+ <varlistentry>
16983+ <term>
16984+ <literal>RETURNING <replaceable class="parameter">json_data_type</replaceable></literal>
16985+ </term>
16986+ <listitem>
16987+ <para>
16988+ The output clause that specifies the type (<type>json</type> or
16989+ <type>jsonb</type>) of the generated <acronym>JSON</acronym> scalar.
16990+ </para>
16991+ </listitem>
16992+ </varlistentry>
16993+ </variablelist>
16994+ </refsect1>
16995+
16996+ <refsect1>
16997+ <title>Notes</title>
16998+ <para>
16999+ Alternatively, you can construct <acronym>JSON</acronym> objects by
17000+ using <productname>PostgreSQL</productname>-specific
17001+ <function>to_json()</function>/<function>to_jsonb()</function> functions.
17002+ See <xref linkend="functions-json-creation-table"/> for details.
17003+ </para>
17004+ </refsect1>
17005+ <refsect1>
17006+ <title>Examples</title>
17007+ <para>
17008+ Construct a JSON from the provided values various types:
17009+ </para>
17010+ <screen>
17011+ SELECT JSON_SCALAR(123.45);
17012+ json_scalar
17013+ -------------
17014+ 123.45
17015+ (1 row)
17016+
17017+ SELECT JSON_SCALAR('123');
17018+ json_scalar
17019+ -------------
17020+ "123"
17021+ (1 row)
17022+
17023+ SELECT JSON_SCALAR(true);
17024+ json_scalar
17025+ -------------
17026+ true
17027+ (1 row)
17028+ </screen>
17029+ </refsect1>
17030+ </refentry>
17031+
1693117032 <sect4 id="functions-jsonobject">
1693217033 <title><literal>JSON_OBJECT</literal></title>
1693317034 <indexterm><primary>json_object</primary></indexterm>
0 commit comments