diff options
| author | Andrew Dunstan <andrew@dunslane.net> | 2015-05-12 15:52:45 -0400 |
|---|---|---|
| committer | Andrew Dunstan <andrew@dunslane.net> | 2015-05-12 15:52:45 -0400 |
| commit | c6947010ceb42143d9f047c65c1eac2b38928ab7 (patch) | |
| tree | 038277e46347e8b1edf953f99289ac03950248ea /doc/src | |
| parent | afb9249d06f47d7a6d4a89fea0c3625fe43c5a5d (diff) | |
Additional functions and operators for jsonb
jsonb_pretty(jsonb) produces nicely indented json output.
jsonb || jsonb concatenates two jsonb values.
jsonb - text removes a key and its associated value from the json
jsonb - int removes the designated array element
jsonb - text[] removes a key and associated value or array element at
the designated path
jsonb_replace(jsonb,text[],jsonb) replaces the array element designated
by the path or the value associated with the key designated by the path
with the given value.
Original work by Dmitry Dolgov, adapted and reworked for PostgreSQL core
by Andrew Dunstan, reviewed and tidied up by Petr Jelinek.
Diffstat (limited to 'doc/src')
| -rw-r--r-- | doc/src/sgml/func.sgml | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index bf8d72e9ff9..b1e94d7b9e2 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -10293,6 +10293,32 @@ table2-mapping <entry>Do all of these key/element <emphasis>strings</emphasis> exist?</entry> <entry><literal>'["a", "b"]'::jsonb ?& array['a', 'b']</literal></entry> </row> + <row> + <entry><literal>||</literal></entry> + <entry><type>jsonb</type></entry> + <entry>Concatentate two jsonb values into a new jsonb value</entry> + <entry><literal>'["a", "b"]'::jsonb || '["c", "d"]'::jsonb</literal></entry> + </row> + <row> + <entry><literal>-</literal></entry> + <entry><type>text</type></entry> + <entry>Delete the field with a specified key, or element with this + value</entry> + <entry><literal>'{"a": "b"}'::jsonb - 'a' </literal></entry> + </row> + <row> + <entry><literal>-</literal></entry> + <entry><type>integer</type></entry> + <entry>Delete the field or element with specified index (Negative + integers count from the end)</entry> + <entry><literal>'["a", "b"]'::jsonb - 1 </literal></entry> + </row> + <row> + <entry><literal>-</literal></entry> + <entry><type>text[]</type></entry> + <entry>Delete the field or element with specified path</entry> + <entry><literal>'["a", {"b":1}]'::jsonb - '{1,b}'::text[] </literal></entry> + </row> </tbody> </tgroup> </table> @@ -10803,6 +10829,42 @@ table2-mapping <entry><literal>json_strip_nulls('[{"f1":1,"f2":null},2,null,3]')</literal></entry> <entry><literal>[{"f1":1},2,null,3]</literal></entry> </row> + <row> + <entry><para><literal>jsonb_replace(target jsonb, path text[], replacement jsonb)</literal> + </para></entry> + <entry><para><type>jsonb</type></para></entry> + <entry> + Returns <replaceable>target</replaceable> + with the section designated by <replaceable>path</replaceable> + replaced by <replaceable>replacement</replaceable>. + </entry> + <entry><literal>jsonb_replace('[{"f1":1,"f2":null},2,null,3]', '{0,f1}','[2,3,4]')</literal></entry> + <entry><literal>[{"f1":[2,3,4],"f2":null},2,null,3]</literal> + </entry> + </row> + <row> + <entry><para><literal>jsonb_pretty(from_json jsonb)</literal> + </para></entry> + <entry><para><type>text</type></para></entry> + <entry> + Returns <replaceable>from_json</replaceable> + as indented json text. + </entry> + <entry><literal>jsonb_pretty('[{"f1":1,"f2":null},2,null,3]')</literal></entry> + <entry> +<programlisting> + [ + { + "f1": 1, + "f2": null + }, + 2, + null, + 3 + ] +</programlisting> + </entry> + </row> </tbody> </tgroup> </table> |
