#35885: JSONField does accept strings that look like dicts and incorrectly saves
them as strings, breaking JSON filtering
-------------------------------------+-------------------------------------
Reporter: DataGreed | Owner: (none)
Type: Uncategorized | Status: closed
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):
* component: Uncategorized => Database layer (models, ORM)
* resolution: => invalid
* status: new => closed
Comment:
JSON accepts top level string as valid input; that is including JSON
serialized as a string.
> [...] since developers usually sanitize the data at least by dumping the
dict to json to make sure it is even possible to dump.
I don't think this is a normal behavior. Usually data transits through
through serialization layers that are in charge of parsing JSON strings as
Python objects just like for datetimes, decimal, float, and other types.
Having `JSONField` auto-magically perform a `json.loads` when provided a
string input is backward incompatible and prevents storing JSON de-
serializable strings as top level values (e.g. `"1", "false", "null"`).
--
Ticket URL: <https://code.djangoproject.com/ticket/35885#comment:1>
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 visit
https://groups.google.com/d/msgid/django-updates/01070192f849c267-2da44bdb-3303-4ea2-84d3-84235ad5d5f1-000000%40eu-central-1.amazonses.com.