Re: Returning JSON or JSONB

From: Vick Khera <vivek(at)khera(dot)org>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Returning JSON or JSONB
Date: 2015-10-20 19:56:14
Message-ID: CALd+dcdz+ycrXrAik0kn40BOCZ0RXNx68FmB807_Tg1L+Vct0g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Oct 20, 2015 at 4:04 AM, Andreas Kretschmer <
akretschmer(at)spamfence(dot)net> wrote:

> If you are returning JSON, so is JSON the best choice.
>

The JSONB type represented as text (i.e., when you query it) is valid JSON.
The same with JSON data type. The DB server renders the data as text when
it sends it to you.

The choice should be made based on what you plant to do with the data in
the database and if the properties of JSON are needed vs. the properties of
JSONB (specifically duplicate key names and ordering of keys) or if it is
not manipulated in the DB ever, then plain text is reasonable too.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dane Foster 2015-10-20 20:22:02 Re: My first PL/pgSQL function
Previous Message Vladimir Sitnikov 2015-10-20 19:10:16 Configurable length of application_name and/or read access to custom gucs of another backend