From: | Benedikt Grundmann <bgrundmann(at)janestreet(dot)com> |
---|---|
To: | Claes Jakobsson <claes(at)surfar(dot)nu> |
Cc: | "David E(dot) Wheeler" <david(at)kineticode(dot)com>, Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr>, Merlin Moncure <mmoncure(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Magnus Hagander <magnus(at)hagander(dot)net>, Jan Urbański <wulczer(at)wulczer(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Joey Adams <joeyadams3(dot)14159(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>, Jan Wieck <janwieck(at)yahoo(dot)com> |
Subject: | Re: JSON for PG 9.2 |
Date: | 2011-12-22 08:21:34 |
Message-ID: | 20111222082133.GO7768@ldn-qws-004.delacy.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Let me mention another lightweight data-interchange format.
At http://www.janestreet.com we have developed a small c module to deal
with S-expressions (sexp) as a way to store arbitrary data. As we write
most of our code in OCaml sexps are a natural way for us to store data.
http://hg.ocaml.info/release/sexplib/ provides automatic ways to convert
"any" ocaml value into a sexp).
The extension is still pretty new but we use it successfully on a daily
basis. After we have upgraded to 9.x we will pack it as an extension
and releast it opensource.
API wise the module at the moment offers the following:
sexp_validate(text) returns boolean
Validate that the passed in text is a valid s expression.
create domain sexp as text check (sexp_validate(value));
BTW: It is a PITA that arrays of domains are not valid types.
And several functions to manipulate take apart sexp's or modify sexp's
using a path into the sexp (similar to what xpath does for xml).
Such as:
sexp_get(sexp, text) returns sexp
Get the sub sexp of sexp identified by the path.
Returns NULL if path is not a valid path in sexp.
Example:
path=.a space.b.[1].x
((ignore this) ("a space" ((b (0 ((also ignored) (x "The Value")) )) )))
-> "The Value"
And sexp_get_atom(sexp, text) returns text
Get the sub atom of sexp identified by the path.
Returns NULL if path is not a valid path in sexp or
does not identify an atom.
Example:
path=.a space.b.[1].x
((ignore this) ("a space" ((b (0 ((also ignored) (x "The Value")) )) )))
^^^^^^^^^
-> The Value
Cheers,
Bene
On 20/12/11 19:39, Claes Jakobsson wrote:
> On Dec 20, 2011, at 12:39 AM, David E. Wheeler wrote:
> > On Dec 19, 2011, at 2:49 AM, Dimitri Fontaine wrote:
> >
> >> My understanding is that JSON is a subset of ECMAscript
> >
> > Well, no, JSON is formally “a lightweight data-interchange format.” It’s derived from JavaScript syntax, but it is not a programming language, so I wouldn’t say it was accurate to describe it as a subset of JS or ECMAScript.
> >
> > http://json.org/
>
> Are people explicitly asking for a) *JSON* datatype or b) a type that lets you store arbitrary complex semi-untyped data structures?
>
> if b) then this might get a lot more interesting
>
> Cheers,
> Claes
> --
> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Leonardo Francalanci | 2011-12-22 08:40:50 | Re: Page Checksums |
Previous Message | Johann 'Myrkraverk' Oskarsson | 2011-12-22 08:07:45 | Re: Typed hstore proposal |