8👍
✅
Python 2.6 comes with a json
module in the standard library — so that would be best if you’re on Python 2.6; for older Python versions, simplejson
may be roughly equivalent.
9👍
Django itself integrates simplejson
and has the ability to use your own version from the system if you have it installed.
from django.core import serializers
json_serializer = serializers.get_serializer("json")()
As Alex notes, the json
module is bundled with Python 2.6 and above — that’s actually simplejson source pulled into Python core. This might demonstrate to you that it has wide acceptance in the Python community.
The reason that you may want to use your own version is that simplejson
when compiled with C extensions and cjson
, a different module, are substantially more performant than the versions bundled with Django or Python.
- [Django]-Django Registration Number of users logged in
- [Django]-Kubernetes liveness probe fails when the logs show a 200 response
- [Django]-Django: In django-tables2 how to modify the way URLField gets rendered
- [Django]-Adding a **kwarg to a class
- [Django]-How can I know if a email is sent correctly with Django/Python?
Source:stackexchange.com