cbor-java
cbor-java copied to clipboard
Creating a finite/fixed-size map
Quite a few embedded libraries do not like indefinite-sized CBOR maps (or arrays for that matter).
For demonstration, I created a map with:
new CborEncoder(baos).encode(new CborBuilder()
.startMap(4)
.put("Timestamp", 123456789)
.end()
.build()
and the resulting map is:
BF # map(*)
69 # text(9)
54696D657374616D70 # "Timestamp"
1A 075BCD15 # unsigned(123456789)
Is there a way to assemble a map that has a specified length in the end result?
Hi @Avamander, is commit https://github.com/c-rack/cbor-java/commit/0ef74dc1a8dfa74fbb5cdcba6b64ad185bb1ba54 what you are looking for?
It probably is if you're proposing it :sweat_smile: as you know your library and CBOR much better.
I could test it out specifically if at some point you'd make a release with the change incorporated, I don't know how to build this library myself.