This Release
pg-json 0.0.1
A json data type and related functions
This library contains a json datatype and some functionality for working with it
Released By
The MIT (X11) License
Special Files


pg-json 0.0.1



pg-json - JSON support for PostgreSQL

This is a postgres extension which provides a JSON type and rudimentary opertators 
and functions on them. It uses the Jansson JSON library ( 
which you need installed and findable by your linker.


$ make USE_PGXS=1
$ sudo make install USE_PGXS=1

It'll install a pg-json.sql in your postgres which you might have to load for your database also.

This module provides a 'json' datatype. It's more or less just a bytea which assumes that 
the data is UTF-8 encoded. When created it validates that it's parseable as JSON.


* json_get_value(data json, path text) : text

  In the json value "data" returns the element for a given "path". The "path" is a combination of keys (separated by .) and array indices (specified in []). For example in the structure '{"foo": {"bar": "quax"}}' the path to the value "quax" would be "".

  More examples

    'foo[3][2]' from '{"foo":[1,2,3, [3,4,5]]}' returns '5'
    '[2].orz' from '{"foo": {"bar": [{}, {}, {"orz", "herp"}]}}' returns 'herp'
* json_equals(this json, that json) : boolean

  Checks if the value "this" is equal to "that". This definition of equality (stolen from Jansson documentation) sums it up

    Two JSON values can be equal not only if they are exactly the same value, but also if they have equal “contents”:

    - Two integer or real values are equal if their contained numeric values are equal. An integer value is never equal to a real value, though.
    - Two strings are equal if their contained UTF-8 strings are equal, byte by byte. Unicode comparison algorithms are not implemented.
    - Two arrays are equal if they have the same number of elements and each element in the first array is equal to the corresponding element in the second array.
    - Two objects are equal if they have exactly the same keys and the value for each key in the first object is equal to the value of the corresponding key in the second object.
    - Two true, false or null values have no “contents”, so they are equal if their types are equal.
* json_not_equals(this json, that json) : boolean

  The inverse of json_equals().


* json ~ text

  This is the operator version of json_get_value

* json = json

  This is the operator version of json_equals
* json != json

  This is the operator version of json_not_equals