summaryrefslogtreecommitdiff
path: root/doc/src/sgml/hstore.sgml
diff options
context:
space:
mode:
authorAndrew Dunstan2013-03-10 21:35:36 +0000
committerAndrew Dunstan2013-03-10 21:35:36 +0000
commit38fb4d978c5bfc377ef979e2595e3472744a3b05 (patch)
treeaf34c36f949f83c6527921cdbac1892c22719ac5 /doc/src/sgml/hstore.sgml
parentdd28c410f77e415ce104cb42bf52c4a5457085da (diff)
JSON generation improvements.
This adds the following: json_agg(anyrecord) -> json to_json(any) -> json hstore_to_json(hstore) -> json (also used as a cast) hstore_to_json_loose(hstore) -> json The last provides heuristic treatment of numbers and booleans. Also, in json generation, if any non-builtin type has a cast to json, that function is used instead of the type's output function. Andrew Dunstan, reviewed by Steve Singer. Catalog version bumped.
Diffstat (limited to 'doc/src/sgml/hstore.sgml')
-rw-r--r--doc/src/sgml/hstore.sgml23
1 files changed, 23 insertions, 0 deletions
diff --git a/doc/src/sgml/hstore.sgml b/doc/src/sgml/hstore.sgml
index a03f926f0b7..85e7efcedc1 100644
--- a/doc/src/sgml/hstore.sgml
+++ b/doc/src/sgml/hstore.sgml
@@ -323,6 +323,22 @@ b
</row>
<row>
+ <entry><function>hstore_to_json(hstore)</function></entry>
+ <entry><type>json</type></entry>
+ <entry>get <type>hstore</type> as a json value</entry>
+ <entry><literal>hstore_to_json('"a key"=&gt;1, b=&gt;t, c=&gt;null, d=&gt;12345, e=&gt;012345, f=&gt;1.234, g=&gt;2.345e+4')</literal></entry>
+ <entry><literal>{"a key": "1", "b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4"}</literal></entry>
+ </row>
+
+ <row>
+ <entry><function>hstore_to_json_loose(hstore)</function></entry>
+ <entry><type>json</type></entry>
+ <entry>get <type>hstore</type> as a json value, but attempting to distinguish numerical and boolean values so they are unquoted in the json</entry>
+ <entry><literal>hstore_to_json('"a key"=&gt;1, b=&gt;t, c=&gt;null, d=&gt;12345, e=&gt;012345, f=&gt;1.234, g=&gt;2.345e+4')</literal></entry>
+ <entry><literal>{"a key": 1, "b": true, "c": null, "d": 12345, "e": "012345", "f": 1.234, "g": 2.345e+4}</literal></entry>
+ </row>
+
+ <row>
<entry><function>slice(hstore, text[])</function></entry>
<entry><type>hstore</type></entry>
<entry>extract a subset of an <type>hstore</></entry>
@@ -398,6 +414,13 @@ b
<note>
<para>
+ The function <function>hstore_to_json</function> is used when an <type>hstore</type>
+ value is cast to <type>json</type>.
+ </para>
+ </note>
+
+ <note>
+ <para>
The function <function>populate_record</function> is actually declared
with <type>anyelement</>, not <type>record</>, as its first argument,
but it will reject non-record types with a run-time error.