Nihilai Collective Logo

Jsonifier

Nihilai Collective

RFC8259-compliant JSON · SIMD + compile-time hash-maps · C++23

What It Is

Jsonifier is a set of classes for validating, serializing, parsing, prettifying, and minifying objects into and out of JSON strings — very rapidly. It is fully RFC8259 compliant, and is positioned as possibly the fastest JSON parser and serializer in C++.

It achieves this through the combined use of SIMD instructions and compile-time hash-maps for the keys of the data being parsed — so key lookup stays O(1) and order-independent rather than degrading on out-of-sequence documents. Registered on the Microsoft vcpkg registry.

Why

Most fast JSON libraries are fast on the happy path and fragile everywhere else. Jsonifier is built to be fast and unbreakable. The serializer leans on compile-time reflection over your types, the parser resolves keys through a perfect hash computed at compile time, and the SIMD layer dispatches to the widest instruction set your CPU supports.

Jsonifier doesn't just parse JSON — it survives it. Every build is hardened against malformed input by a fuzz-simulation test that corrupts a 2000-plus-character JSON string one byte at a time, generating thousands of progressively invalid permutations and force-feeding each through both parsing and schema validation. Zero crashes, zero memory violations, zero undefined behavior — under both AddressSanitizer and UndefinedBehaviorSanitizer, across the full Windows / Linux / macOS matrix, on every push.

Features

  • Fully RFC8259-compliant parsing and serialization
  • Parse, serialize, validate, prettify, and minify — one library
  • SIMD dispatch across AVX-512 / AVX2 / AVX / SSE / NEON
  • Auto-detected CPU arch — x64, AVX, AVX2, AVX-512, ARM-NEON
  • Manual override via JSONIFIER_CPU_FLAGS in CMake
  • Compile-time perfect hash-maps for key resolution
  • Specialized hash maps for 1-, 2-, 3+-field objects
  • Order-independent parsing — no penalty for out-of-sequence keys
  • Partial reading: extract only the keys you ask for
  • Compile-time reflection — no macros, no schema boilerplate
  • Zero-copy parsing where possible
  • ASAN / UBSAN clean against a byte-level fuzz gauntlet
  • Custom parsing/serializing behavior per type
  • Parse arbitrary / unknown data via raw_json_data
  • Runtime key exclusion
  • Detailed error reporting with source-location tracking
  • Optimization mode for already-minified JSON
  • Cross-platform CI: Windows MSVC, Ubuntu GCC/Clang, macOS Clang/GCC

Quick Start

Define a type and parse into it
#include <jsonifier/Index.hpp> struct Person { std::string name; int32_t age; double height; bool active; }; template<> struct jsonifier::core<Person> { using value_type = Person; static constexpr auto parseValue = createValue< &value_type::name, &value_type::age, &value_type::height, &value_type::active>(); }; int main() { jsonifier::jsonifier_core<> parser{}; std::string json = R"({"name":"John","age":30,"height":1.85,"active":true})"; Person person{}; parser.parseJson(person, json); }
Serialize back out
std::string out{}; parser.serializeJson(person, out); // out == {"name":"John","age":30,"height":1.85,"active":true}
Validate, prettify, minify
bool ok = parser.validateJson(json); std::string pretty = parser.prettifyJson(json); std::string minified = parser.minifyJson(pretty);

Every error surfaces through the parser's error vector — see the Error Handling docs for the full reporting API.

Building

Consume via CMake's FetchContent, or install through vcpkg.

vcpkg

vcpkg install jsonifier

CMake (FetchContent)

include(FetchContent) FetchContent_Declare( Jsonifier GIT_REPOSITORY https://github.com/RealTimeChris/Jsonifier.git GIT_TAG main ) FetchContent_MakeAvailable(Jsonifier) target_link_libraries(your_target PRIVATE Jsonifier::Jsonifier)

Requirements

  • A C++23 compiler — MSVC 2022+, GCC 11+, Clang 14+
  • CMake 3.18 or later
  • Supported CPU — x64 or ARM64 with NEON

Testing & Safety

Every push triggers the full test suite across Windows MSVC, Ubuntu GCC, Ubuntu Clang, macOS Clang, and macOS GCC — with both AddressSanitizer and UndefinedBehaviorSanitizer live.

Conformance
30+ RFC8259 conformance tests from the official JSON test suite — pass and fail cases both.
Round-Trip
27 serialize → parse → compare tests covering nulls, empties, large numbers, special floats.
Float Validation
64+ edge cases — denormals, infinities, NaN, extreme magnitudes.
Integer Bounds
Signed and unsigned, 8-bit through 64-bit, full overflow-boundary coverage.
String & Unicode
UTF-8, escape sequences, control characters, full emoji coverage.
Bounds & Truncation
Truncated and malformed input fuzzed byte-by-byte against parse and validate paths.
Type Coverage
Primitives, vector, array, map, unordered_map, tuple, optional, shared_ptr, enums.
Totals
100+ individual test cases run on every push, every platform, with ASAN + UBSAN.
Run the test suite locally
git clone https://github.com/RealTimeChris/Jsonifier.git cd Jsonifier cmake -B build -DJSONIFIER_UNIT_TESTS=ON cmake --build build --target jsonifier_unit_tests ./build/Tests/jsonifier_unit_tests

Documentation

InstallationFetchContent and vcpkg setup
ReflectionDescribing your types to the core template
Serializing / ParsingThe primary read and write APIs
Partial ReadingExtract only the fields you need
ValidatingRFC8259 conformance checking
Prettifying / MinifyingWhitespace-aware reformatting
Optimizing for Minified JSONPerformance mode for already-minified input
Error HandlingInspecting parse and validation failures
CPU Architecture SelectionControlling SIMD dispatch
Excluding Keys at RuntimeSkipping fields dynamically
Custom Parsing / SerializingPer-type behavior overrides
Parsing Arbitrary Dataraw_json_data for unknown shapes
Full usage guide on GitHub →

Benchmark Methodology

Throughput is measured in megabytes processed per second (MB/s) for both reading (parse) and writing (serialize), benchmarked against Glaze and simdjson on identical hardware.

The harness uses adaptive epoch sampling: iterations begin at 60 and double each epoch (60 → 120 → 240 → …) up to a maximum of 1,200 iterations per epoch. Each epoch evaluates a trailing window of max(iterations / 10, 10) samples, capped at 100,000. Convergence requires RSE < 2.5% AND mean shift < 1% epoch-over-epoch simultaneously — the first epoch satisfying both conditions is retained as the canonical result.

If convergence is never reached before 5 seconds elapse or the iteration cap is hit, the result is marked non-converged and excluded from all rankings — only converged results participate in win/tie/loss tallying. Statistical ties are detected via Welch's t-test on Bessel-corrected variance, so a small delta inside the noise floor doesn't get dressed up as a victory.

The output of each call is consumed through do_not_optimize_away() so the compiler can't eliminate the work, and input data is regenerated per iteration to prevent branch predictors and data caches from learning the input distribution.

Platforms: Windows, Linux, macOS — Compilers: MSVC, GCC, Clang — Harness: BenchmarkSuite

View the full benchmark repository →
T

Results

Platform / Compiler
Operation
Loading benchmarks

Acknowledgments

Jsonifier stands on the shoulders of prior work in the high-performance JSON and numeric-conversion space. Credit where it's owed: