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

From: Hannu Krosing <hannu(at)2ndQuadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, 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 06:07:40
Message-ID: 1336198060.19151.232.camel@hvost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 2012-05-04 at 16:12 -0400, Tom Lane wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> > On Fri, May 4, 2012 at 3:49 PM, Hannu Krosing <hannu(at)krosing(dot)net> 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.

> It is possible that that can be made to work, but it's a research
> project, not something to be crammed into 9.2 at the last possible
> minute. In any case, I really dislike the idea that array_to_json
> and row_to_json would contain two entirely different behaviors.
> Leave the extensibility ideas for a future to_json() function.

I did not mean that array_to_json and row_to_json would be different
than the generic to_json, just that they would be thin wrappers around
the to_json function which check that the arguments are of the correct
types for casting to "JSON text".

They need to recurse to each other and generic to_json anyway.

> regards, tom lane

--
-------
Hannu Krosing
PostgreSQL Unlimited Scalability and Performance Consultant
2ndQuadrant Nordic
PG Admin Book: http://www.2ndQuadrant.com/books/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2012-05-05 08:44:08 Re: Documentation for temp_file_limit
Previous Message Hannu Krosing 2012-05-05 06:06:38 Re: JSON in 9.2 - Could we have just one to_json() function instead of two separate versions ?