A simple generic CBOR encoder / decoder
Project description
gencbor
This is a simple generic CBOR (RFC8949) encoder / decoder which will not look at any tag values.
How to use
>>> import gencbor
>>> gencbor.encode(gencbor.Tag(0x1001, [3, 4, 5]))
b'\xd9\x10\x01\x83\x03\x04\x05'
>>> gencbor.decode(b'\xd9\x10\x01\x83\x03\x04\x05')
Tag(4097, (3, 4, 5))
>>> gencbor.encode(gencbor.Map([(0, 'int'), (0.0, 'float')]))
b'\xa2\x00cint\xf9\x00\x00efloat'
>>> gencbor.decode(gencbor.encode(gencbor.Map([(0, 'int'), (0.0, 'float')])))
Map({0: int, 0.0: float})
>>> gencbor.decode(gencbor.encode([gencbor.SimpleValue(i) for i in range(18, 24)]))
(SimpleValue(18), SimpleValue(19), False, True, None, undefined)
>>>
General
-
The library is will treat
0and0.0as distinct, i.e. both values can be in keys in the same map. -
The library is also supposed to treat different
nanvalues as different, but currently there is a bug when encoding non-standardnanvalues. -
The library will check for well-formed-ness and for basic validity. It will not check for tag validity.
-
false,trueandnullwill by default be decoded toFalse,TrueandNone.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gencbor-0.1.2.tar.gz.
File metadata
- Download URL: gencbor-0.1.2.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72df9b915ff1fc95365708941f42a655f9c45edb398dc669dbe0289dc87e9e5c
|
|
| MD5 |
0894ed362374fe28c31aa041e6de9d35
|
|
| BLAKE2b-256 |
034db026c3c3a72b2ecebf12b41eeeebb8b73791b78f423ce3314ab09a6c07b2
|
File details
Details for the file gencbor-0.1.2-py3-none-any.whl.
File metadata
- Download URL: gencbor-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
224c3cbb2849d02d5326b881948b77a430778f6ef14e2b742452cc70db1e6b20
|
|
| MD5 |
31c0fb0d4cae30aaf9b391281be9a3be
|
|
| BLAKE2b-256 |
6676120b04ed7f2f5251a948163f1cc09d090bb84afcdb866a2f51b45412388d
|