Re: JSONB order?

From: Christophe Pettus <xof(at)thebuild(dot)com>
To: Tony Shelver <tshelver(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: JSONB order?
Date: 2020-11-05 16:12:56
Message-ID: 2871D4AD-7885-40BF-86A7-90E321C4E3AF@thebuild.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On Nov 5, 2020, at 07:45, Tony Shelver <tshelver(at)gmail(dot)com> wrote:
> Thanks Christophe, that's what I thought.
> Just seemed weird that they were 'disordered' in exactly the same way every time.
>
> FYI, as of Python 3.7, dicts are ordered.
>
> The problem is that we are possibly going to have many versions of these forms with slightly differing keys, which will be a pain to order in some hard coded way.

As Magnus noted, you can use JSON instead of JSONB. JSON is basically a text blob with a syntax check wrapper around it, so it will be order-stable once created. (If you run it through a JSONB-expecting function, then the ordering may change again.) It's less efficient to operate on than JSONB, but that might be OK for your purposes.

--
-- Christophe Pettus
xof(at)thebuild(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2020-11-05 16:16:37 Re: JSONB order?
Previous Message Ron 2020-11-05 16:04:46 Re: precautions/prerequisites to take for specific table