Skip to content
forked from toravir/csd

CBOR Stream Decoder and JSON convertor with float16 support

License

Notifications You must be signed in to change notification settings

wormbks/cbor2json

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CBOR to JSON converter ( former CBOR Stream Decoder)

This updated version CBOR Stream Decoder with float16 support.

cbor2json decodes a stream of CBOR bytes into JSON. CBOR stream could be copressed by gzip.

Usage:

    cbor2json [-in inputFile] [-out outputFile] [-follow]

Run `csd -h` for a list of supported options and usage.
If `-in` is omitted, csd reads from stdin.
If `-out` is omitted, csd writes to stdout.

Example

Suppose CBOR encoded data is present in file cbor.log, you could do one of these methods to convert to JSON using csd:

Input from file, output to stdout :

$ csd -in cbor.log
{"level":"error","Fault":41650,"time":"2018-03-31T07:17:19-07:00","message":"TCA:"}
{"level":"error","Fault":41654,"time":"2018-03-31T07:17:19-07:00","message":"TCA:"}
...

Input from stdin, output to stdout

$ cat cbor.log | csd 
{"level":"error","Fault":41650,"time":"2018-03-31T07:17:19-07:00","message":"TCA:"}
{"level":"error","Fault":41654,"time":"2018-03-31T07:17:19-07:00","message":"TCA:"}
...

Input from file, output to file

$ csd -in cbor.log -out json.txt
$ cat json.txt
{"level":"error","Fault":41650,"time":"2018-03-31T07:17:19-07:00","message":"TCA:"}
{"level":"error","Fault":41654,"time":"2018-03-31T07:17:19-07:00","message":"TCA:"}
...

Limitations

The input is expected to be CBOR data (either gzib-compressed or not). It is NOT possible to detect JSON (text) output reliably since binary format spans over JSON character set also.

About

CBOR Stream Decoder and JSON convertor with float16 support

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 99.9%
  • Shell 0.1%