nlohmann /json

JSON for Modern C++

★ 50,891⑂ 7,525👁 732⑃ 2,226● 2,539▤ 45
C++MITCreated 2013-07-04json.nlohmann.me
下载:JSON for Modern C++ version 3.12.0JSON-3.12.0 ↓3.12.02025-04-11
-1
日增长
+39
周增长
+129
月增长
50,891
stars
7,525
forks
732
watchers
2,226
prs
2,539
issues
45
releases

README

- Design goals
- Sponsors
- Support (documentation, FAQ, discussions, API, bug issues)
- Quick reference
- Examples
  - Read JSON from a file
  - Creating json objects from JSON literals
  - JSON as a first-class data type
  - Serialization / Deserialization
  - STL-like access
  - Conversion from STL containers
  - JSON Pointer and JSON Patch
  - JSON Merge Patch
  - Implicit conversions
  - Conversions to/from arbitrary types
  - Specializing enum conversion
  - Binary formats (BSON, CBOR, MessagePack, UBJSON, BJData, and BON8)
  - Zero-copy views
- Customers
- Ecosystem
- Supported compilers
- Integration
  - CMake
  - Package Managers
  - Pkg-config
- License
- Contact
- Security
- Thanks
- Used third-party tools
- Notes
- Execute unit tests

 Design goals

There are myriads of JSON libraries out there, and each may even have its reason to exist. Our class had these design goals:

- Intuitive syntax. In languages such as Python, JSON feels like a first-class data type. We used all the operator magic of modern C++ to achieve the same feeling in your code. Check out the examples below and you'll know what I mean.

- Trivial integration. Our whole code consists of a single header file json.hpp. That's it. No library, no subproject, no dependencies, no complex build system. The class is written in vanilla C++11. All in all, everything should require no adjustment of your compiler flags or project settings. The library is also included in all popular package managers.

- Serious testing. Our code is heavily unit-tested and covers 100% of the code, including all exceptional behavior. Furthermore, we checked with Valgrind and the Clang Sanitizers that there are no memory leaks. Google OSS-Fuzz additionally runs fuzz tests against all parsers 24/7, effectively executing billions of tests so far. To maintain high quality, the project is following the OpenSSF Best Practices. See the quality assurance overview documentation.

Other aspects were not so important to us:

- Memory efficiency. Each JSON object has an overhead of one pointer (the maximal size of a union) and one enumeration element (1 byte). The default generalization uses the following C++ data types: std::string for strings, int64_t, uint64_t or double for numbers, std::map for objects, std::vector for arrays, and bool for Booleans. However, you can template the generalized class basic_json to your needs.

- Speed. There are certainly faster JSON libraries out there. However, if your goal is to speed up your development by adding JSON support with a single header, then this library is the way to go. If you know how to use a std::vector or std::map, you are already set. The performance page shows how to get the most out of the library.

See the contribution guidelines for more information.

 Sponsors

You can sponsor this library at GitHub Sponsors.

 :raising_hand: Priority Sponsor

- Martti Laine
- Paul Harrington
- Mercedes-Benz Group
- Ryan McCaffery

 :label: Named Sponsors

- Michael 

Top issues

Discussions

Latest release

JSON for Modern C++ version 3.12.0 v3.12.0 2025-04-11
Release date: 2025-04-11
SHA-256: aaf127c04cb31c406e5b04a63f1ae89369fccde6d8fa7cdda1ed4f32dfc5de63 (json.hpp), b8cb0ef2dd7f57f18933997c9934bb1fa962594f701cd5a8d3c2c80541559372 (include.zip), 42f6e95cad6ec532fd372391373363b62a14af6d771056dbfc86160e6dfff7aa (json.tar.xz)

 Summary

This release fixes some bugs found in the 3.11.3 release and adds some new features.

All changes are backward-compatible.

:moneybag: Note you can support this project via GitHub sponsors or PayPal.

 Key updates and enhancements

- Diagnostic byte positions: A new macro, JSON_DIAGNOSTIC_POSITIONS, intro

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON