Welcome to jsonpacker’s documentation!

JSON Packer

A JSON binary packer.

Synopsis

Usage: jsonpacker [OPTION...] <JSON file>
JSON Packer -- A program to encode JSON key-valued objects in binary format.

  -d, --one-dict             Use a single dicionary for all records (optional)
  -e, --encoder=encoder      Changes default file output name (optional)
  -n, --no-file-output       Do not write binary files
  -o, --output=outfile       Changes default file output name (optional)

 Output formatting
  -b, --print-encondings     Prints the encondings' byte arrays
  -r, --print-records        Prints records in a compact JSON style
  -R, --print-full-records   Prints records in a full JSON style

  -?, --help                 Give this help list
      --usage                Give a short usage message
  -V, --version              Print program version

JSON Packer is a small utility that reads sequences of JSON records and encode them in binary format. JSON Packer makes uses of cJSON to parse the objects.

Each JSON key-value record is split into two pairs: an encValue pair, whith the keys replaced by “numeric” pre-assigned values; and a keyEnc pair, with a mapping between the original keys and the new encoded keys. JSON Packer uses a hash table from the Apache Portable Runtime Librar (APR) to store the dicionary. The encoded values and keys can be optionally written to a file stream.

By default, JSON packer adopts the ASN.1 DER codec to encode the records. New encoder types are expected to be released soon.

Basic usage

In the general use case, JSON packer reads a JSON file containing a series of records (separated by newlines) and generates two binary files in ASN.1 DER encoding:

    ./jsonp <json-records-file> -b

The files are named after the original input file, and written in the same folder.

Building

CMake can be used to configure the build system, assume build as the build directory:

cmake -S . -B build

To compile, type

cmake --build build

Documentation

The documentation can be generated by:

cmake -S . -B build -DWITH_SPHINX=ON
cmake --build build

where the flag -DWITH_SPHINX=ON causes Sphinx to render the final HTML documentation. If this variable is set to OFF, Doxgen will be used instead. Note that Sphinx depends on Doxygen itself and Breathe to act as a bridge between them.

Tests

Unity tests are compiled by:

cmake --build . --target test

Indices and tables