Home Explore Blog CI



postgresql

13th chunk of `doc/src/sgml/json.sgml`
14735222ce3d1a6fbddc55482eba4db9da2417f08a1585a30000000100000b91
 or null.
     </para>
    </listitem>
    <listitem>
     <para>
      Path variables listed in <xref linkend="type-jsonpath-variables"/>.
     </para>
    </listitem>
    <listitem>
     <para>
      Accessor operators listed in <xref linkend="type-jsonpath-accessors"/>.
     </para>
    </listitem>
    <listitem>
     <para>
      <type>jsonpath</type> operators and methods listed
      in <xref linkend="functions-sqljson-path-operators"/>.
     </para>
    </listitem>
    <listitem>
     <para>
      Parentheses, which can be used to provide filter expressions
      or define the order of path evaluation.
     </para>
    </listitem>
   </itemizedlist>
  </para>

  <para>
   For details on using <type>jsonpath</type> expressions with SQL/JSON
   query functions, see <xref linkend="functions-sqljson-path"/>.
  </para>

  <table id="type-jsonpath-variables">
   <title><type>jsonpath</type> Variables</title>
   <tgroup cols="2">
    <colspec colname="col1" colwidth="1*"/>
    <colspec colname="col2" colwidth="2*"/>
    <thead>
     <row>
      <entry>Variable</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>
     <row>
      <entry><literal>$</literal></entry>
      <entry>A variable representing the JSON value being queried
      (the <firstterm>context item</firstterm>).
      </entry>
     </row>
     <row>
      <entry><literal>$varname</literal></entry>
      <entry>
        A named variable. Its value can be set by the parameter
        <parameter>vars</parameter> of several JSON processing functions;
        see <xref linkend="functions-json-processing-table"/> for details.
        <!-- TODO: describe PASSING clause once implemented !-->
      </entry>
     </row>
     <row>
      <entry><literal>@</literal></entry>
      <entry>A variable representing the result of path evaluation
      in filter expressions.
      </entry>
     </row>
    </tbody>
   </tgroup>
  </table>

  <table id="type-jsonpath-accessors">
   <title><type>jsonpath</type> Accessors</title>
   <tgroup cols="2">
    <colspec colname="col1" colwidth="1*"/>
    <colspec colname="col2" colwidth="2*"/>
    <thead>
     <row>
      <entry>Accessor Operator</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>
     <row>
      <entry>
       <para>
        <literal>.<replaceable>key</replaceable></literal>
       </para>
       <para>
        <literal>."$<replaceable>varname</replaceable>"</literal>
       </para>
      </entry>
      <entry>
       <para>
        Member accessor that returns an object member with
        the specified key. If the key name matches some named variable
        starting with <literal>$</literal> or does not meet the
        JavaScript rules for an identifier, it must be enclosed in
        double quotes to make it a string literal.
       </para>
      </entry>
     </row>
     <row>
      <entry>
       <para>
        <literal>.*</literal>
       </para>

Title: SQL/JSON Path Variables and Accessors
Summary
SQL/JSON path expressions can include variables, such as $ for the context item, $varname for named variables, and @ for the result of path evaluation, and accessor operators like .key for member access, with specific syntax and usage rules, including the use of double quotes for key names that match variable names or don't meet JavaScript identifier rules.