[![JSON for Modern C++](docs/json.gif)](https://github.com/nlohmann/json/releases)
[![Build Status](https://ci.appveyor.com/api/projects/status/1acb366xfyg3qybk/branch/develop?svg=true)](https://ci.appveyor.com/project/nlohmann/json)
[![Ubuntu](https://github.com/nlohmann/json/workflows/Ubuntu/badge.svg)](https://github.com/nlohmann/json/actions?query=workflow%3AUbuntu)
[![macOS](https://github.com/nlohmann/json/workflows/macOS/badge.svg)](https://github.com/nlohmann/json/actions?query=workflow%3AmacOS)
[![Windows](https://github.com/nlohmann/json/workflows/Windows/badge.svg)](https://github.com/nlohmann/json/actions?query=workflow%3AWindows)
[![Coverage Status](https://coveralls.io/repos/github/nlohmann/json/badge.svg?branch=develop)](https://coveralls.io/github/nlohmann/json?branch=develop)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/5550/badge.svg)](https://scan.coverity.com/projects/nlohmann-json)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/e0d1a9d5d6fd46fcb655c4cb930bb3e8)](https://www.codacy.com/gh/nlohmann/json/dashboard?utm_source=github.com&utm_medium=referral&utm_content=nlohmann/json&utm_campaign=Badge_Grade)
[![Cirrus CI](https://api.cirrus-ci.com/github/nlohmann/json.svg)](https://cirrus-ci.com/github/nlohmann/json)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/json.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:json)
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/1mp10JbaANo6FUc7)
[![Documentation](https://img.shields.io/badge/docs-mkdocs-blue.svg)](https://json.nlohmann.me)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nlohmann/json/master/LICENSE.MIT)
[![GitHub Releases](https://img.shields.io/github/release/nlohmann/json.svg)](https://github.com/nlohmann/json/releases)
[![Vcpkg Version](https://img.shields.io/vcpkg/v/nlohmann-json)](https://vcpkg.link/ports/nlohmann-json)
[![Packaging status](https://repology.org/badge/tiny-repos/nlohmann-json.svg)](https://repology.org/project/nlohmann-json/versions)
[![GitHub Downloads](https://img.shields.io/github/downloads/nlohmann/json/total)](https://github.com/nlohmann/json/releases)
[![GitHub Issues](https://img.shields.io/github/issues/nlohmann/json.svg)](https://github.com/nlohmann/json/issues)
[![Average time to resolve an issue](https://isitmaintained.com/badge/resolution/nlohmann/json.svg)](https://isitmaintained.com/project/nlohmann/json "Average time to resolve an issue")
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/289/badge)](https://bestpractices.coreinfrastructure.org/projects/289)
[![GitHub Sponsors](https://img.shields.io/badge/GitHub-Sponsors-ff69b4)](https://github.com/sponsors/nlohmann)
[![REUSE status](https://api.reuse.software/badge/github.com/nlohmann/json)](https://api.reuse.software/info/github.com/nlohmann/json)
[![Discord](https://img.shields.io/discord/1003743314341793913)](https://discord.gg/6mrGXKvX7y)
- [Design goals](#design-goals)
- [Sponsors](#sponsors)
- [Support](#support) ([documentation](https://json.nlohmann.me), [FAQ](https://json.nlohmann.me/home/faq/), [discussions](https://github.com/nlohmann/json/discussions), [API](https://json.nlohmann.me/api/basic_json/), [bug issues](https://github.com/nlohmann/json/issues))
- [Examples](#examples)
- [Read JSON from a file](#read-json-from-a-file)
- [Creating `json` objects from JSON literals](#creating-json-objects-from-json-literals)
- [JSON as first-class data type](#json-as-first-class-data-type)
- [Serialization / Deserialization](#serialization--deserialization)
- [STL-like access](#stl-like-access)
- [Conversion from STL containers](#conversion-from-stl-containers)
- [JSON Pointer and JSON Patch](#json-pointer-and-json-patch)
- [JSON Merge Patch](#json-merge-patch)
- [Implicit conversions](#implicit-conversions)
- [Conversions to/from arbitrary types](#arbitrary-types-conversions)
- [Specializing enum conversion](#specializing-enum-conversion)
- [Binary formats (BSON, CBOR, MessagePack, UBJSON, and BJData)](#binary-formats-bson-cbor-messagepack-ubjson-and-bjdata)
- [Supported compilers](#supported-compilers)
- [Integration](#integration)
- [CMake](#cmake)
- [Package Managers](#package-managers)
- [Pkg-config](#pkg-config)
- [License](#license)
- [Contact](#contact)
- [Thanks](#thanks)
- [Used third-party tools](#used-third-party-tools)
- [Projects using JSON for Modern C++](#projects-using-json-for-modern-c)
- [Notes](#notes)
- [Execute unit tests](#execute-unit-tests)
## Design goals
There are myriads of [JSON](https://json.org) 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](#examples) and you'll know what I mean.
- **Trivial integration**. Our whole code consists of a single header file [`json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/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.
- **Serious testing**. Our code is heavily [unit-tested](https://github.com/nlohmann/json/tree/develop/tests/src) and covers [100%](https://coveralls.io/r/nlohmann/json) of the code, including all exceptional behavior. Furthermore, we checked with [Valgrind](https://valgrind.org) and the [Clang Sanitizers](https://clang.llvm.org/docs/index.html) that there are no memory leaks. [Google OSS-Fuzz](https://github.com/google/oss-fuzz/tree/master/projects/json) 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 [Core Infrastructure Initiative (CII) best practices](https://bestpractices.coreinfrastructure.org/projects/289).
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](https://github.com/miloyip/nativejson-benchmark#parsing-time) 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.
See the [contribution guidelines](https://github.com/nlohmann/json/blob/master/.github/CONTRIBUTING.md#please-dont) for more information.
## Sponsors
You can sponsor this library at [GitHub Sponsors](https://github.com/sponsors/nlohmann).
### :raising_hand: Priority Sponsor
- [Martti Laine](https://github.com/codeclown)
### :label: Named Sponsors
- [Michael Hartmann](https://github.com/reFX-Mike)
- [Stefan Hagen](https://github.com/sthagen)
- [Steve Sperandeo](https://github.com/homer6)
- [Robert Jefe Lindstädt](https://github.com/eljefedelrodeodeljefe)
- [Steve Wagner](https://github.com/ciroque)
- [Lion Yang](https://github.com/LionNatsu)
Thanks everyone!
## Support
:question: If you have a **question**, please check if it is already answered in the [**FAQ**](https://json.nlohmann.me/home/faq/) or the [**Q&A**](https://github.com/nlohmann/json/discussions/categories/q-a) section. If not, please [**ask a new question**](https://github.com/nlohman
没有合适的资源?快使用搜索试试~ 我知道了~
C++ json库 (nlohmann/json)https://github.com/nlohmann/json
共1090个文件
cpp:383个
md:241个
output:212个
需积分: 0 3 下载量 81 浏览量
2024-09-05
23:01:16
上传
评论
收藏 8.1MB ZIP 举报
温馨提示
目前有无数种 JSON 库,每种库都有其存在的理由。我们的类有以下设计目标: 1. **直观的语法**。在 Python 等语言中,JSON 作为一种数据类型非常自然。我们使用现代 C++ 的所有运算符魔法来在您的代码中实现同样的感觉。查看下面的示例,您会明白我的意思。 2. **简单的集成**。我们的全部代码仅由一个头文件 `json.hpp` 组成,仅此而已。没有库,没有子项目,没有依赖,没有复杂的构建系统。该类使用纯 C++11 编写。总的来说,一切不需要调整编译器标志或项目设置。 3. **严格的测试**。我们的代码经过了大量单元测试,覆盖了 100% 的代码,包括所有异常行为。此外,我们还使用 Valgrind 和 Clang Sanitizers 检查了是否存在内存泄漏。Google OSS-Fuzz 还对所有解析器进行了 24/7 的模糊测试,迄今为止已经执行了数十亿次测试。为了保持高质量,该项目遵循 Core Infrastructure Initiative (CII) 的最佳实践。
资源推荐
资源详情
资源评论
收起资源包目录
C++ json库 (nlohmann/json)https://github.com/nlohmann/json (1090个子文件)
BUILD.bazel 3KB
WORKSPACE.bazel 34B
meson.build 629B
StandaloneFuzzTargetMain.c 2KB
CITATION.cff 410B
lit.cfg 1KB
lit.cfg 214B
.clang-format 2KB
.clang-tidy 2KB
ci.cmake 44KB
test.cmake 10KB
download_test_data.cmake 3KB
gen_bazel_build_file.cmake 543B
CODEOWNERS 267B
unit-bjdata.cpp 177KB
unit-cbor.cpp 127KB
unit-ubjson.cpp 111KB
unit-testsuites.cpp 102KB
unit-element_access2.cpp 94KB
unit-msgpack.cpp 85KB
unit-class_parser.cpp 83KB
unit-regression1.cpp 54KB
unit-iterators2.cpp 54KB
unit-constructor1.cpp 53KB
unit-conversions.cpp 53KB
unit-iterators1.cpp 49KB
unit-json_patch.cpp 47KB
unit-bson.cpp 44KB
unit-deserialization.cpp 44KB
unit-element_access1.cpp 39KB
unit-items.cpp 35KB
unit-to_chars.cpp 34KB
unit-modifiers.cpp 32KB
unit-json_pointer.cpp 30KB
unit-comparison.cpp 30KB
unit-regression2.cpp 29KB
FuzzerUnittest.cpp 28KB
unit-unicode1.cpp 26KB
FuzzerLoop.cpp 25KB
unit-udt.cpp 23KB
unit-pointer_access.cpp 21KB
unit-unicode2.cpp 20KB
FuzzerMutate.cpp 19KB
FuzzerDriver.cpp 18KB
unit-capacity.cpp 17KB
unit-class_iterator.cpp 17KB
unit-class_const_iterator.cpp 14KB
unit-reference_access.cpp 14KB
unit-inspection.cpp 14KB
unit-udt_macro.cpp 13KB
unit-algorithms.cpp 12KB
FuzzerTracePC.cpp 12KB
unit-serialization.cpp 11KB
FuzzerTraceState.cpp 11KB
afl_driver.cpp 11KB
unit-class_lexer.cpp 11KB
unit-unicode4.cpp 11KB
unit-unicode5.cpp 11KB
unit-unicode3.cpp 11KB
unit-binary_formats.cpp 10KB
unit-readme.cpp 10KB
unit-custom-base-class.cpp 10KB
unit-ordered_map.cpp 9KB
FuzzerMerge.cpp 9KB
unit-diagnostics.cpp 8KB
unit-alt-string.cpp 8KB
benchmarks.cpp 8KB
FuzzerIOWindows.cpp 8KB
unit-allocator.cpp 7KB
unit-merge_patch.cpp 7KB
basic_json__CompatibleType.cpp 6KB
FuzzerUtil.cpp 6KB
unit-convenience.cpp 6KB
FuzzerUtilDarwin.cpp 5KB
FuzzerSHA1.cpp 5KB
unit-concepts.cpp 5KB
FuzzerUtilWindows.cpp 5KB
unit-32bit.cpp 5KB
unit-constructor2.cpp 5KB
unit-hash.cpp 4KB
unit-noexcept.cpp 3KB
sax_parse.cpp 3KB
unit-user_defined_input.cpp 3KB
FuzzerIO.cpp 3KB
FuzzerUtilPosix.cpp 3KB
sax_parse__binary.cpp 3KB
fuzzer-parse_bjdata.cpp 3KB
fuzzer-parse_ubjson.cpp 3KB
unit-byte_container_with_subtype.cpp 3KB
at__json_pointer.cpp 2KB
unit-wstring.cpp 2KB
unit-ordered_json.cpp 2KB
json_base_class_t.cpp 2KB
CallerCalleeTest.cpp 2KB
FuzzerIOPosix.cpp 2KB
unit-type_traits.cpp 2KB
at__json_pointer_const.cpp 2KB
fuzzer-parse_bson.cpp 2KB
fuzzer-parse_msgpack.cpp 2KB
unit-udl.cpp 2KB
共 1090 条
- 1
- 2
- 3
- 4
- 5
- 6
- 11
资源评论
LQS2020
- 粉丝: 534
- 资源: 26
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- LCD1602电子时钟程序
- 西北太平洋热带气旋【灾害风险统计】及【登陆我国次数评估】数据集-1980-2023
- 全球干旱数据集【自校准帕尔默干旱程度指数scPDSI】-190101-202312-0.5x0.5
- 基于Python实现的VAE(变分自编码器)训练算法源代码+使用说明
- 全球干旱数据集【标准化降水蒸发指数SPEI-12】-190101-202312-0.5x0.5
- C语言小游戏-五子棋-详细代码可运行
- 全球干旱数据集【标准化降水蒸发指数SPEI-03】-190101-202312-0.5x0.5
- spring boot aop记录修改前后的值demo
- 全球干旱数据集【标准化降水蒸发指数SPEI-01】-190101-202312-0.5x0.5
- ActiveReports
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功