Example #1
0
def pack(content, *args, default=convert.msgpack, **kwargs):  # type: ignore
    """Msgpacks with preconversion for common unserializable types in place"""
    if isinstance(content, tuple):
        content = convert_namedtuple(content)
    return msgpack.pack(content, default=default, *args, **kwargs)
Example #2
0
def dumps(content, *args, default=convert.json, **kwargs):  # type: ignore
    """JSON dumps with preconversion for common unserializable types in place"""
    if isinstance(content, tuple):
        content = convert_namedtuple(content)
    return json.dumps(content, default=default, *args, **kwargs)
Example #3
0
def dumps(content, *args, on_unknown=convert.bson, **kwargs):  # type: ignore
    """BSON dumps with preconversion for common unserializable types in place"""
    if isinstance(content, tuple):
        content = convert_namedtuple(content)
    return bson.dumps(content, on_unknown=on_unknown, *args, **kwargs)