Re: missing something about json syntax - Mailing list pgsql-general

From Marc Millas
Subject Re: missing something about json syntax
Date
Msg-id CADX_1abh6EevZ4hnoSyDJcKjL4OgOfmJMNQqkw3StgOn14XUHg@mail.gmail.com
Whole thread Raw
In response to Re: missing something about json syntax  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Ok, thanks. 

Le jeu. 20 avr. 2023 à 22:42, Tom Lane <tgl@sss.pgh.pa.us> a écrit :
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

pgsql-general by date:

Previous
From: Maxim Boguk
Date:
Subject: Unexpectedly huge memory usage (over 180x of work_mem) during hash join... confirmed by TopMemoryContext results (postgresql 13.10)
Next
From: Daniel Wu
Date:
Subject: HOT update: why must ALL indexes should be update?