cbor2json

module
v0.0.0-...-5a03880 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2024 License: Apache-2.0

README

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.

Directories

Path Synopsis
Package csd provides primitives for storing different data in the CBOR (binary) format.
Package csd provides primitives for storing different data in the CBOR (binary) format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL