From: | Hannu Krosing <hannu(at)2ndQuadrant(dot)com> |
---|---|
To: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Merlin Moncure <mmoncure(at)gmail(dot)com> |
Subject: | Re: JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ? |
Date: | 2012-05-05 13:27:14 |
Message-ID: | 1336224434.19151.238.camel@hvost |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sat, 2012-05-05 at 12:16 +0300, Peter Eisentraut wrote:
> On fre, 2012-05-04 at 15:59 -0400, Robert Haas wrote:
> > > Can we at least have the xxx_to_json() functions try cast to json
> > first
> > > and fall back to text if the cast fails.
> >
> > I think the idea that you can involve the casting machinery in this is
> > misguided. sometextval::json has got to mean that sometextval is
> > expected to be in the form of a syntactically correct JSON value - and
> > NOT that we wrap it in a JSON string.
>
> I think it's only wrong if you try casting first and fall back to text.
> Otherwise it could work, if the set of all json casts is defined
> consistently.
Currently the default "cast" for non-number, non-bool, not-already-json,
non-null values is to wrap text representation in double quotes.
So casting first then fall back to _quoted_ text is wrong only for those
types which have a very ugly text representation :)
--
-------
Hannu Krosing
PostgreSQL Unlimited Scalability and Performance Consultant
2ndQuadrant Nordic
PG Admin Book: http://www.2ndQuadrant.com/books/
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2012-05-05 15:26:32 | Re: remove dead ports? |
Previous Message | Bruce Momjian | 2012-05-05 13:03:38 | Re: Uppercase tab completion keywords in psql? |