GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - nihilai-collective/Jsonifier: A few classes for extremely fast json parsing/serializing in modern C++. Possibly the fastest json parser in C++. Possibly the fastest json serializer in C++.

BranchesTags
Open more actions menu

Latest commit

 

History

38 Commits
38 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
build_tools
build_tools
 
 
cmake
cmake
 
 
documentation
documentation
 
 
include
include
 
 
unit-tests
unit-tests
 
 
vcpkg
vcpkg
 
 
.clang-format
.clang-format
 
 
.gitignore
.gitignore
 
 
Batched-Drain.md
Batched-Drain.md
 
 
CMakeLists.txt
CMakeLists.txt
 
 
CMakePresets.json
CMakePresets.json
 
 
Generic-Parsing.md
Generic-Parsing.md
 
 
License.md
License.md
 
 
Logo.png
Logo.png
 
 
ReadMe.md
ReadMe.md
 
 
Serialization.md
Serialization.md
 
 
Third_Party_Licenses.md
Third_Party_Licenses.md
 
 
Two-Stages.md
Two-Stages.md
 
 
Version
Version
 
 
normalize.ps1
normalize.ps1
 
 
run-clang-format.ps1
run-clang-format.ps1
 
 
tokei.toml.txt
tokei.toml.txt
 
 

Repository files navigation

Lines of Code License C++ Header-only


Compiler Support

MSVC GCC CLANG

Operating System Support

Windows Linux Mac


At least slightly* faster than most JSON libraries, most of the time.

*Often more than slightly.

