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
0
and0.0
as distinct, i.e. both values can be in keys in the same map. -
The library is also supposed to treat different
nan
values as different, but currently there is a bug when encoding non-standardnan
values. -
The library will check for well-formed-ness and for basic validity. It will not check for tag validity.
-
false
,true
andnull
will by default be decoded toFalse
,True
andNone
.
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
gencbor-0.1.0.tar.gz
(12.1 kB
view hashes)