title: AttributeError: 'bytes' object has no attribute '__dict__'
body: <p>I totally new in Python and stuck with this error:</p>
  
  <p>I am trying to encode an image and then convert it to json to upload into a no-sql db. But when I am trying to convert it to json I am getting this error:</p>
  
  <p>"AttributeError: 'bytes' object has no attribute '<strong>dict</strong>'"</p>
  
  <p>Below is my python code:</p>
  
  <pre><code>import base64  
  import json
  
  
  
  def jsonDefault(object):
      return object.__dict__
  
  
  with open("img123.png", "rb") as imageFile:  
      str = base64.b64encode(imageFile.read())  
      print(str)  
  json_str = {'file_name':'img123','img_str':str}  
  pytojson = json.dumps(json_str, default=jsonDefault)  
  print(pytojson)
  </code></pre>