Thanks for your testing! It's being passed through json.dumps to check it would be possible to store it as JSON. Seems legitimate to me.
The other libraries default to an encoder that allows storage of Decimals, whilst the new field doesn't. Since Decimals don't round-trip in JSON (they're encoded as strings and then decoded back as strings), I think the new JSONField is making the right choice here. On Thu, 6 Feb 2020 at 06:35, Jacob Rief <jacob.r...@gmail.com> wrote: > Hi Carlton, hi Sage, > I just tested this implementation against my JSONField form editor > library, namely django-entangled > <https://github.com/jrief/django-entangled>, using SQLIte. > As you can see from the testing matrix > <https://travis-ci.org/jrief/django-entangled>, everything works fine > using the well known jsonfield <https://pypi.org/project/jsonfield/> and > jsonfield2 <https://pypi.org/project/jsonfield2/>, which until Django-3 > are the only viable options currently available for SQLite. > > However, after switching to the new implementation using the built-in > JSONField, one of my units tests does not pass > <https://travis-ci.org/jrief/django-entangled/jobs/646643632>. After > examining this locally, I discovered, that the form > reports product_form._errors: {'properties': ['Value must be valid > JSON.']} > The location where this exception is raised, is inside the JSONField's > validate() > <https://github.com/laymonage/django/blob/656ec0b97504c8df47c1c570c794de97be8fc338/django/db/models/fields/json.py#L75> > method. > And the reason it is raised > is because json.dumps(value, cls=self.encoder) can not reparse a valid > dictionary containing for instance a Python Decimal value. > Why should a valid Python dictionary be json.dumps(value, > cls=self.encoder) anyway? > > – Jacob > > -- > You received this message because you are subscribed to the Google Groups > "Django developers (Contributions to Django itself)" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-developers+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/02f0df5e-3d9d-49c4-a81a-a1a2261a1b98%40googlegroups.com > <https://groups.google.com/d/msgid/django-developers/02f0df5e-3d9d-49c4-a81a-a1a2261a1b98%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Adam -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMyDDM13toc2jrRm7eg6GSAGR2xmVgeoX8dkaoxTRytjesf0bw%40mail.gmail.com.