.TH "JSON2CBOR" "1" "November 2022" "8.1.0" .SH "NAME" \fBjson2cbor\fR \- convert JSON formatted text to CBOR .SH SYNOPSIS .RS 2 .nf json2cbor test\.json > test\.cbor .fi .RE .SH DESCRIPTION .P \fBjson2cbor\fP output a CBOR data stream for an input set of files\. The files .br can either consist of a single JSON item, or an .br .UR https://tools.ietf.org/html/rfc7464 .I RFC 7464 .UE encoded JSON text series\. .br In the latter case, each JSON item starts with the byte "1e" (hex), "30" (dec), .br otherwise known as "Record Separator" (RS), and finishes with a newline\. .P An example sequence: .RS 2 .nf ␞{"d":"2014\-09\-22T21:58:35\.270Z","value":6}␤ ␞{"d":"2014\-09\-22T21:59:15\.117Z","value":12}␤ .fi .RE .P You can generate a sequence like this from a newline\-separated JSON file like .br this: .RS 2 .nf sed \-e s/^/\\x1e/g [FILE] .fi .RE .P (note: your shell might need $'' around the sed pattern to work\. I'll look .br for a more shell\-inspecific way of encdoding this later\.) .P The reason I'm making you go through this pain is that more of your JSON items .br have newlines embedded in them than you think\. Ideally, you would write .br your files out using RFC 7464, and you'd also get some of the benefits of .br that format, including: .RS 1 .IP \(bu 2 Detect a truncated file due to a process dying in the middle of writing .br your data\. .IP \(bu 2 Recovery while parsing from such a truncated file that was later appended to\. .IP \(bu 2 Detect when multiple processes are writing to the same file in an .br uncoordinated way\. .IP \(bu 2 Maintain newlines in your JSON\. They'll sneak in there anyway\. .RE .SH OPTIONS .P \fB\-\fP: read from stdin instead of a file\. This is the default\. .P \fB\-c, \-\-canonical\fP: Canonical output .P \fB\-x, \-\-hex\fP: output a hex\-encoded version of the CBOR data, instead of the native .br CBOR data .P \fB\-V, \-\-version\fP: print the node\-cbor version and exit .P \fB\-h, \-\-help\fP: print some help text and exit .SH SEE ALSO .RS 1 .IP \(bu 2 .UR https://github.com/hildjj/node-cbor .I node-cbor .UE .IP \(bu 2 .UR https://www.rfc-editor.org/rfc/rfc8949.html .I RFC 8949 .UE .RE