Skip to content

Release v1.0.0

Choose a tag to compare

@RealTimeChris RealTimeChris released this 07 Jun 04:21
· 3 commits to main since this release

Jsonifier v1.0.0

A high-performance, RFC8259-compliant C++23 library for validating, parsing, serializing, prettifying, and minifying JSON — built on SIMD instructions and compile-time reflection for key lookups.

This release marks the first stable, fully-packaged, fully-tested cut of Jsonifier. Below is what landed.


Build System & CMake

  • Modern CMake (3.28+) build targeting C++23, structured as an INTERFACE library with a jsonifier::Jsonifier alias.
  • Modular CMake setup split into library_setup.cmake and installation_setup.cmake for clean separation of build and install logic.
  • Comprehensive compile-definition matrix exposing arch (X64/ARM64), platform (Windows/Linux/Mac), and compiler (Clang/MSVC/GCC) as compile-time constants, plus configurable JSONIFIER_INLINE/JSONIFIER_CLANG_INLINE/JSONIFIER_LIFETIME_BOUND attribute macros that adapt per-compiler and per-config.
  • Full CMakePresets.json covering Windows Release/Debug variants with Benchmarks, Tests, and ASAN permutations.
  • Install/export target support via JsonifierConfig.cmake.in for find_package(Jsonifier CONFIG REQUIRED) consumption.

CPU Architecture Detection

  • Automatic runtime architecture detection (JsonifierDetectArchitecture.cmake + main.cpp feature detector) probing for LZCNT, POPCNT, BMI1, NEON, AVX, AVX2, and AVX-512.
  • Auto-generation of JsonifierCPUInstructions.hpp with the detected instruction-set bitmask and helper macros.
  • Manual override available through JSONIFIER_CPU_FLAGS for fine-grained control.

Continuous Integration

  • Cross-platform unit-tests.yml matrix: Ubuntu (Clang/GCC), macOS (Clang/GCC), and Windows (MSVC), running on every push and PR.
  • Every build runs with ASAN + UBSAN enabled for memory-safety and undefined-behavior detection across all platforms.
  • Automated vcpkg release pipeline (Construct-Vcpkg-Info.yml + PHP make_vcpkg.php/Vcpkg.php) that does a two-pass build to capture the correct SHA512 and open a downstream vcpkg PR on tagged release.
  • Workflow-run cleanup automation (DeleteRuns.yml).

Packaging & Distribution

  • vcpkg port (Vcpkg/ports/jsonifier) with full version history in the registry, supporting Windows/Linux/macOS x64.

Documentation

A complete documentation set landed under Documentation/, covering installation (vcpkg / FetchContent / source), reflection-based structure registration, parsing & serialization usage, validation, error handling, prettifying, minifying, partial reading, minified-JSON optimization, custom parse/serialize specialization, parsing arbitrary raw_json_data, runtime key exclusion, and CPU architecture selection.

Project Standards

  • MIT licensed.
  • Enforced code style via .clang-format (tabs, 180-column limit, C++11 braced-list style).
  • RFC8259 compliance as a baseline guarantee.

Core Engine

Library Entry Points

The umbrella <jsonifier> header and Index.hpp aggregate the full public surface — parsing, serialization, prettifying, minifying, validation, the hash map, raw JSON data, string/SIMD utilities — behind a single include.

Parsing Engine

Full parse_impl and partial-read parse_partial_impl specializations spanning the entire type lattice: jsonifier objects, maps, vectors, raw arrays, tuples, strings, chars, enums, numbers, bools, null, variant, optional, and shared/unique/raw pointers, plus raw-JSON passthrough and skip. Object parsing uses a thread-local antiHashStates table to fast-path known-order keys, falling back to a compile-time hash map on miss, with a dispatch layer that inlines a fold for small member counts (≤6) and switches to a function-pointer jump table beyond that. Minified and prettified inputs each get their own code path so whitespace handling costs nothing when it isn't needed. The parser surfaces precise, source-located errors and supports parse-into-existing, parse-and-return, and parse-many variants.

Validation

