CBOR diagnostic utilities
This little set of tools provides a number of command line utilities for converting to and from CBOR and its diagnostic notation as well as some libraries for this in the Ruby language.
gem install cbor-diag
Command line utilities
Specifically, the tools...
...do pretty much what you would expect them to do, given these definitions:
- "cbor" is a single binary CBOR data item.
- "cborseq" is a sequence of zero or more binary CBOR data items.
- "diag" is CBOR's diagnostic notation, with the extensions in RFC 8610 (extended diagnostic notation, EDN) and RFC 8742 (without the outer brackets).
- "json" is JSON.
- "neatjson" is a neater form of JSON.
- "pretty" is the pretty-printed representation of binary CBOR as used by cbor.me.
- "yaml" is YAML.
Output is to stdout, input from stdin or files given as command line arguments. Options:
-v: be verbose about sizes in bytes.
-e: output byte strings as embedded CBOR if well-formed as such (e.g.,
printf 'CBOR' | cbor2diag.rb -etoutputs
<< 'OR' >>).
-t: output byte strings that are valid UTF-8 text as such in single quotes (e.g.,
-u: don't escape beyond-ASCII characters in strings (e.g.,
These commands have a .rb suffix in their names to avoid conflicts: versions of the
same functionality are available under similar names in other CBOR
json2cbor in the
- "cbor-pure" is a pure-Ruby implementation of CBOR, with some diagnostic capabilities. It is aided by "half.rb" for 16-bit IEEE 754 floating point numbers (which Ruby strangely doesn't directly support).
- "cbor-diag-parser" is a parser for CBOR's diagnostic notation and the heart of diag2cbor.rb and diag2pretty.rb. (Source is in treetop; compiled .rb also included.)
- "cbor-diagnostic" is a dumper for CBOR's diagnostic notation.
- "cbor-pretty" is a pretty-printer for binary CBOR.
No documentation; use the source, for now (the above command line utilities should show the basic usage).