Python 3: Is not JSON serializable
Consider installing and using simplejson, which can handle bytes strings in addition to unicode, to install it use command below:
pip3 install simplejson
Usage in code:
import simplejson as json
json.dumps({b'name': b'dev'})
This is not a string, but a byte sequence. JSON knows only how to handle Unicode strings, not byte sequences. Either transform into Unicode (json.dumps(x.decode("utf-8"))
), or into an integer array (json.dumps(list(x))
).