This commit is contained in:
nlohmann
2026-10-26 21:24:35 +00:00
parent 41c601a7d1
commit d2e264bd84
1400 changed files with 11859 additions and 5440 deletions
File diff suppressed because one or more lines are too long
-2
View File
@@ -43,8 +43,6 @@ Some aspects of the library can be configured by defining preprocessor macros **
- [**JSON_SKIP_UNSUPPORTED_COMPILER_CHECK**](https://json.nlohmann.me/api/macros/json_skip_unsupported_compiler_check/index.md) - do not warn about unsupported compilers
- [**JSON_USE_GLOBAL_UDLS**](https://json.nlohmann.me/api/macros/json_use_global_udls/index.md) - place user-defined string literals (UDLs) into the global namespace
- [**JSON_USE_SIMDUTF**](https://json.nlohmann.me/api/macros/json_use_simdutf/index.md) - use the simdutf library to accelerate UTF-8 validation
- [**JSON_VIEW_NO_SIMD**](https://json.nlohmann.me/api/macros/json_view_no_simd/index.md) - use only portable code in the parser of `json_view.hpp`
- [**JSON_VIEW_USE_SSSE3**](https://json.nlohmann.me/api/macros/json_view_use_ssse3/index.md) - validate non-ASCII strings with SSSE3 in the parser of `json_view.hpp`
## Library version
+2 -2
View File
@@ -38,7 +38,7 @@ Therefore, assertions can be switched off by defining `NDEBUG`.
```cpp
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -64,7 +64,7 @@ Therefore, assertions can be switched off by defining `NDEBUG`.
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -35,7 +35,7 @@ The following code will trigger an assertion at runtime:
```
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -61,7 +61,7 @@ The assertion reporting can be changed by defining `JSON_ASSERT(x)` differently.
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
+2 -2
View File
@@ -79,7 +79,7 @@ The default value is `0` (disabled — existing behavior is preserved).
```cpp
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -98,7 +98,7 @@ The default value is `0` (disabled — existing behavior is preserved).
#define JSON_BRACE_INIT_COPY_SEMANTICS 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
File diff suppressed because one or more lines are too long
@@ -66,7 +66,7 @@ Without the macro, single-element brace initialization wraps the value in an arr
```
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -85,7 +85,7 @@ With the macro, single-element brace initialization copies/moves the value:
#define JSON_BRACE_INIT_COPY_SEMANTICS 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -54,7 +54,7 @@ The default value is `0` (disabled, the deprecated functions can still be called
```cpp
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -72,7 +72,7 @@ The default value is `0` (disabled, the deprecated functions can still be called
#define JSON_DELETE_DEPRECATED_FUNCTIONS 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
File diff suppressed because one or more lines are too long
@@ -41,7 +41,7 @@ Without the macro, the deprecated overload is called, and the compiler warns abo
```
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -59,7 +59,7 @@ With the macro, the call does not compile:
#define JSON_DELETE_DEPRECATED_FUNCTIONS 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
+3 -3
View File
@@ -75,7 +75,7 @@ When the macro is not defined, the library will define it to its default value.
#define JSON_DIAGNOSTIC_POSITIONS 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -190,7 +190,7 @@ When the macro is not defined, the library will define it to its default value.
#define JSON_DIAGNOSTIC_POSITIONS 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
/* Demonstration of type error exception with diagnostic positions support enabled */
int main()
@@ -236,7 +236,7 @@ When the macro is not defined, the library will define it to its default value.
#define JSON_DIAGNOSTIC_POSITIONS 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
/* Demonstration of type error exception with diagnostic positions support enabled */
int main()
File diff suppressed because one or more lines are too long
@@ -57,7 +57,7 @@ Example: retrieving positions
#define JSON_DIAGNOSTIC_POSITIONS 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -169,7 +169,7 @@ Example: using only diagnostic positions in exceptions
#define JSON_DIAGNOSTIC_POSITIONS 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
/* Demonstration of type error exception with diagnostic positions support enabled */
int main()
@@ -215,7 +215,7 @@ Example: using extended diagnostics with positions enabled in exceptions
#define JSON_DIAGNOSTIC_POSITIONS 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
/* Demonstration of type error exception with diagnostic positions support enabled */
int main()
+3 -3
View File
@@ -49,7 +49,7 @@ When the macro is not defined, the library will define it to its default value.
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -86,7 +86,7 @@ When the macro is not defined, the library will define it to its default value.
# define JSON_DIAGNOSTICS 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -123,7 +123,7 @@ When the macro is not defined, the library will define it to its default value.
#define JSON_DIAGNOSTIC_POSITIONS 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
/* Demonstration of type error exception with diagnostic positions support enabled */
int main()
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -40,7 +40,7 @@ Example: default behavior
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -75,7 +75,7 @@ Example: extended diagnostic messages
# define JSON_DIAGNOSTICS 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -110,7 +110,7 @@ Example: using only diagnostic positions in exceptions
#define JSON_DIAGNOSTIC_POSITIONS 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
/* Demonstration of type error exception with diagnostic positions support enabled */
int main()
@@ -39,7 +39,7 @@ The default value is `0`.
#define JSON_DISABLE_ENUM_SERIALIZATION 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
enum class Choice
{
@@ -66,7 +66,7 @@ The default value is `0`.
#define JSON_DISABLE_ENUM_SERIALIZATION 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
enum class Choice
{
@@ -99,7 +99,7 @@ The default value is `0`.
#define JSON_DISABLE_ENUM_SERIALIZATION 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
enum class Choice
{
File diff suppressed because one or more lines are too long
@@ -34,7 +34,7 @@ The code below forces the library **not** to create default serialization/deseri
#define JSON_DISABLE_ENUM_SERIALIZATION 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
enum class Choice
{
@@ -60,7 +60,7 @@ The code below forces the library **not** to create default serialization/deseri
#define JSON_DISABLE_ENUM_SERIALIZATION 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
enum class Choice
{
@@ -92,7 +92,7 @@ The code below forces the library **not** to create default serialization/deseri
#define JSON_DISABLE_ENUM_SERIALIZATION 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
enum class Choice
{
+2 -2
View File
@@ -92,7 +92,7 @@ The default value is `0`: streams are scanned in bulk.
#include <sstream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -115,7 +115,7 @@ The default value is `0`: streams are scanned in bulk.
#include <sstream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
File diff suppressed because one or more lines are too long
@@ -65,7 +65,7 @@ The stream is scanned in bulk, and the values are read one after the other:
#include <sstream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -88,7 +88,7 @@ With the macro, the same program reads the stream one character at a time, with
#include <sstream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -72,7 +72,7 @@ The default value is `0` (disabled — existing behavior is preserved).
```cpp
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -89,7 +89,7 @@ The default value is `0` (disabled — existing behavior is preserved).
#define JSON_DISABLE_TUPLE_REFERENCE_CONVERSION 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
File diff suppressed because one or more lines are too long
@@ -62,7 +62,7 @@ Example: default behavior (macro not defined)
```
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -79,7 +79,7 @@ Example: conversion disabled (macro defined to 1)
#define JSON_DISABLE_TUPLE_REFERENCE_CONVERSION 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
+2 -2
View File
@@ -73,7 +73,7 @@ The default value is `0`: the file is locked once and read with the unlocked std
#include <cstdio>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -92,7 +92,7 @@ The default value is `0`: the file is locked once and read with the unlocked std
#include <cstdio>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
File diff suppressed because one or more lines are too long
@@ -58,7 +58,7 @@ The file is locked once while it is parsed:
#include <cstdio>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -77,7 +77,7 @@ With the macro, every character is read with `std::fgetc`, with the same result:
#include <cstdio>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+4 -2
View File
@@ -5,7 +5,8 @@
```
When defined, the library uses only portable C++ code where it would otherwise use vector instructions: when scanning
strings during parsing, and when writing floating-point numbers during serialization.
strings during parsing, and when writing floating-point numbers during serialization. This includes the parser of
[`basic_json_document`](../basic_json_document/index.md) (`<nlohmann/json_view.hpp>`).
The macro is an escape hatch, for example for toolchains that cannot compile the vector code, for sanitizers or
analyzers that do not understand it, or to compare the speed of both variants. It does not change any result: values,
@@ -61,7 +62,7 @@ By default, `#!cpp JSON_NO_SIMD` is not defined, and vector instructions are use
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -77,6 +78,7 @@ By default, `#!cpp JSON_NO_SIMD` is not defined, and vector instructions are use
- [**JSON_USE_SIMDUTF**](json_use_simdutf.md) - use the simdutf library to accelerate UTF-8 validation
- [**JSON_DISABLE_STREAM_BULK_SCAN**](json_disable_stream_bulk_scan.md) - read a `std::istream` one character at a time
- [Parsing: input sources and performance](../../features/parsing/index.md#input-sources-and-performance)
- [json_view](../../features/json_view.md) - the zero-copy view, whose parser the macro also affects
## Version history
File diff suppressed because one or more lines are too long
+3 -2
View File
@@ -4,7 +4,7 @@
#define JSON_NO_SIMD
```
When defined, the library uses only portable C++ code where it would otherwise use vector instructions: when scanning strings during parsing, and when writing floating-point numbers during serialization.
When defined, the library uses only portable C++ code where it would otherwise use vector instructions: when scanning strings during parsing, and when writing floating-point numbers during serialization. This includes the parser of [`basic_json_document`](https://json.nlohmann.me/api/basic_json_document/index.md) (`<nlohmann/json_view.hpp>`).
The macro is an escape hatch, for example for toolchains that cannot compile the vector code, for sanitizers or analyzers that do not understand it, or to compare the speed of both variants. It does not change any result: values, exceptions, and error positions are the same either way. Only the speed differs.
@@ -45,7 +45,7 @@ The program parses and serializes the same values with and without the macro:
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -61,6 +61,7 @@ int main()
- [**JSON_USE_SIMDUTF**](https://json.nlohmann.me/api/macros/json_use_simdutf/index.md) - use the simdutf library to accelerate UTF-8 validation
- [**JSON_DISABLE_STREAM_BULK_SCAN**](https://json.nlohmann.me/api/macros/json_disable_stream_bulk_scan/index.md) - read a `std::istream` one character at a time
- [Parsing: input sources and performance](https://json.nlohmann.me/features/parsing/#input-sources-and-performance)
- [json_view](https://json.nlohmann.me/features/json_view/index.md) - the zero-copy view, whose parser the macro also affects
## Version history
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -94,7 +94,7 @@ The default value is `0` (disabled — existing behavior is preserved).
#include <sstream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -115,7 +115,7 @@ The default value is `0` (disabled — existing behavior is preserved).
#include <sstream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
File diff suppressed because one or more lines are too long
@@ -77,7 +77,7 @@ Without the macro, the character after a number is consumed:
#include <sstream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -98,7 +98,7 @@ With the macro, the stream is positioned right after the number:
#include <sstream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -64,7 +64,7 @@ The default value is `0` (disabled, the behavior of version 3.12.0 and earlier i
```cpp
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -81,7 +81,7 @@ The default value is `0` (disabled, the behavior of version 3.12.0 and earlier i
#define JSON_STRICT_BINARY_UTF8 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -44,7 +44,7 @@ Without the macro, the bytes are written unchanged:
```
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -61,7 +61,7 @@ With the macro, ill-formed UTF-8 is rejected:
#define JSON_STRICT_BINARY_UTF8 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
+2 -2
View File
@@ -92,7 +92,7 @@ The default value is `0` (disabled — existing behavior is preserved).
```cpp
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -109,7 +109,7 @@ The default value is `0` (disabled — existing behavior is preserved).
#define JSON_STRICT_NUL_HANDLING 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -63,7 +63,7 @@ Without the macro, a NUL byte silently ends parsing at that point:
```
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
@@ -80,7 +80,7 @@ With the macro, a NUL byte is rejected like any other unexpected byte:
#define JSON_STRICT_NUL_HANDLING 1
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -77,7 +77,7 @@ The default value is `0` (disabled — existing behavior is preserved).
#include <map>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
enum TaskState { TS_STOPPED, TS_RUNNING, TS_COMPLETED };
@@ -105,7 +105,7 @@ The default value is `0` (disabled — existing behavior is preserved).
#include <map>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
enum TaskState { TS_STOPPED, TS_RUNNING, TS_COMPLETED };
File diff suppressed because one or more lines are too long
@@ -60,7 +60,7 @@ Without the macro, a map with enum keys is stored as an array of pairs:
#include <map>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
enum TaskState { TS_STOPPED, TS_RUNNING, TS_COMPLETED };
@@ -88,7 +88,7 @@ With the macro, the same map is stored as an object:
#include <map>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
enum TaskState { TS_STOPPED, TS_RUNNING, TS_COMPLETED };
File diff suppressed because one or more lines are too long
-52
View File
@@ -1,52 +0,0 @@
# JSON_VIEW_NO_SIMD
```cpp
#define JSON_VIEW_NO_SIMD
```
When defined, the parser of [`basic_json_document`](../basic_json_document/index.md) (`<nlohmann/json_view.hpp>`)
uses only portable C++ to scan strings. By default, it scans long runs of string bytes 16 at a time with NEON on
AArch64 (with GCC and Clang) and SSE2 on x86-64, which are part of the baseline instruction sets of these
architectures, and validates non-ASCII text with NEON (or SSSE3, see
[`JSON_VIEW_USE_SSSE3`](json_view_use_ssse3.md)).
The same input is accepted or rejected either way, with the same values, and errors are reported the same way; only
the speed differs. The macro exists for platforms whose compilers lack the intrinsics headers, and to test the portable
code.
!!! note "ABI compatibility"
The macro selects between two definitions of the same inline functions. Whether it is defined is encoded in the
[namespace](../../features/namespace.md) (tag `_vns`), resulting in distinct symbol names. Translation units
compiled with and without it can therefore be linked into the same program without One Definition Rule (ODR)
violations, but they cannot exchange instances of library types.
## Default definition
By default, `#!cpp JSON_VIEW_NO_SIMD` is not defined, and the vector code is used where available.
```cpp
#undef JSON_VIEW_NO_SIMD
```
## Examples
??? example
The code below uses the portable string scanning of the view.
```cpp
#define JSON_VIEW_NO_SIMD
#include <nlohmann/json_view.hpp>
...
```
## See also
- [JSON_VIEW_USE_SSSE3](json_view_use_ssse3.md) - validate non-ASCII strings with SSSE3 on x86-64
- [json_view](../../features/json_view.md) - the zero-copy view
## Version history
- Added in version 3.13.0.
File diff suppressed because one or more lines are too long
-43
View File
@@ -1,43 +0,0 @@
# JSON_VIEW_NO_SIMD
```
#define JSON_VIEW_NO_SIMD
```
When defined, the parser of [`basic_json_document`](https://json.nlohmann.me/api/basic_json_document/index.md) (`<nlohmann/json_view.hpp>`) uses only portable C++ to scan strings. By default, it scans long runs of string bytes 16 at a time with NEON on AArch64 (with GCC and Clang) and SSE2 on x86-64, which are part of the baseline instruction sets of these architectures, and validates non-ASCII text with NEON (or SSSE3, see [`JSON_VIEW_USE_SSSE3`](https://json.nlohmann.me/api/macros/json_view_use_ssse3/index.md)).
The same input is accepted or rejected either way, with the same values, and errors are reported the same way; only the speed differs. The macro exists for platforms whose compilers lack the intrinsics headers, and to test the portable code.
ABI compatibility
The macro selects between two definitions of the same inline functions. Whether it is defined is encoded in the [namespace](https://json.nlohmann.me/features/namespace/index.md) (tag `_vns`), resulting in distinct symbol names. Translation units compiled with and without it can therefore be linked into the same program without One Definition Rule (ODR) violations, but they cannot exchange instances of library types.
## Default definition
By default, `JSON_VIEW_NO_SIMD` is not defined, and the vector code is used where available.
```
#undef JSON_VIEW_NO_SIMD
```
## Examples
Example
The code below uses the portable string scanning of the view.
```
#define JSON_VIEW_NO_SIMD
#include <nlohmann/json_view.hpp>
...
```
## See also
- [JSON_VIEW_USE_SSSE3](https://json.nlohmann.me/api/macros/json_view_use_ssse3/index.md) - validate non-ASCII strings with SSSE3 on x86-64
- [json_view](https://json.nlohmann.me/features/json_view/index.md) - the zero-copy view
## Version history
- Added in version 3.13.0 unreleased.
-53
View File
@@ -1,53 +0,0 @@
# JSON_VIEW_USE_SSSE3
```cpp
#define JSON_VIEW_USE_SSSE3
```
When defined on x86-64, the parser of [`basic_json_document`](../basic_json_document/index.md)
(`<nlohmann/json_view.hpp>`) validates non-ASCII text in strings with SSSE3 without asking the CPU first.
By default, the parser checks once at run time whether the CPU has SSSE3 (all x86-64 CPUs since about 2011 have it)
and then validates non-ASCII text 16 bytes at a time, using the "lookup4" algorithm of
[simdjson](https://github.com/simdjson/simdjson); on CPUs without SSSE3, it validates one UTF-8 sequence at a time.
The vector check is compiled for SSSE3 with a function attribute (GCC 4.9 and later, Clang), so this needs no compiler
option. With MSVC, the check uses `__cpuid`. On AArch64, the vector check uses NEON and is always on.
Define the macro only together with a compiler option that enables SSSE3 (e.g. `-mssse3`, or `-march=` with a CPU that
has it), and only for programs that run on such CPUs. It saves the check of the CPU, which costs little. The same
input is accepted or rejected either way; only the speed of non-ASCII text differs.
!!! note "ABI compatibility"
The macro selects between two definitions of the same inline functions. Whether it is defined is encoded in the
[namespace](../../features/namespace.md) (tag `_vssse3`, on every architecture), resulting in distinct symbol
names. Translation units compiled with and without it can therefore be linked into the same program without One
Definition Rule (ODR) violations, but they cannot exchange instances of library types.
## Default definition
By default, `#!cpp JSON_VIEW_USE_SSSE3` is not defined.
```cpp
#undef JSON_VIEW_USE_SSSE3
```
## Examples
??? example
With CMake, for a program that only runs on CPUs with SSSE3:
```cmake
target_compile_definitions(your_target PRIVATE JSON_VIEW_USE_SSSE3)
target_compile_options(your_target PRIVATE -mssse3)
```
## See also
- [JSON_VIEW_NO_SIMD](json_view_no_simd.md) - use only portable code in the view's parser
- [JSON_USE_SIMDUTF](json_use_simdutf.md) - validate UTF-8 with simdutf in `basic_json`'s parser
## Version history
- Added in version 3.13.0.
File diff suppressed because one or more lines are too long
-43
View File
@@ -1,43 +0,0 @@
# JSON_VIEW_USE_SSSE3
```
#define JSON_VIEW_USE_SSSE3
```
When defined on x86-64, the parser of [`basic_json_document`](https://json.nlohmann.me/api/basic_json_document/index.md) (`<nlohmann/json_view.hpp>`) validates non-ASCII text in strings with SSSE3 without asking the CPU first.
By default, the parser checks once at run time whether the CPU has SSSE3 (all x86-64 CPUs since about 2011 have it) and then validates non-ASCII text 16 bytes at a time, using the "lookup4" algorithm of [simdjson](https://github.com/simdjson/simdjson); on CPUs without SSSE3, it validates one UTF-8 sequence at a time. The vector check is compiled for SSSE3 with a function attribute (GCC 4.9 and later, Clang), so this needs no compiler option. With MSVC, the check uses `__cpuid`. On AArch64, the vector check uses NEON and is always on.
Define the macro only together with a compiler option that enables SSSE3 (e.g. `-mssse3`, or `-march=` with a CPU that has it), and only for programs that run on such CPUs. It saves the check of the CPU, which costs little. The same input is accepted or rejected either way; only the speed of non-ASCII text differs.
ABI compatibility
The macro selects between two definitions of the same inline functions. Whether it is defined is encoded in the [namespace](https://json.nlohmann.me/features/namespace/index.md) (tag `_vssse3`, on every architecture), resulting in distinct symbol names. Translation units compiled with and without it can therefore be linked into the same program without One Definition Rule (ODR) violations, but they cannot exchange instances of library types.
## Default definition
By default, `JSON_VIEW_USE_SSSE3` is not defined.
```
#undef JSON_VIEW_USE_SSSE3
```
## Examples
Example
With CMake, for a program that only runs on CPUs with SSSE3:
```
target_compile_definitions(your_target PRIVATE JSON_VIEW_USE_SSSE3)
target_compile_options(your_target PRIVATE -mssse3)
```
## See also
- [JSON_VIEW_NO_SIMD](https://json.nlohmann.me/api/macros/json_view_no_simd/index.md) - use only portable code in the view's parser
- [JSON_USE_SIMDUTF](https://json.nlohmann.me/api/macros/json_use_simdutf/index.md) - validate UTF-8 with simdutf in `basic_json`'s parser
## Version history
- Added in version 3.13.0 unreleased.
+10 -1
View File
@@ -147,6 +147,13 @@ void to_json(BasicJsonType& j, const B& b) {
See Implementation limits for [NLOHMANN_DEFINE_TYPE_INTRUSIVE](nlohmann_define_type_intrusive.md) and
[NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE](nlohmann_define_type_non_intrusive.md), respectively.
!!! info "Views"
The generated `from_json()` also reads the views of [`json_document`](../json_document.md)s
(`<nlohmann/json_view.hpp>`): [`get<T>()`](../basic_json_view/get.md) on a view looks the members up in the
view, without building a `json` value first. The base part is read from the view as well if the base's
`from_json()` accepts views, and from [`materialize()`](../basic_json_view/materialize.md) otherwise.
## Examples
??? example "Example: (1) NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE"
@@ -189,7 +196,7 @@ void to_json(BasicJsonType& j, const B& b) {
B example(23, 42, 3.142, 1.777);
json example_json = example;
std::cout << std::setw(4) << example_json << std::endl;
std::cout << std::setw(4) << example_json << '\n';
}
```
@@ -234,3 +241,5 @@ void to_json(BasicJsonType& j, const B& b) {
6. Added in version 3.12.0.
All six macros were changed to allow an empty member list in version 3.13.0.
The generated `from_json()` reads the views of `json_document`s since version 3.13.0.
File diff suppressed because one or more lines are too long
@@ -129,6 +129,10 @@ Implementation limits
See Implementation limits for [NLOHMANN_DEFINE_TYPE_INTRUSIVE](https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/index.md) and [NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE](https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/index.md), respectively.
Views
The generated `from_json()` also reads the views of [`json_document`](https://json.nlohmann.me/api/json_document/index.md)s (`<nlohmann/json_view.hpp>`): [`get<T>()`](https://json.nlohmann.me/api/basic_json_view/get/index.md) on a view looks the members up in the view, without building a `json` value first. The base part is read from the view as well if the base's `from_json()` accepts views, and from [`materialize()`](https://json.nlohmann.me/api/basic_json_view/materialize/index.md) otherwise.
## Examples
Example: (1) NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE
@@ -171,7 +175,7 @@ int main()
B example(23, 42, 3.142, 1.777);
json example_json = example;
std::cout << std::setw(4) << example_json << std::endl;
std::cout << std::setw(4) << example_json << '\n';
}
```
@@ -209,3 +213,5 @@ Notes:
1. Added in version 3.12.0.
All six macros were changed to allow an empty member list in version 3.13.0 unreleased.
The generated `from_json()` reads the views of `json_document`s since version 3.13.0 unreleased.
+24 -16
View File
@@ -81,6 +81,12 @@ See the examples below for the concrete generated code.
that serializes a struct's members positionally into a JSON array; for that, write `to_json`/`from_json` by
hand, building/reading a `json::array()` of the members in order.
!!! info "Views"
The generated `from_json()` also reads the views of [`json_document`](../json_document.md)s
(`<nlohmann/json_view.hpp>`): [`get<T>()`](../basic_json_view/get.md) on a view looks the members up in the
view, without building a `json` value first.
## Examples
??? example "Example: (1) NLOHMANN_DEFINE_TYPE_INTRUSIVE"
@@ -91,7 +97,7 @@ See the examples below for the concrete generated code.
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -119,7 +125,7 @@ See the examples below for the concrete generated code.
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
@@ -133,7 +139,7 @@ See the examples below for the concrete generated code.
}
catch (const json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
std::cout << "deserialization failed: " << e.what() << '\n';
}
}
@@ -162,7 +168,7 @@ See the examples below for the concrete generated code.
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -204,7 +210,7 @@ See the examples below for the concrete generated code.
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
@@ -218,7 +224,7 @@ See the examples below for the concrete generated code.
}
catch (const json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
std::cout << "deserialization failed: " << e.what() << '\n';
}
}
@@ -232,7 +238,7 @@ See the examples below for the concrete generated code.
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -260,7 +266,7 @@ See the examples below for the concrete generated code.
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
@@ -269,7 +275,7 @@ See the examples below for the concrete generated code.
// incomplete deserialization:
json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
auto p3 = j3.get<ns::person>();
std::cout << "roundtrip: " << json(p3) << std::endl;
std::cout << "roundtrip: " << json(p3) << '\n';
}
```
@@ -296,7 +302,7 @@ See the examples below for the concrete generated code.
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -339,7 +345,7 @@ See the examples below for the concrete generated code.
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
@@ -348,7 +354,7 @@ See the examples below for the concrete generated code.
// incomplete deserialization:
json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
auto p3 = j3.get<ns::person>();
std::cout << "roundtrip: " << json(p3) << std::endl;
std::cout << "roundtrip: " << json(p3) << '\n';
}
```
@@ -362,7 +368,7 @@ See the examples below for the concrete generated code.
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -390,7 +396,7 @@ See the examples below for the concrete generated code.
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
}
```
@@ -416,7 +422,7 @@ See the examples below for the concrete generated code.
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -450,7 +456,7 @@ See the examples below for the concrete generated code.
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
}
```
@@ -475,3 +481,5 @@ See the examples below for the concrete generated code.
All three macros were changed to work with any `basic_json` specialization (not only `nlohmann::json`) in version 3.12.0,
and to allow an empty member list in version 3.13.0.
The generated `from_json()` reads the views of `json_document`s since version 3.13.0.
File diff suppressed because one or more lines are too long
@@ -64,6 +64,10 @@ Implementation limits
- The current implementation is limited to at most 63 member variables. If you want to serialize/deserialize types with more than 63 member variables, you need to define the `to_json`/`from_json` functions manually.
- These macros always produce object-style (named-key) JSON, one key per member. There is no macro variant that serializes a struct's members positionally into a JSON array; for that, write `to_json`/`from_json` by hand, building/reading a `json::array()` of the members in order.
Views
The generated `from_json()` also reads the views of [`json_document`](https://json.nlohmann.me/api/json_document/index.md)s (`<nlohmann/json_view.hpp>`): [`get<T>()`](https://json.nlohmann.me/api/basic_json_view/get/index.md) on a view looks the members up in the view, without building a `json` value first.
## Examples
Example: (1) NLOHMANN_DEFINE_TYPE_INTRUSIVE
@@ -74,7 +78,7 @@ Consider the following complete example:
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -102,7 +106,7 @@ int main()
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
@@ -116,7 +120,7 @@ int main()
}
catch (const json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
std::cout << "deserialization failed: " << e.what() << '\n';
}
}
```
@@ -141,7 +145,7 @@ The macro is equivalent to:
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -183,7 +187,7 @@ int main()
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
@@ -197,7 +201,7 @@ int main()
}
catch (const json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
std::cout << "deserialization failed: " << e.what() << '\n';
}
}
```
@@ -210,7 +214,7 @@ Consider the following complete example:
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -238,7 +242,7 @@ int main()
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
@@ -247,7 +251,7 @@ int main()
// incomplete deserialization:
json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
auto p3 = j3.get<ns::person>();
std::cout << "roundtrip: " << json(p3) << std::endl;
std::cout << "roundtrip: " << json(p3) << '\n';
}
```
@@ -271,7 +275,7 @@ The macro is equivalent to:
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -314,7 +318,7 @@ int main()
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
@@ -323,7 +327,7 @@ int main()
// incomplete deserialization:
json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
auto p3 = j3.get<ns::person>();
std::cout << "roundtrip: " << json(p3) << std::endl;
std::cout << "roundtrip: " << json(p3) << '\n';
}
```
@@ -337,7 +341,7 @@ Consider the following complete example:
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -365,7 +369,7 @@ int main()
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
}
```
@@ -387,7 +391,7 @@ The macro is equivalent to:
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -421,7 +425,7 @@ int main()
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
}
```
@@ -438,3 +442,5 @@ int main()
1. Added in version 3.11.3.
All three macros were changed to work with any `basic_json` specialization (not only `nlohmann::json`) in version 3.12.0, and to allow an empty member list in version 3.13.0 unreleased.
The generated `from_json()` reads the views of `json_document`s since version 3.13.0 unreleased.
@@ -80,6 +80,12 @@ See the examples below for the concrete generated code.
that serializes a struct's members positionally into a JSON array; for that, write `to_json`/`from_json` by
hand, building/reading a `json::array()` of the members in order.
!!! info "Views"
The generated `from_json()` also reads the views of [`json_document`](../json_document.md)s
(`<nlohmann/json_view.hpp>`): [`get<T>()`](../basic_json_view/get.md) on a view looks the members up in the
view, without building a `json` value first.
## Examples
??? example "Example: (1) NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE"
@@ -90,7 +96,7 @@ See the examples below for the concrete generated code.
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -111,7 +117,7 @@ See the examples below for the concrete generated code.
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
@@ -125,7 +131,7 @@ See the examples below for the concrete generated code.
}
catch (const json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
std::cout << "deserialization failed: " << e.what() << '\n';
}
}
@@ -153,7 +159,7 @@ See the examples below for the concrete generated code.
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -188,7 +194,7 @@ See the examples below for the concrete generated code.
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
@@ -202,7 +208,7 @@ See the examples below for the concrete generated code.
}
catch (const json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
std::cout << "deserialization failed: " << e.what() << '\n';
}
}
@@ -216,7 +222,7 @@ See the examples below for the concrete generated code.
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -242,7 +248,7 @@ See the examples below for the concrete generated code.
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
@@ -251,7 +257,7 @@ See the examples below for the concrete generated code.
// incomplete deserialization:
json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
auto p3 = j3.get<ns::person>();
std::cout << "roundtrip: " << json(p3) << std::endl;
std::cout << "roundtrip: " << json(p3) << '\n';
}
```
@@ -279,7 +285,7 @@ See the examples below for the concrete generated code.
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -320,7 +326,7 @@ See the examples below for the concrete generated code.
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
@@ -329,7 +335,7 @@ See the examples below for the concrete generated code.
// incomplete deserialization:
json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
auto p3 = j3.get<ns::person>();
std::cout << "roundtrip: " << json(p3) << std::endl;
std::cout << "roundtrip: " << json(p3) << '\n';
}
```
@@ -344,7 +350,7 @@ See the examples below for the concrete generated code.
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -365,7 +371,7 @@ See the examples below for the concrete generated code.
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
}
```
@@ -390,7 +396,7 @@ See the examples below for the concrete generated code.
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -417,7 +423,7 @@ See the examples below for the concrete generated code.
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
}
```
@@ -442,3 +448,5 @@ See the examples below for the concrete generated code.
All three macros were changed to work with any `basic_json` specialization (not only `nlohmann::json`) in version 3.12.0,
and to allow an empty member list in version 3.13.0.
The generated `from_json()` reads the views of `json_document`s since version 3.13.0.
File diff suppressed because one or more lines are too long
@@ -63,6 +63,10 @@ Implementation limits
- The current implementation is limited to at most 63 member variables. If you want to serialize/deserialize types with more than 63 member variables, you need to define the `to_json`/`from_json` functions manually.
- These macros always produce object-style (named-key) JSON, one key per member. There is no macro variant that serializes a struct's members positionally into a JSON array; for that, write `to_json`/`from_json` by hand, building/reading a `json::array()` of the members in order.
Views
The generated `from_json()` also reads the views of [`json_document`](https://json.nlohmann.me/api/json_document/index.md)s (`<nlohmann/json_view.hpp>`): [`get<T>()`](https://json.nlohmann.me/api/basic_json_view/get/index.md) on a view looks the members up in the view, without building a `json` value first.
## Examples
Example: (1) NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE
@@ -73,7 +77,7 @@ Consider the following complete example:
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -94,7 +98,7 @@ int main()
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
@@ -108,7 +112,7 @@ int main()
}
catch (const json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
std::cout << "deserialization failed: " << e.what() << '\n';
}
}
```
@@ -133,7 +137,7 @@ The macro is equivalent to:
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -168,7 +172,7 @@ int main()
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
@@ -182,7 +186,7 @@ int main()
}
catch (const json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
std::cout << "deserialization failed: " << e.what() << '\n';
}
}
```
@@ -195,7 +199,7 @@ Consider the following complete example:
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -221,7 +225,7 @@ int main()
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
@@ -230,7 +234,7 @@ int main()
// incomplete deserialization:
json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
auto p3 = j3.get<ns::person>();
std::cout << "roundtrip: " << json(p3) << std::endl;
std::cout << "roundtrip: " << json(p3) << '\n';
}
```
@@ -254,7 +258,7 @@ The macro is equivalent to:
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -295,7 +299,7 @@ int main()
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
@@ -304,7 +308,7 @@ int main()
// incomplete deserialization:
json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
auto p3 = j3.get<ns::person>();
std::cout << "roundtrip: " << json(p3) << std::endl;
std::cout << "roundtrip: " << json(p3) << '\n';
}
```
@@ -318,7 +322,7 @@ Consider the following complete example:
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -339,7 +343,7 @@ int main()
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
}
```
@@ -361,7 +365,7 @@ The macro is equivalent to:
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -388,7 +392,7 @@ int main()
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
}
```
@@ -405,3 +409,5 @@ int main()
1. Added in version 3.11.3.
All three macros were changed to work with any `basic_json` specialization (not only `nlohmann::json`) in version 3.12.0, and to allow an empty member list in version 3.13.0 unreleased.
The generated `from_json()` reads the views of `json_document`s since version 3.13.0 unreleased.
@@ -53,7 +53,7 @@ For further information please refer to the corresponding macros without `WITH_N
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -74,7 +74,7 @@ For further information please refer to the corresponding macros without `WITH_N
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"json_address": "742 Evergreen Terrace", "json_age": 40, "json_name": "Homer Simpson"})"_json;
@@ -88,7 +88,7 @@ For further information please refer to the corresponding macros without `WITH_N
}
catch (const json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
std::cout << "deserialization failed: " << e.what() << '\n';
}
}
@@ -116,7 +116,7 @@ For further information please refer to the corresponding macros without `WITH_N
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -151,7 +151,7 @@ For further information please refer to the corresponding macros without `WITH_N
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"json_address": "742 Evergreen Terrace", "json_age": 40, "json_name": "Homer Simpson"})"_json;
@@ -165,7 +165,7 @@ For further information please refer to the corresponding macros without `WITH_N
}
catch (const json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
std::cout << "deserialization failed: " << e.what() << '\n';
}
}
File diff suppressed because one or more lines are too long
@@ -41,7 +41,7 @@ Consider the following complete example:
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -62,7 +62,7 @@ int main()
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"json_address": "742 Evergreen Terrace", "json_age": 40, "json_name": "Homer Simpson"})"_json;
@@ -76,7 +76,7 @@ int main()
}
catch (const json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
std::cout << "deserialization failed: " << e.what() << '\n';
}
}
```
@@ -101,7 +101,7 @@ The macro is equivalent to:
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
using namespace nlohmann::literals;
namespace ns
@@ -136,7 +136,7 @@ int main()
// serialization: person -> json
json j = p;
std::cout << "serialization: " << j << std::endl;
std::cout << "serialization: " << j << '\n';
// deserialization: json -> person
json j2 = R"({"json_address": "742 Evergreen Terrace", "json_age": 40, "json_name": "Homer Simpson"})"_json;
@@ -150,7 +150,7 @@ int main()
}
catch (const json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
std::cout << "deserialization failed: " << e.what() << '\n';
}
}
```
+4 -4
View File
@@ -26,7 +26,7 @@ the library.
#include <nlohmann/json.hpp>
// possible use case: use NLOHMANN_JSON_NAMESPACE instead of nlohmann
using json = NLOHMANN_JSON_NAMESPACE::json;
using NLOHMANN_JSON_NAMESPACE::json;
// macro needed to output the NLOHMANN_JSON_NAMESPACE as string literal
#define Q(x) #x
@@ -34,7 +34,7 @@ the library.
int main()
{
std::cout << QUOTE(NLOHMANN_JSON_NAMESPACE) << std::endl;
std::cout << QUOTE(NLOHMANN_JSON_NAMESPACE) << '\n';
}
```
@@ -54,6 +54,6 @@ the library.
## Version history
- Added in version 3.11.0. Changed inline namespace name in version 3.11.2. Added the ABI tag `_dp` in
version 3.12.0, and the ABI tags `_bics`, `_psp`, `_snul`, `_sbu8`, `_ekmo`, `_dsbs`, `_dufio`, `_ns`, `_vns`,
and `_vssse3` in version 3.13.0; see
version 3.12.0, and the ABI tags `_bics`, `_psp`, `_snul`, `_sbu8`, `_ekmo`, `_dsbs`, `_dufio`, and `_ns` in
version 3.13.0; see
[`nlohmann` Namespace](../../features/namespace.md#structure).
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -23,7 +23,7 @@ The example shows how to use `NLOHMANN_JSON_NAMESPACE` instead of just `nlohmann
#include <nlohmann/json.hpp>
// possible use case: use NLOHMANN_JSON_NAMESPACE instead of nlohmann
using json = NLOHMANN_JSON_NAMESPACE::json;
using NLOHMANN_JSON_NAMESPACE::json;
// macro needed to output the NLOHMANN_JSON_NAMESPACE as string literal
#define Q(x) #x
@@ -31,7 +31,7 @@ using json = NLOHMANN_JSON_NAMESPACE::json;
int main()
{
std::cout << QUOTE(NLOHMANN_JSON_NAMESPACE) << std::endl;
std::cout << QUOTE(NLOHMANN_JSON_NAMESPACE) << '\n';
}
```
@@ -48,4 +48,4 @@ nlohmann::json_abi_v3_12_0
## Version history
- Added in version 3.11.0. Changed inline namespace name in version 3.11.2. Added the ABI tag `_dp` in version 3.12.0, and the ABI tags `_bics`, `_psp`, `_snul`, `_sbu8`, `_ekmo`, `_dsbs`, `_dufio`, `_ns`, `_vns`, and `_vssse3` in version 3.13.0 unreleased; see [`nlohmann` Namespace](https://json.nlohmann.me/features/namespace/#structure).
- Added in version 3.11.0. Changed inline namespace name in version 3.11.2. Added the ABI tag `_dp` in version 3.12.0, and the ABI tags `_bics`, `_psp`, `_snul`, `_sbu8`, `_ekmo`, `_dsbs`, `_dufio`, and `_ns` in version 3.13.0 unreleased; see [`nlohmann` Namespace](https://json.nlohmann.me/features/namespace/#structure).
+1 -1
View File
@@ -72,7 +72,7 @@ When these macros are not defined, the library will define them to their default
NLOHMANN_JSON_NAMESPACE::json j;
j.push_back(o1);
j.push_back(o2);
std::cout << j << std::endl;
std::cout << j << '\n';
}
```
File diff suppressed because one or more lines are too long
@@ -70,7 +70,7 @@ int main()
NLOHMANN_JSON_NAMESPACE::json j;
j.push_back(o1);
j.push_back(o2);
std::cout << j << std::endl;
std::cout << j << '\n';
}
```
@@ -36,7 +36,7 @@ When the macro is not defined, the library will define it to its default value.
int main()
{
std::cout << QUOTE(NLOHMANN_JSON_NAMESPACE) << std::endl;
std::cout << QUOTE(NLOHMANN_JSON_NAMESPACE) << '\n';
}
```
File diff suppressed because one or more lines are too long
@@ -34,7 +34,7 @@ The example shows how to use `NLOHMANN_JSON_NAMESPACE_NO_VERSION` to disable the
int main()
{
std::cout << QUOTE(NLOHMANN_JSON_NAMESPACE) << std::endl;
std::cout << QUOTE(NLOHMANN_JSON_NAMESPACE) << '\n';
}
```
+16 -8
View File
@@ -45,6 +45,12 @@ inline void from_json(const BasicJsonType& j, type& e);
Define [`JSON_USE_OBJECTS_FOR_ENUM_KEYED_MAPS`](json_use_objects_for_enum_keyed_maps.md) to store them as objects
with the converted keys. Such maps can be read from both forms.
!!! info "Views"
The generated `from_json()` also reads the views of [`json_document`](../json_document.md)s
(`<nlohmann/json_view.hpp>`), comparing the view with the entries of the mapping, without building a `json` value
first.
## Examples
??? example "Example: Basic usage"
@@ -56,7 +62,7 @@ inline void from_json(const BasicJsonType& j, type& e);
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
namespace ns
{
@@ -94,7 +100,7 @@ inline void from_json(const BasicJsonType& j, type& e);
json j_stopped = ns::TS_STOPPED;
json j_red = ns::Color::red;
std::cout << "ns::TS_STOPPED -> " << j_stopped
<< ", ns::Color::red -> " << j_red << std::endl;
<< ", ns::Color::red -> " << j_red << '\n';
// deserialization
json j_running = "running";
@@ -102,7 +108,7 @@ inline void from_json(const BasicJsonType& j, type& e);
auto running = j_running.get<ns::TaskState>();
auto blue = j_blue.get<ns::Color>();
std::cout << j_running << " -> " << running
<< ", " << j_blue << " -> " << static_cast<int>(blue) << std::endl;
<< ", " << j_blue << " -> " << static_cast<int>(blue) << '\n';
// deserializing undefined JSON value to enum
// (where the first map entry above is the default)
@@ -110,7 +116,7 @@ inline void from_json(const BasicJsonType& j, type& e);
auto invalid = j_pi.get<ns::TaskState>();
auto unknown = j_pi.get<ns::Color>();
std::cout << j_pi << " -> " << invalid << ", "
<< j_pi << " -> " << static_cast<int>(unknown) << std::endl;
<< j_pi << " -> " << static_cast<int>(unknown) << '\n';
}
```
@@ -134,7 +140,7 @@ inline void from_json(const BasicJsonType& j, type& e);
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
namespace ns
{
@@ -155,14 +161,14 @@ inline void from_json(const BasicJsonType& j, type& e);
{
// serialization
json j_red = ns::Color::red;
std::cout << static_cast<int>(ns::Color::red) << " -> " << j_red << std::endl;
std::cout << static_cast<int>(ns::Color::red) << " -> " << j_red << '\n';
// deserialization
json j_rot = "rot";
auto rot = j_rot.get<ns::Color>();
auto red = j_red.get<ns::Color>();
std::cout << j_rot << " -> " << static_cast<int>(rot) << std::endl;
std::cout << j_red << " -> " << static_cast<int>(red) << std::endl;
std::cout << j_rot << " -> " << static_cast<int>(rot) << '\n';
std::cout << j_red << " -> " << static_cast<int>(red) << '\n';
}
```
@@ -186,3 +192,5 @@ inline void from_json(const BasicJsonType& j, type& e);
## Version history
Added in version 3.4.0.
The generated `from_json()` reads the views of `json_document`s since version 3.13.0.
File diff suppressed because one or more lines are too long
@@ -37,6 +37,10 @@ Important notes
- If an enum or JSON value is specified in multiple conversions, the first matching conversion from the top of the list will be returned when converting to or from JSON. See example 2 below.
- Maps with enum keys (e.g., `std::map<ENUM_TYPE, T>`) are stored as arrays of `[key, value]` pairs by default. Define [`JSON_USE_OBJECTS_FOR_ENUM_KEYED_MAPS`](https://json.nlohmann.me/api/macros/json_use_objects_for_enum_keyed_maps/index.md) to store them as objects with the converted keys. Such maps can be read from both forms.
Views
The generated `from_json()` also reads the views of [`json_document`](https://json.nlohmann.me/api/json_document/index.md)s (`<nlohmann/json_view.hpp>`), comparing the view with the entries of the mapping, without building a `json` value first.
## Examples
Example: Basic usage
@@ -47,7 +51,7 @@ The example shows how `NLOHMANN_JSON_SERIALIZE_ENUM` can be used to serialize/de
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
namespace ns
{
@@ -85,7 +89,7 @@ int main()
json j_stopped = ns::TS_STOPPED;
json j_red = ns::Color::red;
std::cout << "ns::TS_STOPPED -> " << j_stopped
<< ", ns::Color::red -> " << j_red << std::endl;
<< ", ns::Color::red -> " << j_red << '\n';
// deserialization
json j_running = "running";
@@ -93,7 +97,7 @@ int main()
auto running = j_running.get<ns::TaskState>();
auto blue = j_blue.get<ns::Color>();
std::cout << j_running << " -> " << running
<< ", " << j_blue << " -> " << static_cast<int>(blue) << std::endl;
<< ", " << j_blue << " -> " << static_cast<int>(blue) << '\n';
// deserializing undefined JSON value to enum
// (where the first map entry above is the default)
@@ -101,7 +105,7 @@ int main()
auto invalid = j_pi.get<ns::TaskState>();
auto unknown = j_pi.get<ns::Color>();
std::cout << j_pi << " -> " << invalid << ", "
<< j_pi << " -> " << static_cast<int>(unknown) << std::endl;
<< j_pi << " -> " << static_cast<int>(unknown) << '\n';
}
```
@@ -121,7 +125,7 @@ The example shows how to use multiple conversions for a single enumerator. In th
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
namespace ns
{
@@ -142,14 +146,14 @@ int main()
{
// serialization
json j_red = ns::Color::red;
std::cout << static_cast<int>(ns::Color::red) << " -> " << j_red << std::endl;
std::cout << static_cast<int>(ns::Color::red) << " -> " << j_red << '\n';
// deserialization
json j_rot = "rot";
auto rot = j_rot.get<ns::Color>();
auto red = j_red.get<ns::Color>();
std::cout << j_rot << " -> " << static_cast<int>(rot) << std::endl;
std::cout << j_red << " -> " << static_cast<int>(red) << std::endl;
std::cout << j_rot << " -> " << static_cast<int>(rot) << '\n';
std::cout << j_red << " -> " << static_cast<int>(red) << '\n';
}
```
@@ -171,3 +175,5 @@ Output:
## Version history
Added in version 3.4.0.
The generated `from_json()` reads the views of `json_document`s since version 3.13.0 unreleased.
@@ -48,6 +48,12 @@ inline void from_json(const BasicJsonType& j, type& e);
Define [`JSON_USE_OBJECTS_FOR_ENUM_KEYED_MAPS`](json_use_objects_for_enum_keyed_maps.md) to store them as objects
with the converted keys. Such maps can be read from both forms.
!!! info "Views"
The generated `from_json()` also reads the views of [`json_document`](../json_document.md)s
(`<nlohmann/json_view.hpp>`), comparing the view with the entries of the mapping, without building a `json` value
first.
## Examples
??? example "Example: Basic usage"
@@ -59,7 +65,7 @@ inline void from_json(const BasicJsonType& j, type& e);
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
namespace ns
{
@@ -97,7 +103,7 @@ inline void from_json(const BasicJsonType& j, type& e);
json j_stopped = ns::TS_STOPPED;
json j_red = ns::Color::red;
std::cout << "ns::TS_STOPPED -> " << j_stopped
<< ", ns::Color::red -> " << j_red << std::endl;
<< ", ns::Color::red -> " << j_red << '\n';
// deserialization
json j_running = "running";
@@ -105,7 +111,7 @@ inline void from_json(const BasicJsonType& j, type& e);
auto running = j_running.get<ns::TaskState>();
auto blue = j_blue.get<ns::Color>();
std::cout << j_running << " -> " << running
<< ", " << j_blue << " -> " << static_cast<int>(blue) << std::endl;
<< ", " << j_blue << " -> " << static_cast<int>(blue) << '\n';
}
@@ -129,7 +135,7 @@ inline void from_json(const BasicJsonType& j, type& e);
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
namespace ns
{
@@ -150,14 +156,14 @@ inline void from_json(const BasicJsonType& j, type& e);
{
// serialization
json j_red = ns::Color::red;
std::cout << static_cast<int>(ns::Color::red) << " -> " << j_red << std::endl;
std::cout << static_cast<int>(ns::Color::red) << " -> " << j_red << '\n';
// deserialization
json j_rot = "rot";
auto rot = j_rot.get<ns::Color>();
auto red = j_red.get<ns::Color>();
std::cout << j_rot << " -> " << static_cast<int>(rot) << std::endl;
std::cout << j_red << " -> " << static_cast<int>(red) << std::endl;
std::cout << j_rot << " -> " << static_cast<int>(rot) << '\n';
std::cout << j_red << " -> " << static_cast<int>(red) << '\n';
}
```
@@ -182,7 +188,7 @@ inline void from_json(const BasicJsonType& j, type& e);
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
namespace ns
{
@@ -215,7 +221,7 @@ inline void from_json(const BasicJsonType& j, type& e);
}
catch (const json::exception e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
std::cout << "deserialization failed: " << e.what() << '\n';
}
// invalid deserialization
@@ -227,7 +233,7 @@ inline void from_json(const BasicJsonType& j, type& e);
}
catch (const json::exception e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
std::cout << "deserialization failed: " << e.what() << '\n';
}
return 0;
File diff suppressed because one or more lines are too long
@@ -37,6 +37,10 @@ Important notes
- If an enum or JSON value is specified in multiple conversions, the first matching conversion from the top of the list will be returned when converting to or from JSON. See example 2 below.
- Maps with enum keys (e.g., `std::map<ENUM_TYPE, T>`) are stored as arrays of `[key, value]` pairs by default. Define [`JSON_USE_OBJECTS_FOR_ENUM_KEYED_MAPS`](https://json.nlohmann.me/api/macros/json_use_objects_for_enum_keyed_maps/index.md) to store them as objects with the converted keys. Such maps can be read from both forms.
Views
The generated `from_json()` also reads the views of [`json_document`](https://json.nlohmann.me/api/json_document/index.md)s (`<nlohmann/json_view.hpp>`), comparing the view with the entries of the mapping, without building a `json` value first.
## Examples
Example: Basic usage
@@ -47,7 +51,7 @@ The example shows how `NLOHMANN_JSON_SERIALIZE_ENUM_STRICT` can be used to seria
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
namespace ns
{
@@ -85,7 +89,7 @@ int main()
json j_stopped = ns::TS_STOPPED;
json j_red = ns::Color::red;
std::cout << "ns::TS_STOPPED -> " << j_stopped
<< ", ns::Color::red -> " << j_red << std::endl;
<< ", ns::Color::red -> " << j_red << '\n';
// deserialization
json j_running = "running";
@@ -93,7 +97,7 @@ int main()
auto running = j_running.get<ns::TaskState>();
auto blue = j_blue.get<ns::Color>();
std::cout << j_running << " -> " << running
<< ", " << j_blue << " -> " << static_cast<int>(blue) << std::endl;
<< ", " << j_blue << " -> " << static_cast<int>(blue) << '\n';
}
```
@@ -113,7 +117,7 @@ The example shows how to use multiple conversions for a single enumerator. In th
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
namespace ns
{
@@ -134,14 +138,14 @@ int main()
{
// serialization
json j_red = ns::Color::red;
std::cout << static_cast<int>(ns::Color::red) << " -> " << j_red << std::endl;
std::cout << static_cast<int>(ns::Color::red) << " -> " << j_red << '\n';
// deserialization
json j_rot = "rot";
auto rot = j_rot.get<ns::Color>();
auto red = j_red.get<ns::Color>();
std::cout << j_rot << " -> " << static_cast<int>(rot) << std::endl;
std::cout << j_red << " -> " << static_cast<int>(red) << std::endl;
std::cout << j_rot << " -> " << static_cast<int>(rot) << '\n';
std::cout << j_red << " -> " << static_cast<int>(red) << '\n';
}
```
@@ -161,7 +165,7 @@ The example shows how an invalid serialization causes an exception to be thrown.
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
namespace ns
{
@@ -194,7 +198,7 @@ int main()
}
catch (const json::exception e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
std::cout << "deserialization failed: " << e.what() << '\n';
}
// invalid deserialization
@@ -206,7 +210,7 @@ int main()
}
catch (const json::exception e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
std::cout << "deserialization failed: " << e.what() << '\n';
}
return 0;
+2 -2
View File
@@ -24,14 +24,14 @@ The macros are defined according to the current library version.
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
std::cout << "JSON for Modern C++ version "
<< NLOHMANN_JSON_VERSION_MAJOR << "."
<< NLOHMANN_JSON_VERSION_MINOR << "."
<< NLOHMANN_JSON_VERSION_PATCH << std::endl;
<< NLOHMANN_JSON_VERSION_PATCH << '\n';
}
```
File diff suppressed because one or more lines are too long
@@ -22,14 +22,14 @@ The example below shows how `NLOHMANN_JSON_VERSION_MAJOR`, `NLOHMANN_JSON_VERSIO
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using nlohmann::json;
int main()
{
std::cout << "JSON for Modern C++ version "
<< NLOHMANN_JSON_VERSION_MAJOR << "."
<< NLOHMANN_JSON_VERSION_MINOR << "."
<< NLOHMANN_JSON_VERSION_PATCH << std::endl;
<< NLOHMANN_JSON_VERSION_PATCH << '\n';
}
```