Re: JSON for PG 9.2 - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: JSON for PG 9.2
Date
Msg-id 4F284BEE.5020903@dunslane.net
Whole thread Raw
In response to Re: JSON for PG 9.2  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-hackers

On 01/31/2012 02:49 PM, Merlin Moncure wrote:
> The major hole in functionality I see for heavy json users is the 
> reverse; how do you get json back into the database? With xml, at 
> least you could (ab)use xpath for that...with json you have to rely on 
> add-on support and/or ad hoc string parsing (that is, unless I'm 
> missing something -- I just noted Robert's commit of the JSON type). 
> since we can do: select array_to_json(array(select foo from foo)); it 
> seems natural to be able to want do do something like: WITH foos AS 
> (SELECT a_json_var::foo[] AS f) ( INSERT INTO foo SELECT (f).* FROM 
> foos ); Of course, you'd have to have non-anonymous (that is, defined 
> with CREATE TYPE AS) types defined to receive all the data, but that's 
> not so bad. Also, could xxx_to_json be hypothetically executed via 
> casts? e.g. select array(select foo from foo)::json;

At some stage there will possibly be some json-processing (as opposed to 
json-producing) functions, but not in 9.2 - it's too late for that. 
Until then there is PLV8: see 
<http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html> 
for example. Or someone could write an extension.

cheers

andrew




pgsql-hackers by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: [GENERAL] pg_dump -s dumps data?!
Next
From: Andrew Dunstan
Date:
Subject: Re: [GENERAL] pg_dump -s dumps data?!