Trying to convert output into Json format but getting the error. After removing the json.dump getting the data into base64 format. But when using json.dump it shows error.
Code:
import json
import base64
with open(r"C:/Users/Documents/pdf2txt/outputImage.jpg","rb") as img:
image = base64.b64encode(img.read())
data['ProcessedImage'] = image
print(json.dump(data)
Output:
TypeError: Object of type 'bytes' is not JSON serializable
When using:
print(json.dumps(dict(data)))
It's also showing the same error