Fwd: JSONB order?

Поиск
Список
Период
Сортировка
От Tony Shelver
Тема Fwd: JSONB order?
Дата
Msg-id CAG0dhZCROB_8usnZ_WytoVrYdvRYn3GRTYQuXPY15-ybcya17w@mail.gmail.com
обсуждение исходный текст
Ответ на JSONB order?  (Tony Shelver <tshelver@gmail.com>)
Ответы Re: JSONB order?  (Christophe Pettus <xof@thebuild.com>)
Re: JSONB order?  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: JSONB order?  (Rob Sargent <robjsargent@gmail.com>)
Re: Fwd: JSONB order?  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general


---------- Forwarded message ---------
From: Tony Shelver <tshelver@gmail.com>
Date: Thu, 5 Nov 2020 at 17:45
Subject: Re: JSONB order?
To: Christophe Pettus <xof@thebuild.com>


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.



On Thu, 5 Nov 2020 at 17:40, Christophe Pettus <xof@thebuild.com> wrote:


> On Nov 5, 2020, at 07:34, Tony Shelver <tshelver@gmail.com> wrote:
> But...  seen above, the order gets mixed up.
>
> Any ideas?

JSON objects, like Python dicts, are not automatically ordered by key.  Once you move from the column space to the JSON object space, you can't rely on the object keys being in a consistent order.

You'll want to have a step when ingesting the JSON object into a report that lines up the key values appropriately with the right presentation in the report.
--
-- Christophe Pettus
   xof@thebuild.com

В списке pgsql-general по дате отправления:

Предыдущее
От: Magnus Hagander
Дата:
Сообщение: Re: JSONB order?
Следующее
От: Ron
Дата:
Сообщение: Re: precautions/prerequisites to take for specific table