Re: JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ? - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?
Date
Msg-id 1336209194.13755.10.camel@vanquo.pezone.net
Whole thread Raw
In response to Re: JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
On fre, 2012-05-04 at 12:30 -0400, Andrew Dunstan wrote:
> Yeah, what I've been thinking about in conjunction with similar
> problems is some sort of type registry, so that we could code for
> non-builtin types in certain cases.

It certainly seems to come up a lot, but I'm not sure whether the two
main use cases -- mapping types into languages, and mapping types into
JSON (or XML, as an alternative) -- would have the same solution.  A
third use case that could be included as well is changing the main text
or binary format of a type (e.g., what datestyle does).  So instead of
having just a hard-coded set of typinput/typoutput, typrecv/typsend,
you'd have a catalog of

(context, inputfunc, outputfunc)

and the context would a language, something json or xml, or a
user-settable value.  This could become quite complicated, but it sure
could solve a lot of issues in one go.




pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?
Next
From: Peter Eisentraut
Date:
Subject: Re: JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?