pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Marc Millas <marc.millas@mokadb.com>
Cc: Erik Wienhold <ewie@ewie.name>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: missing something about json syntax
Date: Thu, 20 Apr 2023 16:41:56 -0400
Message-ID: <3176185.1682023316@sss.pgh.pa.us> (raw)
In-Reply-To: <CADX_1abD_7_oj8mvZG+pSRqTgz9-ewMQzR6256JnfpxtH=4fyg@mail.gmail.com>
References: <CADX_1aaysDhtyAia0_EN5yhLWPYU+5y0jo_+5eoXCFMuVKVf2w@mail.gmail.com>
	<422485092.653228.1682012851663@office.mailbox.org>
	<CADX_1abD_7_oj8mvZG+pSRqTgz9-ewMQzR6256JnfpxtH=4fyg@mail.gmail.com>

Marc Millas <marc.millas@mokadb.com> writes:
> but it doesnt explain how postgres is able to put a scalar in a json or
> jsonb column without pb:
> I don't understand how this ('"{\"t\"}"') can be considered  a valid enough
> json to be inserted in a json column
> and at the same time invalid for all other json uses.

That's a bare string (it's not an object).  That's valid JSON per
RFC 7159:

   JSON can represent four primitive types (strings, numbers, booleans,
   and null) and two structured types (objects and arrays).
   ...
   A JSON text is a serialized value.  Note that certain previous
   specifications of JSON constrained a JSON text to be an object or an
   array.

However, there certainly are some operations that require the top-level
value to be an object or array.

			regards, tom lane





view thread (5+ messages)  latest in thread

Message-ID: <3176185.1682023316@sss.pgh.pa.us>
Permalink:  ../3176185.1682023316@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3176185.1682023316@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-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, marc.millas@mokadb.com, ewie@ewie.name
  Subject: Re: missing something about json syntax
  In-Reply-To: <3176185.1682023316@sss.pgh.pa.us>
  References: <CADX_1aaysDhtyAia0_EN5yhLWPYU+5y0jo_+5eoXCFMuVKVf2w@mail.gmail.com> <422485092.653228.1682012851663@office.mailbox.org> <CADX_1abD_7_oj8mvZG+pSRqTgz9-ewMQzR6256JnfpxtH=4fyg@mail.gmail.com> <3176185.1682023316@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