1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Built-in JSON data type.

Like the XML data type, we simply store JSON data as text, after checking
that it is valid.  More complex operations such as canonicalization and
comparison may come later, but this is enough for not.

There are a few open issues here, such as whether we should attempt to
detect UTF-8 surrogate pairs represented as \uXXXX\uYYYY, but this gets
the basic framework in place.
This commit is contained in:
Robert Haas
2012-01-31 11:48:23 -05:00
parent 4c6cedd1b0
commit 5384a73f98
11 changed files with 1059 additions and 5 deletions

View File

@ -269,6 +269,12 @@
<entry></entry>
<entry>XML data</entry>
</row>
<row>
<entry><type>json</type></entry>
<entry></entry>
<entry>JSON data</entry>
</row>
</tbody>
</tgroup>
</table>
@ -4169,6 +4175,32 @@ SET xmloption TO { DOCUMENT | CONTENT };
</sect2>
</sect1>
<sect1 id="datatype-json">
<title><acronym>JSON</> Type</title>
<indexterm zone="datatype-json">
<primary>JSON</primary>
</indexterm>
<para>
The <type>json</type> data type can be used to store JSON data. Such
data can also be stored as <type>text</type>, but the
<type>json</type> data type has the advantage of checking that each
stored value is a valid JSON value.
</para>
<para>
<productname>PostgreSQL</productname> allows only one server encoding
per database. It is therefore not possible for JSON to conform rigidly
to the specification unless the server encoding is UTF-8. Attempts to
directly include characters which cannot be represented in the server
encoding will fail; conversely, characters which can be represented in
the server encoding but not in UTF-8 will be allowed.
<literal>\uXXXX</literal> escapes are allowed regardless of the server
encoding, and are checked only for syntactic correctness.
</para>
</sect1>
&array;
&rowtypes;