xref: /OK3568_Linux_fs/buildroot/support/testing/tests/package/sample_python_cbor_enc.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1import cbor
2
3data = {
4    "name": "python-cbor",
5    "versions": ["1", "2"],
6    "group": {
7        "is_a_package": True,
8        "value": 42
9    }
10}
11serialized = cbor.dumps(data)
12print(serialized.decode(errors="ignore"))
13with open("/tmp/data.cbor", "wb") as f:
14    f.write(serialized)
15