[![JSON for Modern C++](https://raw.githubusercontent.com/nlohmann/json/master/doc/json.gif)](https://github.com/nlohmann/json/releases)
[![Build Status](https://travis-ci.org/nlohmann/json.svg?branch=master)](https://travis-ci.org/nlohmann/json)
[![Build Status](https://ci.appveyor.com/api/projects/status/1acb366xfyg3qybk/branch/develop?svg=true)](https://ci.appveyor.com/project/nlohmann/json)
[![Build Status](https://circleci.com/gh/nlohmann/json.svg?style=svg)](https://circleci.com/gh/nlohmann/json)
[![Coverage Status](https://img.shields.io/coveralls/nlohmann/json.svg)](https://coveralls.io/r/nlohmann/json)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/5550/badge.svg)](https://scan.coverity.com/projects/nlohmann-json)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f3732b3327e34358a0e9d1fe9f661f08)](https://www.codacy.com/app/nlohmann/json?utm_source=github.com&utm_medium=referral&utm_content=nlohmann/json&utm_campaign=Badge_Grade)
[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/nlohmann/json.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/nlohmann/json/context:cpp)
[![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/TarF5pPn9NtHQjhf)
[![Documentation](https://img.shields.io/badge/docs-doxygen-blue.svg)](http://nlohmann.github.io/json)
[![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)
[![GitHub Issues](https://img.shields.io/github/issues/nlohmann/json.svg)](http://github.com/nlohmann/json/issues)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/nlohmann/json.svg)](http://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)
- [Design goals](#design-goals)
- [Integration](#integration)
- [CMake](#cmake)
- [Package Managers](#package-managers)
- [Examples](#examples)
- [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, and UBJSON)](#binary-formats-bson-cbor-messagepack-and-ubjson)
- [Supported compilers](#supported-compilers)
- [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](http://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 class is heavily [unit-tested](https://github.com/nlohmann/json/tree/develop/test/src) and covers [100%](https://coveralls.io/r/nlohmann/json) of the code, including all exceptional behavior. Furthermore, we checked with [Valgrind](http://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.
## Integration
[`json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp) is the single required file in `single_include/nlohmann` or [released here](https://github.com/nlohmann/json/releases). You need to add
```cpp
#include <nlohmann/json.hpp>
// for convenience
using json = nlohmann::json;
```
to the files you want to process JSON and set the necessary switches to enable C++11 (e.g., `-std=c++11` for GCC and Clang).
You can further use file [`include/nlohmann/json_fwd.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/json_fwd.hpp) for forward-declarations. The installation of json_fwd.hpp (as part of cmake's install step), can be achieved by setting `-DJSON_MultipleHeaders=ON`.
### CMake
You can also use the `nlohmann_json::nlohmann_json` interface target in CMake. This target populates the appropriate usage requirements for `INTERFACE_INCLUDE_DIRECTORIES` to point to the appropriate include directories and `INTERFACE_COMPILE_FEATURES` for the necessary C++11 flags.
#### External
To use this library from a CMake project, you can locate it directly with `find_package()` and use the namespaced imported target from the generated package configuration:
```cmake
# CMakeLists.txt
find_package(nlohmann_json 3.2.0 REQUIRED)
...
add_library(foo ...)
...
target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json)
```
The package configuration file, `nlohmann_jsonConfig.cmake`, can be used either from an install tree or directly out of the build tree.
#### Embedded
To embed the library directly into an existing CMake project, place the entire source tree in a subdirectory and call `add_subdirectory()` in your `CMakeLists.txt` file:
```cmake
# Typically you don't care so much for a third party library's tests to be
# run from your own project's code.
set(JSON_BuildTests OFF CACHE INTERNAL "")
# If you only include this third party in PRIVATE source files, you do not
# need to install it when your main project gets installed.
# set(JSON_Install OFF CACHE INTERNAL "")
# Don't use include(nlohmann_json/CMakeLists.txt) since that carries with it
# unintended conseque
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Forward 是一款腾讯研发的 GPU 高性能推理加速框架。它提出了一种解析方案,可直接加载主流框架模型(Tensorflow / PyTorch / Keras / ONNX)转换成 TensorRT 推理加速引擎,帮助用户节省中间繁杂的模型转换或网络构建步骤。相对于直接使用 TensorRT,Forward 更易用以及更容易扩展支持更多模型和算子。目前,Forward 除了覆盖支持主流的 CV,NLP 及推荐领域的深度学习模型外,还支持一些诸如 BERT,FaceSwap,StyleTransfer 这类高级模型。
资源推荐
资源详情
资源评论
收起资源包目录
Forward 是一款腾讯研发的 GPU 高性能推理加速框架 (1737个子文件)
ACKNOWLEDGMENTS 683B
Makefile.am 9KB
VS2019.bat 379B
VS2017.bat 379B
meson.build 552B
H5Shyper.c 514KB
H5Tconv.c 387KB
H5C.c 329KB
H5Dchunk.c 308KB
H5VLcallback.c 274KB
H5T.c 238KB
H5Pfapl.c 221KB
H5Pint.c 219KB
H5Dint.c 168KB
H5trace.c 159KB
H5HFsection.c 159KB
H5Dmpio.c 156KB
H5Fint.c 150KB
H5Pdcpl.c 146KB
H5Dvirtual.c 142KB
H5MF.c 140KB
H5HFcache.c 138KB
H5Cimage.c 133KB
H5L.c 132KB
H5CX.c 130KB
H5Sselect.c 121KB
H5Oalloc.c 111KB
H5SM.c 111KB
H5VLpassthru.c 108KB
H5FDs3comms.c 108KB
H5Oint.c 107KB
H5FSsection.c 104KB
H5Aint.c 102KB
H5SL.c 97KB
H5AC.c 91KB
H5Zscaleoffset.c 91KB
H5B2int.c 89KB
H5Spoint.c 85KB
H5ACmpio.c 83KB
H5I.c 82KB
H5Odtype.c 82KB
H5EAcache.c 82KB
H5FL.c 81KB
H5VLint.c 81KB
H5Fsuper.c 79KB
H5Adense.c 78KB
H5Pdxpl.c 78KB
H5F.c 78KB
H5Oattribute.c 77KB
H5B.c 77KB
H5Omessage.c 75KB
H5HFiblock.c 75KB
H5Pocpl.c 74KB
H5Ocopy.c 74KB
H5A.c 68KB
H5P.c 68KB
H5Ztrans.c 68KB
H5FDlog.c 67KB
H5S.c 67KB
H5Gdense.c 66KB
H5Dcontig.c 65KB
H5FDmpio.c 65KB
H5FDmulti.c 64KB
H5Dearray.c 64KB
H5detect.c 63KB
H5FD.c 63KB
H5FDcore.c 63KB
H5Ocache.c 62KB
H5Znbit.c 62KB
H5Smpio.c 62KB
H5Z.c 61KB
H5B2internal.c 60KB
H5FDhdfs.c 60KB
H5B2.c 60KB
H5Cmpio.c 59KB
H5VM.c 59KB
H5O.c 59KB
H5FScache.c 59KB
H5Pdapl.c 59KB
H5Rint.c 58KB
H5PB.c 58KB
H5E.c 57KB
H5Pfcpl.c 57KB
H5Gnode.c 56KB
H5Dfarray.c 56KB
H5Dio.c 54KB
H5HFhdr.c 54KB
H5Cdbg.c 54KB
H5Dbtree2.c 53KB
H5Olayout.c 53KB
H5FDros3.c 52KB
H5Dbtree.c 52KB
H5Faccum.c 48KB
H5Gname.c 48KB
H5Gint.c 47KB
H5FDfamily.c 47KB
H5FDdirect.c 47KB
H5Gobj.c 47KB
H5Gdeprec.c 47KB
H5B2cache.c 47KB
共 1737 条
- 1
- 2
- 3
- 4
- 5
- 6
- 18
资源评论
地理探险家
- 粉丝: 982
- 资源: 5416
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功