I'm writing a small app that saves JSON verified by a schema to a PostgreSQL DB using Django's JSONField class. I am relying on the data to keep nodes in order butJSONField apparently uses PostgreSQL's jsonb type, which reorders the JSON data to increase indexing performance.
Is there a way to preserve the order of elements using this method by forcing the json type instead of jsonb? Or should I give up and look into a different database's JSON support?
Samples:
What I send to the DB to be saved:
"Item": {
"@id": "blah"
"ItemComponent": {
"Weapon": {
"@blah": "blah"
"WeaponFlags": {
"@blah": "blah"
}
}
},
"Flags": {
"@blah": "blah",
}
}
How it is saved to the Database:
"Item": {
"@id": "blah"
"Flags": {
"@blah": "blah",
},
"ItemComponent": {
"Weapon": {
"@blah": "blah"
"WeaponFlags": {
"@blah": "blah"
}
}
}
}