mirror of
https://github.com/nlohmann/json.git
synced 2026-10-26 15:58:55 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6212183c5e | ||
|
|
e6d8a0067b | ||
|
|
0f2b3ae6d5 | ||
|
|
20e022655d | ||
|
|
266432ea65 |
No files matched your search
+7
-36
@@ -1,33 +1,3 @@
|
|||||||
# Style or vendor rule sets that do not fit a header-only library:
|
|
||||||
# altera-*, fuchsia-*, llvmlibc-*, android-cloexec-fopen, boost-use-ranges, llvm-header-guard,
|
|
||||||
# llvm-include-order, llvm-prefer-static-over-anonymous-namespace, llvm-use-ranges,
|
|
||||||
# misc-use-anonymous-namespace, google-runtime-float, google-runtime-int, hicpp-signed-bitwise,
|
|
||||||
# bugprone-signed-bitwise, hicpp-explicit-conversions, google-explicit-constructor,
|
|
||||||
# cppcoreguidelines-explicit-constructor, misc-explicit-constructor (implicit conversions are the
|
|
||||||
# API), readability-trailing-comma,
|
|
||||||
# hicpp-avoid-goto / cppcoreguidelines-avoid-goto, hicpp-no-array-decay,
|
|
||||||
# hicpp-uppercase-literal-suffix, readability-uppercase-literal-suffix, modernize-use-trailing-return-type.
|
|
||||||
# Constructs the library needs on purpose (the library supports C++11 and legacy compilers):
|
|
||||||
# cppcoreguidelines-macro-usage, cppcoreguidelines-avoid-do-while (macros),
|
|
||||||
# cppcoreguidelines-pro-bounds-*, cppcoreguidelines-pro-type-reinterpret-cast,
|
|
||||||
# cppcoreguidelines-pro-type-union-access (parsers, serializers, basic_json's value union),
|
|
||||||
# cppcoreguidelines-avoid-const-or-ref-data-members, cppcoreguidelines-rvalue-reference-param-not-moved,
|
|
||||||
# cppcoreguidelines-avoid-non-const-global-variables, misc-non-private-member-variables-in-classes,
|
|
||||||
# misc-no-recursion (value walks are recursive, bounded by detail::recursion_depth_limit()),
|
|
||||||
# modernize-type-traits, modernize-use-constraints, modernize-use-ranges, modernize-use-std-numbers,
|
|
||||||
# modernize-use-designated-initializers, modernize-use-nodiscard, modernize-concat-nested-namespaces,
|
|
||||||
# readability-redundant-typename, readability-redundant-parentheses,
|
|
||||||
# readability-redundant-access-specifiers, readability-simplify-boolean-expr,
|
|
||||||
# readability-use-concise-preprocessor-directives, modernize-use-string-view,
|
|
||||||
# modernize-use-integer-sign-comparison (needs std::cmp_less; the flagged
|
|
||||||
# static_cast<std::size_t>(end - pos) < n comparisons are deliberate)
|
|
||||||
# (all need a newer standard or compiler than C++11, or would change macro-generated or
|
|
||||||
# deliberately explicit code).
|
|
||||||
# Too noisy to be useful (numeric parsing/formatting code, doctest, tests):
|
|
||||||
# bugprone-easily-swappable-parameters, cppcoreguidelines-avoid-magic-numbers, readability-magic-numbers,
|
|
||||||
# readability-identifier-length, readability-function-cognitive-complexity, performance-enum-size,
|
|
||||||
# concurrency-mt-unsafe, misc-confusable-identifiers, misc-include-cleaner (run on its own for
|
|
||||||
# the consumer headers in cmake/ci.cmake).
|
|
||||||
# portability-avoid-pragma-once: kept disabled on purpose. #pragma once is accepted
|
# portability-avoid-pragma-once: kept disabled on purpose. #pragma once is accepted
|
||||||
# by every supported compiler, and tools/amalgamate/amalgamate.py strips it from
|
# by every supported compiler, and tools/amalgamate/amalgamate.py strips it from
|
||||||
# single_include, so there is nothing left to fix here.
|
# single_include, so there is nothing left to fix here.
|
||||||
@@ -40,14 +10,14 @@ Checks: '*,
|
|||||||
-android-cloexec-fopen,
|
-android-cloexec-fopen,
|
||||||
-boost-use-ranges,
|
-boost-use-ranges,
|
||||||
-bugprone-easily-swappable-parameters,
|
-bugprone-easily-swappable-parameters,
|
||||||
-bugprone-signed-bitwise,
|
-cert-err58-cpp,
|
||||||
|
-clang-analyzer-webkit.NoUncountedMemberChecker,
|
||||||
-concurrency-mt-unsafe,
|
-concurrency-mt-unsafe,
|
||||||
-cppcoreguidelines-avoid-const-or-ref-data-members,
|
-cppcoreguidelines-avoid-const-or-ref-data-members,
|
||||||
-cppcoreguidelines-avoid-do-while,
|
-cppcoreguidelines-avoid-do-while,
|
||||||
-cppcoreguidelines-avoid-goto,
|
-cppcoreguidelines-avoid-goto,
|
||||||
-cppcoreguidelines-avoid-magic-numbers,
|
-cppcoreguidelines-avoid-magic-numbers,
|
||||||
-cppcoreguidelines-avoid-non-const-global-variables,
|
-cppcoreguidelines-avoid-non-const-global-variables,
|
||||||
-cppcoreguidelines-explicit-constructor,
|
|
||||||
-cppcoreguidelines-macro-usage,
|
-cppcoreguidelines-macro-usage,
|
||||||
-cppcoreguidelines-pro-bounds-avoid-unchecked-container-access,
|
-cppcoreguidelines-pro-bounds-avoid-unchecked-container-access,
|
||||||
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||||
@@ -56,15 +26,19 @@ Checks: '*,
|
|||||||
-cppcoreguidelines-pro-type-reinterpret-cast,
|
-cppcoreguidelines-pro-type-reinterpret-cast,
|
||||||
-cppcoreguidelines-pro-type-union-access,
|
-cppcoreguidelines-pro-type-union-access,
|
||||||
-cppcoreguidelines-rvalue-reference-param-not-moved,
|
-cppcoreguidelines-rvalue-reference-param-not-moved,
|
||||||
|
-cppcoreguidelines-virtual-class-destructor,
|
||||||
-fuchsia-default-arguments-calls,
|
-fuchsia-default-arguments-calls,
|
||||||
-fuchsia-default-arguments-declarations,
|
-fuchsia-default-arguments-declarations,
|
||||||
-fuchsia-overloaded-operator,
|
-fuchsia-overloaded-operator,
|
||||||
-google-explicit-constructor,
|
-google-explicit-constructor,
|
||||||
|
-google-readability-function-size,
|
||||||
-google-runtime-float,
|
-google-runtime-float,
|
||||||
-google-runtime-int,
|
-google-runtime-int,
|
||||||
-hicpp-avoid-goto,
|
-hicpp-avoid-goto,
|
||||||
-hicpp-explicit-conversions,
|
-hicpp-explicit-conversions,
|
||||||
|
-hicpp-function-size,
|
||||||
-hicpp-no-array-decay,
|
-hicpp-no-array-decay,
|
||||||
|
-hicpp-no-assembler,
|
||||||
-hicpp-signed-bitwise,
|
-hicpp-signed-bitwise,
|
||||||
-hicpp-uppercase-literal-suffix,
|
-hicpp-uppercase-literal-suffix,
|
||||||
-llvm-header-guard,
|
-llvm-header-guard,
|
||||||
@@ -74,7 +48,6 @@ Checks: '*,
|
|||||||
-llvmlibc-*,
|
-llvmlibc-*,
|
||||||
-misc-use-anonymous-namespace,
|
-misc-use-anonymous-namespace,
|
||||||
-misc-confusable-identifiers,
|
-misc-confusable-identifiers,
|
||||||
-misc-explicit-constructor,
|
|
||||||
-misc-include-cleaner,
|
-misc-include-cleaner,
|
||||||
-misc-no-recursion,
|
-misc-no-recursion,
|
||||||
-misc-non-private-member-variables-in-classes,
|
-misc-non-private-member-variables-in-classes,
|
||||||
@@ -82,22 +55,20 @@ Checks: '*,
|
|||||||
-modernize-type-traits,
|
-modernize-type-traits,
|
||||||
-modernize-use-constraints,
|
-modernize-use-constraints,
|
||||||
-modernize-use-designated-initializers,
|
-modernize-use-designated-initializers,
|
||||||
-modernize-use-integer-sign-comparison,
|
|
||||||
-modernize-use-nodiscard,
|
-modernize-use-nodiscard,
|
||||||
-modernize-use-ranges,
|
-modernize-use-ranges,
|
||||||
-modernize-use-string-view,
|
|
||||||
-modernize-use-std-numbers,
|
-modernize-use-std-numbers,
|
||||||
-modernize-use-trailing-return-type,
|
-modernize-use-trailing-return-type,
|
||||||
-performance-enum-size,
|
-performance-enum-size,
|
||||||
-portability-avoid-pragma-once,
|
-portability-avoid-pragma-once,
|
||||||
-readability-function-cognitive-complexity,
|
-readability-function-cognitive-complexity,
|
||||||
|
-readability-function-size,
|
||||||
-readability-identifier-length,
|
-readability-identifier-length,
|
||||||
-readability-magic-numbers,
|
-readability-magic-numbers,
|
||||||
-readability-redundant-access-specifiers,
|
-readability-redundant-access-specifiers,
|
||||||
-readability-redundant-parentheses,
|
-readability-redundant-parentheses,
|
||||||
-readability-redundant-typename,
|
-readability-redundant-typename,
|
||||||
-readability-simplify-boolean-expr,
|
-readability-simplify-boolean-expr,
|
||||||
-readability-trailing-comma,
|
|
||||||
-readability-uppercase-literal-suffix,
|
-readability-uppercase-literal-suffix,
|
||||||
-readability-use-concise-preprocessor-directives'
|
-readability-use-concise-preprocessor-directives'
|
||||||
|
|
||||||
|
|||||||
@@ -163,9 +163,9 @@ jobs:
|
|||||||
python3 $GENERATOR --list-tags
|
python3 $GENERATOR --list-tags
|
||||||
TAG_COUNT=$(python3 $GENERATOR --list-tags | wc -l)
|
TAG_COUNT=$(python3 $GENERATOR --list-tags | wc -l)
|
||||||
|
|
||||||
python3 $GENERATOR --abi-tags diag,_dp,_vns --abi-tags _diag --output $RUNNER_TEMP/abi_tags.natvis
|
python3 $GENERATOR --abi-tags diag,_dp,_ns --abi-tags _diag --output $RUNNER_TEMP/abi_tags.natvis
|
||||||
grep -q '<!-- Namespace nlohmann::json_abi_diag_dp_vns -->' $RUNNER_TEMP/abi_tags.natvis
|
grep -q '<!-- Namespace nlohmann::json_abi_diag_dp_ns -->' $RUNNER_TEMP/abi_tags.natvis
|
||||||
grep -q '<!-- Namespace nlohmann::json_abi_diag_dp_vns_v[0-9_]* -->' $RUNNER_TEMP/abi_tags.natvis
|
grep -q '<!-- Namespace nlohmann::json_abi_diag_dp_ns_v[0-9_]* -->' $RUNNER_TEMP/abi_tags.natvis
|
||||||
test $(grep -c '<!-- Namespace ' $RUNNER_TEMP/abi_tags.natvis) -eq $(( $(grep -c '<!-- Namespace ' nlohmann_json.natvis) + 2 ))
|
test $(grep -c '<!-- Namespace ' $RUNNER_TEMP/abi_tags.natvis) -eq $(( $(grep -c '<!-- Namespace ' nlohmann_json.natvis) + 2 ))
|
||||||
|
|
||||||
python3 $GENERATOR --all --output $RUNNER_TEMP/all.natvis
|
python3 $GENERATOR --all --output $RUNNER_TEMP/all.natvis
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ jobs:
|
|||||||
- name: flawfinder_scan
|
- name: flawfinder_scan
|
||||||
uses: david-a-wheeler/flawfinder@c4216b74cf2639ffa98503768bd6e4299b5440c9 # v2.0.20
|
uses: david-a-wheeler/flawfinder@c4216b74cf2639ffa98503768bd6e4299b5440c9 # v2.0.20
|
||||||
with:
|
with:
|
||||||
# single_include/ is omitted: it is generated from include/ and would report every finding twice
|
arguments: '--sarif ./'
|
||||||
arguments: '--sarif ./cmake ./docs ./include ./src ./tests ./tools'
|
|
||||||
output: 'flawfinder_results.sarif'
|
output: 'flawfinder_results.sarif'
|
||||||
|
|
||||||
- name: Upload analysis results to GitHub Security tab
|
- name: Upload analysis results to GitHub Security tab
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ cc_library(
|
|||||||
"include/nlohmann/detail/view/simd.hpp",
|
"include/nlohmann/detail/view/simd.hpp",
|
||||||
"include/nlohmann/detail/view/string_ref.hpp",
|
"include/nlohmann/detail/view/string_ref.hpp",
|
||||||
"include/nlohmann/detail/view/value.hpp",
|
"include/nlohmann/detail/view/value.hpp",
|
||||||
|
"include/nlohmann/detail/view/view_mode.hpp",
|
||||||
"include/nlohmann/json.hpp",
|
"include/nlohmann/json.hpp",
|
||||||
"include/nlohmann/json_fwd.hpp",
|
"include/nlohmann/json_fwd.hpp",
|
||||||
"include/nlohmann/json_literals.hpp",
|
"include/nlohmann/json_literals.hpp",
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ The "Check amalgamation" workflow fails if the file is out of date.
|
|||||||
|
|
||||||
The file covers the namespace variants with up to two ABI tags. A Natvis file for other configurations can be
|
The file covers the namespace variants with up to two ABI tags. A Natvis file for other configurations can be
|
||||||
generated with the `--abi-tags` or `--all` options, for example
|
generated with the `--abi-tags` or `--all` options, for example
|
||||||
`make natvis NATVIS_ARGS="--abi-tags _diag,_dp,_vns --output my_nlohmann_json.natvis"`; see
|
`make natvis NATVIS_ARGS="--abi-tags _diag,_dp,_ns --output my_nlohmann_json.natvis"`; see
|
||||||
[`tools/generate_natvis`](tools/generate_natvis/README.md). With MSVC, CMake adds the file to the `nlohmann_json`
|
[`tools/generate_natvis`](tools/generate_natvis/README.md). With MSVC, CMake adds the file to the `nlohmann_json`
|
||||||
target and installs it.
|
target and installs it.
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ $(AMALGAMATED_VIEW_FILE): $(SRCS)
|
|||||||
tools/amalgamate/amalgamate.py -c tools/amalgamate/config_json_view.json -s . --verbose=yes
|
tools/amalgamate/amalgamate.py -c tools/amalgamate/config_json_view.json -s . --verbose=yes
|
||||||
|
|
||||||
NATVIS_VENV=tools/generate_natvis/venv
|
NATVIS_VENV=tools/generate_natvis/venv
|
||||||
# extra options for generate_natvis.py, e.g. NATVIS_ARGS="--abi-tags _diag,_dp,_vns --output my.natvis"
|
# extra options for generate_natvis.py, e.g. NATVIS_ARGS="--abi-tags _diag,_dp,_ns --output my.natvis"
|
||||||
NATVIS_ARGS=
|
NATVIS_ARGS=
|
||||||
|
|
||||||
# regenerate nlohmann_json.natvis from the ABI tags and version in include/nlohmann/detail/abi_macros.hpp
|
# regenerate nlohmann_json.natvis from the ABI tags and version in include/nlohmann/detail/abi_macros.hpp
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ The `json` class provides an API for manipulating a JSON value. To create a `jso
|
|||||||
```cpp
|
```cpp
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ If using modules (enabled with `NLOHMANN_JSON_BUILD_MODULES`), this example beco
|
|||||||
import std;
|
import std;
|
||||||
import nlohmann.json;
|
import nlohmann.json;
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -842,7 +842,7 @@ assert(p == p2);
|
|||||||
To make this work with one of your types, you only need to provide two functions:
|
To make this work with one of your types, you only need to provide two functions:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
namespace ns {
|
namespace ns {
|
||||||
void to_json(json& j, const person& p) {
|
void to_json(json& j, const person& p) {
|
||||||
@@ -1257,7 +1257,7 @@ See the page [quality assurance](https://json.nlohmann.me/community/quality_assu
|
|||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
// for convenience
|
// for convenience
|
||||||
using nlohmann::json;
|
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).
|
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).
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ Constant.
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ void erase(view_type array, I idx);
|
|||||||
std::size_t erase(const json_pointer& ptr);
|
std::size_t erase(const json_pointer& ptr);
|
||||||
```
|
```
|
||||||
|
|
||||||
Only an **editable** document (`#!cpp Editable == true`, e.g. [`json_editable_document`](../json_editable_document.md))
|
Only an **editable** document (`#!cpp view_mode::editable`, e.g. [`json_editable_document`](../json_editable_document.md))
|
||||||
has `erase`; calling it on a read-only `basic_json_document` fails to compile (`#!cpp static_assert`).
|
has `erase`; calling it on a read-only `basic_json_document` fails to compile (`#!cpp static_assert`).
|
||||||
|
|
||||||
1. Removes every member of `object` whose key is `key` (see [Notes](#notes) on duplicate keys) and returns how many
|
1. Removes every member of `object` whose key is `key` (see [Notes](#notes) on duplicate keys) and returns how many
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename BasicJsonType, bool Editable = false>
|
template<typename BasicJsonType, view_mode Mode = view_mode::read_only>
|
||||||
class basic_json_document;
|
class basic_json_document;
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -20,9 +20,9 @@ is move-only: a copy would duplicate the whole index, the decoded-string buffer,
|
|||||||
enough in every use we know of. The index, the decoded strings, and the owned text live in one heap block that the
|
enough in every use we know of. The index, the decoded strings, and the owned text live in one heap block that the
|
||||||
document holds through a `#!cpp std::unique_ptr`; this is also why views survive a move of the document.
|
document holds through a `#!cpp std::unique_ptr`; this is also why views survive a move of the document.
|
||||||
|
|
||||||
With `#!cpp Editable == true`, the document also offers [`set`](set.md), [`push_back`](push_back.md),
|
With `#!cpp Mode == view_mode::editable`, the document also offers [`set`](set.md), [`push_back`](push_back.md),
|
||||||
[`insert`](insert.md), and [`erase`](erase.md) to change values in place, see [Edits](#edits) below. The source text
|
[`insert`](insert.md), and [`erase`](erase.md) to change values in place, see [Edits](#edits) below. The source text
|
||||||
itself is never written; a read-only document (`#!cpp Editable == false`, the default) does not carry any of the
|
itself is never written; a read-only document (`#!cpp view_mode::read_only`, the default) does not carry any of the
|
||||||
bookkeeping edits need, and calling any of them on one fails to compile (`#!cpp static_assert`).
|
bookkeeping edits need, and calling any of them on one fails to compile (`#!cpp static_assert`).
|
||||||
|
|
||||||
## Template parameters
|
## Template parameters
|
||||||
@@ -32,9 +32,10 @@ bookkeeping edits need, and calling any of them on one fails to compile (`#!cpp
|
|||||||
[`ordered_json`](../ordered_json.md). Only 64-bit `number_integer_t`/`number_unsigned_t` types are supported; this
|
[`ordered_json`](../ordered_json.md). Only 64-bit `number_integer_t`/`number_unsigned_t` types are supported; this
|
||||||
is checked with a `static_assert`.
|
is checked with a `static_assert`.
|
||||||
|
|
||||||
`Editable`
|
`Mode`
|
||||||
: whether the document supports [`set`](set.md), [`push_back`](push_back.md), [`insert`](insert.md), and
|
: a [`view_mode`](../view_mode.md): `#!cpp view_mode::editable` if the document supports [`set`](set.md),
|
||||||
[`erase`](erase.md) (optional, `#!cpp false` by default). See [Edits](#edits) below.
|
[`push_back`](push_back.md), [`insert`](insert.md), and [`erase`](erase.md) (optional, `#!cpp view_mode::read_only`
|
||||||
|
by default). See [Edits](#edits) below.
|
||||||
|
|
||||||
## Specializations
|
## Specializations
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ bookkeeping edits need, and calling any of them on one fails to compile (`#!cpp
|
|||||||
|
|
||||||
## Member types
|
## Member types
|
||||||
|
|
||||||
- **view_type** - the type of view returned by [`root()`](root.md) (`#!cpp basic_json_view<BasicJsonType, Editable>`)
|
- **view_type** - the type of view returned by [`root()`](root.md) (`#!cpp basic_json_view<BasicJsonType, Mode>`)
|
||||||
- **value_t** - the JSON type enumeration, see [`basic_json::value_t`](../basic_json/value_t.md)
|
- **value_t** - the JSON type enumeration, see [`basic_json::value_t`](../basic_json/value_t.md)
|
||||||
- **image_check** - how [`load()`](load.md) validates an image (`full`, `bounds`, `none`), see [`image_check`](load.md#image_check)
|
- **image_check** - how [`load()`](load.md) validates an image (`full`, `bounds`, `none`), see [`image_check`](load.md#image_check)
|
||||||
|
|
||||||
@@ -80,15 +81,15 @@ bookkeeping edits need, and calling any of them on one fails to compile (`#!cpp
|
|||||||
### Edits
|
### Edits
|
||||||
|
|
||||||
- [**set**](set.md) - replace a value, or set an object member, an array element, or the value a JSON pointer refers
|
- [**set**](set.md) - replace a value, or set an object member, an array element, or the value a JSON pointer refers
|
||||||
to (`#!cpp Editable` documents only)
|
to (editable documents only)
|
||||||
- [**push_back**](push_back.md) - append to an array (`#!cpp Editable` documents only)
|
- [**push_back**](push_back.md) - append to an array (editable documents only)
|
||||||
- [**insert**](insert.md) - insert an element into an array before a given position (`#!cpp Editable` documents only)
|
- [**insert**](insert.md) - insert an element into an array before a given position (editable documents only)
|
||||||
- [**erase**](erase.md) - remove an object member, an array element, or the value a JSON pointer refers to
|
- [**erase**](erase.md) - remove an object member, an array element, or the value a JSON pointer refers to
|
||||||
(`#!cpp Editable` documents only)
|
(editable documents only)
|
||||||
|
|
||||||
## Edits
|
## Edits
|
||||||
|
|
||||||
An editable document (`#!cpp Editable == true`) can be changed after parsing, with [`set`](set.md),
|
An editable document (`#!cpp view_mode::editable`) can be changed after parsing, with [`set`](set.md),
|
||||||
[`push_back`](push_back.md), [`insert`](insert.md), and [`erase`](erase.md);
|
[`push_back`](push_back.md), [`insert`](insert.md), and [`erase`](erase.md);
|
||||||
[`json_editable_document`](../json_editable_document.md) and
|
[`json_editable_document`](../json_editable_document.md) and
|
||||||
[`ordered_json_editable_document`](../ordered_json_editable_document.md) are the corresponding specializations. A few
|
[`ordered_json_editable_document`](../ordered_json_editable_document.md) are the corresponding specializations. A few
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ template<typename I, typename V>
|
|||||||
view_type insert(view_type array, I idx, V&& value);
|
view_type insert(view_type array, I idx, V&& value);
|
||||||
```
|
```
|
||||||
|
|
||||||
Only an **editable** document (`#!cpp Editable == true`, e.g. [`json_editable_document`](../json_editable_document.md))
|
Only an **editable** document (`#!cpp view_mode::editable`, e.g. [`json_editable_document`](../json_editable_document.md))
|
||||||
has `insert`; calling it on a read-only `basic_json_document` fails to compile (`#!cpp static_assert`).
|
has `insert`; calling it on a read-only `basic_json_document` fails to compile (`#!cpp static_assert`).
|
||||||
|
|
||||||
Inserts `value` into `array` as a new element before position `idx`, which must not be past the end
|
Inserts `value` into `array` as a new element before position `idx`, which must not be past the end
|
||||||
|
|||||||
@@ -55,10 +55,7 @@ validate with overload 2 first, if the original vector must survive a failed loa
|
|||||||
|
|
||||||
## Exceptions
|
## Exceptions
|
||||||
|
|
||||||
On a big-endian target, throws [`type_error.320`](../../home/exceptions.md#jsonexceptiontype_error320) -- the same
|
Throws [`parse_error.116`](../../home/exceptions.md#jsonexceptionparse_error116) if `image` is not one
|
||||||
exception [`save()`](save.md#exceptions) throws there, since the image format is little-endian only.
|
|
||||||
|
|
||||||
Otherwise throws [`parse_error.116`](../../home/exceptions.md#jsonexceptionparse_error116) if `image` is not one
|
|
||||||
`save()` could have written, or fails the requested `check`:
|
`save()` could have written, or fails the requested `check`:
|
||||||
|
|
||||||
| message | when |
|
| message | when |
|
||||||
@@ -95,6 +92,9 @@ are checked once, however many nodes refer to it.
|
|||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
|
**Little-endian targets only.** On a big-endian target, `load()` does not exist, just like
|
||||||
|
[`save()`](save.md#notes): the image format is little-endian, so a call fails to compile.
|
||||||
|
|
||||||
### `image_check` { #image_check }
|
### `image_check` { #image_check }
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ editable, and it does not have to be `array`'s own document -- which is copied s
|
|||||||
source document afterward; a `BasicJsonType` value; or anything `BasicJsonType` can be constructed from (numbers,
|
source document afterward; a `BasicJsonType` value; or anything `BasicJsonType` can be constructed from (numbers,
|
||||||
strings, `#!cpp bool`, `#!cpp nullptr`, containers, ...).
|
strings, `#!cpp bool`, `#!cpp nullptr`, containers, ...).
|
||||||
|
|
||||||
Only an **editable** document (`#!cpp Editable == true`, e.g. [`json_editable_document`](../json_editable_document.md))
|
Only an **editable** document (`#!cpp view_mode::editable`, e.g. [`json_editable_document`](../json_editable_document.md))
|
||||||
has `push_back`; calling it on a read-only `basic_json_document` fails to compile (`#!cpp static_assert`).
|
has `push_back`; calling it on a read-only `basic_json_document` fails to compile (`#!cpp static_assert`).
|
||||||
|
|
||||||
## Template parameters
|
## Template parameters
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ An edited document is written in its *current* state, with its values in documen
|
|||||||
parser would have produced them for that JSON text: a member [`set`](set.md) added goes at the end, an
|
parser would have produced them for that JSON text: a member [`set`](set.md) added goes at the end, an
|
||||||
[`erase`](erase.md)d member leaves no trace, and a float that is not finite (NaN or positive/negative infinity)
|
[`erase`](erase.md)d member leaves no trace, and a float that is not finite (NaN or positive/negative infinity)
|
||||||
becomes null, the same substitution [`dump()`](../basic_json_view/dump.md) makes. The same document always saves to
|
becomes null, the same substitution [`dump()`](../basic_json_view/dump.md) makes. The same document always saves to
|
||||||
the same bytes -- also across `BasicJsonType` and `#!cpp Editable`, since the image reflects document order and
|
the same bytes -- also across `BasicJsonType` and the [`view_mode`](../view_mode.md), since the image reflects document order and
|
||||||
values only, not which specialization produced them.
|
values only, not which specialization produced them.
|
||||||
|
|
||||||
## Return value
|
## Return value
|
||||||
@@ -31,9 +31,6 @@ Throws [`type_error.320`](../../home/exceptions.md#jsonexceptiontype_error320) i
|
|||||||
[discarded](is_discarded.md) -- a default-constructed document, or one a failed [`parse()`](parse.md)/
|
[discarded](is_discarded.md) -- a default-constructed document, or one a failed [`parse()`](parse.md)/
|
||||||
[`read()`](read.md) with `allow_exceptions == false` left discarded.
|
[`read()`](read.md) with `allow_exceptions == false` left discarded.
|
||||||
|
|
||||||
On a big-endian target, throws `type_error.320` with a different message instead: the image format is little-endian
|
|
||||||
only (see [Notes](#notes)).
|
|
||||||
|
|
||||||
Throws [`out_of_range.416`](../../home/exceptions.md#jsonexceptionout_of_range416) if the node count, the text, or
|
Throws [`out_of_range.416`](../../home/exceptions.md#jsonexceptionout_of_range416) if the node count, the text, or
|
||||||
the decoded strings of the image would individually reach 4 GiB -- the same 32-bit offsets
|
the decoded strings of the image would individually reach 4 GiB -- the same 32-bit offsets
|
||||||
[`parse()`](parse.md#exceptions) and, for edits, [`set`](set.md)/[`push_back`](push_back.md) are already limited to.
|
[`parse()`](parse.md#exceptions) and, for edits, [`set`](set.md)/[`push_back`](push_back.md) are already limited to.
|
||||||
@@ -44,9 +41,6 @@ the decoded strings of the image would individually reach 4 GiB -- the same 32-b
|
|||||||
[json.exception.type_error.320] cannot save a discarded json_document
|
[json.exception.type_error.320] cannot save a discarded json_document
|
||||||
```
|
```
|
||||||
```
|
```
|
||||||
[json.exception.type_error.320] json_document images need a little-endian target
|
|
||||||
```
|
|
||||||
```
|
|
||||||
[json.exception.out_of_range.416] images of 4 GiB or more are not supported by json_document
|
[json.exception.out_of_range.416] images of 4 GiB or more are not supported by json_document
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -70,9 +64,9 @@ else -- see [`load`'s Exceptions](load.md#exceptions).
|
|||||||
the *same* build on the *same* (little-endian) machine -- not as a long-term storage format. Keep the original
|
the *same* build on the *same* (little-endian) machine -- not as a long-term storage format. Keep the original
|
||||||
JSON text if you need to read a saved document back with a future library version.
|
JSON text if you need to read a saved document back with a future library version.
|
||||||
|
|
||||||
**Little-endian only.** The image is written as raw little-endian bytes, with no byte-swapping. `save()` (and
|
**Little-endian targets only.** The image is written as raw little-endian bytes, with no byte-swapping. On a
|
||||||
[`load`](load.md)) throw `type_error.320` on a big-endian target rather than silently produce bytes a big-endian
|
big-endian target, `save()` and [`load`](load.md) do not exist: a call fails to compile rather than produce bytes a
|
||||||
reader could not interpret correctly.
|
big-endian reader could not interpret correctly.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ template<typename V>
|
|||||||
view_type set(const json_pointer& ptr, V&& value);
|
view_type set(const json_pointer& ptr, V&& value);
|
||||||
```
|
```
|
||||||
|
|
||||||
Only an **editable** document (`#!cpp Editable == true`, e.g. [`json_editable_document`](../json_editable_document.md))
|
Only an **editable** document (`#!cpp view_mode::editable`, e.g. [`json_editable_document`](../json_editable_document.md))
|
||||||
has `set`; calling it on a read-only `basic_json_document` fails to compile (`#!cpp static_assert`).
|
has `set`; calling it on a read-only `basic_json_document` fails to compile (`#!cpp static_assert`).
|
||||||
|
|
||||||
1. Replaces the value `target` refers to with `value`.
|
1. Replaces the value `target` refers to with `value`.
|
||||||
|
|||||||
@@ -23,10 +23,6 @@ Linear in [`node_count()`](node_count.md) plus the length of the decoded strings
|
|||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
The node index of a small document (an estimate of up to 1024 nodes, which is up to about 4 KiB of minified text) is
|
|
||||||
allocated together with the document's header, so that parsing needs one allocation. That part cannot be released
|
|
||||||
separately: `shrink_to_fit()` only trims a node index that has its own allocation, and the decoded strings.
|
|
||||||
|
|
||||||
!!! warning "Invalidates views"
|
!!! warning "Invalidates views"
|
||||||
|
|
||||||
Unlike moving the document, `shrink_to_fit()` **invalidates every view taken from this document before the
|
Unlike moving the document, `shrink_to_fit()` **invalidates every view taken from this document before the
|
||||||
|
|||||||
@@ -27,8 +27,25 @@ For the types below, the conversion works directly on the flat index -- no `Basi
|
|||||||
[`materialize()`](materialize.md)) does; `#!cpp std::map<std::string, basic_json_view>` keeps views of the members
|
[`materialize()`](materialize.md)) does; `#!cpp std::map<std::string, basic_json_view>` keeps views of the members
|
||||||
instead of values
|
instead of values
|
||||||
|
|
||||||
Every other `T` -- `#!cpp std::list`, `#!cpp std::pair`, `#!cpp std::array`, enumerations, user types with a
|
A default-constructible `T` whose `from_json()` accepts views reads the view directly as well, member by member, without
|
||||||
`from_json()`, ... -- is converted by `#!cpp materialize().get<T>()`: the subtree is built into a real `BasicJsonType`
|
building a `BasicJsonType` value. This covers the types of the
|
||||||
|
[`NLOHMANN_DEFINE_TYPE_*`](../macros/nlohmann_define_type_intrusive.md) and
|
||||||
|
[`NLOHMANN_DEFINE_DERIVED_TYPE_*`](../macros/nlohmann_define_derived_type.md) macros and the enumerations of
|
||||||
|
[`NLOHMANN_JSON_SERIALIZE_ENUM`](../macros/nlohmann_json_serialize_enum.md), and any `from_json()` constrained to
|
||||||
|
accept views, e.g. with [`is_json_view`](../is_json_view.md). A `from_json()` that also accepts types that are no JSON
|
||||||
|
values at all, such as the unconstrained `#!cpp template<typename BasicJsonType> void from_json(const BasicJsonType&,
|
||||||
|
T&)` of [arbitrary type conversions](../../features/arbitrary_types.md), is not called with a view: it may use
|
||||||
|
`BasicJsonType` functions a view does not have. See [json_view](../../features/json_view.md).
|
||||||
|
|
||||||
|
!!! warning "Duplicate keys"
|
||||||
|
|
||||||
|
Such a `from_json()` looks members up in the view, where a repeated key finds the **first** member, while
|
||||||
|
`#!cpp materialize().get<T>()` sees the **last** one, as [`BasicJsonType::parse()`](../basic_json/parse.md)
|
||||||
|
keeps it: for `#!cpp {"x":1,"x":2}`, `#!cpp get<point>()` reads `#!cpp x == 1`. See
|
||||||
|
[Duplicate keys](../../features/json_view.md#duplicate-keys).
|
||||||
|
|
||||||
|
Every other `T` -- `#!cpp std::list`, `#!cpp std::pair`, `#!cpp std::array`, user types whose `from_json()` is
|
||||||
|
written for `BasicJsonType` only, ... -- is converted by `#!cpp materialize().get<T>()`: the subtree is built into a real `BasicJsonType`
|
||||||
value first (as [`BasicJsonType::parse()`](../basic_json/parse.md) would), and converted from there exactly as
|
value first (as [`BasicJsonType::parse()`](../basic_json/parse.md) would), and converted from there exactly as
|
||||||
[`BasicJsonType::get<T>()`](../basic_json/get.md) would convert it.
|
[`BasicJsonType::get<T>()`](../basic_json/get.md) would convert it.
|
||||||
|
|
||||||
@@ -55,10 +72,13 @@ Strong guarantee: there are no changes to the view or the document it refers to.
|
|||||||
an element to `U` throws.
|
an element to `U` throws.
|
||||||
- For `#!cpp std::map`/`#!cpp std::unordered_map`: throws `type_error.302` if the value is not an object; otherwise,
|
- For `#!cpp std::map`/`#!cpp std::unordered_map`: throws `type_error.302` if the value is not an object; otherwise,
|
||||||
whatever converting a member to the mapped type throws.
|
whatever converting a member to the mapped type throws.
|
||||||
|
- For a `T` whose `from_json()` reads the view: whatever that `from_json()` throws; for the macros, the same
|
||||||
|
exceptions with the same messages as [`BasicJsonType::get<T>()`](../basic_json/get.md) of the same value.
|
||||||
- For every other `T`: whatever [`materialize().get<T>()`](../basic_json/get.md) throws -- typically `type_error.302`,
|
- For every other `T`: whatever [`materialize().get<T>()`](../basic_json/get.md) throws -- typically `type_error.302`,
|
||||||
or whatever a user-provided `from_json()` throws.
|
or whatever a user-provided `from_json()` throws.
|
||||||
|
|
||||||
None of the exceptions thrown directly by this function (the first three bullets above) carry a
|
None of the exceptions thrown directly by this function or by a `from_json()` that reads the view (the first four
|
||||||
|
bullets above) carry a
|
||||||
[`JSON_DIAGNOSTICS`](../macros/json_diagnostics.md) path: the view has no `BasicJsonType` value to point at. An
|
[`JSON_DIAGNOSTICS`](../macros/json_diagnostics.md) path: the view has no `BasicJsonType` value to point at. An
|
||||||
exception thrown while converting through `materialize()` (the last bullet) is different: it is thrown by a real
|
exception thrown while converting through `materialize()` (the last bullet) is different: it is thrown by a real
|
||||||
`BasicJsonType` value, so it **does** carry a `JSON_DIAGNOSTICS` path if `BasicJsonType` was built with it enabled.
|
`BasicJsonType` value, so it **does** carry a `JSON_DIAGNOSTICS` path if `BasicJsonType` was built with it enabled.
|
||||||
@@ -76,6 +96,8 @@ document.
|
|||||||
- `#!cpp std::map`/`#!cpp std::unordered_map`: linear in the number of members for walking them, plus the container's
|
- `#!cpp std::map`/`#!cpp std::unordered_map`: linear in the number of members for walking them, plus the container's
|
||||||
own insertion cost per member (logarithmic for `#!cpp std::map`, amortized constant for `#!cpp
|
own insertion cost per member (logarithmic for `#!cpp std::map`, amortized constant for `#!cpp
|
||||||
std::unordered_map`), times the complexity of converting one member to the mapped type.
|
std::unordered_map`), times the complexity of converting one member to the mapped type.
|
||||||
|
- a `T` whose `from_json()` reads the view: the cost of that `from_json()`; for the macros, linear in the number of
|
||||||
|
members times the cost of a lookup, plus the cost of converting the members.
|
||||||
- every other `T`: the cost of [`materialize()`](materialize.md) and of destroying the `BasicJsonType` value
|
- every other `T`: the cost of [`materialize()`](materialize.md) and of destroying the `BasicJsonType` value
|
||||||
afterwards, plus that of [`BasicJsonType::get<T>()`](../basic_json/get.md).
|
afterwards, plus that of [`BasicJsonType::get<T>()`](../basic_json/get.md).
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,14 @@ template<typename T>
|
|||||||
T& get_to(T& v) const;
|
T& get_to(T& v) const;
|
||||||
```
|
```
|
||||||
|
|
||||||
Converts the value to `T` and stores it in `v`, in one of two ways:
|
Converts the value to `T` and stores it in `v`, in one of three ways:
|
||||||
|
|
||||||
- For the types that [`get<T>()`](get.md) converts directly -- arithmetic types, `#!cpp bool`,
|
- For the types that [`get<T>()`](get.md) converts directly -- arithmetic types, `#!cpp bool`,
|
||||||
`#!cpp std::nullptr_t`, [`string_view_t`](index.md#member-types), `#!cpp std::basic_string`, `BasicJsonType`,
|
`#!cpp std::nullptr_t`, [`string_view_t`](index.md#member-types), `#!cpp std::basic_string`, `BasicJsonType`,
|
||||||
`basic_json_view`, `#!cpp std::vector`, and `#!cpp std::map`/`#!cpp std::unordered_map` with string keys -- `v` is
|
`basic_json_view`, `#!cpp std::vector`, and `#!cpp std::map`/`#!cpp std::unordered_map` with string keys -- `v` is
|
||||||
assigned: `#!cpp v = get<T>()`.
|
assigned: `#!cpp v = get<T>()`.
|
||||||
|
- For a type whose `from_json()` accepts views (see [`get<T>()`](get.md)), that `from_json()` is called with the
|
||||||
|
view and the existing `v`, without building a `BasicJsonType` value.
|
||||||
- For every other type, the subtree is built into a `BasicJsonType` value and `#!cpp materialize().get_to(v)` is
|
- For every other type, the subtree is built into a `BasicJsonType` value and `#!cpp materialize().get_to(v)` is
|
||||||
called, i.e. `from_json()` is invoked with the existing `v`, exactly as
|
called, i.e. `from_json()` is invoked with the existing `v`, exactly as
|
||||||
[`BasicJsonType::get_to()`](../basic_json/get_to.md) does.
|
[`BasicJsonType::get_to()`](../basic_json/get_to.md) does.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template<typename BasicJsonType, bool Editable = false>
|
template<typename BasicJsonType, view_mode Mode = view_mode::read_only>
|
||||||
class basic_json_view;
|
class basic_json_view;
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ Moving the document itself does not invalidate its views: the index is heap-allo
|
|||||||
`#!cpp operator ValueType()`), and no `#!cpp get_ptr()` or `#!cpp get_ref()`; see [`get`](get.md).
|
`#!cpp operator ValueType()`), and no `#!cpp get_ptr()` or `#!cpp get_ref()`; see [`get`](get.md).
|
||||||
|
|
||||||
`basic_json_view` itself is always read-only -- it never has a `set` or `push_back` of its own. A view of an
|
`basic_json_view` itself is always read-only -- it never has a `set` or `push_back` of its own. A view of an
|
||||||
**editable** document (`#!cpp Editable == true`) sees every edit made through
|
**editable** document (`#!cpp view_mode::editable`) sees every edit made through
|
||||||
[`basic_json_document::set`](../basic_json_document/set.md) and
|
[`basic_json_document::set`](../basic_json_document/set.md) and
|
||||||
[`basic_json_document::push_back`](../basic_json_document/push_back.md): once a value is changed, every view that
|
[`basic_json_document::push_back`](../basic_json_document/push_back.md): once a value is changed, every view that
|
||||||
still refers to it -- including ones taken before the change -- reads the new value. See
|
still refers to it -- including ones taken before the change -- reads the new value. See
|
||||||
@@ -49,9 +49,10 @@ still refers to it -- including ones taken before the change -- reads the new va
|
|||||||
: a specialization of [`basic_json`](../basic_json/index.md), matching the
|
: a specialization of [`basic_json`](../basic_json/index.md), matching the
|
||||||
[`basic_json_document`](../basic_json_document/index.md) the view was taken from.
|
[`basic_json_document`](../basic_json_document/index.md) the view was taken from.
|
||||||
|
|
||||||
`Editable`
|
`Mode`
|
||||||
: whether the view is of an editable document, matching the [`basic_json_document`](../basic_json_document/index.md)
|
: a [`view_mode`](../view_mode.md): whether the view is of an editable document, matching the
|
||||||
it was taken from (optional, `#!cpp false` by default). See [Edits](../basic_json_document/index.md#edits).
|
[`basic_json_document`](../basic_json_document/index.md) it was taken from (optional, `#!cpp view_mode::read_only` by
|
||||||
|
default). See [Edits](../basic_json_document/index.md#edits).
|
||||||
|
|
||||||
## Specializations
|
## Specializations
|
||||||
|
|
||||||
@@ -63,6 +64,7 @@ still refers to it -- including ones taken before the change -- reads the new va
|
|||||||
|
|
||||||
## Member types
|
## Member types
|
||||||
|
|
||||||
|
- **basic_json_type** - `BasicJsonType` (it also marks the class for [`is_json_view`](../is_json_view.md))
|
||||||
- **value_t** - the JSON type enumeration, see [`basic_json::value_t`](../basic_json/value_t.md)
|
- **value_t** - the JSON type enumeration, see [`basic_json::value_t`](../basic_json/value_t.md)
|
||||||
- **string_t**, **number_integer_t**, **number_unsigned_t**, **number_float_t**, **json_pointer** - the corresponding
|
- **string_t**, **number_integer_t**, **number_unsigned_t**, **number_float_t**, **json_pointer** - the corresponding
|
||||||
member types of `BasicJsonType`
|
member types of `BasicJsonType`
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
# <small>nlohmann::</small>is_json_view
|
||||||
|
|
||||||
|
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
template<typename T>
|
||||||
|
struct is_json_view;
|
||||||
|
```
|
||||||
|
|
||||||
|
A type trait: `#!cpp is_json_view<T>::value` is `#!cpp true` if `T` is a [`basic_json_view`](basic_json_view/index.md)
|
||||||
|
of any `BasicJsonType` and any [`view_mode`](view_mode.md) -- [`json_view`](json_view.md),
|
||||||
|
[`json_editable_view`](json_editable_view.md), [`ordered_json_view`](ordered_json_view.md), ... -- and
|
||||||
|
`#!cpp false` otherwise, for [`basic_json`](basic_json/index.md) as well.
|
||||||
|
|
||||||
|
It is meant for constraining templates that accept views, in particular a `from_json()` that should read views
|
||||||
|
directly: [`get<T>()`](basic_json_view/get.md) on a view calls a `from_json()` with the view only if that `from_json()`
|
||||||
|
accepts views but not arbitrary types.
|
||||||
|
|
||||||
|
## Template parameters
|
||||||
|
|
||||||
|
`T`
|
||||||
|
: the type to check (without cv-qualifiers or references)
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
A view is recognized by its member type `basic_json_type` (a [`basic_json`](basic_json/index.md) specialization) and
|
||||||
|
its [`materialize()`](basic_json_view/materialize.md) returning that type, so the trait needs no declaration of the
|
||||||
|
view class.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example below shows the trait, and a `from_json()` constrained to `json` values and views: `get<T>()` on a view
|
||||||
|
reads the view directly.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/is_json_view.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/is_json_view.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
- [basic_json_view](basic_json_view/index.md) - a handle to one value of a document
|
||||||
|
- [get](basic_json_view/get.md) - which conversions read the view directly
|
||||||
|
- [view_mode](view_mode.md) - read-only or editable
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
Added in version 3.13.0.
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
using json_document = basic_json_document<json>;
|
using json_document = basic_json_document<json, view_mode::read_only>;
|
||||||
```
|
```
|
||||||
|
|
||||||
This type is a [`basic_json_document`](basic_json_document/index.md) of the default [`json`](json.md)
|
This type is a [`basic_json_document`](basic_json_document/index.md) of the default [`json`](json.md)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
using json_editable_document = basic_json_document<json, true>;
|
using json_editable_document = basic_json_document<json, view_mode::editable>;
|
||||||
```
|
```
|
||||||
|
|
||||||
This type is an **editable** [`basic_json_document`](basic_json_document/index.md) of the default
|
This type is an **editable** [`basic_json_document`](basic_json_document/index.md) of the default
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
using json_editable_view = basic_json_view<json, true>;
|
using json_editable_view = basic_json_view<json, view_mode::editable>;
|
||||||
```
|
```
|
||||||
|
|
||||||
This type is a [`basic_json_view`](basic_json_view/index.md) of a value of a
|
This type is a [`basic_json_view`](basic_json_view/index.md) of a value of a
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
using json_view = basic_json_view<json>;
|
using json_view = basic_json_view<json, view_mode::read_only>;
|
||||||
```
|
```
|
||||||
|
|
||||||
This type is a [`basic_json_view`](basic_json_view/index.md) of a value of a [`json_document`](json_document.md).
|
This type is a [`basic_json_view`](basic_json_view/index.md) of a value of a [`json_document`](json_document.md).
|
||||||
|
|||||||
@@ -43,8 +43,6 @@ header. See also the [macro overview page](../../features/macros.md).
|
|||||||
- [**JSON_SKIP_UNSUPPORTED_COMPILER_CHECK**](json_skip_unsupported_compiler_check.md) - do not warn about unsupported compilers
|
- [**JSON_SKIP_UNSUPPORTED_COMPILER_CHECK**](json_skip_unsupported_compiler_check.md) - do not warn about unsupported compilers
|
||||||
- [**JSON_USE_GLOBAL_UDLS**](json_use_global_udls.md) - place user-defined string literals (UDLs) into the global namespace
|
- [**JSON_USE_GLOBAL_UDLS**](json_use_global_udls.md) - place user-defined string literals (UDLs) into the global namespace
|
||||||
- [**JSON_USE_SIMDUTF**](json_use_simdutf.md) - use the simdutf library to accelerate UTF-8 validation
|
- [**JSON_USE_SIMDUTF**](json_use_simdutf.md) - use the simdutf library to accelerate UTF-8 validation
|
||||||
- [**JSON_VIEW_NO_SIMD**](json_view_no_simd.md) - use only portable code in the parser of `json_view.hpp`
|
|
||||||
- [**JSON_VIEW_USE_SSSE3**](json_view_use_ssse3.md) - validate non-ASCII strings with SSSE3 in the parser of `json_view.hpp`
|
|
||||||
|
|
||||||
## Library version
|
## Library version
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ Therefore, assertions can be switched off by defining `NDEBUG`.
|
|||||||
```cpp
|
```cpp
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@@ -64,7 +64,7 @@ Therefore, assertions can be switched off by defining `NDEBUG`.
|
|||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ The default value is `0` (disabled — existing behavior is preserved).
|
|||||||
```cpp
|
```cpp
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@@ -98,7 +98,7 @@ The default value is `0` (disabled — existing behavior is preserved).
|
|||||||
#define JSON_BRACE_INIT_COPY_SEMANTICS 1
|
#define JSON_BRACE_INIT_COPY_SEMANTICS 1
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ The default value is `0` (disabled, the deprecated functions can still be called
|
|||||||
```cpp
|
```cpp
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
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
|
#define JSON_DELETE_DEPRECATED_FUNCTIONS 1
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ The default value is `0`.
|
|||||||
#define JSON_DISABLE_ENUM_SERIALIZATION 1
|
#define JSON_DISABLE_ENUM_SERIALIZATION 1
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
enum class Choice
|
enum class Choice
|
||||||
{
|
{
|
||||||
@@ -66,7 +66,7 @@ The default value is `0`.
|
|||||||
#define JSON_DISABLE_ENUM_SERIALIZATION 1
|
#define JSON_DISABLE_ENUM_SERIALIZATION 1
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
enum class Choice
|
enum class Choice
|
||||||
{
|
{
|
||||||
@@ -99,7 +99,7 @@ The default value is `0`.
|
|||||||
#define JSON_DISABLE_ENUM_SERIALIZATION 1
|
#define JSON_DISABLE_ENUM_SERIALIZATION 1
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
enum class Choice
|
enum class Choice
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ The default value is `0`: streams are scanned in bulk.
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@@ -115,7 +115,7 @@ The default value is `0`: streams are scanned in bulk.
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ The default value is `0` (disabled — existing behavior is preserved).
|
|||||||
```cpp
|
```cpp
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@@ -89,7 +89,7 @@ The default value is `0` (disabled — existing behavior is preserved).
|
|||||||
#define JSON_DISABLE_TUPLE_REFERENCE_CONVERSION 1
|
#define JSON_DISABLE_TUPLE_REFERENCE_CONVERSION 1
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ The default value is `0`: the file is locked once and read with the unlocked std
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
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 <cstdio>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
```
|
```
|
||||||
|
|
||||||
When defined, the library uses only portable C++ code where it would otherwise use vector instructions: when scanning
|
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
|
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,
|
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 <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
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_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
|
- [**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)
|
- [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
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ The default value is `0` (disabled — existing behavior is preserved).
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@@ -115,7 +115,7 @@ The default value is `0` (disabled — existing behavior is preserved).
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ The default value is `0` (disabled, the behavior of version 3.12.0 and earlier i
|
|||||||
```cpp
|
```cpp
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
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
|
#define JSON_STRICT_BINARY_UTF8 1
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ The default value is `0` (disabled — existing behavior is preserved).
|
|||||||
```cpp
|
```cpp
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@@ -109,7 +109,7 @@ The default value is `0` (disabled — existing behavior is preserved).
|
|||||||
#define JSON_STRICT_NUL_HANDLING 1
|
#define JSON_STRICT_NUL_HANDLING 1
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ The default value is `0` (disabled — existing behavior is preserved).
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
enum TaskState { TS_STOPPED, TS_RUNNING, TS_COMPLETED };
|
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 <map>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
enum TaskState { TS_STOPPED, TS_RUNNING, TS_COMPLETED };
|
enum TaskState { TS_STOPPED, TS_RUNNING, TS_COMPLETED };
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
|
||||||
@@ -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.
|
|
||||||
@@ -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
|
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.
|
[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
|
## Examples
|
||||||
|
|
||||||
??? example "Example: (1) NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE"
|
??? example "Example: (1) NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE"
|
||||||
@@ -192,3 +199,5 @@ void to_json(BasicJsonType& j, const B& b) {
|
|||||||
6. Added in version 3.12.0.
|
6. Added in version 3.12.0.
|
||||||
|
|
||||||
All six macros were changed to allow an empty member list in version 3.13.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.
|
||||||
@@ -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
|
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.
|
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
|
## Examples
|
||||||
|
|
||||||
??? example "Example: (1) NLOHMANN_DEFINE_TYPE_INTRUSIVE"
|
??? example "Example: (1) NLOHMANN_DEFINE_TYPE_INTRUSIVE"
|
||||||
@@ -189,3 +195,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,
|
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.
|
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.
|
||||||
@@ -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
|
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.
|
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
|
## Examples
|
||||||
|
|
||||||
??? example "Example: (1) NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE"
|
??? example "Example: (1) NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE"
|
||||||
@@ -188,3 +194,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,
|
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.
|
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.
|
||||||
@@ -39,6 +39,6 @@ the library.
|
|||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
- Added in version 3.11.0. Changed inline namespace name in version 3.11.2. Added the ABI tag `_dp` in
|
- 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`,
|
version 3.12.0, and the ABI tags `_bics`, `_psp`, `_snul`, `_sbu8`, `_ekmo`, `_dsbs`, `_dufio`, and `_ns` in
|
||||||
and `_vssse3` in version 3.13.0; see
|
version 3.13.0; see
|
||||||
[`nlohmann` Namespace](../../features/namespace.md#structure).
|
[`nlohmann` Namespace](../../features/namespace.md#structure).
|
||||||
@@ -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
|
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.
|
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
|
## Examples
|
||||||
|
|
||||||
??? example "Example: Basic usage"
|
??? example "Example: Basic usage"
|
||||||
@@ -88,3 +94,5 @@ inline void from_json(const BasicJsonType& j, type& e);
|
|||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
Added in version 3.4.0.
|
Added in version 3.4.0.
|
||||||
|
|
||||||
|
The generated `from_json()` reads the views of `json_document`s since version 3.13.0.
|
||||||
@@ -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
|
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.
|
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
|
## Examples
|
||||||
|
|
||||||
??? example "Example: Basic usage"
|
??? example "Example: Basic usage"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
using ordered_json_document = basic_json_document<ordered_json>;
|
using ordered_json_document = basic_json_document<ordered_json, view_mode::read_only>;
|
||||||
```
|
```
|
||||||
|
|
||||||
This type is a [`basic_json_document`](basic_json_document/index.md) of the [`ordered_json`](ordered_json.md)
|
This type is a [`basic_json_document`](basic_json_document/index.md) of the [`ordered_json`](ordered_json.md)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
using ordered_json_editable_document = basic_json_document<ordered_json, true>;
|
using ordered_json_editable_document = basic_json_document<ordered_json, view_mode::editable>;
|
||||||
```
|
```
|
||||||
|
|
||||||
This type is an **editable** [`basic_json_document`](basic_json_document/index.md) of the
|
This type is an **editable** [`basic_json_document`](basic_json_document/index.md) of the
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
using ordered_json_editable_view = basic_json_view<ordered_json, true>;
|
using ordered_json_editable_view = basic_json_view<ordered_json, view_mode::editable>;
|
||||||
```
|
```
|
||||||
|
|
||||||
This type is a [`basic_json_view`](basic_json_view/index.md) of a value of an
|
This type is a [`basic_json_view`](basic_json_view/index.md) of a value of an
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
using ordered_json_view = basic_json_view<ordered_json>;
|
using ordered_json_view = basic_json_view<ordered_json, view_mode::read_only>;
|
||||||
```
|
```
|
||||||
|
|
||||||
This type is a [`basic_json_view`](basic_json_view/index.md) of a value of an
|
This type is a [`basic_json_view`](basic_json_view/index.md) of a value of an
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
# <small>nlohmann::</small>view_mode
|
||||||
|
|
||||||
|
<small>Defined in header `<nlohmann/json_view.hpp>`</small>
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
enum class view_mode : std::uint8_t
|
||||||
|
{
|
||||||
|
read_only,
|
||||||
|
editable
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
The second template parameter of [`basic_json_document`](basic_json_document/index.md) and
|
||||||
|
[`basic_json_view`](basic_json_view/index.md): whether a document can be changed after parsing, and whether a view is
|
||||||
|
of such a document.
|
||||||
|
|
||||||
|
`read_only`
|
||||||
|
: the default: the document is parsed once and then only read. It carries none of the bookkeeping edits need, and
|
||||||
|
calling [`set`](basic_json_document/set.md), [`push_back`](basic_json_document/push_back.md),
|
||||||
|
[`insert`](basic_json_document/insert.md), or [`erase`](basic_json_document/erase.md) on it fails to compile.
|
||||||
|
|
||||||
|
`editable`
|
||||||
|
: the document also offers [`set`](basic_json_document/set.md), [`push_back`](basic_json_document/push_back.md),
|
||||||
|
[`insert`](basic_json_document/insert.md), and [`erase`](basic_json_document/erase.md); its views see every edit,
|
||||||
|
see [Edits](basic_json_document/index.md#edits).
|
||||||
|
|
||||||
|
The shortcuts name both modes: [`json_document`](json_document.md) and [`json_view`](json_view.md) are read-only,
|
||||||
|
[`json_editable_document`](json_editable_document.md) and [`json_editable_view`](json_editable_view.md) are editable
|
||||||
|
(and likewise for `ordered_json`).
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
The mode is a compile-time property of the document's and the view's type, not a setting of a call, and there is no conversion between the two modes: a read-only view reads a
|
||||||
|
container in place, while a view of an editable document follows the links that edits leave behind. A function that
|
||||||
|
accepts views therefore names the modes it accepts in its signature:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
// views of editable documents only
|
||||||
|
template<typename BasicJsonType>
|
||||||
|
void f(basic_json_view<BasicJsonType, view_mode::editable> v);
|
||||||
|
|
||||||
|
// views of read-only documents only
|
||||||
|
template<typename BasicJsonType>
|
||||||
|
void f(basic_json_view<BasicJsonType, view_mode::read_only> v);
|
||||||
|
|
||||||
|
// either
|
||||||
|
template<typename BasicJsonType, view_mode Mode>
|
||||||
|
void f(basic_json_view<BasicJsonType, Mode> v);
|
||||||
|
```
|
||||||
|
|
||||||
|
A function that takes a [`json_view`](json_view.md) accepts neither an [`ordered_json_view`](ordered_json_view.md)
|
||||||
|
nor a [`json_editable_view`](json_editable_view.md). Views of the two modes still compare with
|
||||||
|
[`operator==`](basic_json_view/operator_eq.md).
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example
|
||||||
|
|
||||||
|
The example below shows a function template that accepts the views of both modes, and one that accepts only
|
||||||
|
views of editable documents.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/view_mode.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```
|
||||||
|
--8<-- "examples/view_mode.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
- [basic_json_document](basic_json_document/index.md) - a parsed JSON text
|
||||||
|
- [basic_json_view](basic_json_view/index.md) - a handle to one value of a document
|
||||||
|
- [json_editable_document](json_editable_document.md) - an editable document of `json`
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
Added in version 3.13.0.
|
||||||
@@ -188,13 +188,10 @@ Note: Some modern features (like C++20 ranges or filesystem support) may be disa
|
|||||||
```
|
```
|
||||||
|
|
||||||
- [x] The code is checked with the latest [Cppcheck](https://cppcheck.sourceforge.io) with all warnings enabled.
|
- [x] The code is checked with the latest [Cppcheck](https://cppcheck.sourceforge.io) with all warnings enabled.
|
||||||
- [x] The code is checked with the latest [Clang Static Analyzer](https://clang-analyzer.llvm.org) with 52 enabled
|
- [x] The code is checked with the latest [Clang Static Analyzer](https://clang-analyzer.llvm.org) with 89 enabled
|
||||||
checkers.
|
rules.
|
||||||
- [x] The code is checked with [Infer](https://fbinfer.com).
|
- [x] The code is checked with [Infer](https://fbinfer.com).
|
||||||
- [x] The code is checked with [Codacy](https://app.codacy.com/gh/nlohmann/json/dashboard).
|
- [x] The code is checked with [Codacy](https://app.codacy.com/gh/nlohmann/json/dashboard).
|
||||||
- [x] The code is scanned with [CodeQL](https://codeql.github.com), [Semgrep](https://semgrep.dev), and
|
|
||||||
[Flawfinder](https://dwheeler.com/flawfinder/) on every push and pull request and on a schedule; the findings are
|
|
||||||
reported to GitHub's code scanning.
|
|
||||||
|
|
||||||
## Dynamic analysis
|
## Dynamic analysis
|
||||||
|
|
||||||
@@ -207,8 +204,6 @@ Note: Some modern features (like C++20 ranges or filesystem support) may be disa
|
|||||||
- [x] The test suite is executed with [Valgrind](https://valgrind.org) (Memcheck) to detect memory leaks.
|
- [x] The test suite is executed with [Valgrind](https://valgrind.org) (Memcheck) to detect memory leaks.
|
||||||
- [x] The test suite is executed with [Sanitizers](https://github.com/google/sanitizers) (address sanitizer, undefined
|
- [x] The test suite is executed with [Sanitizers](https://github.com/google/sanitizers) (address sanitizer, undefined
|
||||||
behavior sanitizer, integer overflow detection, nullability violations).
|
behavior sanitizer, integer overflow detection, nullability violations).
|
||||||
- [x] The fuzz targets are run with [CIFuzz](https://google.github.io/oss-fuzz/getting-started/continuous-integration/)
|
|
||||||
on every pull request to catch regressions before they are merged.
|
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
@@ -228,8 +223,6 @@ Note: Some modern features (like C++20 ranges or filesystem support) may be disa
|
|||||||
No release is made while such an alert is open.
|
No release is made while such an alert is open.
|
||||||
- [x] Third-party code included in the repository for testing, such as [doctest](https://github.com/doctest/doctest),
|
- [x] Third-party code included in the repository for testing, such as [doctest](https://github.com/doctest/doctest),
|
||||||
is updated manually.
|
is updated manually.
|
||||||
- [x] The repository is evaluated with the [OpenSSF Scorecard](https://securityscorecards.dev) on a schedule and on
|
|
||||||
every push to the default branch, and the results are reported to GitHub's code scanning.
|
|
||||||
|
|
||||||
## Style check
|
## Style check
|
||||||
|
|
||||||
@@ -265,21 +258,4 @@ Note: Some modern features (like C++20 ranges or filesystem support) may be disa
|
|||||||
- [x] The library is tested against relevant CMake versions:
|
- [x] The library is tested against relevant CMake versions:
|
||||||
- CMake 3.5 (the earliest supported)
|
- CMake 3.5 (the earliest supported)
|
||||||
- CMake 3.31.6 (the latest 3.x release)
|
- CMake 3.31.6 (the latest 3.x release)
|
||||||
- CMake 4.0.0 (the first 4.x release)
|
- CMake 4.0.0 (a very recent release)
|
||||||
!!! success "Requirement: Other build systems"
|
|
||||||
|
|
||||||
The library can be used with build systems and package managers other than CMake.
|
|
||||||
|
|
||||||
- [x] The library can be consumed with [Meson](https://json.nlohmann.me/integration/package_managers/) and the Swift
|
|
||||||
Package Manager; the installation with Meson and the resolution of `Package.swift` are tested in the CI.
|
|
||||||
|
|
||||||
!!! success "Requirement: Reproducible and verifiable builds"
|
|
||||||
|
|
||||||
The library can be built and tested without network access or a Git checkout, and its licensing is machine-readable.
|
|
||||||
|
|
||||||
- [x] The test suite is executed from an exported source tree without the `.git` directory and with the test data
|
|
||||||
being available offline.
|
|
||||||
- [x] The test suite is executed without the tests that change installed files to check that builds are reproducible.
|
|
||||||
- [x] The repository is checked for compliance with the [REUSE specification](https://reuse.software) so that the
|
|
||||||
license and copyright of every file is machine-readable.
|
|
||||||
- [x] The documentation is built with warnings treated as errors, and its links are checked regularly.
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,19 +2,19 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// a valid JSON text
|
// a valid JSON text
|
||||||
const auto* valid_text = R"(
|
auto valid_text = R"(
|
||||||
{
|
{
|
||||||
"numbers": [1, 2, 3]
|
"numbers": [1, 2, 3]
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
// an invalid JSON text
|
// an invalid JSON text
|
||||||
const auto* invalid_text = R"(
|
auto invalid_text = R"(
|
||||||
{
|
{
|
||||||
"strings": ["extra", "comma", ]
|
"strings": ["extra", "comma", ]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::cout << std::boolalpha << std::is_same<std::vector<json>, json::array_t>::value << '\n';
|
std::cout << std::boolalpha << std::is_same<std::vector<json>, json::array_t>::value << std::endl;
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
using namespace nlohmann::literals;
|
using namespace nlohmann::literals;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
using namespace nlohmann::literals;
|
using namespace nlohmann::literals;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using namespace std::string_view_literals;
|
using namespace std::string_view_literals;
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using namespace std::string_view_literals;
|
using namespace std::string_view_literals;
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
using nlohmann::ordered_json;
|
using ordered_json = nlohmann::ordered_json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <valarray>
|
#include <valarray>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
using nlohmann::json_editable_document;
|
using json_editable_document = nlohmann::json_editable_document;
|
||||||
using nlohmann::json_editable_view;
|
using json_editable_view = nlohmann::json_editable_view;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
using nlohmann::json_editable_document;
|
using json_editable_document = nlohmann::json_editable_document;
|
||||||
using nlohmann::json_editable_view;
|
using json_editable_view = nlohmann::json_editable_view;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
using image_check = json_document::image_check;
|
using image_check = json_document::image_check;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
|
|
||||||
json_document parse_from_temporary_buffer()
|
json_document parse_from_temporary_buffer()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
using nlohmann::json_editable_document;
|
using json_editable_document = nlohmann::json_editable_document;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
using nlohmann::json_editable_document;
|
using json_editable_document = nlohmann::json_editable_document;
|
||||||
using nlohmann::json_editable_view;
|
using json_editable_view = nlohmann::json_editable_view;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
using nlohmann::json_view;
|
using json_view = nlohmann::json_view;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
using json_pointer = nlohmann::json::json_pointer;
|
using json_pointer = nlohmann::json::json_pointer;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <nlohmann/json_view.hpp>
|
#include <nlohmann/json_view.hpp>
|
||||||
|
|
||||||
using nlohmann::json_document;
|
using json_document = nlohmann::json_document;
|
||||||
using nlohmann::json_view;
|
using json_view = nlohmann::json_view;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|||||||
Loaded 100 of 495 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user