Source code for intranet.utils.serialization
from rest_framework.renderers import JSONRenderer
from django.utils.html import escapejs
[docs]def safe_json(obj):
return escapejs(
JSONRenderer()
.render(obj)
.decode("utf-8")
.replace("&", "&")
.replace("<", "<")
.replace(">", ">")
.replace('\\"', """)
.replace("'", "'")
)