Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XtfJt-0003wA-LP for pgsql-bugs@arkaria.postgresql.org; Wed, 26 Nov 2014 16:19:57 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XtfJt-0003m9-5o for pgsql-bugs@arkaria.postgresql.org; Wed, 26 Nov 2014 16:19:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XtfJs-0003kV-3J; Wed, 26 Nov 2014 16:19:56 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XtfJo-0001Id-Ks; Wed, 26 Nov 2014 16:19:55 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id sAQGJnKH015818; Wed, 26 Nov 2014 11:19:49 -0500 From: Tom Lane To: bouda@edookit.com cc: pgsql-bugs@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: BUG #12070: hstore extension: hstore_to_json_loose produces invalid JSON In-reply-to: <20141126081059.15510.5034@wrigleys.postgresql.org> References: <20141126081059.15510.5034@wrigleys.postgresql.org> Comments: In-reply-to bouda@edookit.com message dated "Wed, 26 Nov 2014 08:10:59 +0000" Date: Wed, 26 Nov 2014 11:19:49 -0500 Message-ID: <15817.1417018789@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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