pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kouber Saparev <kouber@gmail.com>
Cc: Vitaly Burovoy <vitaly.burovoy@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14354: Wrong interpretation of JSON 'null'
Date: Thu, 06 Oct 2016 08:47:16 -0400
Message-ID: <28893.1475758036@sss.pgh.pa.us> (raw)
In-Reply-To: <CAN4RuQuWY-ph8dwSNN6yOBNcZju6SX_Leof3swO-rd6re1VMaA@mail.gmail.com>
References: <20161005101259.27234.41202@wrigleys.postgresql.org>
	<CAKOSWN=EQk2+SO00TOp-_QRktZxrUhxGzVdN5hjGKnLfcfij6w@mail.gmail.com>
	<CAN4RuQuWY-ph8dwSNN6yOBNcZju6SX_Leof3swO-rd6re1VMaA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Kouber Saparev <kouber@gmail.com> 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



view thread (6+ messages)  latest in thread

Message-ID: <28893.1475758036@sss.pgh.pa.us>
Permalink:  ../28893.1475758036@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28893.1475758036@sss.pgh.pa.us

 · 

reply

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, kouber@gmail.com, vitaly.burovoy@gmail.com
  Subject: Re: BUG #14354: Wrong interpretation of JSON 'null'
  In-Reply-To: <28893.1475758036@sss.pgh.pa.us>
  References: <20161005101259.27234.41202@wrigleys.postgresql.org> <CAKOSWN=EQk2+SO00TOp-_QRktZxrUhxGzVdN5hjGKnLfcfij6w@mail.gmail.com> <CAN4RuQuWY-ph8dwSNN6yOBNcZju6SX_Leof3swO-rd6re1VMaA@mail.gmail.com> <28893.1475758036@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