In Python 3, they removed support bytein json. (Source: https://bugs.python.org/issue10976 ).
Possible workaround:
import json
data = {"foo": "bar", "bar": b"foo"}
data["bar"] = data["bar"].decode("utf8")
json_encoded_data = json.dumps(data)
json_decoded_data = json.loads(data)
data["bar"] = data["bar"].encode("utf8")
If you do not have a usage limit json, you can use bson(binary JSON):
import bson
data = {"foo": "bar", "bar": b"foo"}
bson_encoded_data = bson.BSON.encode(data)
bson_decoded_data = bson.BSON.decode(data)