Reputation: 3325
I am getting this error in django. How can I get a better look at the offending piece of data and perhaps delete it? Or what similar type is JSON serializable?
This error came out of the blue, my site was working and now it won't load because of this error.
Traceback:
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response
100. response = callback(request, *callback_args, **callback_kwargs)
File "/var/www/site/instance/src/server/site/site_core/views.py" in os_show
1193. return json_result(result)
File "/var/www/site/instance/src/server/site/../site/includes/jsonutils.py" in json_result
25. return HttpResponse(serialize(result, ensure_ascii=True))
File "/var/www/site/instance/src/server/site/../site/includes/jsonutils.py" in serialize
10. return json.dumps(object)
File "/usr/lib64/python2.4/site-packages/simplejson/__init__.py" in dumps
230. return _default_encoder.encode(obj)
File "/usr/lib64/python2.4/site-packages/simplejson/encoder.py" in encode
200. chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib64/python2.4/site-packages/simplejson/encoder.py" in iterencode
260. return _iterencode(o, 0)
File "/usr/lib64/python2.4/site-packages/simplejson/encoder.py" in default
177. raise TypeError(repr(o) + " is not JSON serializable")
Exception Type: TypeError at /os/show/1/
Exception Value: array([ 0.63266369]) is not JSON serializable
Upvotes: 0
Views: 98
Reputation: 3158
It looks like you are trying to serialize an array. When I try to do simplejson.dumps(my_array), I get the same error. Does you view create an array? If so, can it convert it to a list or something else that works with dumps?
Upvotes: 1
Reputation: 3734
I would set a breakpoint (if you are using a debugger) or log some output in your views.py at 1193. Have a look at object
that gets passed to json_result()
.
It may be that one of the object attributes is that array.
Upvotes: 0