An ultralightweight, single-file JSON parser and printer written in portable ANSI C.
cJSON is an ultralightweight JSON parser and printer library written in portable ANSI C. It allows C programs to easily parse JSON data into a manipulable tree structure, modify it, and serialize it back to a string. It solves the problem of handling JSON in resource-constrained or highly portable C environments where larger libraries are impractical.
C developers working on embedded systems, legacy platforms, or any project requiring a minimal, dependency-free JSON library with maximum portability.
Developers choose cJSON for its extreme simplicity, single-file deployment, and strict ANSI C compliance, which guarantees it will work on virtually any platform with a C compiler. It provides a no-frills, reliable way to handle JSON without bloat.
Ultralightweight JSON parser in ANSI C
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Consists of just one C source file and one header file, written in ANSI C89 for maximum compatibility across obscure or legacy platforms and compilers.
Offers straightforward functions like cJSON_Parse and cJSON_Print, with helper utilities such as cJSON_AddStringToObject that reduce boilerplate and common errors.
Provides reference-based items (e.g., cJSON_CreateStringReference) and explicit ownership rules to prevent double frees, crucial for manual memory management in C.
Supports CMake, Make, Meson, and Vcpkg, allowing easy adoption into diverse project setups without forcing a specific build system.
Cannot handle strings containing zero characters ('\0') and only loosely accepts UTF-8 without validation, risking issues with malformed or non-standard JSON inputs.
Not inherently thread-safe; safe usage requires avoiding cJSON_GetErrorPtr and carefully managing cJSON_InitHooks, adding complexity for concurrent applications.
Officially supports only IEEE754 doubles and has a compile-time nesting limit (default 1000), which can cause stack overflows or parsing failures in edge cases.