I want to save a model instance with JSON dict with integer keys, like {2: 3}.
But after saving my dict turns into {"2": 3}. Is there any way to save integer keys into JSON?
class MyModel(models.Model):
data = JSONField("data")
record = MyModel.objects.create(
data={2: 3},
)
record.refresh_from_db()
print(record.data)
# > {"2": 3}
# And I want record.data == {2: 3}
Behavior same for from django.contrib.postgres.fields import JSONField and for modern from django.db.models import JSONField