Re: a bug jsonb?

From: Francisco Olarte <folarte(at)peoplecall(dot)com>
To: gubanovss(at)gmail(dot)com
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: a bug jsonb?
Date: 2018-11-22 15:05:30
Message-ID: CA+bJJbxQjAHqsUyWswUwJ65O4kRvam3jqCiN33RW77+g+y8Xxg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Nov 22, 2018 at 3:59 PM Станислав Губанов <gubanovss(at)gmail(dot)com> wrote:
....
> order of key in json is changed in such query:
> SELECT json_data FROM test_json;
> expected result: {"rootC":{},"rootB":{},"rootZ":{},"rootA":[]}
> actual result: {"rootA": [], "rootB": {}, "rootC": {}, "rootZ": {}}

From https://www.postgresql.org/docs/11/datatype-json.html

"There are two JSON data types: json and jsonb. They accept almost
identical sets of values as input. The major practical difference is
one of efficiency. The json data type stores an exact copy of the
input text, which processing functions must reparse on each execution;
while jsonb data is stored in a decomposed binary format that makes it
slightly slower to input due to added conversion overhead, but
significantly faster to process, since no reparsing is needed. jsonb
also supports indexing, which can be a significant advantage.

Because the json type stores an exact copy of the input text, it will
preserve semantically-insignificant white space between tokens, as
well as the order of keys within JSON objects. Also, if a JSON object
within the value contains the same key more than once, all the
key/value pairs are kept. (The processing functions consider the last
value as the operative one.) By contrast, jsonb does not preserve
white space, does not preserve the order of object keys, and does not
keep duplicate object keys. If duplicate keys are specified in the
input, only the last value is kept."

Francisco Olarte.

In response to

  • a bug jsonb? at 2018-11-22 14:58:21 from Станислав Губанов

Browse pgsql-general by date

  From Date Subject
Next Message Ádám Maracska 2018-11-22 15:16:48 Compile postgresql libraries with VS17
Previous Message Josef Šimánek 2018-11-22 15:04:27 Re: a bug jsonb?