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
Specifically, the tools...
- cbor2diag.rb
- cbor2json.rb
- cbor2pretty.rb
- cbor2yaml.rb
- cborseq2json.rb
- cborseq2neatjson.rb
- cborseq2yaml.rb
- diag2cbor.rb
- diag2pretty.rb
- json2cbor.rb
- json2pretty.rb
- pretty2cbor.rb
- pretty2diag.rb
- yaml2cbor.rb
...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.
- "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). (json2cbor.rb
also has a -v
option.)
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
packages, e.g. json2cbor
in the
CBOR NPM.
- "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).