At 2012-02-02 08:54:32 -0500, robertmhaas@gmail.com wrote:
>
> Someone is eventually going to propose a function with a name like
> json_to_string() which, when given this JSON object, returns a
> three-character string with the PostgreSQL text type.
Ah, that's the bit I was missing. I thought you were talking about an
immediate error condition.
> That's useful and I support it.
Agreed. Also, now I understand that you are saying that json_to_string()
(json_string_to_text?) would fail if the result couldn't be represented
as a text in the current encoding, and that's sensible as well. I had
misunderstood "is going to admit of a number of error…" in your mail.
As for surrogate pairs, just to be clear, what I was proposing earlier
in the thread was to change json.c:json_lex_string() to detect errors
(e.g. only one half of a surrogate pair, which is the commonest error
I've encountered in the wild) and reject such strings.
Thanks for the explanation.
-- ams