Nullus157 / cbor-diag-rs

Support for parsing/encoding CBOR diagnostic notation and annotated hex
https://cbor.nemo157.com
Apache License 2.0
9 stars 6 forks source link

Wishlist: support for CBOR Sequences #145

Open extemporalgenome opened 4 weeks ago

extemporalgenome commented 4 weeks ago

https://www.rfc-editor.org/rfc/rfc8742.html

For example, if support for cbor sequences were present, I believe the following should parse:

{
  echo '{"a":1}' | cbor-diag --to=bytes ;
  echo '{"b":2}' | cbor-diag --to=bytes ;
} | cbor-diag --to=annotated

Ideally the following would work as well (accept jsonl/ndjson and other representations of sequences of documents):

{ echo '{"a":1}' ; echo '{"b":2}' ; } | cbor-diag --to=annotated
Nemo157 commented 4 weeks ago
> {
  echo '{"a":1}' | cbor-diag --to=bytes ;
  echo '{"b":2}' | cbor-diag --to=bytes ;
} | cbor-diag --seq --to=annotated
a1       # map(1)
   61    #   text(1)
      61 #     "a"
   01    #   unsigned(1)

a1       # map(1)
   61    #   text(1)
      62 #     "b"
   02    #   unsigned(2)

--seq currently implies --from=bytes, but it seems reasonable to support other formats with it too (would need to add more _partial functions to the library for them).