Re: a bug jsonb?

From: Josef Šimánek <josef(dot)simanek(at)gmail(dot)com>
To: gubanovss(at)gmail(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: a bug jsonb?
Date: 2018-11-22 15:26:10
Message-ID: CAFp7QwoBLLKNFJETuPLENMOV1Z=b3qykg-bb15oWLmBGkfHoDw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

the order is changed as well on your screenshot
čt 22. 11. 2018 v 16:23 odesílatel Станислав Губанов <gubanovss(at)gmail(dot)com>
napsal:

> I think yes.
> Please look at this screen shot
> order of key in json not changed in pgAdmin, maybe exists some option for
> turn on/off this feature.
>
> [image: image.png]
>
> чт, 22 нояб. 2018 г. в 18:04, Josef Šimánek <josef(dot)simanek(at)gmail(dot)com>:
>
>> If I understand well your question, this is expected with JSONB.
>>
>> see https://www.postgresql.org/docs/current/datatype-json.html for more
>> info:
>>
>> ...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...
>>
>> čt 22. 11. 2018 v 15:59 odesílatel Станислав Губанов <gubanovss(at)gmail(dot)com>
>> napsal:
>>
>>> Hello!
>>>
>>> I'd like to clarify, if this a bug or a feature
>>>
>>> simple JSON
>>> {"rootC":{},"rootB":{},"rootZ":{},"rootA":[]}
>>>
>>> Table for data
>>> create table test_json (json_data jsonb);
>>>
>>> put json into table
>>> INSERT INTO test_json (json_data) VALUES
>>> ('{"rootC":{},"rootB":{},"rootZ":{},"rootA":[]}');
>>>
>>> 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": {}}
>>>
>>> ----- console log -----
>>> test=# create table test_json (json_data jsonb);
>>> CREATE TABLE
>>> test=# INSERT INTO test_json (json_data) VALUES
>>> ('{"rootC":{},"rootB":{},"rootZ":{},"rootA":[]}');
>>> INSERT 0 1
>>> test=# select json_data from test_json;
>>> json_data
>>> ------------------------------------------------------
>>> {"rootA": [], "rootB": {}, "rootC": {}, "rootZ": {}}
>>> (1 row)
>>>
>>> test=# drop table test_json;
>>> DROP TABLE
>>>
>>> --
>>> Sincerely, Stanislav!
>>>
>>
>
> --
> С уважением, Станислав!
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Glenn Schultz 2018-11-22 16:25:08 table value function help
Previous Message Ádám Maracska 2018-11-22 15:16:48 Compile postgresql libraries with VS17