Permalink
Browse files

Doc changes

  • Loading branch information...
1 parent e68df64 commit 1559ba3607c1b4a3ad3264793a90b18f56ddd4f1 @theirix committed Oct 3, 2012
Showing with 23 additions and 23 deletions.
  1. +1 −1 README.md
  2. +21 −21 doc/json_accessors.md
  3. +1 −1 sql/json_accessors.sql
View
@@ -13,7 +13,7 @@ JSON parsing functions may be written using [PL/V8](http://code.google.com/p/plv
This project provides accessor functions for JSON without using PL/V8.
Usage
----------
+-----
Please consult with [doc/json_accessors.md](doc/json_accessors.md) for a function reference.
View
@@ -43,55 +43,55 @@ Functions usually fails when actual object is not of requested type.
### Scalar extraction functions ###
-#### json_get_object(text, text) -> text
+#### ``json_get_object(text, text) -> text``
Extracts a child JSON object as a string.
Example:
select json_get_text('{"foo": 42, "key":"foobar"]}', 'key') = 'foobar';
-#### json_get_text(text, text) -> text
+#### `json_get_text(text, text) -> text`
Extracts and returns a child JSON text object converted to PG `text`.
Example:
select json_get_text('{"key":"foobar"]}', 'key') = 'foobar';
-#### json_get_boolean(text, text) -> boolean
+#### `json_get_boolean(text, text) -> boolean`
Extracts and returns a child JSON boolean object converted to PG `boolean`.
Example:
select json_get_boolean('{"key": true]}', 'key');
-#### json_get_int(text, text) -> int
+#### `json_get_int(text, text) -> int`
Extracts and returns a child JSON integer object converted to PG `int` (`int4`).
Example:
select json_get_int('{"key": 42]}', 'key') = 42;
-#### json_get_bigint(text, text) -> bigint
+#### `json_get_bigint(text, text) -> bigint`
Extracts and returns a child JSON integer object converted to PG `bigint` (`int8`).
Example:
select json_get_bigint('{"key": 42]}', 'key') = 42;
-#### json_get_numeric(text, text) -> numeric
+#### `json_get_numeric(text, text) -> numeric`
Extracts and returns a child JSON integer object converted to PG `numeric`.
Example:
select json_get_numeric('{"key": 42.99]}', 'key') = 42.99;
-#### json_get_timestamp(text, text) -> timestamp
+#### `json_get_timestamp(text, text) -> timestamp`
Extracts and returns a child JSON text object converted to PG `timestamp without timezone`.
Timestamp format `YYYY-MM-DD HH:MI:SS` is fixed.
@@ -106,7 +106,7 @@ Example:
Functions convert JSON arrays to PostgreSQL arrays.
-#### json_array_to_object_array(text) -> text[]
+#### `json_array_to_object_array(text) -> text[]`
Converts a JSON array of any JSON objects to PG array `text[]`. Each object is represented as a string.
@@ -115,31 +115,31 @@ Example:
select json_array_to_object_array('[{"foo":42}, {"bar":[]}]') = array['{"foo":42}','{"bar":[]}']
-#### json_array_to_text_array(text) -> text[]
+#### `json_array_to_text_array(text) -> text[]`
Converts a JSON array of text objects to PG array `text[]`.
Example:
select json_array_to_text_array('["foo", "bar"]') = array['foo','bar'];
-#### json_array_to_boolean_array(text) -> boolean[]
+#### `json_array_to_boolean_array(text) -> boolean[]`
Converts a JSON array of boolean objects to PG array `boolean[]`.
-#### json_array_to_int_array(text) -> int[]
+#### `json_array_to_int_array(text) -> int[]`
Converts a JSON array of integer objects to PG array `int[]` (`int4[]`)
-#### json_array_to_bigint_array(text) -> bigint[]
+#### `json_array_to_bigint_array(text) -> bigint[]`
Converts a JSON array of integer objects to PG array `bigint[]` (`int8[]`)
-#### json_array_to_numeric_array(text) -> numeric[]
+#### `json_array_to_numeric_array(text) -> numeric[]`
Converts a JSON array of integer objects to PG array `numeric[]`.
-#### json_array_to_timestamp_array(text) -> timestamp without time zone[]
+#### `json_array_to_timestamp_array(text) -> timestamp without time zone[]`
Converts a JSON array of text objects to PG array `timestamp[]` without time zones.
Time format is the same.
@@ -151,39 +151,39 @@ Shortcut functions to directly extract an array by the key.
Could be emulated by `json_get_object` and array convertor functions.
Array is referenced in a JSON expression by a key.
-#### json_get_object_array(text, text) -> text[]
+#### `json_get_object_array(text, text) -> text[]`
Extract and converts a JSON array of any JSON objects to PG array `text[]`. JSON objects are represented as a text.
Example:
select json_get_object_array('{"key" : [{"foo":42}, {"bar":[]}]}', 'key') = array['{"foo":42}','{"bar":[]}'];
-#### json_get_text_array(text, text) -> text[]
+#### `json_get_text_array(text, text) -> text[]`
Extract and converts a JSON array of text objects to PG array `text[]`.
Example:
select json_get_text_array('{"foo":"qq", "bar": ["baz1", "baz2", "baz3"]}', 'bar') = array['baz1','baz2','baz3'];
-#### json_get_boolean_array(text, text) -> boolean[]
+#### `json_get_boolean_array(text, text) -> boolean[]`
Extract and converts a JSON array of boolean objects to PG array `boolean[]`.
-#### json_get_int_array(text, text) -> int[]
+#### `json_get_int_array(text, text) -> int[]`
Extract and converts a JSON array of integer objects to PG array `int[]` (`int4[]`)
-#### json_get_bigint_array(text, text) -> bigint[]
+#### `json_get_bigint_array(text, text) -> bigint[]`
Extract and converts a JSON array of integer objects to PG array `bigint[]` (`int8[]`)
-#### json_get_numeric_array(text, text) -> numeric[]
+#### `json_get_numeric_array(text, text) -> numeric[]`
Extract and converts a JSON array of integer objects to PG array `numeric[]`.
-#### json_get_timestamp_array(text, text) -> timestamp without time zone[]
+#### `json_get_timestamp_array(text, text) -> timestamp without time zone[]`
Extract and converts a JSON array of text objects to PG array `timestamp[]` without time zones.
Time format is the same.
@@ -1,4 +1,4 @@
-/* json_accessors--1.3.sql */
+/* json_accessors.sql */
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "create extension json_accessors" to load this file. \quit

0 comments on commit 1559ba3

Please sign in to comment.