Jsonifier uses SIMD structural indexing and compile-time perfect hash maps to read and write JSON 1.8x to 2.1x faster than Glaze and 1.8x to 2.8x faster than simdjson, across every major compiler and both x86-64 and ARM64. (Nov 23, 2026 results)

  • Schema-aware (reflected structs): 1010 wins, 12 ties, and 23 losses in 1045 head-to-head tests against Glaze and simdjson on Linux, macOS, and Windows.
  • Faster reads: geometric-mean parse throughput is 1.37x to 1.50x that of Glaze, 1.71x to 2.05x that of simdjson On Demand, and 1.43x that of simdjson's C++26 reflection reader on both GCC builds.
  • Faster writes: geometric-mean serialization throughput is 2.20x to 3.38x that of Glaze and 4.76x to 5.70x that of simdjson's C++26 reflection writer.
  • Generic (schemaless) parsing: 1722 wins, 20 ties, and 58 losses in 1800 head-to-head tests against simdjson On Demand, running 1.29x to 1.40x faster across all five builds.
  • Portable: CI-verified on GCC, Clang, and MSVC, on both the detected SIMD backend (whatever the runner's CPU supports, such as AVX-512 on x86-64 or NEON on arm64 macOS) and the pure-scalar fallback.
  • Strict: fully RFC8259 compliant.
Platform vs Glaze (schema-aware) vs simdjson (schema-aware) vs simdjson On Demand (generic)
Linux GCC 16.2.1 1.84x 2.52x 1.34x
Linux Clang 24.0.0 1.84x 1.91x 1.29x
macOS GCC 16.2.0 2.13x 2.75x 1.40x
macOS Clang 23.1.5 2.01x 2.05x 1.39x
Windows MSVC 19.52 1.81x 1.84x 1.34x

Geometric mean of per-test throughput ratios: Jsonifier's best variant against each competitor's best variant. Glaze has no schemaless entry in the generic suite.

Jsonifier is fully RFC8259 compliant.

A high-performance C++ library for validating, serializing, parsing, prettifying, and minifying JSON data, very rapidly.

It achieves this through the usage of SIMD instructions as well as compile-time hash maps for efficient key lookups during parsing.

  • Stage-1 Document
  • Full Arch Document
  • Generic Parsing Document
  • Serialization Document
  • Benchmarks
  • More Benchmarks

Android: JSONIFIER_PLATFORM_ANDROID is detected and handled distinctly from JSONIFIER_PLATFORM_LINUX (separate mmap/unistd.h wiring, its own entry in the supported-platform check), for NDK cross-compilation. It is not part of the CI matrix above, so treat it as best-effort rather than continuously verified.

CPU Architecture Support

Jsonifier automatically detects and optimizes for your CPU architecture:

  • x64 / AMD64: 64-bit extension of x86 with enhanced memory addressing
  • AVX: 128-bit vector registers for SIMD operations
  • AVX2: 256-bit vector registers with additional integer operations
  • AVX-512: 512-bit vector registers for maximum parallelism (requires F + BW + VBMI2 support detected together)
  • PCLMULQDQ: carry-less multiplication support, detected and used where available
  • ARM-NEON: SIMD instructions for ARM processors
  • ARM-SVE2: scalable vector extensions for ARM processors ⚠️ experimental: the SVE2 backend is new and still under active development; a handful of parsing cases are not yet handled correctly. NEON remains the recommended path for production ARM builds until SVE2 correctness is fully verified. Feedback and bug reports on SVE2-specific behavior are very welcome.

Exactly one SIMD backend is compiled into each build, chosen at configure time; nothing is selected at run time. A binary configured for AVX-512 requires AVX-512 on every machine that runs it, so configure for the lowest tier you need to support when distributing to mixed hardware. Pass -DJSONIFIER_SIMD_TIER=AVX2 (or AVX, NEON, NONE, ...) at configure time to build a lower tier than the one detected. See One tier per build.

Manual configuration and cross-compilation are supported by defining JSONIFIER_CPU_INSTRUCTIONS (plus JSONIFIER_SVE2_VECTOR_BITS for SVE2 targets) at CMake configure time, which replaces the detected feature bits with the target's. See Overriding the Detected Features.


Features

Compile-Time Reflection

Structures are registered via template specialization using member pointers as non-type template parameters. No macros, no code generation, no runtime type registry; the entire schema is known to the compiler, which means key lookups collapse into compile-time hash-map dispatch and dead branches get eliminated before they exist. Custom JSON key names (kebab-case, digit-prefixed, reserved words) are handled at compile time via makeJsonEntity<&member, "custom-name">() with zero runtime overhead.

SIMD-Accelerated Stage-1

Structural indexing runs through a batched-drain, fused-scan architecture: character classification, quote-scope tracking, and UTF-8 validation happen in the same pass over the input, with cross-SIMD-width validation state carried between blocks via a dedicated register-scoped validator. The structural index itself is stored as a compact array of offsets into the source buffer rather than raw pointers, keeping the index footprint small and cache-friendly. Everything the compiler can know statically about the target architecture (cache-line size, vector width, alignment) is baked into the binary as constexpr.

UTF-8 Validation, By Default

Full UTF-8 validation runs as part of every parse, always, built on a Lemire/simdjson-derived table-lookup validator with both a bulk-buffer path and a streaming, register-scoped path that carries state across chunk boundaries. Validation is fused directly into string scanning rather than requiring a separate pass. Correctness is backed by the full Markus Kuhn UTF-8 stress-test corpus, alignment-sweep fuzzing, and page-boundary overrun checks.

Purpose-Built Hash Maps

Key lookups during parsing use compile-time-generated hash maps. Structs with 0, 1, 2, or 3 fields get dedicated maps; larger ones fall through a compile-time cascade (single distinguishing byte, first byte plus unique column, unique byte plus length, unique column per length, and finally a seeded SIMD full-key hash) until one produces a collision-free table. No bucket walks; the lookup is generated for the specific set of keys your struct declares.

Complete JSON Support

Full RFC8259 compliance. All types (objects, arrays, strings, numbers, booleans, null), full Unicode with proper surrogate-pair handling, all escape sequences, and jsonifier::raw_json_data for preserving arbitrary sub-trees verbatim.

Flexible Parsing Modes

  • Default parsing: single pass over the raw buffer, compile-time hash-map key dispatch, keys accepted in any order
  • Known-order parsing: tries the declaration-order key first, then a self-tuning per-position memo, then the hash map; adds a fused literal-match fast path for minified input
  • Partial reading: parse unordered or partial JSON structures
  • Arbitrary data: work with unknown JSON via raw_json_data
  • Generic (schema-free) parsing: lazy, On Demand-style jsonifier_core::iterate with re-readable values, out-of-order field access, JSON Pointers and iterateMany for NDJSON and comma-delimited streams

Every parsing-family test in the suite is run across all eight combinations of partialRead, knownOrder, and nullTerminated.

Choosing a Parsing Mode

Full-document parses can take either the default fused single-pass path or the two-stage (stage-1 tape + stage-2) path, selected with partialRead = true. Which one is faster depends on whether your input is indented and which SIMD backend you are on. The Two Stages, On Demand whitepaper measures both paths in one binary across 245 tests on five builds; its results suggest:

Input x86 (AVX2 / AVX-512) ARM (NEON)
POD-type values Fused (default): won all 15 Fused (default): won all 10
Minified documents Fused (default) + minified = true: won 61 of 66 Fused (default) + minified = true: won all 44
Prettified documents Two-stage (partialRead = true): won 63 of 66 Fused (default): won 34 of 44
// Minified input, any architecture
parser.parseJson<jsonifier::parse_options{ .minified = true }>(data, json);

// Prettified input on x86
parser.parseJson<jsonifier::parse_options{ .partialRead = true }>(data, json);

// Prettified input on NEON
parser.parseJson(data, json);

Notes from the data:

  • The five minified documents the tape won on x86 were all under MSVC (Marine IK and Marine IK Reverse among them), so MSVC users parsing number-heavy minified input may want to benchmark both paths.
  • On x86 the two-stage path wins prettified documents by up to roughly 45%; on NEON the fused path wins most of them, with GCC leaning a little more toward the tape than Clang.
  • If you control the producer, minifyJson once and parse with minified = true: minified input on the fused path is the fastest combination on every platform measured.
  • Add knownOrder = true when keys arrive in declaration order (see Known Order Parsing).
  • Jsonifier does not yet pick the path automatically from architecture, compiler or indentation, so this choice is yours to make.

Safety & Reliability

Comprehensive error reporting with source location tracking, backed by a compact, purpose-built status-code model: parsing, validation, minification, and prettification each propagate failure immediately on the first error rather than continuing to walk a broken buffer. Configurable maximum nesting depth (parse_options::maxDepth, default 1024) guards against malicious or runaway input.

Continuous integration runs AddressSanitizer and UndefinedBehaviorSanitizer on every push across every supported platform and compiler. The conformance test suite covers the full RFC8259 pass/fail battery (both the classic jsonchecker corpus and the full JSONTestSuite Y/N corpus) through both the typed and generic parsers, plus dedicated UTF-8 correctness tests including the full Markus Kuhn stress-test set, chunk/block-boundary crossings, unaligned-pointer sweeps, and an mmap page-boundary fault check.


Testing

Every push runs the full unit-test suite on Ubuntu (Clang/GCC), macOS (Clang/GCC), and Windows (MSVC), with ASan and UBSan enabled where supported, once with the detected SIMD backend and once more as a pure-scalar build (JSONIFIER_CPU_INSTRUCTIONS=0). See Unit Tests for the CI setup, how to run the tests locally, and a breakdown of every test suite.


Quick Example

#include <jsonifier>

struct event {
    int64_t id{};
    std::string name{};
    std::optional<std::string> logo{};
    std::vector<int64_t> topicIds{};
};

struct catalog {
    std::unordered_map<std::string, event> events{};
    std::string schema_version{};
};

template<> struct jsonifier::core<event> {
    using value_type = event;
    static constexpr auto parseValue = createValue<
        &value_type::id,
        &value_type::name,
        &value_type::logo,
        &value_type::topicIds>();
};

template<> struct jsonifier::core<catalog> {
    using value_type = catalog;
    static constexpr auto parseValue = createValue<
        &value_type::events,
        makeJsonEntity<&value_type::schema_version, "schema-version">()>();
};

int32_t main() {
    jsonifier::jsonifier_core<> parser;

    catalog data;
    std::string json = R"({"events":{"42":{"id":42,"name":"Concert","logo":null,"topicIds":[1,2,3]}},"schema-version":"1.0"})";
    parser.parseJson(data, json);

    std::string output;
    parser.serializeJson(data, output);

    return 0;
}

Note the makeJsonEntity<&value_type::schema_version, "schema-version">(): Jsonifier maps the C++-legal schema_version member to the kebab-case "schema-version" key in JSON entirely at compile time, with zero runtime cost.

Warning: Include only . Direct inclusion of internal headers may cause unrelated code in the including translation unit to become uncompilable.

The jsonifier_core<> type is templated on an initial scratch-buffer size in bytes (default 1MB), e.g. jsonifier::jsonifier_core<4 * 1024 * 1024> parser; for workloads that consistently deal with larger documents. It is compiled for the single SIMD tier configured at build time, so a binary configured for AVX-512 requires AVX-512 on every machine that runs it. See Backends and the Core.


Godbolt

Some users may want to browse code along with the compiled assembly. The following examples use the Jsonifier trunk available on Compiler Explorer:

  • Schema-aware parsing: Ice Lake (AVX-512), Haswell (AVX2), NEON
  • Schema-aware serializing: Ice Lake (AVX-512), Haswell (AVX2), NEON

Documentation

Getting Started

  • Installation: Install via vcpkg, CMake FetchContent, or source
  • Quick Start: Five-minute onramp with a working example

Core Usage

  • Reflection: Registering structures with compile-time reflection
  • Serializing & Parsing: Complete serialization/parsing guide
  • Validating: JSON validation against RFC standards

Optimization

  • Known Order Parsing: Guaranteed-order optimization for hot paths
  • Optimizing For Minified JSON: Boost performance for minified input
  • Partial Reading: Parse unordered or partial JSON structures
  • CPU Architecture Selection: Configure-time backend selection, stage-1 step tuning, and manual CPU instruction set configuration, including SVE2 and cross-compilation overrides

Output Formatting

  • Prettifying: Pretty-print JSON with customizable indentation
  • Minifying: Minify JSON for compact output

Advanced Topics

  • UTF-8 Validation: Cross-SIMD-width validation architecture
  • Error Handling: Detailed error reporting and handling
  • Excluding Keys at Runtime: Dynamic key exclusion during serialization
  • Parsing Arbitrary Data: Working with unknown JSON structures
  • Generic Parsing: Schema-free, On Demand-style parsing and NDJSON or comma-delimited streams
  • Unit Tests: CI matrix, running tests locally, and everything the suite covers

Requirements

  • CMake 3.28 or later
  • C++23 compliant compiler (MSVC 2022 v19.40+, GCC 14+, Clang 18+)
  • Supported CPU (x64, ARM64 with NEON or SVE2*)

* SVE2 support is experimental; see the CPU Architecture Support section above.


License

This library is licensed under the MIT License. See the LICENSE file for details.


Acknowledgments

  • SIMD parsing techniques inspired by simdjson
  • Reflection interface inspired by Glaze
  • zmij for shortest round-trip float serialization
  • FastFloat for number parsing
  • Unit test harness: rt-ut
  • Raymond, because, Thanks.
  • Paul Mandarino. "Back yourself up, back your words up."

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues on GitHub.


Star this repository if you find it useful! ⭐


The contents of the documentation in this project were mostly generated with Claude Opus 5.5, then reviewed by an engineer. The code in this project was "AI Assisted" according to this definition

About

A few classes for extremely fast json parsing/serializing in modern C++. Possibly the fastest json parser in C++. Possibly the fastest json serializer in C++.

Topics

avxavx2avx512c-plus-pluscppjasonparserjsonjson-parsingjson-parsing-libraryjson-simdjsonifierparsingserializationsimd-instructions

Resources

Readme
MIT license

Contributing

Contributing
Activity
Custom properties

Stars

104 stars

Watchers

5 watching

Forks

7 forks
Report repository

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.