JSONB order? - Mailing list pgsql-general

From Tony Shelver
Subject JSONB order?
Date
Msg-id CAG0dhZD8tAuSe3mQQ1sUfj92njUgHQ39sht4yNamkJfZx386gg@mail.gmail.com
Whole thread Raw
Responses Re: JSONB order?  (Christophe Pettus <xof@thebuild.com>)
Re: JSONB order?  (Magnus Hagander <magnus@hagander.net>)
List pgsql-general
I am getting data out of a spreadsheet (Google API) and loading it into a Python 3.8 dict.
I then dump it to json format. On printing, it's in the correct order:
{
"Timestamp": "05/11/2020 17:08:08",
"Site Name": "SureSecurity Calgary",
"Last Name": "Shelver",
"First Name": "Anthony",
"Middle Name(s)": "",
"Phone": 555757007,
 "Person visited": "test",
 "Body Temperature": 44,
 "Fever or chills": "No",
 "Difficulty breathing or shortness of breath": "No",
 "Cough": "No",
 "Sore throat, trouble swallowing": "No",
 "Runny nose/stuffy nose or nasal congestion": "No",
 "Decrease or loss of smell or taste": "No",
 "Nausea, vomiting, diarrhea, abdominal pain": "No",
 "Not feeling well, extreme tiredness, sore muscles":
 "Yes", "Have you travelled outside of Canada in the past 14 days?": "No",
 "Have you had close contact with a confirmed or probable case of COVID-19?": "No"
 }

It's passed to a plpgsql function, using a jsonb parameter variable.
This insets it into the table, into into a jsonb column.

When looking at what the column contents are, it's been rearranged.  The order always seems to have been rearranged in the same way, as below:
{
    "Cough": "No",
    "Phone": 5555757007,
    "Last Name": "Shelver",
    "Site Name": "SureSecurity Calgary",
    "Timestamp": "04/11/2020 17:34:48",
    "First Name": "Anthony",
    "Middle Name(s)": "",
    "Person visited": "Many",
    "Fever or chills": "No",
    "Body Temperature": 44,
    "Sore throat, trouble swallowing": "No",
    "Decrease or loss of smell or taste": "No",
    "Nausea, vomiting, diarrhea, abdominal pain": "No",
    "Runny nose/stuffy nose or nasal congestion": "No",
    "Difficulty breathing or shortness of breath": "No",
    "Not feeling well, extreme tiredness, sore muscles": "No",
    "Have you travelled outside of Canada in the past 14 days?": "No",
    "Have you had close contact with a confirmed or probable case of COVID-19?": "No"
}

If the order had remained the same, it's child's play to pull the data out and present it in a report, even if the data elements change.
But...  seen above, the order gets mixed up.

Any ideas?

Thanks

Tony Shelver
 

pgsql-general by date:

Previous
From: Philip Semanchuk
Date:
Subject: Re: precautions/prerequisites to take for specific table
Next
From: Christophe Pettus
Date:
Subject: Re: JSONB order?