Skip to content

neojson v0.1.0

Latest

Choose a tag to compare

@fox1245 fox1245 released this 24 Nov 06:38
177289e

neojson v0.1.0

Initial public release of neojson — an nlohmann::ordered_json-compatible C++17 JSON library combining native x86-64 AVX2 and ARM64 NEON SIMD parsers, a vendored yyjson fallback, and a lazy Copy-on-Write DOM.

Highlights

  • Native AVX2 / NEON / SWAR Parsers + Pooled Buffers: Native x86-64 AVX2 (Avx2ParserOps) and ARM64 NEON (NeonParserOps) SIMD parser backends with Keiser-Lemire UTF-8 validation, Eisel-Lemire float conversion, SWAR 8-digit integer/fractional parsing, and bounded thread-local buffer caching (ThreadLargeCache, ThreadSlabCache), falling back seamlessly to vendored yyjson on unsupported targets and small/comment/BOM inputs.
  • Lazy Copy-on-Write DOM & DocArena Views: sizeof(neojson::json) == 16, atomic-refcounted SharedString payloads, bump-allocated DocArena immutable const views with shape caching (ArenaShapeCache) and string interning, compact SmallArray2/SmallObject4/CompactObject layouts, open-addressed ordered_map indexing (HashIndex), and iterative deep destruction.
  • Fused Single-Pass Direct Serializer: Streams unmaterialized unique-key subtrees directly into a pre-reserved std::string with AVX2/SSE2/NEON/scalar UTF-8 validation and escape scanning, plus Schubfach shortest round-trip IEEE-754 formatting.
  • Safety & Production Controls: Configurable json::parse_options::max_depth (default 1100), thread-local cache budgets (get_thread_cache_limits(), set_thread_cache_limits(), trim_thread_caches()), differential tests against nlohmann/json, time-complexity bounds tests, and runnable C++17 examples under examples/.
  • Packaging & CMake / pkg-config Support:
    • Public NEOJSON_VERSION_MAJOR (0), NEOJSON_VERSION_MINOR (1), NEOJSON_VERSION_PATCH (0), and NEOJSON_VERSION_STRING ("0.1.0") macros.
    • find_package(neojson 0.1 CONFIG REQUIRED), relocatable neojson.pc (pkg-config), FetchContent/add_subdirectory subproject defaults (NEOJSON_BUILD_TESTS, NEOJSON_BUILD_EXAMPLES, NEOJSON_INSTALL default to OFF when embedded), BUILD_SHARED_LIBS support on ELF/Mach-O (STATIC on Windows), and hidden vendored yyjson symbols.

Benchmark Summary (7.94 MB Standard 4-File Corpus)

Single-thread throughput vs 6 established C/C++ JSON libraries (GCC 13.3.0 -O3 -DNDEBUG, portable Release without -march=native):

Architecture Workload neojson vs yyjson (C) vs simdjson (DOM) vs nlohmann::ordered_json
x86-64 AVX2 Parse (4 files) 2,575 MB/s (3.08 ms) 1.85× 1.45× 31.1×
Parse + Full Read 1,539 MB/s (5.16 ms) 1.29× 1.10× 19.0×
Write (Minified) 2,783 MB/s (2.85 ms) 1.54× 1.74× 8.7×
Field Lookup (twitter.json) 165.7 K/s (6.03 µs) 1.71× 2.17× 1.33×
ARM64 NEON Parse (4 files) 1,885 MB/s (4.21 ms) 1.65× 1.61× 34.5×
Parse + Full Read 1,155 MB/s (6.87 ms) 1.19× 1.19× 21.7×
Write (Minified) 1,918 MB/s (4.14 ms) 1.44× 1.78× 7.3×
Field Lookup (twitter.json) 123.9 K/s (8.07 µs) 1.26× 1.95× 1.16×

See docs/benchmarks.md for the complete 7-library tables, per-file breakdowns, charts, and reproduction instructions.

Installation

CMake FetchContent

include(FetchContent)
FetchContent_Declare(
    neojson
    GIT_REPOSITORY https://github.com/fox1245/neojson.git
    GIT_TAG        v0.1.0
)
FetchContent_MakeAvailable(neojson)

target_link_libraries(my_app PRIVATE neojson::neojson)

System Install + find_package

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DNEOJSON_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build build --parallel
cmake --install build

See README.md and CHANGELOG.md for compatibility notes (array_t/object_t allocator types, lazy/COW const reference stability, Schubfach float formatting).