A C++23 command-line application and reusable library for converting JSON, XML, YAML, and TOML.
Convert a file:
cppcli convert --from json --to yaml input.jsonRead from standard input:
printf'{"name":"Ada"}'| cppcli convert --from json --to tomlXML uses a natural mapping: object keys become element names, repeated elements become arrays, attributes use @-prefixed keys, and mixed text uses #text. When an object cannot provide one document element, XML output uses <root>.
TOML output requires an object at the document root and rejects null values because TOML cannot represent them.
Each format is an independent class derived from cppcli::Format. Interfaces call
cppcli::convert(input, input_format, output_format), so adding another format only
requires a class implementing name(), parse(), and serialize(). Register an
instance in format_for() only when the CLI should recognize its name.
Enter the Nix development shell to obtain Premake, the compiler, and libraries:
nix develop
premake5 gmake
bear -- make -C build -B config=release
./build/bin/Release/cppcli --helpBear writes compile_commands.json, allowing clangd to resolve the core include path and Nix-provided libraries.
Run the package directly with nix run -- convert ..., or build it with nix build.
make -C build config=debug
./build/bin/Debug/cppcli-tests