This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Madison May
Recipients Madison May
Date 2015-07-15.20:49:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1436993372.93.0.482029912936.issue24641@psf.upfronthosting.co.za>
In-reply-to
Content
Currently the json lib only logs the string representation of the variable, which does not always include type information.

I recently ran into a difficult to debug issue with code similar to the following:

```
import json
import numpy as np
d = {'data': np.int16(5)}
json.dumps(d)
```

which produces the following error:

```
TypeError: 5 is not JSON serializable
```

It took us quite a while to determine that `5` was actually of type `np.int` instead of the native type.

A cursory glance at StackOverflow suggests that I'm not alone in running into this issue: http://stackoverflow.com/questions/10872604/json-dump-throwing-typeerror-is-not-json-serializable-on-seemingly-vali


I'd like to consider modifying the error message to be more similar to the following:

```
TypeError: 5 of type `numpy.int16` is not JSON serializable
```
History
Date User Action Args
2015-07-15 20:49:32Madison Maysetrecipients: + Madison May
2015-07-15 20:49:32Madison Maysetmessageid: <1436993372.93.0.482029912936.issue24641@psf.upfronthosting.co.za>
2015-07-15 20:49:32Madison Maylinkissue24641 messages
2015-07-15 20:49:32Madison Maycreate