How to use the cbor2.decoder.CBORDecoder.decode function in cbor2

To help you get started, we’ve selected a few cbor2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github agronholm / cbor2 / cbor2 / decoder.py View on Github external
def load(fp, **kwargs):
    """
    Deserialize an object from an open file.

    :param fp:
        the input file (any file-like object)
    :param kwargs:
        keyword arguments passed to :class:`CBORDecoder`
    :return:
        the deserialized object
    """
    return CBORDecoder(fp, **kwargs).decode()
github agronholm / cbor2 / cbor2 / decoder.py View on Github external
def loads(s, **kwargs):
    """
    Deserialize an object from a bytestring.

    :param bytes s:
        the bytestring to deserialize
    :param kwargs:
        keyword arguments passed to :class:`CBORDecoder`
    :return:
        the deserialized object
    """
    with BytesIO(s) as fp:
        return CBORDecoder(fp, **kwargs).decode()