pygsti.serialization.jsoncodec.encode_obj#
- encode_obj(py_obj, binary)#
Returns JSON-compatible version of py_obj.
Constructs in-memory a JSON-format-compatible copy of the Python object py_obj, handling pyGSTi objects appropriately. When binary=False, the output must contain only ASCII-compatible strings (no ‘bytes’), otherwise the output is allowed to contain non-ASCII string values (OK for binary formats like MSGPACK and BSON).
- Parameters:
py_obj (object) – The object to encode.
binary (bool) – Whether the output is allowed to have binary-mode strings or not.
- Returns:
A JSON-format compatible object. Usually a dict, list, or string.
- Return type:
object