Re: PATCH: Implement value_to_json for single-datum conversion

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: PATCH: Implement value_to_json for single-datum conversion
Дата
Msg-id 21962.1344833311@sss.pgh.pa.us
обсуждение исходный текст
Ответ на PATCH: Implement value_to_json for single-datum conversion  (Craig Ringer <ringerc@ringerc.id.au>)
Ответы Re: PATCH: Implement value_to_json for single-datum conversion
Список pgsql-hackers
Craig Ringer <ringerc@ringerc.id.au> writes:
> Whenever I try to work with the new json types I trip over the lack of a 
> function to escape text to json. The attached patch against master 
> provides one by exposing the existing datum_to_json function to SQL.
> ...
> This feels basic enough that I'm wondering if there's a reason it wasn't 
> included from the start,

There actually was a previous thread about this:
http://archives.postgresql.org/pgsql-hackers/2012-05/msg00001.php
Note in particular Andrew's comment:
Second, RFC 4627 is absolutely clear: a valid JSON value canonly be an object or an array, so this thing about
convertingarbitrarydatum values to JSON is a fantasy. If anything, weshould adjust the JSON input routines to disallow
anythingelse,rather than start to output what is not valid JSON.
 

It's possible he's misread the spec, but I think we ought to tread very
carefully before adding "obvious" conversions we might regret later.

> Please consider this for the 9.2 branch as well as to HEAD, as IMO it's 
> very important for basic usability of the json functionality. It applies 
> to 9.2 fine and passes "make check". I know it's late in the game,

It's several months too late for feature additions to 9.2, especially
ones that would require an initdb to install.  We can look at this for
9.3, but I'm still worried about the spec-compliance question.
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: PATCH: Implement value_to_json for single-datum conversion
Следующее
От: Craig Ringer
Дата:
Сообщение: Re: PATCH: Implement value_to_json for single-datum conversion