This is a command line tool which can convert JSON to CBOR and vice versa, with support for Matrix key enums. This utility always produces canonical output for deterministic behaviour.
./jc '{"foo":"bar"}'
Output to 'output' (9 bytes) a163666f6f63626172
Matrix key enum event_id
is replaced with byte 0x01
.
./jc -out '-' '{"event_id":"$something"}'
?j$something%
Round trip:
./jc -out '-' '{"event_id":"$something", "foo":"bar"}' |
./jc -c2j -out '-' '-'
{"event_id":"$something","foo":"bar"}
For the full list of Matrix key enums, see MSC3079.