A standalone structural validator walks objects, arrays, strings, numbers, bools, and null against RFC8259, emitting specific validate_status codes (missing colon, missing comma/closing brace, invalid number/string/bool/null, etc.) rather than a bare pass/fail.

Serialization

The serializer estimates output size at compile time via getPaddingSize and refines it at runtime with computeRuntimeSize, so the buffer is sized in as few reallocations as possible. Prettify indentation is emitted through a precomputed indent_table blitter that memcpys whole indent runs (with an overflow path for deep nesting) instead of looping per-space, and small fixed tokens go through packed char_blitter writes. A branchless bool serializer packs true/false via integer arithmetic and a single 5-byte store.

Minify & Prettify

Both operate directly on the SIMD structural index, classifying each structural via a 256-entry lookup table — the minifier back-tracks whitespace per token, and the prettifier maintains an explicit depth/state stack with customizable indent size and character.


Test Suite & Validation

Test Harness & Build Integration

  • Dedicated jsonifier-unit-tests target wired into CMake, pulling in the rt-ut unit-test framework and benchmarksuite via FetchContent.
  • Per-compiler sanitizer and warning configuration: Clang builds run under the full -Weverything/-Wpedantic/-Werror gauntlet (with noise-floor exclusions like -Wno-padded, -Wno-c++98-compat), GCC and MSVC get their own tuned -Wall/-Wextra/-Werror and /Wall//W4//WX matrices, all with ASAN/UBSAN plumbing.
  • Smart sanitizer fallbacks: auto-disables on GCC/macOS where unsupported, warns and disables UBSAN under MSVC, and auto-detects the Homebrew GCC runtime path for libstdc++ rpath linking.
  • BASE_PATH compile definition so tests can locate their JSON fixtures at runtime.

Real-World Parse/Serialize Coverage

Round-trip parse → serialize validation across a large set of representative real-world payloads, each with full reflection mappings: Apache Builds, Canada (GeoJSON), CITM Catalog, Discord, GitHub Events, Google Maps, Instruments, Marine IK, Mesh, Random, and Twitter (including dedicated partial-read variants for Twitter and the ABC structs). Each runs in both minified and prettified modes, and across both knownOrder = true and false paths.

Conformance Testing

RFC8259 conformance suite running 60+ fail cases and 27 pass cases from the jsonchecker corpus, with each test asserting the specific expected parse_status (e.g. Missing_Array_End, Invalid_Number_Value, Unfinished_Input, Invalid_String_Characters) rather than just pass/fail — so regressions in error classification get caught, not just error presence.

Type & Primitive Validation

  • Float: 64 hand-picked edge cases including denormals, subnormal boundaries, e±308 extremes, the 9223372036854775808 rounding cliffs, and long-digit mantissa stress strings, each checked against an exact expected double.
  • Integer / Unsigned: bounds testing right up to INT64_MIN/UINT64_MAX, overflow rejection (18446744073709551616), plus malformed-exponent and type-mismatch fail cases.
  • String: 35 pass cases covering escape sequences, surrogate pairs (\uD834\uDD1E), control chars, and multi-codepoint emoji/ZWJ sequences, 35 expected decoded outputs, and 26 fail cases for malformed escapes, lone/inverted surrogates, and truncated input.

Robustness Testing

  • Bounds/truncation: serializes a seed object, then byte-by-byte truncates from the tail, asserting that every truncated prefix fails validation — for both minified and prettified forms.
  • Round-trip integrity: 27 round-trip files including unique_ptr members and move-only types (Obj3 with deleted copy).

Inline Type-Coverage Tests (main.cpp)

A broad battery of ~75 inline assertions covering partial-read mode, renamed keys (makeJsonEntity), std::optional present/absent, enums (as integers, in arrays, as map keys), nested structs, shared_ptr, tuples, nested maps, vectors of vectors, escaped keys, large numbers, Unicode, and special characters — each as both a standalone reflection test and a partial-read variant, with boundary-length padding sweeps (0–80 chars) to flush out off-by-one and SIMD-tail bugs.