Fighting with JSON — A Cpp War Story
Member-only story
Software Development
Cplusplus
Nlomann
Cpp
Programming Languages
Fighting with JSON — A Cpp War Story
3 min read
·
Jul 23, 2025
\--
Share
Press enter or click to view image in full size
Photo by Juanjo Jaramillo on Unsplash
Read it for free
When an unknown compiler features drives you mad
I was refactoring the build environment for an internal C++ project at work. To keep things simple, we used the following JSON library:
<https://github.com/nlohmann/json>
The build system was based on CMake. I planned to replace our wrapper scripts for CMake with a preset.json. If you haven’t heard of this feature yet: when you want to set specific configurations for customers via CMake defines, you can predefine these in a dedicated preset file. It works surprisingly well. For my experimental render engine, I put all the Windows packages installation via vcpkg into a preset file like this:
{ "version": 3, "configurePresets": [ { "name": "default", "binaryDir": "${sourceDir}", "cacheVariables": { "CMAKE_TOOLCHAIN_FILE": "contrib/vcpkg/scripts/buildsystems/vcpkg.cmake" } } ] }
You now invoke the build with
`cmake .\CMakeLists.txt --preset=default`
under Windows, and the user no longer needs to worry about installing vcpkg, since it’s shipped under `contrib`.




