Skip site navigation (1) Skip section navigation (2)

Another swing at JSON

From: Joseph Adams <joeyadams3(dot)14159(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Another swing at JSON
Date: 2011-03-28 17:21:20
Message-ID: BANLkTik1k6bdafEzi7xvnB8vy+hcv4iD1Q@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Attached is a patch that adds a 'json' contrib module.  Although we
may want a built-in JSON data type in the near future, making it a
module (for the time being) has a couple advantages:

 * Installable on current and previous versions of PostgreSQL.  The
json module supports PostgreSQL 8.4.0 and up.
 * Easier to maintain.  json.sql.in is easy to work on,
src/include/catalog/pg_proc.h is not.

Currently, there are no functions for converting to/from PostgreSQL
values or getting/setting sub-values (e.g. JSONPath).  However, I did
adapt the json_stringify function written by Itagaki Takahiro in his
patch ( http://archives.postgresql.org/pgsql-hackers/2010-09/msg01200.php
).

JSON datums are stored internally as condensed JSON text.  By
"condensed", I mean that whitespace is removed, and escapes are
converted to characters when it's possible and efficient to do so.
Although a binary internal format would be more size-efficient in
theory, condensed JSON text is pretty efficient, too.  Internally, the
implementation does not construct any parse trees, which should
provide a major performance advantage.

Almost all of the code has been rewritten since my original patch (
http://archives.postgresql.org/pgsql-hackers/2010-07/msg01215.php ).
Some will be happy to know that the new code doesn't have any gotos
:-)


Joey Adams

Attachment: add-json-contrib-module-20110328.patch
Description: text/x-patch (76.3 KB)

Responses

pgsql-hackers by date

Next:From: Robert HaasDate: 2011-03-28 17:48:26
Subject: Re: Another swing at JSON
Previous:From: Simon RiggsDate: 2011-03-28 17:13:16
Subject: Re: Additional options for Sync Replication

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group