title: How to deal with TypeError: Object of type 'bytes' is not JSON serializable?
body: <p>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.</p>
  <p>Code:</p>
  <pre><code>import json 
  import base64
  
  with open(r&quot;C:/Users/Documents/pdf2txt/outputImage.jpg&quot;,&quot;rb&quot;) as img:
      image = base64.b64encode(img.read())
      data['ProcessedImage'] = image
  
  print(json.dump(data)
  </code></pre>
  <p>Output:</p>
  <pre><code>TypeError: Object of type 'bytes' is not JSON serializable
  </code></pre>
  <p>When using:</p>
  <pre><code>print(json.dumps(dict(data)))
  </code></pre>
  <p>It's also showing the same error</p>