I am trying to use JSON with Django.
When I execute import json
in the shell, I receive no errors. However, when I try to use json_dumps()
or just dumps()
I get the following error:
NameError: name 'json_dumps' is not defined
Apparently my json
import didn't work despite having no errors. How can I get it to work?
Additionally:
simplejson
and json
the same packages?Your error doesn't have anything to do with your question. This is a simple matter of Python namespacing: the function is json.dumps
not json_dumps
.
However, json
has been a part of the standard library since 2.5. simplejson
is a separate library. Unless you know you need it, you should use json
.