#33086: ArrayField with JSONField and custom encoder raises error on
serialization
with "django.core.serializers.json".
-------------------------------------+-------------------------------------
Reporter: Anudeep Samaiya | Owner: Anudeep
| Samaiya
Type: Bug | Status: closed
Component: contrib.postgres | Version: 3.2
Severity: Normal | Resolution: wontfix
Keywords: postgres, json | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):
* status: new => closed
* needs_better_patch: 1 => 0
* needs_tests: 1 => 0
* easy: 1 => 0
* needs_docs: 1 => 0
* has_patch: 1 => 0
* resolution: => wontfix
Comment:
Thanks for extra details. Unfortunately proposed change is backward
incompatible, we also cannot fix this by changing `to_python()` and
`value_to_string()` for `JSONField` (see discussions in
[https://github.com/django/django/pull/9801 PR9801],
[https://github.com/django/django/pull/9809 PR9809], and
[https://github.com/django/django/pull/11538 PR11538]). `JSONField` can
store JSON arrays so you should be able to use
`JSONField(encoder=DjangoJSONEncoder)` instead of
`ArrayField(JSONField(encoder=DjangoJSONEncoder))`. It also works with the
db round-trip
{{{
>>> test = Test.objects.create(data=[{'id': uuid.uuid4()}])
>>> test.refresh_from_db()
>>> serializers.serialize('json', (test,))
'[{"model": "test_33086.test", "pk": 16, "fields": {"array": "[]",
"nested_array": null, "data": "[{\\"id\\":
\\"2a7cc8f4-a541-49ce-8310-c73c6cc2dc4c\\"}]"}}]'
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33086#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/072.479dc361ce82bf5a242438a282ffb33f%40djangoproject.com.