#27183: JSONField escaped in admin interface during normal usage -------------------------------+-------------------- Reporter: sjuxax | Owner: nobody Type: Uncategorized | Status: new Component: Uncategorized | Version: 1.10 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------+-------------------- The line of code at https://github.com/django/django/blob/68de48c96328e13d5dbdb1f3006e4a1ca74f3c34/django/contrib/postgres/forms/jsonb.py#L45 results in the escaping of a plain JSON string. That's because the string is already in valid JSON when run through json.dumps. This is user-facing and visible in the Django admin interface when a JSONField is edited.
With the current code, the line in the admin looks like this: http://imgur.com/fw29t1c.jpg If we just return value instead of json.dumps(value), we get this: http://imgur.com/msBT1tI.jpg (Someone may want to attach those jpgs directly to this report for posterity; I don't know what the convention is on this bug tracker) In fact, looking at the code now, I wonder if we just need to swap lines 44 and 45. It would seem that if a value is invalid JSON, as the check on line 43 implies, that we *should* be dumping it through the json serializer, whereas if it's valid JSON, we shouldn't. Maybe the logic just got swapped there. #25532 deals with a similar topic. -- Ticket URL: <https://code.djangoproject.com/ticket/27183> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/049.43ad710acd22f9036ee3755963434575%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.