Skip to content

msight_core.data.utils

msight_core.data.utils

BytesEncoder

Bases: JSONEncoder

JSON encoder that converts bytes to Base64 ASCII strings.

This encoder can be passed to json.dumps via the cls argument to automatically encode bytes objects as Base64-encoded ASCII strings.

Example

json.dumps({'b': b''}, cls=BytesEncoder)

Note

The decoder must explicitly base64-decode the string to recover the original bytes (e.g. base64.b64decode(value)).