From: | Peter van Hardenberg <pvh(at)pvh(dot)ca> |
---|---|
To: | Josh Berkus <josh(at)agliodbs(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org, Joseph Adams <joeyadams3(dot)14159(at)gmail(dot)com> |
Subject: | Re: JSON for PG 9.2 |
Date: | 2011-12-13 00:51:54 |
Message-ID: | CAAcg=kUJDjx4QQoUt3Ebgj-mSYp_uGj90aR7x=fQ8ez2DO-o8Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
We reached out to Joseph to see if we could help sponsor the project,
but never really heard back from him.
Because we haven't heard from him in a while we've been using PL/V8 to
validate a JSON datatype simulated by a DOMAIN with a simple
acceptance function. (See below.) This is not ideally performant but
thanks to V8's JIT the JSON parser is actually reasonably good.
I think releasing something simple and non-performant with reasonable
semantics would be the best next step. If it were up to me, I'd
probably even try to just land PL/V8 as PL/JavaScript for 9.2 if the
crash bugs and deal breakers can be sifted out.
PL/V8 is fast, it's sandboxed, and while it doesn't provide GIN or
GIST operators out of the box, maybe those could be motivated by its
inclusion.
Andrew, you've been down in the guts here, what do you think?
-pvh
(Code sample.)
create or replace function valid_json(json text)
returns bool as $$
try { JSON.parse(json); return true }
catch(e) { return false}
$$ LANGUAGE plv8 IMMUTABLE STRICT;
select valid_json('{"key": "value"}'), valid_json('lol');
valid_json | t
valid_json | f
Time: 0.283 ms
create domain json
as text check(valid_json(VALUE));
create table jsononly(data json);
insert into jsononly values 'lol';
ERROR: syntax error at or near "'lol'"
LINE 1: insert into jsononly values 'lol';
insert into jsononly
values ('{"ok": true}');
INSERT 0 1
-p
On Mon, Dec 12, 2011 at 1:34 PM, Josh Berkus <josh(at)agliodbs(dot)com> wrote:
> Bruce,
>
> I thought that Joseph Adams was still working on this, sponsored by
> Heroku. Joseph?
>
>
> --
> Josh Berkus
> PostgreSQL Experts Inc.
> http://pgexperts.com
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
--
Peter van Hardenberg
San Francisco, California
"Everything was beautiful, and nothing hurt." -- Kurt Vonnegut
From | Date | Subject | |
---|---|---|---|
Next Message | David E. Wheeler | 2011-12-13 01:05:21 | Re: WIP: URI connection string support for libpq |
Previous Message | Tom Lane | 2011-12-13 00:27:39 | Re: Is anybody actually using XLR_BKP_REMOVABLE? |