From: Tom Lane <tgl@sss.pgh.pa.us>
To: bouda@edookit.com
Cc: pgsql-bugs@postgresql.org
Cc: pgsql-hackers@postgresql.org
Subject: Re: BUG #12070: hstore extension: hstore_to_json_loose produces invalid JSON
Date: Wed, 26 Nov 2014 11:19:49 -0500
Message-ID: <15817.1417018789@sss.pgh.pa.us> (raw)
In-Reply-To: <20141126081059.15510.5034@wrigleys.postgresql.org>
References: <20141126081059.15510.5034@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
bouda@edookit.com writes:
> The hstore_to_json_loose(hstore) produces an invalid JSON in the following
> case:
> SELECT hstore_to_json_loose(hstore(ARRAY ['name'], ARRAY ['1.'] :: TEXT
> []))
> Output: {"name": 1.}
> The actual output is indeed incorrect as JSON does not permit `1.` - it must
> be a string.
Yeah. The problem seems to be the ad-hoc (I'm being polite) code in
hstore_to_json_loose to decide whether a string should be treated as a
number. It does much more work than it needs to, and fails to have any
tight connection to the JSON syntax rules for numbers.
Offhand, it seems like the nicest fix would be if the core json code
exposed a function that would say whether a string matches the JSON
number syntax. Does that functionality already exist someplace,
or is it too deeply buried in the JSON parser guts?
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, bouda@edookit.com, pgsql-hackers@postgresql.org
Subject: Re: BUG #12070: hstore extension: hstore_to_json_loose produces invalid JSON
In-Reply-To: <15817.1417018789@sss.pgh.pa.us>
References: <20141126081059.15510.5034@wrigleys.postgresql.org> <15817.1417018789@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox