Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def encode(self, o):
if isinstance(o, (bytes, bytearray)):
return '"{}"'.format(base64.b64encode(o).decode("utf-8"))
else:
return json.JSONEncoder.encode(self, o)