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!

Reply via email to