The best way would be to avoid creating JSON manually or using Django templates, and instead use the proper JSON library. In Python 2.6+, it is as simple as import json
. In older Pythons, you need pip install simplejson
and import simplejson as json
.
It's hard to create your own JSON yourself - your experience with manually serializing bool
values ββis just the beginning. For another example, how to properly escape quoted strings?
source share