Choosing a Binary JSON

Choosing a Binary JSON Alternative

Across all 100,000 sample orders the two formats save the same 16 percent and decode faster in Python:

all_orders.sh: size and decode time for the whole order fileShell
python all_orders.py        # all 100,000 orders in each format; decode time relative to JSON
Output
JSON Lines    23,575,414 bytes, 100,000 records, decode time 1.00x
MessagePack   19,894,799 bytes, 100,000 records, decode time 0.37x
CBOR          19,896,789 bytes, 100,000 records, decode time 0.67x

Ratios held over two runs on the shared 4-CPU host and reflect each library's C code too. Choose JSON when people and every tool must read the data, MessagePack 229,447 for compact JSON-shaped messages between your own services, and CBOR when you want a standard with typed decimals and dates. None removes the repeated field names: Avro 129 's 42-byte order is five times smaller.