Thursday 1 April 2021

Json dumping bytes fails in Python 3

 With Json module you cannot dump bytes. A suitable alternative is to use Simple Json Module.

To Install Simple json:

pip3 install simplejson

Code:

import simplejson as json
data = {"foo": "bar", "bar": b"foo"}
json.dumps(data)


from : https://stackoverflow.com/questions/33794707/json-dumping-bytes-fails-in-python-3

No comments:

Post a Comment