On 08/13/2012 01:55 PM, Tom Lane wrote:
Actually, given the above, what did you need value_to_json(text) for at
all? Wouldn't value_to_json(anyelement) have covered it?
Usability. Without the version accepting text an explicit cast to text
is required to disambiguate a literal argument like
Craig Ringer writes:
> As for the value_to_json crashing, works for me:
> postgres=# SELECT value_to_json(42);
> value_to_json
> ---
> 42
> (1 row)
Oh, right, because there actually is support for anyelement in the
underlying C function. There is not in the quote_literal case.
On 08/13/2012 12:48 PM, Tom Lane wrote:
There actually was a previous thread about this:
http://archives.postgresql.org/pgsql-hackers/2012-05/msg1.php
Note in particular Andrew's comment:
Second, RFC 4627 is absolutely clear: a valid JSON value can
only be an object or an arr
Craig Ringer 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'
Craig Ringer writes:
> OK, opr_sanity was failing because I added the value_to_json(text) alias
> to ensure that:
>value_to_json('some_literal')
> worked, following the same approach as quote_literal(anyelement) and
> quote_literal(text). That should be reasonable, right?
No, it isn't. W
OK, opr_sanity was failing because I added the value_to_json(text) alias
to ensure that:
value_to_json('some_literal')
worked, following the same approach as quote_literal(anyelement) and
quote_literal(text). That should be reasonable, right? The comments on
the affected check in opr_sanity
Whoops. It actually looks like the posted patch muffed up opr_sanity
checks. I'm totally new to pg_proc.h wrangling so I'm not sure why yet,
looking.
Sorry, not sure how I missed that. I'll follow up shortly.
--
Craig Ringer
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.or
Hi all
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.
I've used the name value_to_json, but I'm not sure it's necessarily the
right