C++ library for JSON parsing/serialization
Top 47.7% on sourcepulse
This library provides a C++ JSON parser and serializer optimized for performance and minimal code size, targeting developers who need a fast, lightweight, and hackable JSON solution for classic C++ environments. It aims to be significantly faster and smaller than modern C++ alternatives like nlohmann/json, while maintaining high conformance with the JSONTestSuite.
How It Works
The library employs a C-style parsing approach, prioritizing speed and simplicity over extensive C++ template metaprogramming. It leverages Google's double-conversion library for efficient floating-point serialization, preserving float
precision without upcasting to double
. This design choice results in a smaller codebase and faster compilation times compared to more feature-rich C++ JSON libraries.
Quick Start & Requirements
json.cpp
and json.h
into your project.Highlighted Details
float
precision during serialization, unlike libraries that upcast to double
.json.h
and 1,303 lines for json.cpp
.Maintenance & Community
Originally developed for Redbean in C, it was converted to C++ for Mozilla's llamafile project in 2024.
Licensing & Compatibility
The library is licensed under the MIT License, allowing for commercial use and integration into closed-source projects.
Limitations & Caveats
The library exhibits IMPLEMENTATION_FAIL
for several JSONTestSuite cases related to malformed UTF-8, overlong sequences, and control codes within strings. It also fails on deeply nested arrays (depth_exceeded
).
3 days ago
1 day