Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bs85j-0006QZ-Pm for pgsql-bugs@arkaria.postgresql.org; Thu, 06 Oct 2016 12:48:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bs85j-0003lS-3E for pgsql-bugs@arkaria.postgresql.org; Thu, 06 Oct 2016 12:48:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bs855-000334-EV for pgsql-bugs@postgresql.org; Thu, 06 Oct 2016 12:47:23 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bs851-0005sh-GL for pgsql-bugs@postgresql.org; Thu, 06 Oct 2016 12:47:22 +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 u96ClHgV028894; Thu, 6 Oct 2016 08:47:17 -0400 From: Tom Lane To: Kouber Saparev cc: Vitaly Burovoy , pgsql-bugs@postgresql.org Subject: Re: BUG #14354: Wrong interpretation of JSON 'null' In-reply-to: References: <20161005101259.27234.41202@wrigleys.postgresql.org> Comments: In-reply-to Kouber Saparev message dated "Thu, 06 Oct 2016 10:29:23 +0300" Date: Thu, 06 Oct 2016 08:47:16 -0400 Message-ID: <28893.1475758036@sss.pgh.pa.us> X-Pg-Spam-Score: -4.5 (----) 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 Kouber Saparev writes: > Okay, I also saw in the source code that it is looking for an _json-object_ > (whatever that means) and is throwing that error otherwise. The thing is - > in my perception the string 'null' , being valid json(b), should also be > treated as valid _json-object_, isn't it? No. A JSON "object" is something with field names and values, like a Perl hash. JSON also has scalars and arrays; those are JSON values, but not JSON objects. 'null' is a scalar, I think, although for some purposes it might be better to view it as a fourth primitive kind of JSON value. jsonb_each_text() needs to work on a JSON object because otherwise its return convention of returning a set of field names and values makes no sense. What would you imagine jsonb_each_text('2'::jsonb) ought to do? Similarly, there's not really any sensible interpretation of jsonb_each_text('null'::jsonb). > ... I felt its an > inconsistency in PostgreSQL itself. The distinction between objects and other kinds of JSON values is drawn in the JSON standard; we did not make it up. See http://rfc7159.net/rfc7159 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