diff options
| author | Andrew Dunstan <andrew@dunslane.net> | 2014-12-12 09:00:43 -0500 |
|---|---|---|
| committer | Andrew Dunstan <andrew@dunslane.net> | 2014-12-12 09:00:43 -0500 |
| commit | 237a8824430c607fce1eafde0c625744d50a455c (patch) | |
| tree | e8f0fcf9806697ef2754e83b24815a2c97af363d /doc/src | |
| parent | b1332e98c441b40300670f55a4303bf69cd8b226 (diff) | |
Add json_strip_nulls and jsonb_strip_nulls functions.
The functions remove object fields, including in nested objects, that
have null as a value. In certain cases this can lead to considerably
smaller datums, with no loss of semantic information.
Andrew Dunstan, reviewed by Pavel Stehule.
Diffstat (limited to 'doc/src')
| -rw-r--r-- | doc/src/sgml/func.sgml | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index c3b61269438..da138e1fee7 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -10716,6 +10716,19 @@ table2-mapping </programlisting> </entry> </row> + <row> + <entry><para><literal>json_strip_nulls(from_json json)</literal> + </para><para><literal>jsonb_strip_nulls(from_json jsonb)</literal> + </para></entry> + <entry><para><type>json</type></para><para><type>jsonb</type></para></entry> + <entry> + Returns <replaceable>from_json</replaceable> + with all object fields that have null values omitted. Other null values + are untouched. + </entry> + <entry><literal>json_strip_nulls('[{"f1":1,"f2":null},2,null,3]')</literal></entry> + <entry><literal>[{"f1":1},2,null,3]</literal></entry> + </row> </tbody> </tgroup> </table> @@ -10752,6 +10765,16 @@ table2-mapping </para> </note> + <note> + <para> + If the argument to <literal>json_strip_nulls</> contains duplicate + field names in any object, the result could be semantically somewhat + different, depending on the order in which they occur. This is not an + issue for <literal>jsonb_strip_nulls</> since jsonb values never have + duplicate object field names. + </para> + </note> + <para> See also <xref linkend="functions-aggregate"> for the aggregate function <function>json_agg</function> which aggregates record |
