JSON for Humans.
JSON is great. Until you miss that trailing comma... or want to use comments. What about multiline strings? JSONH provides a much more elegant way to write JSON that's designed for humans rather than machines.
Since JSONH is compatible with JSON, any JSONH syntax can be represented with equivalent JSON.
JsonhCpp is a parser implementation of JSONH V1 & V2 for C++.
{
// use #, // or /**/ comments
// quotes are optional
keys: without quotes,
// commas are optional
isn\'t: {
that: cool? # yes
}
// use multiline strings
haiku: '''
Let me die in spring
beneath the cherry blossoms
while the moon is full.
'''
// compatible with JSON5
key: 0xDEADCAFE
// or use JSON
"old school": 1337
}
Everything you need is contained within jsonh_reader:
#include "jsonh_cpp.hpp" // for jsonh_cpp
std::string jsonh = R"(
{
this is: awesome
}
)";
json::object_t element = jsonh_cpp::jsonh_reader::parse_element<json::object_t>(jsonh).value();- C++20
- nlohmann/json (v3.12.0 - patch 2026/02/19 22:32)
- lewissbaker/generator (patch 2026/03/03 23:26)
- martinmoene/expected-lite (v0.10.0) - backport
- catchorg/Catch2 (v3.13.0) - help
- rindeal/Amalgamate (v0.99.0)
In comparison to JsonhCs, this C++ implementation has some limitations.
The input stream must be in UTF-8 encoding.
If using a different encoding, consider converting to UTF-8 using utfcpp.
There is no option to parse numbers with arbitrary range/precision.
Numbers are parsed as long double, which is generally 64-bit.