Re: JSON for PG 9.2

Abhijit Menon-Sen <ams@toroid.org>

From: Abhijit Menon-Sen <ams@toroid.org>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Joey Adams <joeyadams3.14159@gmail.com>, Peter Eisentraut <peter_e@gmx.net>, Andrew Dunstan <andrew@dunslane.net>, Jeff Janes <jeff.janes@gmail.com>, Pavel Stehule <pavel.stehule@gmail.com>, "David E. Wheeler" <david@kineticode.com>, Claes Jakobsson <claes@surfar.nu>, Dimitri Fontaine <dimitri@2ndquadrant.fr>, Merlin Moncure <mmoncure@gmail.com>, Magnus Hagander <magnus@hagander.net>, Jan Urbański <wulczer@wulczer.org>, Simon Riggs <simon@2ndquadrant.com>, Bruce Momjian <bruce@momjian.us>, pgsql-hackers@postgresql.org, Jan Wieck <janwieck@yahoo.com>
Date: 2012-02-02T14:51:26Z
Lists: pgsql-hackers
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