From: | Tony Shelver <tshelver(at)gmail(dot)com> |
---|---|
To: | pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | JSONB order? |
Date: | 2020-11-05 15:34:51 |
Message-ID: | CAG0dhZD8tAuSe3mQQ1sUfj92njUgHQ39sht4yNamkJfZx386gg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Christophe Pettus | 2020-11-05 15:40:00 | Re: JSONB order? |
Previous Message | Philip Semanchuk | 2020-11-05 15:05:32 | Re: precautions/prerequisites to take for specific table |