mirror of
https://github.com/nlohmann/json.git
synced 2026-10-26 15:58:55 +00:00
Compare commits
46
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
172eba6e46 | ||
|
|
02d05057a5 | ||
|
|
444dba381f | ||
|
|
44f1bec789 | ||
|
|
2a56afc714 | ||
|
|
d176d8d61e | ||
|
|
1cf5492bcd | ||
|
|
330fbead59 | ||
|
|
fe231dc692 | ||
|
|
ffd4242dc2 | ||
|
|
cc917d7123 | ||
|
|
3eae5680d6 | ||
|
|
fe5e401870 | ||
|
|
52b72b5684 | ||
|
|
01139dc192 | ||
|
|
9c50bdd140 | ||
|
|
dd7686a269 | ||
|
|
e9c4fe3cdf | ||
|
|
1e9222f955 | ||
|
|
ffcd392be0 | ||
|
|
e28506dd86 | ||
|
|
03a0595c1e | ||
|
|
4e72af9d54 | ||
|
|
0f5d07310c | ||
|
|
0b924f5375 | ||
|
|
6fa14d8f95 | ||
|
|
dec0e9b749 | ||
|
|
86d5c56c54 | ||
|
|
aa0b371f7c | ||
|
|
ace1030107 | ||
|
|
2dc1e54856 | ||
|
|
9855db81f3 | ||
|
|
533cbfee51 | ||
|
|
9bf531436f | ||
|
|
3e031b06a5 | ||
|
|
7c26e99ac5 | ||
|
|
6aefd8c662 | ||
|
|
52fecc1fab | ||
|
|
fa37b952df | ||
|
|
e9970066c5 | ||
|
|
3f8677d028 | ||
|
|
ef3d350639 | ||
|
|
5e13f834c1 | ||
|
|
e13e976801 | ||
|
|
898e6ee81d | ||
|
|
ef1cdb59ac |
No files matched your search
+36
-7
@@ -1,3 +1,33 @@
|
|||||||
|
# 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.
|
||||||
@@ -10,14 +40,14 @@ Checks: '*,
|
|||||||
-android-cloexec-fopen,
|
-android-cloexec-fopen,
|
||||||
-boost-use-ranges,
|
-boost-use-ranges,
|
||||||
-bugprone-easily-swappable-parameters,
|
-bugprone-easily-swappable-parameters,
|
||||||
-cert-err58-cpp,
|
-bugprone-signed-bitwise,
|
||||||
-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,
|
||||||
@@ -26,19 +56,15 @@ 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,
|
||||||
@@ -48,6 +74,7 @@ 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,
|
||||||
@@ -55,20 +82,22 @@ 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'
|
||||||
|
|
||||||
|
|||||||
+3
-10
@@ -108,16 +108,9 @@ The tests are located in [`tests/src/unit-*.cpp`](https://github.com/nlohmann/js
|
|||||||
are structured along the features of the library or the nature of the tests. Usually, it should be clear from the
|
are structured along the features of the library or the nature of the tests. Usually, it should be clear from the
|
||||||
context which existing file needs to be extended, and only very few cases require creating new test files.
|
context which existing file needs to be extended, and only very few cases require creating new test files.
|
||||||
|
|
||||||
When fixing a bug, edit `unit-regression3.cpp` and add a section referencing the fixed issue. Tests that need C++17 or
|
When fixing a bug, edit `unit-regression3.cpp` and add a section referencing the fixed issue.
|
||||||
C++20 go into `unit-regression3-cpp17.cpp` or `unit-regression3-cpp20.cpp` instead, so the large file is not rebuilt
|
`unit-regression2.cpp` holds the older tests; the two files exist because a single one grew large enough for the
|
||||||
for every C++ standard. `unit-regression2.cpp` holds the older tests; the two files exist because a single one grew
|
MinGW linker to fail relocating it, so please keep adding to the smaller file rather than growing the larger one.
|
||||||
large enough for the MinGW linker to fail relocating it, so please keep adding to the smaller file rather than growing
|
|
||||||
the larger one.
|
|
||||||
|
|
||||||
To keep compile times down, several test files are compiled together as one translation unit. This sets a few rules
|
|
||||||
for test files, such as giving file-scope helpers file-specific names. See the README in the
|
|
||||||
[`tests`](https://github.com/nlohmann/json/tree/develop/tests) folder for how the tests are built and what to keep in
|
|
||||||
mind when adding them.
|
|
||||||
|
|
||||||
#### Exceptions
|
#### Exceptions
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ environment:
|
|||||||
matrix:
|
matrix:
|
||||||
# The Visual Studio 2017 jobs compile everything with /std:c++17, so they
|
# The Visual Studio 2017 jobs compile everything with /std:c++17, so they
|
||||||
# only build the C++17 variant of each test, split into two jobs each to
|
# only build the C++17 variant of each test, split into two jobs each to
|
||||||
# stay below AppVeyor's 60-minute limit per job.
|
# stay below AppVeyor's 60-minute limit per job. The Visual Studio 2019
|
||||||
|
# job builds the tests for all standards and is split for the same reason.
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
configuration: Debug
|
configuration: Debug
|
||||||
platform: x86
|
platform: x86
|
||||||
@@ -50,7 +51,13 @@ environment:
|
|||||||
configuration: Release
|
configuration: Release
|
||||||
platform: x86
|
platform: x86
|
||||||
CXX_FLAGS: "/W4 /WX"
|
CXX_FLAGS: "/W4 /WX"
|
||||||
CMAKE_OPTIONS: "-DJSON_ImplicitConversions=OFF"
|
CMAKE_OPTIONS: "-DJSON_ImplicitConversions=OFF -DJSON_TestShard=0/2"
|
||||||
|
GENERATOR: Visual Studio 16 2019
|
||||||
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||||
|
configuration: Release
|
||||||
|
platform: x86
|
||||||
|
CXX_FLAGS: "/W4 /WX"
|
||||||
|
CMAKE_OPTIONS: "-DJSON_ImplicitConversions=OFF -DJSON_TestShard=1/2"
|
||||||
GENERATOR: Visual Studio 16 2019
|
GENERATOR: Visual Studio 16 2019
|
||||||
|
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ labels:
|
|||||||
- "tests/src/unit-json_view.*"
|
- "tests/src/unit-json_view.*"
|
||||||
- "tests/src/json_view_test_helpers\\.hpp"
|
- "tests/src/json_view_test_helpers\\.hpp"
|
||||||
- "tests/src/fuzzer-(parse_json_view|json_view_image)\\.cpp"
|
- "tests/src/fuzzer-(parse_json_view|json_view_image)\\.cpp"
|
||||||
|
- "tests/benchmarks/json_view/.*"
|
||||||
- "tools/amalgamate/config_json_view\\.json"
|
- "tools/amalgamate/config_json_view\\.json"
|
||||||
- "docs/mkdocs/docs/features/json_view\\.md"
|
- "docs/mkdocs/docs/features/json_view\\.md"
|
||||||
- "docs/mkdocs/docs/api/basic_json_(document|view)/.*"
|
- "docs/mkdocs/docs/api/basic_json_(document|view)/.*"
|
||||||
|
|||||||
@@ -154,6 +154,28 @@ jobs:
|
|||||||
# PR content in a job without credentials.
|
# PR content in a job without credentials.
|
||||||
python3 tools/generate_natvis/generate_natvis.py $MAIN_DIR
|
python3 tools/generate_natvis/generate_natvis.py $MAIN_DIR
|
||||||
|
|
||||||
|
- name: Check the nlohmann_json.natvis generator options
|
||||||
|
run: |
|
||||||
|
cd $MAIN_DIR
|
||||||
|
# The options for configurations outside the checked-in file write
|
||||||
|
# to a temporary file, so they do not affect the diff below.
|
||||||
|
GENERATOR=tools/generate_natvis/generate_natvis.py
|
||||||
|
python3 $GENERATOR --list-tags
|
||||||
|
TAG_COUNT=$(python3 $GENERATOR --list-tags | wc -l)
|
||||||
|
|
||||||
|
python3 $GENERATOR --abi-tags diag,_dp,_vns --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_vns_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 ))
|
||||||
|
|
||||||
|
python3 $GENERATOR --all --output $RUNNER_TEMP/all.natvis
|
||||||
|
test $(grep -c '<!-- Namespace ' $RUNNER_TEMP/all.natvis) -eq $(( (1 << TAG_COUNT) * 2 + 1 ))
|
||||||
|
|
||||||
|
if python3 $GENERATOR --abi-tags _unknown --output $RUNNER_TEMP/unknown.natvis; then
|
||||||
|
echo "generate_natvis.py accepted an unknown ABI tag"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Build patch and check for differences
|
- name: Build patch and check for differences
|
||||||
id: diff
|
id: diff
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -38,14 +38,14 @@ jobs:
|
|||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3
|
uses: github/codeql-action/init@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
|
||||||
with:
|
with:
|
||||||
languages: c-cpp
|
languages: c-cpp
|
||||||
|
|
||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
# If this step fails, then you should remove it and run the build manually (see below)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3
|
uses: github/codeql-action/autobuild@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3
|
uses: github/codeql-action/analyze@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
|
||||||
@@ -37,6 +37,14 @@ jobs:
|
|||||||
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
|
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
|
||||||
return artifact.name == "pr"
|
return artifact.name == "pr"
|
||||||
})[0];
|
})[0];
|
||||||
|
// a run that failed before its jobs started (e.g. a stale queued
|
||||||
|
// run cancelled long after its push) has no artifact to report on
|
||||||
|
if (!matchArtifact) {
|
||||||
|
core.notice('Run ${{ github.event.workflow_run.id }} has no "pr" artifact; nothing to comment on.');
|
||||||
|
core.setOutput('found', 'false');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
core.setOutput('found', 'true');
|
||||||
var download = await github.rest.actions.downloadArtifact({
|
var download = await github.rest.actions.downloadArtifact({
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
@@ -51,9 +59,11 @@ jobs:
|
|||||||
# Extract the untrusted PR artifact into a dedicated empty directory and
|
# Extract the untrusted PR artifact into a dedicated empty directory and
|
||||||
# read only the two expected files by fixed path afterwards. This avoids a
|
# read only the two expected files by fixed path afterwards. This avoids a
|
||||||
# malicious archive overwriting workspace files or escaping via ../ paths.
|
# malicious archive overwriting workspace files or escaping via ../ paths.
|
||||||
- run: unzip -o pr.zip -d ./pr_artifact
|
- if: steps.download.outputs.found == 'true'
|
||||||
|
run: unzip -o pr.zip -d ./pr_artifact
|
||||||
|
|
||||||
- name: 'Comment on PR'
|
- name: 'Comment on PR'
|
||||||
|
if: steps.download.outputs.found == 'true'
|
||||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
with:
|
with:
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
@@ -43,10 +43,11 @@ 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:
|
||||||
arguments: '--sarif ./'
|
# single_include/ is omitted: it is generated from include/ and would report every finding twice
|
||||||
|
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
|
||||||
uses: github/codeql-action/upload-sarif@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3
|
uses: github/codeql-action/upload-sarif@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
|
||||||
with:
|
with:
|
||||||
sarif_file: ${{github.workspace}}/flawfinder_results.sarif
|
sarif_file: ${{github.workspace}}/flawfinder_results.sarif
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
name: "json_view benchmarks"
|
||||||
|
|
||||||
|
# On demand only: runs the comparison of json_view with yyjson, simdjson, and
|
||||||
|
# Boost.JSON (tests/benchmarks/json_view/compare.py) on GitHub-hosted runners,
|
||||||
|
# for numbers from x86-64 and AArch64 Linux. It runs when started by hand, or
|
||||||
|
# when a pull request gets the label "benchmark" (on both architectures, with
|
||||||
|
# GCC and the default settings). Shared runners are noisy: the results show
|
||||||
|
# where json_view stands, but published numbers need a quiet machine (see
|
||||||
|
# tests/benchmarks/json_view/README.md).
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [labeled]
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
runner:
|
||||||
|
description: "Runner image"
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- ubuntu-24.04
|
||||||
|
- ubuntu-24.04-arm
|
||||||
|
default: ubuntu-24.04
|
||||||
|
compiler:
|
||||||
|
description: "Compiler"
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- g++
|
||||||
|
- clang++
|
||||||
|
default: g++
|
||||||
|
native:
|
||||||
|
description: "Compile for the runner's CPU (-march=native)"
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
rounds:
|
||||||
|
description: "Rounds of bench_view"
|
||||||
|
type: number
|
||||||
|
default: 30
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
# (the label is part of the group: adding an unrelated label must not cancel a running benchmark)
|
||||||
|
group: json-view-benchmarks-${{ github.workflow }}-${{ github.ref }}-${{ github.event.label.name }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
compare:
|
||||||
|
if: github.event_name == 'workflow_dispatch' || github.event.label.name == 'benchmark'
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
runner: ${{ fromJSON(github.event_name == 'workflow_dispatch' && format('["{0}"]', inputs.runner) || '["ubuntu-24.04", "ubuntu-24.04-arm"]') }}
|
||||||
|
runs-on: ${{ matrix.runner }}
|
||||||
|
timeout-minutes: 60
|
||||||
|
steps:
|
||||||
|
- name: Harden Runner
|
||||||
|
uses: step-security/harden-runner@ccd8616d44fd3846e67624a50d5aad6d37bf2d25 # v2.22.1
|
||||||
|
with:
|
||||||
|
egress-policy: audit
|
||||||
|
|
||||||
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
|
- name: Download test data
|
||||||
|
run: |
|
||||||
|
cmake -S . -B build -DJSON_BuildTests=On
|
||||||
|
cmake --build build --target download_test_data
|
||||||
|
|
||||||
|
- name: Run the comparison
|
||||||
|
env:
|
||||||
|
CXX: ${{ inputs.compiler || 'g++' }}
|
||||||
|
CC: ${{ inputs.compiler == 'clang++' && 'clang' || 'gcc' }}
|
||||||
|
ROUNDS: ${{ inputs.rounds || 30 }}
|
||||||
|
NATIVE: ${{ inputs.native && '--native' || '' }}
|
||||||
|
run: python3 tests/benchmarks/json_view/compare.py --data build/test_files --download --rounds "$ROUNDS" $NATIVE
|
||||||
|
|
||||||
|
- name: Summary
|
||||||
|
run: cat tests/benchmarks/json_view/results/*.md >> "$GITHUB_STEP_SUMMARY"
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||||
|
with:
|
||||||
|
name: json_view-benchmarks-${{ matrix.runner }}-${{ inputs.compiler || 'g++' }}
|
||||||
|
path: tests/benchmarks/json_view/results/
|
||||||
@@ -80,6 +80,6 @@ jobs:
|
|||||||
|
|
||||||
# Upload the results to GitHub's code scanning dashboard.
|
# Upload the results to GitHub's code scanning dashboard.
|
||||||
- name: "Upload to code-scanning"
|
- name: "Upload to code-scanning"
|
||||||
uses: github/codeql-action/upload-sarif@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3
|
uses: github/codeql-action/upload-sarif@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
|
||||||
with:
|
with:
|
||||||
sarif_file: results.sarif
|
sarif_file: results.sarif
|
||||||
@@ -65,7 +65,7 @@ jobs:
|
|||||||
|
|
||||||
# Upload SARIF file generated in previous step
|
# Upload SARIF file generated in previous step
|
||||||
- name: Upload SARIF file
|
- name: Upload SARIF file
|
||||||
uses: github/codeql-action/upload-sarif@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3
|
uses: github/codeql-action/upload-sarif@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
|
||||||
with:
|
with:
|
||||||
sarif_file: semgrep.sarif
|
sarif_file: semgrep.sarif
|
||||||
if: always()
|
if: always()
|
||||||
@@ -37,6 +37,7 @@ cc_library(
|
|||||||
"include/nlohmann/detail/input/parser.hpp",
|
"include/nlohmann/detail/input/parser.hpp",
|
||||||
"include/nlohmann/detail/input/position_t.hpp",
|
"include/nlohmann/detail/input/position_t.hpp",
|
||||||
"include/nlohmann/detail/input/pow5_table.hpp",
|
"include/nlohmann/detail/input/pow5_table.hpp",
|
||||||
|
"include/nlohmann/detail/input/simd_scan.hpp",
|
||||||
"include/nlohmann/detail/input/string_scan.hpp",
|
"include/nlohmann/detail/input/string_scan.hpp",
|
||||||
"include/nlohmann/detail/iterators/internal_iterator.hpp",
|
"include/nlohmann/detail/iterators/internal_iterator.hpp",
|
||||||
"include/nlohmann/detail/iterators/iter_impl.hpp",
|
"include/nlohmann/detail/iterators/iter_impl.hpp",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ This file describes the source for supporting files; that is, files that are not
|
|||||||
- [GitHub](#github)
|
- [GitHub](#github)
|
||||||
- [REUSE](#reuse)
|
- [REUSE](#reuse)
|
||||||
- [Package Managers](#package-managers)
|
- [Package Managers](#package-managers)
|
||||||
|
- [Debugging](#debugging)
|
||||||
|
|
||||||
## Continuous Integration
|
## Continuous Integration
|
||||||
|
|
||||||
@@ -289,3 +290,29 @@ The module definition for [Bazel](https://bazel.build)'s [Bzlmod](https://bazel.
|
|||||||
Further documentation:
|
Further documentation:
|
||||||
|
|
||||||
- [Bazel modules](https://bazel.build/external/module)
|
- [Bazel modules](https://bazel.build/external/module)
|
||||||
|
|
||||||
|
## Debugging
|
||||||
|
|
||||||
|
### `nlohmann_json.natvis`
|
||||||
|
|
||||||
|
The [Natvis](https://learn.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects) file that
|
||||||
|
gives `json` values a friendly view in the Visual Studio debugger. The file is generated by
|
||||||
|
`tools/generate_natvis/generate_natvis.py` from the template `tools/generate_natvis/nlohmann_json.natvis.j2` and the ABI
|
||||||
|
tags and version in `include/nlohmann/detail/abi_macros.hpp`; change the script or the template rather than editing
|
||||||
|
the file by hand. The file can be updated by calling
|
||||||
|
|
||||||
|
```shell
|
||||||
|
make natvis
|
||||||
|
```
|
||||||
|
|
||||||
|
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
|
||||||
|
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
|
||||||
|
[`tools/generate_natvis`](tools/generate_natvis/README.md). With MSVC, CMake adds the file to the `nlohmann_json`
|
||||||
|
target and installs it.
|
||||||
|
|
||||||
|
Further documentation:
|
||||||
|
|
||||||
|
- [Create custom views of C++ objects in the debugger using the Natvis framework](https://learn.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects)
|
||||||
@@ -46,7 +46,7 @@ all:
|
|||||||
@echo "clean - remove built files"
|
@echo "clean - remove built files"
|
||||||
@echo "(fuzzers) - see tests/fuzzing.md, or run 'make -C tests fuzzers' to build the AFL fuzzers"
|
@echo "(fuzzers) - see tests/fuzzing.md, or run 'make -C tests fuzzers' to build the AFL fuzzers"
|
||||||
@echo "macro_builder_check - check that macro_scope.hpp matches tools/macro_builder's output"
|
@echo "macro_builder_check - check that macro_scope.hpp matches tools/macro_builder's output"
|
||||||
@echo "natvis - regenerate nlohmann_json.natvis from the current ABI tags and version"
|
@echo "natvis - regenerate nlohmann_json.natvis from the current ABI tags and version (pass generator options via NATVIS_ARGS, see tools/generate_natvis/README.md)"
|
||||||
@echo "pretty - beautify code with Artistic Style"
|
@echo "pretty - beautify code with Artistic Style"
|
||||||
@echo "pvs_studio - run the PVS-Studio static analyzer and open the report"
|
@echo "pvs_studio - run the PVS-Studio static analyzer and open the report"
|
||||||
@echo "release - create the release files (include.zip, json.tar.xz, single headers, signatures, hashes)"
|
@echo "release - create the release files (include.zip, json.tar.xz, single headers, signatures, hashes)"
|
||||||
@@ -120,13 +120,15 @@ $(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"
|
||||||
|
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
|
||||||
# (the dependencies are installed into a virtual environment first)
|
# (the dependencies are installed into a virtual environment first)
|
||||||
natvis:
|
natvis:
|
||||||
@test -d $(NATVIS_VENV) || python3 -mvenv $(NATVIS_VENV)
|
@test -d $(NATVIS_VENV) || python3 -mvenv $(NATVIS_VENV)
|
||||||
@$(NATVIS_VENV)/bin/python3 -c 'import jinja2' 2>/dev/null || $(NATVIS_VENV)/bin/pip3 install --quiet -r tools/generate_natvis/requirements.txt
|
@$(NATVIS_VENV)/bin/python3 -c 'import jinja2' 2>/dev/null || $(NATVIS_VENV)/bin/pip3 install --quiet -r tools/generate_natvis/requirements.txt
|
||||||
$(NATVIS_VENV)/bin/python3 tools/generate_natvis/generate_natvis.py .
|
$(NATVIS_VENV)/bin/python3 tools/generate_natvis/generate_natvis.py $(NATVIS_ARGS) .
|
||||||
|
|
||||||
# regenerate the two tools/macro_builder blocks of $(MACRO_SCOPE_HPP) (see its README.md) and diff against the
|
# regenerate the two tools/macro_builder blocks of $(MACRO_SCOPE_HPP) (see its README.md) and diff against the
|
||||||
# checked-in header; phony, because it never writes $(MACRO_SCOPE_HPP) itself
|
# checked-in header; phony, because it never writes $(MACRO_SCOPE_HPP) itself
|
||||||
|
|||||||
@@ -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 json = nlohmann::json;
|
using 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 json = nlohmann::json;
|
using 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 json = nlohmann::json;
|
using 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 json = nlohmann::json;
|
using 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).
|
||||||
|
|||||||
+3
-3
@@ -890,11 +890,11 @@ add_custom_target(ci_icpx
|
|||||||
# The following tests are excluded as they trigger known nvc++ 25.5 defects (not
|
# The following tests are excluded as they trigger known nvc++ 25.5 defects (not
|
||||||
# library bugs); see https://github.com/nlohmann/json for tracking. Only the
|
# library bugs); see https://github.com/nlohmann/json for tracking. Only the
|
||||||
# affected language-standard variants are excluded so coverage is otherwise kept:
|
# affected language-standard variants are excluded so coverage is otherwise kept:
|
||||||
# - test-comparison-cpp20_cpp20, test-comparison_legacy-cpp20_cpp20
|
# - test-comparison_cpp20, test-comparison_legacy_cpp20
|
||||||
# miscompiles cross-type/<=> comparison (e.g. `-17 <= null`)
|
# miscompiles cross-type/<=> comparison (e.g. `-17 <= null`)
|
||||||
# - test-constructor1_cpp11
|
# - test-constructor1_cpp11
|
||||||
# std::initializer_list lifetime bug -> SIGSEGV
|
# std::initializer_list lifetime bug -> SIGSEGV
|
||||||
# - test-deserialization-cpp20_cpp20
|
# - test-deserialization_cpp20
|
||||||
# mangles the UTF-8 u8"" string literal in the char8_t (C++20) section
|
# mangles the UTF-8 u8"" string literal in the char8_t (C++20) section
|
||||||
add_custom_target(ci_nvhpc
|
add_custom_target(ci_nvhpc
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
@@ -906,7 +906,7 @@ add_custom_target(ci_nvhpc
|
|||||||
COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_nvhpc
|
COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_nvhpc
|
||||||
# the pipes are escaped so the surrounding shell passes them to ctest verbatim
|
# the pipes are escaped so the surrounding shell passes them to ctest verbatim
|
||||||
# instead of treating them as shell pipe operators
|
# instead of treating them as shell pipe operators
|
||||||
COMMAND cd ${PROJECT_BINARY_DIR}/build_nvhpc && ${CMAKE_CTEST_COMMAND} --parallel ${N} --exclude-regex "test-comparison-cpp20_cpp20\\|test-comparison_legacy-cpp20_cpp20\\|test-constructor1_cpp11\\|test-deserialization-cpp20_cpp20" --output-on-failure
|
COMMAND cd ${PROJECT_BINARY_DIR}/build_nvhpc && ${CMAKE_CTEST_COMMAND} --parallel ${N} --exclude-regex "test-comparison_cpp20\\|test-comparison_legacy_cpp20\\|test-constructor1_cpp11\\|test-deserialization_cpp20" --output-on-failure
|
||||||
COMMENT "Compile and test with NVIDIA HPC SDK (nvc++)"
|
COMMENT "Compile and test with NVIDIA HPC SDK (nvc++)"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+39
-366
@@ -109,55 +109,6 @@ function(_json_test_apply_test_properties test_target properties_target)
|
|||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# for internal use by _json_test_add_test() and _json_test_add_unity_batch():
|
|
||||||
# registers the CTest test <test_name>_cpp<cxx_standard> (plus its Valgrind
|
|
||||||
# variant), which runs the executable target <test_target> with the arguments
|
|
||||||
# in ARGN, and applies the test properties of the test- and standard-specific
|
|
||||||
# interface targets
|
|
||||||
function(_json_test_register_test test_name test_target cxx_standard)
|
|
||||||
set(ctest_name ${test_name}_cpp${cxx_standard})
|
|
||||||
|
|
||||||
if (JSON_FastTests)
|
|
||||||
add_test(NAME ${ctest_name}
|
|
||||||
COMMAND ${test_target} ${DOCTEST_TEST_FILTER} ${ARGN}
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
add_test(NAME ${ctest_name}
|
|
||||||
COMMAND ${test_target} ${DOCTEST_TEST_FILTER} ${ARGN} --no-skip
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
set_tests_properties(${ctest_name} PROPERTIES LABELS "all" FIXTURES_REQUIRED TEST_DATA)
|
|
||||||
|
|
||||||
# apply standard-specific test properties
|
|
||||||
if(TARGET _json_test_interface__cpp_${cxx_standard})
|
|
||||||
_json_test_apply_test_properties(${ctest_name} _json_test_interface__cpp_${cxx_standard})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# apply test-specific test properties
|
|
||||||
if(TARGET _json_test_interface_${test_name})
|
|
||||||
_json_test_apply_test_properties(${ctest_name} _json_test_interface_${test_name})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# apply test- and standard-specific test properties
|
|
||||||
if(TARGET _json_test_interface_${test_name}_cpp_${cxx_standard})
|
|
||||||
_json_test_apply_test_properties(${ctest_name}
|
|
||||||
_json_test_interface_${test_name}_cpp_${cxx_standard}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(JSON_Valgrind)
|
|
||||||
add_test(NAME ${ctest_name}_valgrind
|
|
||||||
COMMAND ${memcheck_command} $<TARGET_FILE:${test_target}> ${DOCTEST_TEST_FILTER} ${ARGN}
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
||||||
)
|
|
||||||
set_tests_properties(${ctest_name}_valgrind PROPERTIES
|
|
||||||
LABELS "valgrind" FIXTURES_REQUIRED TEST_DATA
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
# for internal use by json_test_add_test_for()
|
# for internal use by json_test_add_test_for()
|
||||||
function(_json_test_add_test test_name file main cxx_standard)
|
function(_json_test_add_test test_name file main cxx_standard)
|
||||||
set(test_target ${test_name}_cpp${cxx_standard})
|
set(test_target ${test_name}_cpp${cxx_standard})
|
||||||
@@ -192,7 +143,45 @@ function(_json_test_add_test test_name file main cxx_standard)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
_json_test_register_test(${test_name} ${test_target} ${cxx_standard})
|
if (JSON_FastTests)
|
||||||
|
add_test(NAME ${test_target}
|
||||||
|
COMMAND ${test_target} ${DOCTEST_TEST_FILTER}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
add_test(NAME ${test_target}
|
||||||
|
COMMAND ${test_target} ${DOCTEST_TEST_FILTER} --no-skip
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
set_tests_properties(${test_target} PROPERTIES LABELS "all" FIXTURES_REQUIRED TEST_DATA)
|
||||||
|
|
||||||
|
# apply standard-specific test properties
|
||||||
|
if(TARGET _json_test_interface__cpp_${cxx_standard})
|
||||||
|
_json_test_apply_test_properties(${test_target} _json_test_interface__cpp_${cxx_standard})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# apply test-specific test properties
|
||||||
|
if(TARGET _json_test_interface_${test_name})
|
||||||
|
_json_test_apply_test_properties(${test_target} _json_test_interface_${test_name})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# apply test- and standard-specific test properties
|
||||||
|
if(TARGET _json_test_interface_${test_name}_cpp_${cxx_standard})
|
||||||
|
_json_test_apply_test_properties(${test_target}
|
||||||
|
_json_test_interface_${test_name}_cpp_${cxx_standard}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(JSON_Valgrind)
|
||||||
|
add_test(NAME ${test_target}_valgrind
|
||||||
|
COMMAND ${memcheck_command} $<TARGET_FILE:${test_target}> ${DOCTEST_TEST_FILTER}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
set_tests_properties(${test_target}_valgrind PROPERTIES
|
||||||
|
LABELS "valgrind" FIXTURES_REQUIRED TEST_DATA
|
||||||
|
)
|
||||||
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
@@ -211,14 +200,6 @@ endfunction()
|
|||||||
# Use NAME <name> to override the filename-derived test name.
|
# Use NAME <name> to override the filename-derived test name.
|
||||||
# Use FORCE to create the test regardless of the file containing
|
# Use FORCE to create the test regardless of the file containing
|
||||||
# JSON_HAS_CPP_<version_number>.
|
# JSON_HAS_CPP_<version_number>.
|
||||||
#
|
|
||||||
# Tests that depend on the C++ standard (e.g., because they use the macros
|
|
||||||
# JSON_HAS_FILESYSTEM, JSON_HAS_RANGES, or JSON_HAS_THREE_WAY_COMPARISON)
|
|
||||||
# should not make the whole of a large unit-foo.cpp be rebuilt for every
|
|
||||||
# standard. Put them into a separate file unit-foo-cpp<NN>.cpp (see, e.g.,
|
|
||||||
# unit-items-cpp17.cpp) which wraps its content in #ifdef JSON_HAS_CPP_<NN>.
|
|
||||||
# Then, unit-foo.cpp itself contains no JSON_HAS_CPP_<NN> and is only built for
|
|
||||||
# C++11.
|
|
||||||
# Test targets are linked against <main>.
|
# Test targets are linked against <main>.
|
||||||
# CXX_STANDARDS defaults to "11".
|
# CXX_STANDARDS defaults to "11".
|
||||||
#############################################################################
|
#############################################################################
|
||||||
@@ -262,314 +243,6 @@ function(json_test_add_test_for file)
|
|||||||
endforeach()
|
endforeach()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# for internal use by json_test_add_unity_tests(): sets <result> to whether the
|
|
||||||
# (absolute) <file> is built for <cxx_standard>; same rule as in
|
|
||||||
# json_test_add_test_for(): C++11 always, others only if the file contains
|
|
||||||
# JSON_HAS_CPP_<cxx_standard> or <force> is set
|
|
||||||
function(_json_test_unity_applies file cxx_standard force result)
|
|
||||||
set(${result} TRUE PARENT_SCOPE)
|
|
||||||
if(NOT ("${cxx_standard}" STREQUAL 11 OR force))
|
|
||||||
file(READ ${file} file_content)
|
|
||||||
string(FIND "${file_content}" JSON_HAS_CPP_${cxx_standard} has_cpp_found)
|
|
||||||
if(${has_cpp_found} EQUAL -1)
|
|
||||||
set(${result} FALSE PARENT_SCOPE)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
# for internal use by json_test_add_unity_tests(): creates the executable
|
|
||||||
# test-unity-<batch_name>_cpp<cxx_standard> from the (absolute) source files
|
|
||||||
# in ARGN, which are #include-d by a generated source file, and registers one
|
|
||||||
# CTest test per source file that runs only the test cases of that file; if
|
|
||||||
# <private> is true, the generated file defines JSON_TESTS_PRIVATE first
|
|
||||||
function(_json_test_add_unity_batch batch_name cxx_standard main private)
|
|
||||||
set(batch_target test-unity-${batch_name}_cpp${cxx_standard})
|
|
||||||
set(batch_source ${PROJECT_BINARY_DIR}/tests/unity/${batch_target}.cpp)
|
|
||||||
|
|
||||||
set(batch_content "// generated by cmake/test.cmake; do not edit\n")
|
|
||||||
if(private)
|
|
||||||
string(APPEND batch_content "// at least one file of this batch needs access to private members of the library\n")
|
|
||||||
string(APPEND batch_content "#define JSON_TESTS_PRIVATE\n")
|
|
||||||
# the files define the macro again; mark this definition as used, as
|
|
||||||
# -Wunused-macros reports an unused definition when it is redefined
|
|
||||||
string(APPEND batch_content "#ifdef JSON_TESTS_PRIVATE\n#endif\n")
|
|
||||||
endif()
|
|
||||||
foreach(file ${ARGN})
|
|
||||||
string(APPEND batch_content "#include \"${file}\" // NOLINT(bugprone-suspicious-include)\n")
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# only touch the generated file if it changed to keep incremental builds incremental
|
|
||||||
set(old_content "")
|
|
||||||
if(EXISTS ${batch_source})
|
|
||||||
file(READ ${batch_source} old_content)
|
|
||||||
endif()
|
|
||||||
if(NOT "${old_content}" STREQUAL "${batch_content}")
|
|
||||||
file(WRITE ${batch_source} "${batch_content}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_executable(${batch_target} ${batch_source})
|
|
||||||
target_link_libraries(${batch_target} PRIVATE ${main})
|
|
||||||
set_target_properties(${batch_target} PROPERTIES
|
|
||||||
CXX_STANDARD ${cxx_standard}
|
|
||||||
CXX_STANDARD_REQUIRED ON
|
|
||||||
)
|
|
||||||
if(TARGET _json_test_interface__cpp_${cxx_standard})
|
|
||||||
target_link_libraries(${batch_target} PRIVATE _json_test_interface__cpp_${cxx_standard})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# rebuild the batch when one of its files changes, and show the files in IDEs;
|
|
||||||
# files that are also built standalone (VARIANT_FILES) are left out, as
|
|
||||||
# HEADER_FILE_ONLY is a per-file property and would also affect those targets
|
|
||||||
set_source_files_properties(${batch_source} PROPERTIES OBJECT_DEPENDS "${ARGN}")
|
|
||||||
foreach(file ${ARGN})
|
|
||||||
if(NOT file IN_LIST _json_test_unity_variant_files)
|
|
||||||
set_source_files_properties(${file} PROPERTIES HEADER_FILE_ONLY ON)
|
|
||||||
target_sources(${batch_target} PRIVATE ${file})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
foreach(file ${ARGN})
|
|
||||||
get_filename_component(file_basename ${file} NAME_WE)
|
|
||||||
string(REGEX REPLACE "unit-(.+)" "test-\\1" test_name ${file_basename})
|
|
||||||
|
|
||||||
# run only the test cases defined in this file (and in the shared
|
|
||||||
# make_test_data_available.hpp if the file uses it)
|
|
||||||
file(READ ${file} file_content)
|
|
||||||
set(source_filter "--source-file=*${file_basename}.cpp")
|
|
||||||
string(FIND "${file_content}" make_test_data_available.hpp uses_test_data)
|
|
||||||
if(NOT ${uses_test_data} EQUAL -1)
|
|
||||||
string(APPEND source_filter ",*make_test_data_available.hpp")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
_json_test_register_test(${test_name} ${batch_target} ${cxx_standard} "${source_filter}")
|
|
||||||
endforeach()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
#############################################################################
|
|
||||||
# json_test_add_unity_tests(
|
|
||||||
# FILES <files>...
|
|
||||||
# MAIN <main>
|
|
||||||
# [CXX_STANDARDS <version_number>...] [FORCE]
|
|
||||||
# [BATCH_SIZE <size>]
|
|
||||||
# [GROUPS <group>...]
|
|
||||||
# [VARIANT_FILES <files>...])
|
|
||||||
#
|
|
||||||
# Like calling json_test_add_test_for(<file> MAIN <main> ...) for each of the
|
|
||||||
# <files>, but compiles several files together to speed up the build: for each
|
|
||||||
# C++ standard, the files are split into batches of <size> files (default: 8)
|
|
||||||
# and each batch is built as a single executable
|
|
||||||
#
|
|
||||||
# test-unity-<pool><index>_cpp<version_number>
|
|
||||||
#
|
|
||||||
# whose generated source file #include-s the files of the batch (so they share
|
|
||||||
# the template instantiations of the library). The tests are still named
|
|
||||||
# test-foo_cpp<version_number>, one per file, but run the batch executable with
|
|
||||||
# a doctest filter that selects the test cases of that file only.
|
|
||||||
#
|
|
||||||
# Files are only batched with files that agree on the macros defined before
|
|
||||||
# the library is included: files that define at most JSON_TESTS_PRIVATE (or
|
|
||||||
# macros derived from global compile definitions) form the pools "plain" and
|
|
||||||
# "private". All other files are added with json_test_add_test_for() as usual,
|
|
||||||
# as are files with test-specific build settings (see
|
|
||||||
# json_test_set_test_options()) and the files listed in the explicit
|
|
||||||
# exclusion list below.
|
|
||||||
# Each <group> names a list variable json_test_unity_group_<group> of test file
|
|
||||||
# stems (file names without "unit-" and ".cpp"). The batchable files of a group
|
|
||||||
# are compiled together (regardless of BATCH_SIZE) as one executable
|
|
||||||
#
|
|
||||||
# test-unity-<group>_cpp<version_number>
|
|
||||||
#
|
|
||||||
# so that related tests, which instantiate the same templates, share one
|
|
||||||
# translation unit. A group may mix the pools "plain" and "private"; if any of
|
|
||||||
# its files needs JSON_TESTS_PRIVATE, the whole group is built with it. Files
|
|
||||||
# that cannot be batched stay standalone even if they are listed in a group.
|
|
||||||
# Files in no group are batched by BATCH_SIZE as described above.
|
|
||||||
# <files> in VARIANT_FILES are also built standalone with other settings, so
|
|
||||||
# they are not marked as header-only sources of the batch.
|
|
||||||
#############################################################################
|
|
||||||
|
|
||||||
function(json_test_add_unity_tests)
|
|
||||||
cmake_parse_arguments(args "FORCE" "MAIN;BATCH_SIZE" "FILES;CXX_STANDARDS;VARIANT_FILES;GROUPS" ${ARGN})
|
|
||||||
|
|
||||||
if("${args_MAIN}" STREQUAL "")
|
|
||||||
message(FATAL_ERROR "Required argument MAIN <main> missing.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("${args_BATCH_SIZE}" STREQUAL "")
|
|
||||||
set(args_BATCH_SIZE 8)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("${args_CXX_STANDARDS}" STREQUAL "")
|
|
||||||
set(args_CXX_STANDARDS 11)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(args_FORCE)
|
|
||||||
set(force FORCE)
|
|
||||||
else()
|
|
||||||
set(force "")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(_json_test_unity_variant_files "")
|
|
||||||
foreach(file ${args_VARIANT_FILES})
|
|
||||||
get_filename_component(file ${file} ABSOLUTE)
|
|
||||||
list(APPEND _json_test_unity_variant_files ${file})
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# files that must not be merged into a batch: unit-32bit.cpp is only built
|
|
||||||
# for 32bit targets, and unit-no-macro-leak.cpp checks that including the
|
|
||||||
# library defines no unprefixed macro, which any other file would disturb
|
|
||||||
set(standalone_files unit-32bit.cpp unit-no-macro-leak.cpp)
|
|
||||||
|
|
||||||
set(harmless_macros "^(DOCTEST_.*|SKIP_TESTS_FOR_.*|JSON_TEST_DEPRECATED_FUNCTIONS_DELETED|JSON_TEST_STRICT_NUL_HANDLING_ENABLED|JSON_TEST_STRINGIZE)$")
|
|
||||||
|
|
||||||
# classify the files
|
|
||||||
set(plain_files "")
|
|
||||||
set(private_files "")
|
|
||||||
set(standalone_abs_files "")
|
|
||||||
foreach(file ${args_FILES})
|
|
||||||
get_filename_component(file_name ${file} NAME)
|
|
||||||
get_filename_component(file_basename ${file} NAME_WE)
|
|
||||||
string(REGEX REPLACE "unit-(.+)" "test-\\1" test_name ${file_basename})
|
|
||||||
|
|
||||||
set(batchable TRUE)
|
|
||||||
if(file_name IN_LIST standalone_files)
|
|
||||||
set(batchable FALSE)
|
|
||||||
endif()
|
|
||||||
if(TARGET _json_test_interface_${test_name})
|
|
||||||
set(batchable FALSE)
|
|
||||||
endif()
|
|
||||||
foreach(cxx_standard ${args_CXX_STANDARDS})
|
|
||||||
if(TARGET _json_test_interface_${test_name}_cpp_${cxx_standard})
|
|
||||||
set(batchable FALSE)
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# files that suppress GCC's -Wnoexcept around their include of the
|
|
||||||
# library: the suppression has no effect once another file of the
|
|
||||||
# batch included the library first
|
|
||||||
if(batchable)
|
|
||||||
file(READ ${file} file_content)
|
|
||||||
string(FIND "${file_content}" "SUPPRESS_WARNING(\"-Wnoexcept\")" suppresses_noexcept)
|
|
||||||
if(NOT ${suppresses_noexcept} EQUAL -1)
|
|
||||||
set(batchable FALSE)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(pool plain)
|
|
||||||
if(batchable)
|
|
||||||
# collect the macros (un)defined before the library is included
|
|
||||||
file(READ ${file} file_content)
|
|
||||||
string(FIND "${file_content}" "#include <nlohmann/" include_position)
|
|
||||||
if(NOT ${include_position} EQUAL -1)
|
|
||||||
string(SUBSTRING "${file_content}" 0 ${include_position} file_content)
|
|
||||||
endif()
|
|
||||||
string(REGEX MATCHALL "(^|\n)[ \t]*#[ \t]*(define|undef)[ \t]+[A-Za-z_0-9]+" directives "${file_content}")
|
|
||||||
foreach(directive ${directives})
|
|
||||||
string(REGEX REPLACE "^.*[ \t]([A-Za-z_0-9]+)$" "\\1" macro "${directive}")
|
|
||||||
if(macro MATCHES "${harmless_macros}")
|
|
||||||
continue()
|
|
||||||
elseif("${macro}" STREQUAL JSON_TESTS_PRIVATE)
|
|
||||||
set(pool private)
|
|
||||||
else()
|
|
||||||
set(batchable FALSE)
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
get_filename_component(file_abs ${file} ABSOLUTE)
|
|
||||||
if(NOT batchable)
|
|
||||||
list(APPEND standalone_abs_files ${file_abs})
|
|
||||||
json_test_add_test_for(${file} MAIN ${args_MAIN} CXX_STANDARDS ${args_CXX_STANDARDS} ${force})
|
|
||||||
continue()
|
|
||||||
endif()
|
|
||||||
get_filename_component(file ${file} ABSOLUTE)
|
|
||||||
list(APPEND ${pool}_files ${file})
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# resolve the explicit groups: group_<name>_files are the (absolute) files
|
|
||||||
# of the group, group_<name>_private tells whether one of them is private
|
|
||||||
set(grouped_files "")
|
|
||||||
foreach(group ${args_GROUPS})
|
|
||||||
if(NOT DEFINED json_test_unity_group_${group})
|
|
||||||
message(FATAL_ERROR "Unity test group '${group}' is not defined (json_test_unity_group_${group}).")
|
|
||||||
endif()
|
|
||||||
set(group_${group}_files "")
|
|
||||||
set(group_${group}_private FALSE)
|
|
||||||
foreach(stem ${json_test_unity_group_${group}})
|
|
||||||
# check against the source directory, because FILES may be filtered (JSON_TestShard)
|
|
||||||
get_filename_component(file ${CMAKE_CURRENT_SOURCE_DIR}/src/unit-${stem}.cpp ABSOLUTE)
|
|
||||||
if(NOT EXISTS ${file})
|
|
||||||
message(FATAL_ERROR "Unity test group '${group}' lists '${stem}', but ${file} does not exist.")
|
|
||||||
endif()
|
|
||||||
if(file IN_LIST grouped_files)
|
|
||||||
message(FATAL_ERROR "Unity test file unit-${stem}.cpp is listed in more than one group (second: '${group}').")
|
|
||||||
endif()
|
|
||||||
list(APPEND grouped_files ${file})
|
|
||||||
|
|
||||||
if(file IN_LIST standalone_abs_files)
|
|
||||||
message(STATUS "Unity test group '${group}': unit-${stem}.cpp cannot be batched and stays standalone")
|
|
||||||
elseif(file IN_LIST plain_files)
|
|
||||||
list(APPEND group_${group}_files ${file})
|
|
||||||
list(REMOVE_ITEM plain_files ${file})
|
|
||||||
elseif(file IN_LIST private_files)
|
|
||||||
list(APPEND group_${group}_files ${file})
|
|
||||||
list(REMOVE_ITEM private_files ${file})
|
|
||||||
set(group_${group}_private TRUE)
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
foreach(cxx_standard ${args_CXX_STANDARDS})
|
|
||||||
if(NOT compiler_supports_cpp_${cxx_standard})
|
|
||||||
continue()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# explicit groups: one batch per group
|
|
||||||
foreach(group ${args_GROUPS})
|
|
||||||
set(batch_files "")
|
|
||||||
foreach(file ${group_${group}_files})
|
|
||||||
_json_test_unity_applies(${file} ${cxx_standard} "${force}" applies)
|
|
||||||
if(applies)
|
|
||||||
list(APPEND batch_files ${file})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
if(batch_files)
|
|
||||||
_json_test_add_unity_batch(${group} ${cxx_standard} ${args_MAIN} ${group_${group}_private} ${batch_files})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# remaining files: batches of BATCH_SIZE files per pool
|
|
||||||
foreach(pool plain private)
|
|
||||||
set(is_private FALSE)
|
|
||||||
if(pool STREQUAL private)
|
|
||||||
set(is_private TRUE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(batch_files "")
|
|
||||||
set(batch_count 0)
|
|
||||||
set(batch_index 0)
|
|
||||||
foreach(file ${${pool}_files})
|
|
||||||
_json_test_unity_applies(${file} ${cxx_standard} "${force}" applies)
|
|
||||||
if(NOT applies)
|
|
||||||
continue()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
list(APPEND batch_files ${file})
|
|
||||||
math(EXPR batch_count "${batch_count} + 1")
|
|
||||||
if(batch_count EQUAL args_BATCH_SIZE)
|
|
||||||
_json_test_add_unity_batch(${pool}${batch_index} ${cxx_standard} ${args_MAIN} ${is_private} ${batch_files})
|
|
||||||
set(batch_files "")
|
|
||||||
set(batch_count 0)
|
|
||||||
math(EXPR batch_index "${batch_index} + 1")
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
if(batch_files)
|
|
||||||
_json_test_add_unity_batch(${pool}${batch_index} ${cxx_standard} ${args_MAIN} ${is_private} ${batch_files})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
endforeach()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
# json_test_should_build_32bit_test(
|
# json_test_should_build_32bit_test(
|
||||||
# <build_32bit_var> <build_32bit_only_var> <input>)
|
# <build_32bit_var> <build_32bit_only_var> <input>)
|
||||||
|
|||||||
@@ -341,13 +341,14 @@ def download(url, docs) -> str:
|
|||||||
raise ValueError(f'not an http(s) URL: {url}')
|
raise ValueError(f'not an http(s) URL: {url}')
|
||||||
req = urllib.request.Request(u.geturl(), headers={'User-Agent': USER_AGENT})
|
req = urllib.request.Request(u.geturl(), headers={'User-Agent': USER_AGENT})
|
||||||
# (the scheme is checked above)
|
# (the scheme is checked above)
|
||||||
|
# nosemgrep: python.lang.security.audit.dynamic-urllib-use-detected.dynamic-urllib-use-detected
|
||||||
with urllib.request.urlopen(req, timeout=20) as r: # nosec B310
|
with urllib.request.urlopen(req, timeout=20) as r: # nosec B310
|
||||||
data = r.read()
|
data = r.read()
|
||||||
ctype = r.headers.get_content_type()
|
ctype = r.headers.get_content_type()
|
||||||
path = urllib.parse.unquote(u.path).lstrip('/')
|
path = urllib.parse.unquote(u.path).lstrip('/')
|
||||||
ext = os.path.splitext(path)[1]
|
ext = os.path.splitext(path)[1]
|
||||||
if u.query or not ext or path.endswith('/'):
|
if u.query or not ext or path.endswith('/'):
|
||||||
digest = hashlib.sha1(url.encode(), usedforsecurity=False).hexdigest()[:12]
|
digest = hashlib.sha256(url.encode()).hexdigest()[:12]
|
||||||
path = os.path.join(os.path.dirname(path), digest + CONTENT_TYPE_EXT.get(ctype, ext or '.bin'))
|
path = os.path.join(os.path.dirname(path), digest + CONTENT_TYPE_EXT.get(ctype, ext or '.bin'))
|
||||||
rel = os.path.normpath(os.path.join('assets', 'external', u.hostname, path))
|
rel = os.path.normpath(os.path.join('assets', 'external', u.hostname, path))
|
||||||
out = os.path.join(docs, rel)
|
out = os.path.join(docs, rel)
|
||||||
|
|||||||
@@ -67,7 +67,9 @@ class (either explicitly or via the conversion operators).
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [to_json](to_json.md)
|
- [`to_json`](to_json.md) - convert a C++ value to JSON
|
||||||
|
- [Arbitrary Type Conversions](../../features/arbitrary_types.md) - write your own `from_json` and `to_json` functions
|
||||||
|
- [Converting values](../../features/conversions.md) - overview of `get`, `get_to` and implicit conversions
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,14 @@ struct adl_serializer {
|
|||||||
- [**from_json**](from_json.md) - convert a JSON value to any value type
|
- [**from_json**](from_json.md) - convert a JSON value to any value type
|
||||||
- [**to_json**](to_json.md) - convert any value type to a JSON value
|
- [**to_json**](to_json.md) - convert any value type to a JSON value
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
- [Arbitrary type conversions](../../features/arbitrary_types.md) - how to make your types convertible
|
||||||
|
- [`get`](../basic_json/get.md) - / [`get_to`](../basic_json/get_to.md) - convert a JSON value to a C++ type
|
||||||
|
- [`basic_json`](../basic_json/basic_json.md) - construct a JSON value from a C++ value
|
||||||
|
- [`NLOHMANN_DEFINE_TYPE_INTRUSIVE`](../macros/nlohmann_define_type_intrusive.md) - generate the conversion functions for a type
|
||||||
|
- [Specializing enum conversion](../../features/enum_conversion.md) - serializing enums as JSON strings
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
- Added in version 2.1.0.
|
- Added in version 2.1.0.
|
||||||
@@ -36,7 +36,9 @@ This function is usually called by the constructors of the [basic_json](../basic
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [from_json](from_json.md)
|
- [`from_json`](from_json.md) - convert JSON to a C++ value
|
||||||
|
- [Arbitrary Type Conversions](../../features/arbitrary_types.md) - write your own `from_json` and `to_json` functions
|
||||||
|
- [Converting values](../../features/conversions.md) - overview of `get`, `get_to` and implicit conversions
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ Checks whether the input is valid JSON.
|
|||||||
respectively as UTF-8, UTF-16, and UTF-32. If `SentinelType` differs from `IteratorType`, it must be comparable to
|
respectively as UTF-8, UTF-16, and UTF-32. If `SentinelType` differs from `IteratorType`, it must be comparable to
|
||||||
the iterator type with `operator!=`.
|
the iterator type with `operator!=`.
|
||||||
|
|
||||||
|
Ill-formed UTF-16 and UTF-32 sequences are rejected: a lone surrogate, a high surrogate that is not followed by its
|
||||||
|
low surrogate, and a code point above `U+10FFFF` all make this function return `false`.
|
||||||
|
|
||||||
Unlike the [`parse()`](parse.md) function, this function neither throws an exception in case of invalid JSON input
|
Unlike the [`parse()`](parse.md) function, this function neither throws an exception in case of invalid JSON input
|
||||||
(i.e., a parse error) nor creates diagnostic information.
|
(i.e., a parse error) nor creates diagnostic information.
|
||||||
|
|
||||||
@@ -35,9 +38,12 @@ Unlike the [`parse()`](parse.md) function, this function neither throws an excep
|
|||||||
- a `#!c FILE` pointer (throws if null)
|
- a `#!c FILE` pointer (throws if null)
|
||||||
- a C-style array of characters
|
- a C-style array of characters
|
||||||
- a pointer to a null-terminated string of single byte characters (throws if null)
|
- a pointer to a null-terminated string of single byte characters (throws if null)
|
||||||
- a `std::string`
|
- a `std::string` or a `std::string_view` (C++17)
|
||||||
- a container `obj` for which `begin(obj)` and `end(obj)` produce a valid pair of iterators
|
- a container `obj` for which `begin(obj)` and `end(obj)` produce a valid pair of iterators
|
||||||
(as found via ADL or member functions, with semantics compatible to `std::begin` and `std::end`)
|
(as found via ADL or member functions, with semantics compatible to `std::begin` and `std::end`)
|
||||||
|
- wide characters (`wchar_t`, `char16_t`, `char32_t`), which are converted to UTF-8: a wide string object
|
||||||
|
(`std::wstring`, `std::u16string`, `std::u32string`) or an array (e.g. a wide string literal); a pointer to a
|
||||||
|
null-terminated wide string (e.g. `std::u16string::c_str()`) is not supported
|
||||||
|
|
||||||
`IteratorType`
|
`IteratorType`
|
||||||
: a compatible iterator type, for instance.
|
: a compatible iterator type, for instance.
|
||||||
@@ -125,17 +131,37 @@ outside of a string, invalid) byte; see the [FAQ entry](../../home/faq.md#nul-by
|
|||||||
--8<-- "examples/accept__iterator_pair.output"
|
--8<-- "examples/accept__iterator_pair.output"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
??? example "Example: (3) reading from UTF-16 strings"
|
||||||
|
|
||||||
|
The encoding is deduced from the character type of the input. String literals like `u"..."`, `U"..."`, and
|
||||||
|
`L"..."` work as well.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
--8<-- "examples/accept__wide_string.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```json
|
||||||
|
--8<-- "examples/accept__wide_string.output"
|
||||||
|
```
|
||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [parse](parse.md) - deserialize from a compatible input
|
- [`parse`](parse.md) - deserialize from a compatible input
|
||||||
- [sax_parse](sax_parse.md) - parse input using the SAX interface
|
- [`sax_parse`](sax_parse.md) - parse input using the SAX interface
|
||||||
- [operator>>](../operator_gtgt.md) - deserialize from stream
|
- [`operator>>`](../operator_gtgt.md) - deserialize from stream
|
||||||
- [`JSON_STRICT_NUL_HANDLING`](../macros/json_strict_nul_handling.md) - opt in to rejecting a NUL byte in the input
|
- [`JSON_STRICT_NUL_HANDLING`](../macros/json_strict_nul_handling.md) - opt in to rejecting a NUL byte in the input
|
||||||
instead of treating it as end of input
|
instead of treating it as end of input
|
||||||
- [`JSON_DISABLE_STREAM_BULK_SCAN`](../macros/json_disable_stream_bulk_scan.md) - read a `std::istream` one character
|
- [`JSON_DISABLE_STREAM_BULK_SCAN`](../macros/json_disable_stream_bulk_scan.md) - read a `std::istream` one character
|
||||||
at a time
|
at a time
|
||||||
- [`JSON_DISABLE_UNLOCKED_FILE_IO`](../macros/json_disable_unlocked_file_io.md) - read a `FILE*` with the locking stdio
|
- [`JSON_DISABLE_UNLOCKED_FILE_IO`](../macros/json_disable_unlocked_file_io.md) - read a `FILE*` with the locking stdio
|
||||||
functions
|
functions
|
||||||
|
- [Parsing](../../features/parsing/index.md) - overview of the parsing functions
|
||||||
|
- [Comments](../../features/comments.md) - ignore `//` and `/* */` comments while parsing
|
||||||
|
- [Trailing Commas](../../features/trailing_commas.md) - accept trailing commas in arrays and objects
|
||||||
|
- [Parsing and Exceptions](../../features/parsing/parse_exceptions.md) - handling parse errors and locating them in the input
|
||||||
|
- [Parsing Untrusted Input](../../features/parsing/untrusted_input.md) - limits and checks for input you do not control
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
@@ -151,6 +177,9 @@ outside of a string, invalid) byte; see the [FAQ entry](../../home/faq.md#nul-by
|
|||||||
([`JSON_DISABLE_STREAM_BULK_SCAN`](../macros/json_disable_stream_bulk_scan.md)).
|
([`JSON_DISABLE_STREAM_BULK_SCAN`](../macros/json_disable_stream_bulk_scan.md)).
|
||||||
- Parsing from a `FILE*` locks the file once instead of once per character in version 3.13.0
|
- Parsing from a `FILE*` locks the file once instead of once per character in version 3.13.0
|
||||||
([`JSON_DISABLE_UNLOCKED_FILE_IO`](../macros/json_disable_unlocked_file_io.md)).
|
([`JSON_DISABLE_UNLOCKED_FILE_IO`](../macros/json_disable_unlocked_file_io.md)).
|
||||||
|
- Ill-formed UTF-16 and UTF-32 input (a lone surrogate, a high surrogate that is not followed by its low surrogate, or
|
||||||
|
a code point above `U+10FFFF`) is rejected in version 3.13.0; before that, some such sequences were accepted or
|
||||||
|
ended the input silently.
|
||||||
|
|
||||||
!!! warning "Deprecation"
|
!!! warning "Deprecation"
|
||||||
|
|
||||||
|
|||||||
@@ -69,10 +69,12 @@ Arrays are stored as pointers in a `basic_json` type. That is, for any access to
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [object_t](object_t.md) the type used to store JSON objects
|
- [`object_t`](object_t.md) - the type used to store JSON objects
|
||||||
- [binary_t](binary_t.md) the type used to store binary values
|
- [`binary_t`](binary_t.md) - the type used to store binary values
|
||||||
- [is_array](is_array.md) checks whether the JSON value is an array
|
- [`is_array`](is_array.md) - checks whether the JSON value is an array
|
||||||
- [max_size](max_size.md) returns the maximum possible number of elements
|
- [`max_size`](max_size.md) - returns the maximum possible number of elements
|
||||||
|
- [Types](../../features/types/index.md) - how arrays are stored
|
||||||
|
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the `ArrayType` template parameter
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ The function is equivalent to `static_cast<json_base_class_t&>(j)` (or `static_c
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [json_base_class_t](json_base_class_t.md) - type of the custom base class
|
- [`json_base_class_t`](json_base_class_t.md) - type of the custom base class
|
||||||
|
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the `CustomBaseClass` template parameter
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -230,18 +230,19 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- documentation on [checked access](../../features/element_access/checked_access.md)
|
- [Checked access](../../features/element_access/checked_access.md) - element access with range checking
|
||||||
- [`operator[]`](operator%5B%5D.md) for unchecked access by reference
|
- [`operator[]`](operator%5B%5D.md) - unchecked access by reference
|
||||||
- [`value`](value.md) for access with default value
|
- [`value`](value.md) - access with default value
|
||||||
- [basic_json_view::at](../basic_json_view/at.md) - the same access on a zero-copy view
|
- [`basic_json_view::at`](../basic_json_view/at.md) - the same access on a zero-copy view
|
||||||
|
- [Element Access](../../features/element_access/index.md) - overview of all ways to access elements
|
||||||
|
- [JSON Pointer](../../features/json_pointer.md) - access nested values with a pointer
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
1. Added in version 1.0.0.
|
1. Added in version 1.0.0.
|
||||||
2. Added in version 1.0.0.
|
2. Added in version 1.0.0.
|
||||||
3. Added in version 3.11.0. Fixed in version 3.13.0 to consistently accept `std::string_view`-convertible keys, as
|
3. Added in version 3.11.0. Support for keys convertible to `std::string_view` added in version 3.13.0, consistently
|
||||||
already supported by [`operator[]`](operator[].md), [`value`](value.md), [`find`](find.md), and other lookup
|
across the lookup functions.
|
||||||
functions.
|
|
||||||
4. Added in version 2.0.0. Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) instead of
|
4. Added in version 2.0.0. Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) instead of
|
||||||
[`out_of_range.404`](../../home/exceptions.md#jsonexceptionout_of_range404) for a one-character array index that is not
|
[`out_of_range.404`](../../home/exceptions.md#jsonexceptionout_of_range404) for a one-character array index that is not
|
||||||
a digit (e.g., `/x`) in version 3.13.0, as it already did for longer ones.
|
a digit (e.g., `/x`) in version 3.13.0, as it already did for longer ones.
|
||||||
@@ -57,10 +57,11 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [front](front.md) to access the first element
|
- [`front`](front.md) - to access the first element
|
||||||
- [basic_json_view::back](../basic_json_view/back.md) - the same access on a zero-copy view
|
- [`basic_json_view::back`](../basic_json_view/back.md) - the same access on a zero-copy view
|
||||||
|
- [Element Access](../../features/element_access/index.md) - overview of all ways to access elements
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
- Added in version 1.0.0.
|
- Added in version 1.0.0.
|
||||||
- Adjusted code to return reference to binary values in version 3.8.0.
|
- Binary values are supported since version 3.8.0.
|
||||||
@@ -113,19 +113,22 @@ basic_json(basic_json&& other) noexcept;
|
|||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
flowchart TD
|
flowchart TD
|
||||||
A(["initializer_list init"]) --> B{"empty, or every element is a 2-element<br/>array whose first element is a string?"}
|
A(["initializer_list init"]) --> B{{"empty, or every element is a 2-element<br/>array whose first element is a string?"}}
|
||||||
B -->|"yes"| C{"type_deduction"}
|
B -->|"yes"| C{{"type_deduction"}}
|
||||||
B -->|"no"| D{"type_deduction"}
|
B -->|"no"| D{{"type_deduction"}}
|
||||||
C -->|"true"| OBJ["create object"]
|
C -->|"true"| OBJ["create object"]
|
||||||
C -->|"false"| E{"manual_type"}
|
C -->|"false"| E{{"manual_type"}}
|
||||||
E -->|"object"| OBJ
|
E -->|"object"| OBJ
|
||||||
E -->|"array"| ARR["create array"]
|
E -->|"array"| ARR["create array"]
|
||||||
D -->|"true"| ARR
|
D -->|"true"| ARR
|
||||||
D -->|"false"| F{"manual_type"}
|
D -->|"false"| F{{"manual_type"}}
|
||||||
F -->|"array"| ARR
|
F -->|"array"| ARR
|
||||||
F -->|"object"| ERR["throw type_error.301"]
|
F -->|"object"| ERR["throw type_error.301"]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<p class="nj-caption" markdown>Decision flow for an initializer list: hexagons are checks, edge labels are their
|
||||||
|
outcomes, and rectangles are the resulting value or exception.</p>
|
||||||
|
|
||||||
The rules aim to create the best fit between a C++ initializer list and JSON values. The rationale is as follows:
|
The rules aim to create the best fit between a C++ initializer list and JSON values. The rationale is as follows:
|
||||||
|
|
||||||
1. The empty initializer list is written as `#!cpp {}` which is exactly an empty JSON object.
|
1. The empty initializer list is written as `#!cpp {}` which is exactly an empty JSON object.
|
||||||
@@ -473,24 +476,25 @@ basic_json(basic_json&& other) noexcept;
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [array](array.md) create a JSON array value, forcing array creation from an initializer list even when it looks like
|
- [`array`](array.md) - create a JSON array value, forcing array creation from an initializer list even when it looks like
|
||||||
an object
|
an object
|
||||||
- [object](object.md) create a JSON object value, forcing object creation from an initializer list
|
- [`object`](object.md) - create a JSON object value, forcing object creation from an initializer list
|
||||||
- [binary](binary.md) create a JSON binary array value
|
- [`binary`](binary.md) - create a JSON binary array value
|
||||||
- [operator=](operator=.md) copy assignment operator
|
- [`operator=`](operator=.md) - copy assignment operator
|
||||||
- [Creating JSON values](../../features/creating_values.md) - the article on creating JSON values
|
- [Creating JSON values](../../features/creating_values.md) - the article on creating JSON values
|
||||||
|
- [Converting values](../../features/conversions.md) - which C++ types can be converted
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
1. Since version 1.0.0.
|
1. Added in version 1.0.0.
|
||||||
2. Since version 1.0.0.
|
2. Added in version 1.0.0.
|
||||||
3. Since version 2.1.0.
|
3. Added in version 2.1.0.
|
||||||
4. Since version 3.2.0. Explicit for different string types if `JSON_USE_IMPLICIT_CONVERSIONS` is `0` since
|
4. Added in version 3.1.2. Explicit for different string types if `JSON_USE_IMPLICIT_CONVERSIONS` is `0` since
|
||||||
version 3.13.0.
|
version 3.13.0.
|
||||||
5. Since version 1.0.0.
|
5. Added in version 1.0.0.
|
||||||
6. Since version 1.0.0.
|
6. Added in version 1.0.0.
|
||||||
7. Since version 1.0.0. Fixed in version 3.13.0 to also check the iterator range for binary values; before, a range
|
7. Added in version 1.0.0. Fixed in version 3.13.0 to also check the iterator range for binary values; before, a range
|
||||||
that did not cover the whole value (such as `(end(), end())`) was accepted and the whole binary value was copied,
|
that did not cover the whole value (such as `(end(), end())`) was accepted and the whole binary value was copied,
|
||||||
unlike the other primitive types.
|
unlike the other primitive types.
|
||||||
8. Since version 1.0.0.
|
8. Added in version 1.0.0.
|
||||||
9. Since version 1.0.0.
|
9. Added in version 1.0.0.
|
||||||
@@ -7,7 +7,12 @@ const_iterator begin() const noexcept;
|
|||||||
|
|
||||||
Returns an iterator to the first element.
|
Returns an iterator to the first element.
|
||||||
|
|
||||||

|
<div class="nj-fig-wrap" markdown>
|
||||||
|
--8<-- "images/range-begin-end.svg"
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="nj-caption" markdown>`begin()` points to the first element and `end()` to the position after the last element;
|
||||||
|
the dashed cell is the past-the-last position, which must not be dereferenced.</p>
|
||||||
|
|
||||||
## Return value
|
## Return value
|
||||||
|
|
||||||
@@ -39,12 +44,12 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [end](end.md) returns an iterator to one past the last element
|
- [`end`](end.md) - returns an iterator to one past the last element
|
||||||
- [cbegin](cbegin.md) returns a const iterator to the first element
|
- [`cbegin`](cbegin.md) - returns a const iterator to the first element
|
||||||
- [rbegin](rbegin.md) returns a reverse iterator to the last element
|
- [`rbegin`](rbegin.md) - returns a reverse iterator to the last element
|
||||||
- [items](items.md) returns an iteration proxy to access keys and values during range-based for loops
|
- [`items`](items.md) - returns an iteration proxy to access keys and values during range-based for loops
|
||||||
- [Iterators](../../features/iterators.md) - the article on iterators
|
- [Iterators](../../features/iterators.md) - the article on iterators
|
||||||
- [basic_json_view::begin](../basic_json_view/begin.md) - the same iteration on a zero-copy view (in document order,
|
- [`basic_json_view::begin`](../basic_json_view/begin.md) - the same iteration on a zero-copy view (in document order,
|
||||||
not sorted by key)
|
not sorted by key)
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|||||||
@@ -63,10 +63,11 @@ initialization of a binary array type, for backwards compatibility and so it doe
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [binary_t](binary_t.md) type for binary values
|
- [Binary formats](../../features/binary_formats/index.md) - formats that can store binary values
|
||||||
- [get_binary](get_binary.md) get a reference to the stored binary value
|
- [`binary_t`](binary_t.md) - type for binary values
|
||||||
- [is_binary](is_binary.md) return whether the value is binary
|
- [`get_binary`](get_binary.md) - get a reference to the stored binary value
|
||||||
- [byte_container_with_subtype](../byte_container_with_subtype/index.md) container for binary values with subtype
|
- [`is_binary`](is_binary.md) - return whether the value is binary
|
||||||
|
- [`byte_container_with_subtype`](../byte_container_with_subtype/index.md) - container for binary values with subtype
|
||||||
- [Binary Values](../../features/binary_values.md) - the article on binary values
|
- [Binary Values](../../features/binary_values.md) - the article on binary values
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|||||||
@@ -117,7 +117,9 @@ type `#!cpp binary_t*` must be dereferenced.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [byte_container_with_subtype](../byte_container_with_subtype/index.md)
|
- [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
|
||||||
|
- [Binary formats](../../features/binary_formats/index.md) - formats that can store binary values
|
||||||
|
- [`byte_container_with_subtype`](../byte_container_with_subtype/index.md) - container type used by binary values
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,9 @@ Boolean values are stored directly inside a `basic_json` type.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [is_boolean](is_boolean.md) checks whether the JSON value is a boolean
|
- [`is_boolean`](is_boolean.md) - checks whether the JSON value is a boolean
|
||||||
|
- [Types](../../features/types/index.md) - how booleans are stored
|
||||||
|
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the `BooleanType` template parameter
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,12 @@ const_iterator cbegin() const noexcept;
|
|||||||
|
|
||||||
Returns an iterator to the first element.
|
Returns an iterator to the first element.
|
||||||
|
|
||||||

|
<div class="nj-fig-wrap" markdown>
|
||||||
|
--8<-- "images/range-begin-end.svg"
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="nj-caption" markdown>`cbegin()` points to the first element, like `begin()`, and `end()` to the position after
|
||||||
|
the last element; the dashed cell is the past-the-last position, which must not be dereferenced.</p>
|
||||||
|
|
||||||
## Return value
|
## Return value
|
||||||
|
|
||||||
@@ -38,11 +43,11 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [begin](begin.md) returns an iterator to the first element
|
- [`begin`](begin.md) - returns an iterator to the first element
|
||||||
- [cend](cend.md) returns a const iterator to one past the last element
|
- [`cend`](cend.md) - returns a const iterator to one past the last element
|
||||||
- [crbegin](crbegin.md) returns a const reverse iterator to the last element
|
- [`crbegin`](crbegin.md) - returns a const reverse iterator to the last element
|
||||||
- [Iterators](../../features/iterators.md) - the article on iterators
|
- [Iterators](../../features/iterators.md) - the article on iterators
|
||||||
- [basic_json_view::cbegin](../basic_json_view/cbegin.md) - the same iteration on a zero-copy view
|
- [`basic_json_view::cbegin`](../basic_json_view/cbegin.md) - the same iteration on a zero-copy view
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -40,9 +40,10 @@ store
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [from_cbor](from_cbor.md) deserializes a JSON value from CBOR
|
- [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
|
||||||
- [input_format_t](input_format_t.md) the enumeration of supported input formats
|
- [`from_cbor`](from_cbor.md) - deserializes a JSON value from CBOR
|
||||||
- [CBOR](../../features/binary_formats/cbor.md) - the article on the CBOR format
|
- [`input_format_t`](input_format_t.md) - the enumeration of supported input formats
|
||||||
|
- [`CBOR`](../../features/binary_formats/cbor.md) - the article on the CBOR format
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,12 @@ const_iterator cend() const noexcept;
|
|||||||
|
|
||||||
Returns an iterator to one past the last element.
|
Returns an iterator to one past the last element.
|
||||||
|
|
||||||

|
<div class="nj-fig-wrap" markdown>
|
||||||
|
--8<-- "images/range-begin-end.svg"
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="nj-caption" markdown>`cend()` points to the position after the last element, like `end()`, and `begin()` to
|
||||||
|
the first element; the dashed cell is the past-the-last position, which must not be dereferenced.</p>
|
||||||
|
|
||||||
## Return value
|
## Return value
|
||||||
|
|
||||||
@@ -38,11 +43,11 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [end](end.md) returns an iterator to one past the last element
|
- [`end`](end.md) - returns an iterator to one past the last element
|
||||||
- [cbegin](cbegin.md) returns a const iterator to the first element
|
- [`cbegin`](cbegin.md) - returns a const iterator to the first element
|
||||||
- [crend](crend.md) returns a const reverse iterator to one before the first element
|
- [`crend`](crend.md) - returns a const reverse iterator to one before the first element
|
||||||
- [Iterators](../../features/iterators.md) - the article on iterators
|
- [Iterators](../../features/iterators.md) - the article on iterators
|
||||||
- [basic_json_view::cend](../basic_json_view/cend.md) - the same iteration on a zero-copy view
|
- [`basic_json_view::cend`](../basic_json_view/cend.md) - the same iteration on a zero-copy view
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -54,8 +54,9 @@ All iterators, pointers, and references related to this container are invalidate
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [erase](erase.md) removes elements from a JSON value
|
- [`erase`](erase.md) - removes elements from a JSON value
|
||||||
- [empty](empty.md) checks whether the JSON value has no elements
|
- [`empty`](empty.md) - checks whether the JSON value has no elements
|
||||||
|
- [Modifying values](../../features/modifying_values.md) - the article on modifying values
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -134,16 +134,16 @@ Logarithmic in the size of the JSON object.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [find](find.md) find a value in an object
|
- [`find`](find.md) - find a value in an object
|
||||||
- [count](count.md) returns the number of occurrences of a key
|
- [`count`](count.md) - returns the number of occurrences of a key
|
||||||
- [basic_json_view::contains](../basic_json_view/contains.md) - the same check on a zero-copy view
|
- [`basic_json_view::contains`](../basic_json_view/contains.md) - the same check on a zero-copy view
|
||||||
|
- [Element Access](../../features/element_access/index.md#does-this-key-exist) - how to test whether a key exists
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
1. Added in version 3.11.0.
|
1. Added in version 3.11.0.
|
||||||
2. Added in version 3.6.0. Extended template `KeyType` to support comparable types in version 3.11.0. Fixed in
|
2. Added in version 3.6.0. Extended template `KeyType` to support comparable types in version 3.11.0. Support for keys
|
||||||
version 3.13.0 to consistently accept `std::string_view`-convertible keys, as already supported by
|
convertible to `std::string_view` added in version 3.13.0, consistently across the lookup functions.
|
||||||
[`operator[]`](operator[].md), [`at`](at.md), [`value`](value.md), and other lookup functions.
|
|
||||||
3. Added in version 3.7.0.
|
3. Added in version 3.7.0.
|
||||||
4. Deleted overloads for integral key types added in version 3.13.0 to reject such calls at compile time instead of
|
4. Deleted overloads for integral key types added in version 3.13.0 to reject such calls at compile time instead of
|
||||||
causing undefined behavior at runtime.
|
causing undefined behavior at runtime.
|
||||||
@@ -85,15 +85,15 @@ Logarithmic in the size of the JSON object.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [find](find.md) find a value in an object
|
- [`find`](find.md) - find a value in an object
|
||||||
- [contains](contains.md) checks whether a key exists
|
- [`contains`](contains.md) - checks whether a key exists
|
||||||
- [basic_json_view::count](../basic_json_view/count.md) - the same check on a zero-copy view
|
- [`basic_json_view::count`](../basic_json_view/count.md) - the same check on a zero-copy view
|
||||||
|
- [Element Access](../../features/element_access/index.md#does-this-key-exist) - how to test whether a key exists
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
1. Added in version 3.11.0.
|
1. Added in version 3.11.0.
|
||||||
2. Added in version 1.0.0. Changed parameter `key` type to `KeyType&&` in version 3.11.0. Fixed in version 3.13.0 to
|
2. Added in version 1.0.0. Changed to support comparable key types in version 3.11.0. Support for keys convertible to
|
||||||
consistently accept `std::string_view`-convertible keys, as already supported by [`operator[]`](operator[].md),
|
`std::string_view` added in version 3.13.0, consistently across the lookup functions.
|
||||||
[`at`](at.md), [`value`](value.md), and other lookup functions.
|
|
||||||
3. Deleted overload for integral key types added in version 3.13.0 to reject such calls at compile time instead of
|
3. Deleted overload for integral key types added in version 3.13.0 to reject such calls at compile time instead of
|
||||||
causing undefined behavior at runtime.
|
causing undefined behavior at runtime.
|
||||||
@@ -6,7 +6,13 @@ const_reverse_iterator crbegin() const noexcept;
|
|||||||
|
|
||||||
Returns an iterator to the reverse-beginning; that is, the last element.
|
Returns an iterator to the reverse-beginning; that is, the last element.
|
||||||
|
|
||||||

|
<div class="nj-fig-wrap" markdown>
|
||||||
|
--8<-- "images/range-rbegin-rend.svg"
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="nj-caption" markdown>`crbegin()` points to the last element, like `rbegin()`, and `rend()` to the position
|
||||||
|
before the first element. The upper row is the reversed sequence and the lower row the forward sequence; dashed arrows
|
||||||
|
link each reverse iterator to the forward iterator it stores, and dashed cells are past-the-last positions.</p>
|
||||||
|
|
||||||
## Return value
|
## Return value
|
||||||
|
|
||||||
@@ -38,9 +44,9 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [crend](crend.md) returns a const reverse iterator to one before the first element
|
- [`crend`](crend.md) - returns a const reverse iterator to one before the first element
|
||||||
- [rbegin](rbegin.md) returns a reverse iterator to the last element
|
- [`rbegin`](rbegin.md) - returns a reverse iterator to the last element
|
||||||
- [cbegin](cbegin.md) returns a const iterator to the first element
|
- [`cbegin`](cbegin.md) - returns a const iterator to the first element
|
||||||
- [Iterators](../../features/iterators.md) - the article on iterators
|
- [Iterators](../../features/iterators.md) - the article on iterators
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|||||||
@@ -7,7 +7,13 @@ const_reverse_iterator crend() const noexcept;
|
|||||||
Returns an iterator to the reverse-end; that is, one before the first element. This element acts as a placeholder,
|
Returns an iterator to the reverse-end; that is, one before the first element. This element acts as a placeholder,
|
||||||
attempting to access it results in undefined behavior.
|
attempting to access it results in undefined behavior.
|
||||||
|
|
||||||

|
<div class="nj-fig-wrap" markdown>
|
||||||
|
--8<-- "images/range-rbegin-rend.svg"
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="nj-caption" markdown>`crend()` points to the position before the first element, like `rend()`, and `rbegin()`
|
||||||
|
to the last element. The upper row is the reversed sequence and the lower row the forward sequence; dashed arrows link
|
||||||
|
each reverse iterator to the forward iterator it stores, and dashed cells are past-the-last positions.</p>
|
||||||
|
|
||||||
## Return value
|
## Return value
|
||||||
|
|
||||||
@@ -39,9 +45,9 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [crbegin](crbegin.md) returns a const reverse iterator to the last element
|
- [`crbegin`](crbegin.md) - returns a const reverse iterator to the last element
|
||||||
- [rend](rend.md) returns a reverse iterator to one before the first element
|
- [`rend`](rend.md) - returns a reverse iterator to one before the first element
|
||||||
- [cend](cend.md) returns a const iterator to one past the last element
|
- [`cend`](cend.md) - returns a const iterator to one past the last element
|
||||||
- [Iterators](../../features/iterators.md) - the article on iterators
|
- [Iterators](../../features/iterators.md) - the article on iterators
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|||||||
@@ -32,8 +32,10 @@ The actual comparator used depends on [`object_t`](object_t.md) and can be obtai
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [object_comparator_t](object_comparator_t.md) the comparator actually used by `object_t`
|
- [`object_comparator_t`](object_comparator_t.md) - the comparator actually used by `object_t`
|
||||||
- [object_t](object_t.md) the type used to store JSON objects
|
- [`object_t`](object_t.md) - the type used to store JSON objects
|
||||||
|
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the `ObjectType` template parameter
|
||||||
|
- [Object order](../../features/object_order.md) - preserve the insertion order of keys
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -55,11 +55,12 @@ Currently, only `remove`, `add`, and `replace` operations are generated.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902)
|
- [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) - specification of JSON Patch
|
||||||
- [patch](patch.md) applies a JSON Patch
|
- [`patch`](patch.md) - applies a JSON Patch
|
||||||
- [patch_inplace](patch_inplace.md) applies a JSON Patch in place
|
- [`patch_inplace`](patch_inplace.md) - applies a JSON Patch in place
|
||||||
- [merge_patch](merge_patch.md) applies a JSON Merge Patch
|
- [`merge_patch`](merge_patch.md) - applies a JSON Merge Patch
|
||||||
- [merge_diff](merge_diff.md) creates a diff as a JSON Merge Patch
|
- [`merge_diff`](merge_diff.md) - creates a diff as a JSON Merge Patch
|
||||||
|
- [JSON Patch and Diff](../../features/json_patch.md) - the article on JSON Patch
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -89,9 +89,9 @@ Binary values are serialized as an object containing two keys:
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [to_string](to_string.md) returns a string representation of a JSON value
|
- [`to_string`](to_string.md) - returns a string representation of a JSON value
|
||||||
- [operator<<](../operator_ltlt.md) serialize to stream
|
- [`operator<<`](../operator_ltlt.md) - serialize to stream
|
||||||
- [`basic_json_view::dump`](../basic_json_view/dump.md) the corresponding function of `basic_json_view`, serializing
|
- [`basic_json_view::dump`](../basic_json_view/dump.md) - the corresponding function of `basic_json_view`, serializing
|
||||||
directly from a flat index without building a `basic_json` value
|
directly from a flat index without building a `basic_json` value
|
||||||
- [Serialization](../../features/serialization.md) - the serialization article
|
- [Serialization](../../features/serialization.md) - the serialization article
|
||||||
|
|
||||||
|
|||||||
@@ -63,12 +63,12 @@ Logarithmic in the size of the container, O(log(`size()`)).
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [emplace_back](emplace_back.md) add a value to an array
|
- [`emplace_back`](emplace_back.md) - add a value to an array
|
||||||
- [insert](insert.md) add values to an array/object
|
- [`insert`](insert.md) - add values to an array/object
|
||||||
- [Modifying values](../../features/modifying_values.md) - the article on modifying values
|
- [Modifying values](../../features/modifying_values.md) - the article on modifying values
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
- Since version 2.0.8.
|
- Added in version 2.0.8.
|
||||||
- Fixed in version 3.13.0: for [`ordered_json`](../ordered_json.md), the value could previously only be passed as an
|
- Fixed in version 3.13.0: for [`ordered_json`](../ordered_json.md), the value could previously only be passed as an
|
||||||
rvalue; it can now also be passed as an lvalue or a `#!cpp const` lvalue, matching the behavior of `json`.
|
rvalue; it can now also be passed as an lvalue or a `#!cpp const` lvalue, matching the behavior of `json`.
|
||||||
@@ -61,11 +61,11 @@ Amortized constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [operator+=](operator+=.md) add a value to an array/object
|
- [`operator+=`](operator+=.md) - add a value to an array/object
|
||||||
- [push_back](push_back.md) add a value to an array/object
|
- [`push_back`](push_back.md) - add a value to an array/object
|
||||||
- [Modifying values](../../features/modifying_values.md) - the article on modifying values
|
- [Modifying values](../../features/modifying_values.md) - the article on modifying values
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
- Since version 2.0.8.
|
- Added in version 2.0.8.
|
||||||
- Returns reference since 3.7.0.
|
- Returns reference since 3.7.0.
|
||||||
@@ -62,9 +62,9 @@ itself is empty which is `#!cpp false` in the case of a string.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [size](size.md) returns the number of elements
|
- [`size`](size.md) - returns the number of elements
|
||||||
- [clear](clear.md) clears the content and resets the value to the default value
|
- [`clear`](clear.md) - clears the content and resets the value to the default value
|
||||||
- [basic_json_view::empty](../basic_json_view/empty.md) - the same check on a zero-copy view
|
- [`basic_json_view::empty`](../basic_json_view/empty.md) - the same check on a zero-copy view
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,12 @@ const_iterator end() const noexcept;
|
|||||||
|
|
||||||
Returns an iterator to one past the last element.
|
Returns an iterator to one past the last element.
|
||||||
|
|
||||||

|
<div class="nj-fig-wrap" markdown>
|
||||||
|
--8<-- "images/range-begin-end.svg"
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="nj-caption" markdown>`end()` points to the position after the last element and `begin()` to the first element;
|
||||||
|
the dashed cell is the past-the-last position, which must not be dereferenced.</p>
|
||||||
|
|
||||||
## Return value
|
## Return value
|
||||||
|
|
||||||
@@ -39,11 +44,11 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [begin](begin.md) returns an iterator to the first element
|
- [`begin`](begin.md) - returns an iterator to the first element
|
||||||
- [cend](cend.md) returns a const iterator to one past the last element
|
- [`cend`](cend.md) - returns a const iterator to one past the last element
|
||||||
- [rend](rend.md) returns a reverse iterator to one before the first element
|
- [`rend`](rend.md) - returns a reverse iterator to one before the first element
|
||||||
- [Iterators](../../features/iterators.md) - the article on iterators
|
- [Iterators](../../features/iterators.md) - the article on iterators
|
||||||
- [basic_json_view::end](../basic_json_view/end.md) - the same iteration on a zero-copy view
|
- [`basic_json_view::end`](../basic_json_view/end.md) - the same iteration on a zero-copy view
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -60,8 +60,9 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [start_pos](start_pos.md) to access the start position
|
- [`start_pos`](start_pos.md) - to access the start position
|
||||||
- [JSON_DIAGNOSTIC_POSITIONS](../macros/json_diagnostic_positions.md) for an overview of the diagnostic positions
|
- [`JSON_DIAGNOSTIC_POSITIONS`](../macros/json_diagnostic_positions.md) - overview of the supported conversions
|
||||||
|
- [Parsing and Exceptions](../../features/parsing/parse_exceptions.md) - handling parse errors and locating them in the input
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -204,8 +204,8 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [clear](clear.md) clears the contents
|
- [`clear`](clear.md) - clears the contents
|
||||||
- [insert](insert.md) add values to an array/object
|
- [`insert`](insert.md) - add values to an array/object
|
||||||
- [Modifying values](../../features/modifying_values.md) - the article on modifying values
|
- [Modifying values](../../features/modifying_values.md) - the article on modifying values
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
@@ -213,7 +213,6 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
|||||||
1. Added in version 1.0.0. Added support for binary types in version 3.8.0.
|
1. Added in version 1.0.0. Added support for binary types in version 3.8.0.
|
||||||
2. Added in version 1.0.0. Added support for binary types in version 3.8.0.
|
2. Added in version 1.0.0. Added support for binary types in version 3.8.0.
|
||||||
3. Added in version 1.0.0.
|
3. Added in version 1.0.0.
|
||||||
4. Added in version 3.11.0. Fixed in version 3.13.0 to consistently accept `std::string_view`-convertible keys, as
|
4. Added in version 3.11.0. Support for keys convertible to `std::string_view` added in version 3.13.0, consistently
|
||||||
already supported by [`operator[]`](operator[].md), [`at`](at.md), [`value`](value.md), and other lookup
|
across the lookup functions.
|
||||||
functions.
|
|
||||||
5. Added in version 1.0.0.
|
5. Added in version 1.0.0.
|
||||||
@@ -61,7 +61,7 @@ keep
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [dump](dump.md) serializes a JSON value, with an `error_handler_t` parameter to configure invalid UTF-8 handling
|
- [`dump`](dump.md) - serializes a JSON value, with an `error_handler_t` parameter to configure invalid UTF-8 handling
|
||||||
- [Handling invalid UTF-8](../../features/serialization.md#handling-invalid-utf-8) - the article on handling invalid UTF-8
|
- [Handling invalid UTF-8](../../features/serialization.md#handling-invalid-utf-8) - the article on handling invalid UTF-8
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ classDiagram
|
|||||||
style json_exception fill:#CCCCFF
|
style json_exception fill:#CCCCFF
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<p class="nj-caption" markdown>Class hierarchy of the library's exceptions; arrows point from a derived class to its
|
||||||
|
base class, and the highlighted box is `basic_json::exception`.</p>
|
||||||
|
|
||||||
Subclasses:
|
Subclasses:
|
||||||
|
|
||||||
- [`parse_error`](parse_error.md) for exceptions indicating a parse error
|
- [`parse_error`](parse_error.md) for exceptions indicating a parse error
|
||||||
@@ -80,8 +83,12 @@ constructor.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
[List of exceptions](../../home/exceptions.md)
|
- [List of exceptions](../../home/exceptions.md) - overview of all exceptions thrown by the library
|
||||||
|
- [Working Without Exceptions](../../features/no_exceptions.md) - using the library without exceptions
|
||||||
|
- [`JSON_DIAGNOSTICS`](../macros/json_diagnostics.md) - extended exception messages with the path of the failing value
|
||||||
|
- [Parsing and Exceptions](../../features/parsing/parse_exceptions.md) - parsing alternatives that do not throw
|
||||||
|
- [Debugging](../../home/debugging.md) - debugging aids
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
- Since version 3.0.0.
|
- Added in version 3.0.0.
|
||||||
@@ -91,16 +91,16 @@ Logarithmic in the size of the JSON object.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [count](count.md) returns the number of occurrences of a key
|
- [`count`](count.md) - returns the number of occurrences of a key
|
||||||
- [contains](contains.md) checks whether a key exists
|
- [`contains`](contains.md) - checks whether a key exists
|
||||||
- [basic_json_view::find](../basic_json_view/find.md) - the same lookup on a zero-copy view (a duplicate key resolves
|
- [`basic_json_view::find`](../basic_json_view/find.md) - the same lookup on a zero-copy view (a duplicate key resolves
|
||||||
to the first member, whereas `parse()` keeps the last)
|
to the first member, whereas `parse()` keeps the last)
|
||||||
|
- [Element Access](../../features/element_access/index.md#does-this-key-exist) - how to test whether a key exists
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
1. Added in version 3.11.0.
|
1. Added in version 3.11.0.
|
||||||
2. Added in version 1.0.0. Changed to support comparable types in version 3.11.0. Fixed in version 3.13.0 to
|
2. Added in version 1.0.0. Changed to support comparable types in version 3.11.0. Support for keys convertible to
|
||||||
consistently accept `std::string_view`-convertible keys, as already supported by [`operator[]`](operator[].md),
|
`std::string_view` added in version 3.13.0, consistently across the lookup functions.
|
||||||
[`at`](at.md), [`value`](value.md), and other lookup functions.
|
|
||||||
3. Deleted overloads for integral key types added in version 3.13.0 to reject such calls at compile time instead of
|
3. Deleted overloads for integral key types added in version 3.13.0 to reject such calls at compile time instead of
|
||||||
causing undefined behavior at runtime.
|
causing undefined behavior at runtime.
|
||||||
@@ -58,7 +58,8 @@ Empty objects and arrays are flattened to `#!json null` and will not be reconstr
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [unflatten](unflatten.md) the reverse function
|
- [`unflatten`](unflatten.md) - the reverse function
|
||||||
|
- [JSON Pointer](../../features/json_pointer.md#flatten-unflatten) - the article on JSON Pointer and flattening
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -86,8 +86,8 @@ std::string format_as(const BasicJsonType& j)
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [dump](dump.md)
|
- [`dump`](dump.md) - serialize a JSON value to a string
|
||||||
- [std::formatter<basic_json>](std_formatter.md) - the `std::format` (C++20) equivalent
|
- [`std::formatter<basic_json>`](std_formatter.md) - the `std::format` (C++20) equivalent
|
||||||
- [Serialization](../../features/serialization.md) - the serialization article
|
- [Serialization](../../features/serialization.md) - the serialization article
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|||||||
@@ -107,12 +107,16 @@ Linear in the size of the input.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [to_bjdata](to_bjdata.md) create a BJData serialization of a JSON value
|
- [BJData](../../features/binary_formats/bjdata.md) - the format, its byte layout and how values are mapped
|
||||||
- [from_cbor](from_cbor.md) create a JSON value from an input in CBOR format
|
- [Binary formats](../../features/binary_formats/index.md) - overview and comparison of the supported binary formats
|
||||||
- [from_msgpack](from_msgpack.md) create a JSON value from an input in MessagePack format
|
- [Parsing untrusted input](../../features/parsing/untrusted_input.md) - limits and safe handling of hostile data
|
||||||
- [from_bson](from_bson.md) create a JSON value from an input in BSON format
|
- [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
|
||||||
- [from_ubjson](from_ubjson.md) create a JSON value from an input in UBJSON format
|
- [`to_bjdata`](to_bjdata.md) - create a BJData serialization of a JSON value
|
||||||
- [from_bon8](from_bon8.md) create a JSON value from an input in BON8 format
|
- [`from_cbor`](from_cbor.md) - create a JSON value from an input in CBOR format
|
||||||
|
- [`from_msgpack`](from_msgpack.md) - create a JSON value from an input in MessagePack format
|
||||||
|
- [`from_bson`](from_bson.md) - create a JSON value from an input in BSON format
|
||||||
|
- [`from_ubjson`](from_ubjson.md) - create a JSON value from an input in UBJSON format
|
||||||
|
- [`from_bon8`](from_bon8.md) - create a JSON value from an input in BON8 format
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -96,12 +96,15 @@ Linear in the size of the input.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [to_bon8](to_bon8.md) create a BON8 serialization of a JSON value
|
- [`BON8`](../../features/binary_formats/bon8.md) - the format, its byte layout and how values are mapped
|
||||||
- [from_cbor](from_cbor.md) create a JSON value from an input in CBOR format
|
- [Binary formats](../../features/binary_formats/index.md) - overview and comparison of the supported binary formats
|
||||||
- [from_msgpack](from_msgpack.md) create a JSON value from an input in MessagePack format
|
- [Parsing untrusted input](../../features/parsing/untrusted_input.md) - limits and safe handling of hostile data
|
||||||
- [from_bson](from_bson.md) create a JSON value from an input in BSON format
|
- [`to_bon8`](to_bon8.md) - create a BON8 serialization of a JSON value
|
||||||
- [from_ubjson](from_ubjson.md) create a JSON value from an input in UBJSON format
|
- [`from_cbor`](from_cbor.md) - create a JSON value from an input in CBOR format
|
||||||
- [from_bjdata](from_bjdata.md) create a JSON value from an input in BJData format
|
- [`from_msgpack`](from_msgpack.md) - create a JSON value from an input in MessagePack format
|
||||||
|
- [`from_bson`](from_bson.md) - create a JSON value from an input in BSON format
|
||||||
|
- [`from_ubjson`](from_ubjson.md) - create a JSON value from an input in UBJSON format
|
||||||
|
- [`from_bjdata`](from_bjdata.md) - create a JSON value from an input in BJData format
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -108,13 +108,17 @@ Linear in the size of the input.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [BSON specification](http://bsonspec.org/spec.html)
|
- [`BSON`](../../features/binary_formats/bson.md) - the format, its byte layout and how values are mapped
|
||||||
- [to_bson](to_bson.md) for the analogous serialization
|
- [Binary formats](../../features/binary_formats/index.md) - overview and comparison of the supported binary formats
|
||||||
- [from_cbor](from_cbor.md) for the related CBOR format
|
- [Parsing untrusted input](../../features/parsing/untrusted_input.md) - limits and safe handling of hostile data
|
||||||
- [from_msgpack](from_msgpack.md) for the related MessagePack format
|
- [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
|
||||||
- [from_ubjson](from_ubjson.md) for the related UBJSON format
|
- [BSON specification](http://bsonspec.org/spec.html) - specification of the BSON format
|
||||||
- [from_bjdata](from_bjdata.md) for the related BJData format
|
- [`to_bson`](to_bson.md) - the analogous serialization
|
||||||
- [from_bon8](from_bon8.md) for the related BON8 format
|
- [`from_cbor`](from_cbor.md) - the related CBOR format
|
||||||
|
- [`from_msgpack`](from_msgpack.md) - the related MessagePack format
|
||||||
|
- [`from_ubjson`](from_ubjson.md) - the related UBJSON format
|
||||||
|
- [`from_bjdata`](from_bjdata.md) - the related BJData format
|
||||||
|
- [`from_bon8`](from_bon8.md) - the related BON8 format
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -114,12 +114,16 @@ Linear in the size of the input.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [to_cbor](to_cbor.md) create a CBOR serialization of a JSON value
|
- [`CBOR`](../../features/binary_formats/cbor.md) - the format, its byte layout and how values are mapped
|
||||||
- [from_msgpack](from_msgpack.md) create a JSON value from an input in MessagePack format
|
- [Binary formats](../../features/binary_formats/index.md) - overview and comparison of the supported binary formats
|
||||||
- [from_bson](from_bson.md) create a JSON value from an input in BSON format
|
- [Parsing untrusted input](../../features/parsing/untrusted_input.md) - limits and safe handling of hostile data
|
||||||
- [from_ubjson](from_ubjson.md) create a JSON value from an input in UBJSON format
|
- [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
|
||||||
- [from_bjdata](from_bjdata.md) create a JSON value from an input in BJData format
|
- [`to_cbor`](to_cbor.md) - create a CBOR serialization of a JSON value
|
||||||
- [from_bon8](from_bon8.md) create a JSON value from an input in BON8 format
|
- [`from_msgpack`](from_msgpack.md) - create a JSON value from an input in MessagePack format
|
||||||
|
- [`from_bson`](from_bson.md) - create a JSON value from an input in BSON format
|
||||||
|
- [`from_ubjson`](from_ubjson.md) - create a JSON value from an input in UBJSON format
|
||||||
|
- [`from_bjdata`](from_bjdata.md) - create a JSON value from an input in BJData format
|
||||||
|
- [`from_bon8`](from_bon8.md) - create a JSON value from an input in BON8 format
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -107,12 +107,16 @@ Linear in the size of the input.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [to_msgpack](to_msgpack.md) create a MessagePack serialization of a JSON value
|
- [MessagePack](../../features/binary_formats/messagepack.md) - the format, its byte layout and how values are mapped
|
||||||
- [from_cbor](from_cbor.md) create a JSON value from an input in CBOR format
|
- [Binary formats](../../features/binary_formats/index.md) - overview and comparison of the supported binary formats
|
||||||
- [from_bson](from_bson.md) create a JSON value from an input in BSON format
|
- [Parsing untrusted input](../../features/parsing/untrusted_input.md) - limits and safe handling of hostile data
|
||||||
- [from_ubjson](from_ubjson.md) create a JSON value from an input in UBJSON format
|
- [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
|
||||||
- [from_bjdata](from_bjdata.md) create a JSON value from an input in BJData format
|
- [`to_msgpack`](to_msgpack.md) - create a MessagePack serialization of a JSON value
|
||||||
- [from_bon8](from_bon8.md) create a JSON value from an input in BON8 format
|
- [`from_cbor`](from_cbor.md) - create a JSON value from an input in CBOR format
|
||||||
|
- [`from_bson`](from_bson.md) - create a JSON value from an input in BSON format
|
||||||
|
- [`from_ubjson`](from_ubjson.md) - create a JSON value from an input in UBJSON format
|
||||||
|
- [`from_bjdata`](from_bjdata.md) - create a JSON value from an input in BJData format
|
||||||
|
- [`from_bon8`](from_bon8.md) - create a JSON value from an input in BON8 format
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -107,12 +107,16 @@ Linear in the size of the input.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [to_ubjson](to_ubjson.md) create a UBJSON serialization of a JSON value
|
- [`UBJSON`](../../features/binary_formats/ubjson.md) - the format, its byte layout and how values are mapped
|
||||||
- [from_cbor](from_cbor.md) create a JSON value from an input in CBOR format
|
- [Binary formats](../../features/binary_formats/index.md) - overview and comparison of the supported binary formats
|
||||||
- [from_msgpack](from_msgpack.md) create a JSON value from an input in MessagePack format
|
- [Parsing untrusted input](../../features/parsing/untrusted_input.md) - limits and safe handling of hostile data
|
||||||
- [from_bson](from_bson.md) create a JSON value from an input in BSON format
|
- [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
|
||||||
- [from_bjdata](from_bjdata.md) create a JSON value from an input in BJData format
|
- [`to_ubjson`](to_ubjson.md) - create a UBJSON serialization of a JSON value
|
||||||
- [from_bon8](from_bon8.md) create a JSON value from an input in BON8 format
|
- [`from_cbor`](from_cbor.md) - create a JSON value from an input in CBOR format
|
||||||
|
- [`from_msgpack`](from_msgpack.md) - create a JSON value from an input in MessagePack format
|
||||||
|
- [`from_bson`](from_bson.md) - create a JSON value from an input in BSON format
|
||||||
|
- [`from_bjdata`](from_bjdata.md) - create a JSON value from an input in BJData format
|
||||||
|
- [`from_bon8`](from_bon8.md) - create a JSON value from an input in BON8 format
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -50,11 +50,12 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [back](back.md) to access the last element
|
- [`back`](back.md) - to access the last element
|
||||||
- [basic_json_view::front](../basic_json_view/front.md) - the same access on a zero-copy view (document order, not
|
- [`basic_json_view::front`](../basic_json_view/front.md) - the same access on a zero-copy view (document order, not
|
||||||
sorted; duplicate keys are visited)
|
sorted; duplicate keys are visited)
|
||||||
|
- [Element Access](../../features/element_access/index.md) - overview of all ways to access elements
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
- Added in version 1.0.0.
|
- Added in version 1.0.0.
|
||||||
- Adjusted code to return reference to binary values in version 3.8.0.
|
- Binary values are supported since version 3.8.0.
|
||||||
@@ -178,16 +178,17 @@ overload (3).
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [get_to](get_to.md) convert and write into a passed value
|
- [`get_to`](get_to.md) - convert and write into a passed value
|
||||||
- [get_ptr](get_ptr.md) get a pointer to the stored value
|
- [`get_ptr`](get_ptr.md) - get a pointer to the stored value
|
||||||
- [get_ref](get_ref.md) get a reference to the stored value
|
- [`get_ref`](get_ref.md) - get a reference to the stored value
|
||||||
- [operator ValueType](operator_ValueType.md) get a value via implicit conversion
|
- [`operator ValueType`](operator_ValueType.md) - get a value via implicit conversion
|
||||||
- [Converting values](../../features/conversions.md) - the type conversions article
|
- [Converting values](../../features/conversions.md) - the type conversions article
|
||||||
- [basic_json_view::get](../basic_json_view/get.md) - the same conversion on a zero-copy view (many types are
|
- [`basic_json_view::get`](../basic_json_view/get.md) - the same conversion on a zero-copy view (many types are
|
||||||
converted without ever building a `basic_json` value)
|
converted without ever building a `basic_json` value)
|
||||||
|
- [Arbitrary Type Conversions](../../features/arbitrary_types.md) - make your own types usable with `get`
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
1. Since version 2.1.0.
|
1. Added in version 2.1.0.
|
||||||
2. Since version 2.1.0. Extended to work with other specializations of `basic_json` in version 3.2.0.
|
2. Added in version 2.1.0. Extended to work with other specializations of `basic_json` in version 3.1.2.
|
||||||
3. Since version 1.0.0.
|
3. Added in version 1.0.0.
|
||||||
@@ -36,7 +36,7 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [basic_json](index.md#template-parameters) the class template, with `AllocatorType` as one of its template parameters
|
- [`basic_json`](index.md#template-parameters) - the class template, with `AllocatorType` as one of its template parameters
|
||||||
- [Template Parameter Requirements](../../features/types/template_parameters.md#allocatortype) - the requirements for `AllocatorType`
|
- [Template Parameter Requirements](../../features/types/template_parameters.md#allocatortype) - the requirements for `AllocatorType`
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|||||||
@@ -42,8 +42,11 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [get](get.md) get a value (explicit conversion)
|
- [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
|
||||||
- [get_ref](get_ref.md) get a reference to the stored value
|
- [`binary`](binary.md) - create a binary value
|
||||||
|
- [`is_binary`](is_binary.md) - check whether a value is binary
|
||||||
|
- [`get`](get.md) - get a value (explicit conversion)
|
||||||
|
- [`get_ref`](get_ref.md) - get a reference to the stored value
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ Constant.
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using json = nlohmann::json;
|
using nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@@ -86,7 +86,8 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [get_ref()](get_ref.md) get a reference value
|
- [`get_ref()`](get_ref.md) - get a reference value
|
||||||
|
- [Converting values](../../features/conversions.md) - getting values out, with or without copying
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -60,9 +60,10 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [get_ptr()](get_ptr.md) get a pointer value
|
- [`get_ptr()`](get_ptr.md) - get a pointer value
|
||||||
- [basic_json_view::get_string](../basic_json_view/get_string.md) - the closest counterpart on a zero-copy view: a
|
- [`basic_json_view::get_string`](../basic_json_view/get_string.md) - the closest counterpart on a zero-copy view: a
|
||||||
string without a copy, but as a view rather than a reference to a value that must already exist
|
string without a copy, but as a view rather than a reference to a value that must already exist
|
||||||
|
- [Converting values](../../features/conversions.md) - getting values out, with or without copying
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -68,13 +68,14 @@ Depends on the `json_serializer<ValueType>::from_json()` implementation.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [get](get.md) get a value (explicit conversion)
|
- [`get`](get.md) - get a value (explicit conversion)
|
||||||
- [get_ref](get_ref.md) get a reference to the stored value
|
- [`get_ref`](get_ref.md) - get a reference to the stored value
|
||||||
- [get_ptr](get_ptr.md) get a pointer to the stored value
|
- [`get_ptr`](get_ptr.md) - get a pointer to the stored value
|
||||||
- [Converting values](../../features/conversions.md) - the type conversions article
|
- [Converting values](../../features/conversions.md) - the type conversions article
|
||||||
- [basic_json_view::get_to](../basic_json_view/get_to.md) - the same conversion on a zero-copy view
|
- [`basic_json_view::get_to`](../basic_json_view/get_to.md) - the same conversion on a zero-copy view
|
||||||
|
- [Arbitrary Type Conversions](../../features/arbitrary_types.md) - make your own types usable with `get_to`
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
- Since version 3.3.0.
|
- Added in version 3.3.0.
|
||||||
- Added a `static_assert` with a clear message for `const` arguments in version 3.13.0.
|
- Added a `static_assert` with a clear message for `const` arguments in version 3.13.0.
|
||||||
@@ -44,6 +44,22 @@ are collected in [Template Parameter Requirements](../../features/types/template
|
|||||||
- [**json**](../json.md) - default specialization
|
- [**json**](../json.md) - default specialization
|
||||||
- [**ordered_json**](../ordered_json.md) - a specialization that maintains the insertion order of object keys
|
- [**ordered_json**](../ordered_json.md) - a specialization that maintains the insertion order of object keys
|
||||||
|
|
||||||
|
## Documents and views
|
||||||
|
|
||||||
|
Besides `basic_json`, the library offers a second way to hold a parsed JSON text: a
|
||||||
|
[`basic_json_document`](../basic_json_document/index.md), which owns or borrows the text and holds a flat index of the
|
||||||
|
values in it, and a [`basic_json_view`](../basic_json_view/index.md), a read-only handle to one value of such a document.
|
||||||
|
Both are defined in the header `<nlohmann/json_view.hpp>`; see
|
||||||
|
[Zero-copy JSON views](../../features/json_view.md) for the concept and the trade-offs.
|
||||||
|
|
||||||
|
- [**json_document**](../json_document.md) / [**ordered_json_document**](../ordered_json_document.md) - read-only
|
||||||
|
documents of the `basic_json` specialization they belong to
|
||||||
|
- [**json_editable_document**](../json_editable_document.md) /
|
||||||
|
[**ordered_json_editable_document**](../ordered_json_editable_document.md) - documents that can be modified in place
|
||||||
|
- [**json_view**](../json_view.md) / [**ordered_json_view**](../ordered_json_view.md) - views of a document
|
||||||
|
- [**json_editable_view**](../json_editable_view.md) /
|
||||||
|
[**ordered_json_editable_view**](../ordered_json_editable_view.md) - views of an editable document
|
||||||
|
|
||||||
## Iterator invalidation
|
## Iterator invalidation
|
||||||
|
|
||||||
All operations that add values to an **array** ([`push_back`](push_back.md) , [`operator+=`](operator+=.md),
|
All operations that add values to an **array** ([`push_back`](push_back.md) , [`operator+=`](operator+=.md),
|
||||||
@@ -172,7 +188,7 @@ The class satisfies the following concept requirements:
|
|||||||
Functions to inspect the type of a JSON value.
|
Functions to inspect the type of a JSON value.
|
||||||
|
|
||||||
- [**type**](type.md) - return the type of the JSON value
|
- [**type**](type.md) - return the type of the JSON value
|
||||||
- [**operator value_t**](operator_value_t.md) - return the type of the JSON value
|
- [`operator value_t`](operator_value_t.md) - return the type of the JSON value
|
||||||
- [**type_name**](type_name.md) - return the type as string
|
- [**type_name**](type_name.md) - return the type as string
|
||||||
- [**is_primitive**](is_primitive.md) - return whether the type is primitive
|
- [**is_primitive**](is_primitive.md) - return whether the type is primitive
|
||||||
- [**is_structured**](is_structured.md) - return whether the type is structured
|
- [**is_structured**](is_structured.md) - return whether the type is structured
|
||||||
@@ -201,7 +217,7 @@ Direct access to the stored value of a JSON value.
|
|||||||
- [**get_to**](get_to.md) - get a value and write it to a destination
|
- [**get_to**](get_to.md) - get a value and write it to a destination
|
||||||
- [**get_ptr**](get_ptr.md) - get a pointer value
|
- [**get_ptr**](get_ptr.md) - get a pointer value
|
||||||
- [**get_ref**](get_ref.md) - get a reference value
|
- [**get_ref**](get_ref.md) - get a reference value
|
||||||
- [**operator ValueType**](operator_ValueType.md) - get a value
|
- [`operator ValueType`](operator_ValueType.md) - get a value
|
||||||
- [**get_binary**](get_binary.md) - get a binary value
|
- [**get_binary**](get_binary.md) - get a binary value
|
||||||
- [**as_base_class**](as_base_class.md) - access the custom base class
|
- [**as_base_class**](as_base_class.md) - access the custom base class
|
||||||
|
|
||||||
@@ -342,7 +358,15 @@ Access to the JSON value
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format](https://tools.ietf.org/html/rfc8259)
|
- [RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format](https://tools.ietf.org/html/rfc8259) -
|
||||||
|
specification of the JSON data interchange format
|
||||||
|
- [`basic_json_document`](../basic_json_document/index.md) - / [`basic_json_view`](../basic_json_view/index.md) - parse a JSON
|
||||||
|
text into a flat index and read it through a view
|
||||||
|
- [Zero-copy JSON views](../../features/json_view.md) - when to use a document and a view instead of a `basic_json`
|
||||||
|
- [Types](../../features/types/index.md) - how JSON values are stored and which types exist
|
||||||
|
- [Converting values](../../features/conversions.md) - get values out of a JSON value and put values in
|
||||||
|
- [Creating JSON values](../../features/creating_values.md) - all the ways to build a JSON value
|
||||||
|
- [Arbitrary Type Conversions](../../features/arbitrary_types.md) - convert your own types to and from JSON
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -53,8 +53,9 @@ bon8
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [sax_parse](sax_parse.md) generic SAX parse interface, taking an `input_format_t` to select the input format
|
- [`sax_parse`](sax_parse.md) - generic SAX parse interface, taking an `input_format_t` to select the input format
|
||||||
- [cbor_tag_handler_t](cbor_tag_handler_t.md) configures how CBOR tags are treated while parsing
|
- [`cbor_tag_handler_t`](cbor_tag_handler_t.md) - configures how CBOR tags are treated while parsing
|
||||||
|
- [Binary Formats](../../features/binary_formats/index.md) - CBOR, MessagePack, BSON, and other formats
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -185,10 +185,11 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [emplace](emplace.md) add a value to an object
|
- [`emplace`](emplace.md) - add a value to an object
|
||||||
- [emplace_back](emplace_back.md) add a value to an array
|
- [`emplace_back`](emplace_back.md) - add a value to an array
|
||||||
- [push_back](push_back.md) add a value to an array/object
|
- [`push_back`](push_back.md) - add a value to an array/object
|
||||||
- [update](update.md) merges objects
|
- [`update`](update.md) - merges objects
|
||||||
|
- [Modifying values](../../features/modifying_values.md) - the article on modifying values
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ classDiagram
|
|||||||
style json_invalid_iterator fill:#CCCCFF
|
style json_invalid_iterator fill:#CCCCFF
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<p class="nj-caption" markdown>Class hierarchy of the library's exceptions; arrows point from a derived class to its
|
||||||
|
base class, and the highlighted box is `basic_json::invalid_iterator`.</p>
|
||||||
|
|
||||||
## Member functions
|
## Member functions
|
||||||
|
|
||||||
- **what** - returns explanatory string
|
- **what** - returns explanatory string
|
||||||
@@ -66,13 +69,15 @@ classDiagram
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [`exception`](exception.md) for the base class of all exceptions thrown by the library
|
- [`exception`](exception.md) - the base class of all exceptions thrown by the library
|
||||||
- [List of iterator errors](../../home/exceptions.md#iterator-errors)
|
- [List of iterator errors](../../home/exceptions.md#iterator-errors) - overview of iterator errors (`invalid_iterator`)
|
||||||
- [`parse_error`](parse_error.md) for exceptions indicating a parse error
|
- [`parse_error`](parse_error.md) - exceptions indicating a parse error
|
||||||
- [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type
|
- [`type_error`](type_error.md) - exceptions indicating executing a member function with a wrong type
|
||||||
- [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range
|
- [`out_of_range`](out_of_range.md) - exceptions indicating access out of the defined range
|
||||||
- [`other_error`](other_error.md) for exceptions indicating other library errors
|
- [`other_error`](other_error.md) - exceptions indicating other library errors
|
||||||
|
- [Exceptions](../../home/exceptions.md) - all exceptions and their error codes
|
||||||
|
- [`JSON_DIAGNOSTICS`](../macros/json_diagnostics.md) - extended exception messages with the path of the failing value
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
- Since version 3.0.0.
|
- Added in version 3.0.0.
|
||||||
@@ -36,11 +36,12 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [is_object](is_object.md) checks whether the JSON value is an object
|
- [`is_object`](is_object.md) - checks whether the JSON value is an object
|
||||||
- [is_structured](is_structured.md) checks whether the JSON value is structured (array or object)
|
- [`is_structured`](is_structured.md) - checks whether the JSON value is structured (array or object)
|
||||||
- [type](type.md) returns the type of the JSON value
|
- [`type`](type.md) - returns the type of the JSON value
|
||||||
- [array_t](array_t.md) the type used to store JSON arrays
|
- [`array_t`](array_t.md) - the type used to store JSON arrays
|
||||||
- [basic_json_view::is_array](../basic_json_view/is_array.md) - the same check on a zero-copy view
|
- [`basic_json_view::is_array`](../basic_json_view/is_array.md) - the same check on a zero-copy view
|
||||||
|
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -36,10 +36,11 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [is_primitive](is_primitive.md) checks whether the JSON value is primitive
|
- [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
|
||||||
- [binary_t](binary_t.md) the type used to store binary values
|
- [`is_primitive`](is_primitive.md) - checks whether the JSON value is primitive
|
||||||
- [get_binary](get_binary.md) returns a reference to the stored binary value
|
- [`binary_t`](binary_t.md) - the type used to store binary values
|
||||||
- [basic_json_view::is_binary](../basic_json_view/is_binary.md) - the same check on a zero-copy view
|
- [`get_binary`](get_binary.md) - returns a reference to the stored binary value
|
||||||
|
- [`basic_json_view::is_binary`](../basic_json_view/is_binary.md) - the same check on a zero-copy view
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -36,9 +36,10 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [boolean_t](boolean_t.md) the type used to store JSON booleans
|
- [`boolean_t`](boolean_t.md) - the type used to store JSON booleans
|
||||||
- [is_primitive](is_primitive.md) checks whether the JSON value is primitive
|
- [`is_primitive`](is_primitive.md) - checks whether the JSON value is primitive
|
||||||
- [basic_json_view::is_boolean](../basic_json_view/is_boolean.md) - the same check on a zero-copy view
|
- [`basic_json_view::is_boolean`](../basic_json_view/is_boolean.md) - the same check on a zero-copy view
|
||||||
|
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -87,8 +87,9 @@ with `allow_exceptions` set to `#!cpp false`: a parse error then yields a discar
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [basic_json_view::is_discarded](../basic_json_view/is_discarded.md) - the corresponding check on a zero-copy view,
|
- [`basic_json_view::is_discarded`](../basic_json_view/is_discarded.md) - the corresponding check on a zero-copy view,
|
||||||
which is `#!cpp true` if the view refers to no value
|
which is `#!cpp true` if the view refers to no value
|
||||||
|
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -36,11 +36,12 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [is_array](is_array.md) checks whether the JSON value is an array
|
- [`is_array`](is_array.md) - checks whether the JSON value is an array
|
||||||
- [is_object](is_object.md) checks whether the JSON value is an object
|
- [`is_object`](is_object.md) - checks whether the JSON value is an object
|
||||||
- [type](type.md) returns the type of the JSON value
|
- [`type`](type.md) - returns the type of the JSON value
|
||||||
- [value_t](value_t.md) the enumeration of JSON types
|
- [`value_t`](value_t.md) - the enumeration of JSON types
|
||||||
- [basic_json_view::is_null](../basic_json_view/is_null.md) - the same check on a zero-copy view
|
- [`basic_json_view::is_null`](../basic_json_view/is_null.md) - the same check on a zero-copy view
|
||||||
|
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -46,10 +46,12 @@ constexpr bool is_number() const noexcept
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [is_number_integer()](is_number_integer.md) check if the value is an integer or unsigned integer number
|
- [`is_number_integer()`](is_number_integer.md) - check if the value is an integer or unsigned integer number
|
||||||
- [is_number_unsigned()](is_number_unsigned.md) check if the value is an unsigned integer number
|
- [`is_number_unsigned()`](is_number_unsigned.md) - check if the value is an unsigned integer number
|
||||||
- [is_number_float()](is_number_float.md) check if the value is a floating-point number
|
- [`is_number_float()`](is_number_float.md) - check if the value is a floating-point number
|
||||||
- [basic_json_view::is_number](../basic_json_view/is_number.md) - the same check on a zero-copy view
|
- [`basic_json_view::is_number`](../basic_json_view/is_number.md) - the same check on a zero-copy view
|
||||||
|
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
|
||||||
|
- [Number Handling](../../features/types/number_handling.md) - how numbers are stored and converted
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -37,10 +37,12 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [is_number()](is_number.md) check if the value is a number
|
- [`is_number()`](is_number.md) - check if the value is a number
|
||||||
- [is_number_integer()](is_number_integer.md) check if the value is an integer or unsigned integer number
|
- [`is_number_integer()`](is_number_integer.md) - check if the value is an integer or unsigned integer number
|
||||||
- [is_number_unsigned()](is_number_unsigned.md) check if the value is an unsigned integer number
|
- [`is_number_unsigned()`](is_number_unsigned.md) - check if the value is an unsigned integer number
|
||||||
- [basic_json_view::is_number_float](../basic_json_view/is_number_float.md) - the same check on a zero-copy view
|
- [`basic_json_view::is_number_float`](../basic_json_view/is_number_float.md) - the same check on a zero-copy view
|
||||||
|
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
|
||||||
|
- [Number Handling](../../features/types/number_handling.md) - how numbers are stored and converted
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -37,10 +37,12 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [is_number()](is_number.md) check if the value is a number
|
- [`is_number()`](is_number.md) - check if the value is a number
|
||||||
- [is_number_unsigned()](is_number_unsigned.md) check if the value is an unsigned integer number
|
- [`is_number_unsigned()`](is_number_unsigned.md) - check if the value is an unsigned integer number
|
||||||
- [is_number_float()](is_number_float.md) check if the value is a floating-point number
|
- [`is_number_float()`](is_number_float.md) - check if the value is a floating-point number
|
||||||
- [basic_json_view::is_number_integer](../basic_json_view/is_number_integer.md) - the same check on a zero-copy view
|
- [`basic_json_view::is_number_integer`](../basic_json_view/is_number_integer.md) - the same check on a zero-copy view
|
||||||
|
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
|
||||||
|
- [Number Handling](../../features/types/number_handling.md) - how numbers are stored and converted
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -40,10 +40,12 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [is_number()](is_number.md) check if the value is a number
|
- [`is_number()`](is_number.md) - check if the value is a number
|
||||||
- [is_number_integer()](is_number_integer.md) check if the value is an integer or unsigned integer number
|
- [`is_number_integer()`](is_number_integer.md) - check if the value is an integer or unsigned integer number
|
||||||
- [is_number_float()](is_number_float.md) check if the value is a floating-point number
|
- [`is_number_float()`](is_number_float.md) - check if the value is a floating-point number
|
||||||
- [basic_json_view::is_number_unsigned](../basic_json_view/is_number_unsigned.md) - the same check on a zero-copy view
|
- [`basic_json_view::is_number_unsigned`](../basic_json_view/is_number_unsigned.md) - the same check on a zero-copy view
|
||||||
|
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
|
||||||
|
- [Number Handling](../../features/types/number_handling.md) - how numbers are stored and converted
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -36,11 +36,12 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [is_array](is_array.md) checks whether the JSON value is an array
|
- [`is_array`](is_array.md) - checks whether the JSON value is an array
|
||||||
- [is_structured](is_structured.md) checks whether the JSON value is structured (array or object)
|
- [`is_structured`](is_structured.md) - checks whether the JSON value is structured (array or object)
|
||||||
- [type](type.md) returns the type of the JSON value
|
- [`type`](type.md) - returns the type of the JSON value
|
||||||
- [object_t](object_t.md) the type used to store JSON objects
|
- [`object_t`](object_t.md) - the type used to store JSON objects
|
||||||
- [basic_json_view::is_object](../basic_json_view/is_object.md) - the same check on a zero-copy view
|
- [`basic_json_view::is_object`](../basic_json_view/is_object.md) - the same check on a zero-copy view
|
||||||
|
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -56,13 +56,14 @@ This library extends primitive types to binary types, because binary types are r
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [is_structured()](is_structured.md) returns whether the JSON value is structured
|
- [`is_structured()`](is_structured.md) - returns whether the JSON value is structured
|
||||||
- [is_null()](is_null.md) returns whether the JSON value is `null`
|
- [`is_null()`](is_null.md) - returns whether the JSON value is `null`
|
||||||
- [is_string()](is_string.md) returns whether the JSON value is a string
|
- [`is_string()`](is_string.md) - returns whether the JSON value is a string
|
||||||
- [is_boolean()](is_boolean.md) returns whether the JSON value is a boolean
|
- [`is_boolean()`](is_boolean.md) - returns whether the JSON value is a boolean
|
||||||
- [is_number()](is_number.md) returns whether the JSON value is a number
|
- [`is_number()`](is_number.md) - returns whether the JSON value is a number
|
||||||
- [is_binary()](is_binary.md) returns whether the JSON value is a binary array
|
- [`is_binary()`](is_binary.md) - returns whether the JSON value is a binary array
|
||||||
- [basic_json_view::is_primitive](../basic_json_view/is_primitive.md) - the same check on a zero-copy view
|
- [`basic_json_view::is_primitive`](../basic_json_view/is_primitive.md) - the same check on a zero-copy view
|
||||||
|
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -36,10 +36,11 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [is_primitive](is_primitive.md) checks whether the JSON value is primitive
|
- [`is_primitive`](is_primitive.md) - checks whether the JSON value is primitive
|
||||||
- [type](type.md) returns the type of the JSON value
|
- [`type`](type.md) - returns the type of the JSON value
|
||||||
- [string_t](string_t.md) the type used to store JSON strings
|
- [`string_t`](string_t.md) - the type used to store JSON strings
|
||||||
- [basic_json_view::is_string](../basic_json_view/is_string.md) - the same check on a zero-copy view
|
- [`basic_json_view::is_string`](../basic_json_view/is_string.md) - the same check on a zero-copy view
|
||||||
|
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -54,10 +54,11 @@ Note that though strings are containers in C++, they are treated as primitive va
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [is_primitive()](is_primitive.md) returns whether JSON value is primitive
|
- [`is_primitive()`](is_primitive.md) - returns whether JSON value is primitive
|
||||||
- [is_array()](is_array.md) returns whether the value is an array
|
- [`is_array()`](is_array.md) - returns whether the value is an array
|
||||||
- [is_object()](is_object.md) returns whether the value is an object
|
- [`is_object()`](is_object.md) - returns whether the value is an object
|
||||||
- [basic_json_view::is_structured](../basic_json_view/is_structured.md) - the same check on a zero-copy view
|
- [`basic_json_view::is_structured`](../basic_json_view/is_structured.md) - the same check on a zero-copy view
|
||||||
|
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -97,15 +97,16 @@ When iterating over an array, `key()` will return the index of the element as st
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [begin](begin.md) returns an iterator to the first element
|
- [`begin`](begin.md) - returns an iterator to the first element
|
||||||
- [end](end.md) returns an iterator to one past the last element
|
- [`end`](end.md) - returns an iterator to one past the last element
|
||||||
- [basic_json_view::items](../basic_json_view/items.md) - the same range on a zero-copy view (`#!cpp const auto`,
|
- [`basic_json_view::items`](../basic_json_view/items.md) - the same range on a zero-copy view (`#!cpp const auto`,
|
||||||
not `#!cpp const auto&`: items are produced on the fly; document order, not sorted; duplicate keys are visited)
|
not `#!cpp const auto&`: items are produced on the fly; document order, not sorted; duplicate keys are visited)
|
||||||
|
- [Iterators](../../features/iterators.md#access-object-keys-during-iteration) - the article on iterating over keys and values
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
- Added `iterator_wrapper` in version 3.0.0.
|
- Added in version 3.1.0 as the replacement of the static function `iterator_wrapper`, which was available since
|
||||||
- Added `items` and deprecated `iterator_wrapper` in version 3.1.0.
|
version 1.0.0 and is deprecated since version 3.1.0.
|
||||||
- Added structured binding support in version 3.5.0.
|
- Added structured binding support in version 3.5.0.
|
||||||
|
|
||||||
!!! warning "Deprecation"
|
!!! warning "Deprecation"
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ same name. Hidden members remain accessible via [`as_base_class`](as_base_class.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [as_base_class](as_base_class.md) - access the custom base class
|
- [`as_base_class`](as_base_class.md) - access the custom base class
|
||||||
- [Template Parameter Requirements](../../features/types/template_parameters.md#custombaseclass) - the requirements for `CustomBaseClass`
|
- [Template Parameter Requirements](../../features/types/template_parameters.md#custombaseclass) - the requirements for `CustomBaseClass`
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|||||||
@@ -44,11 +44,12 @@ deserializes. See [Template Parameter Requirements](../../features/types/templat
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [adl_serializer](../adl_serializer/index.md) the default `json_serializer`
|
- [`adl_serializer`](../adl_serializer/index.md) - the default `json_serializer`
|
||||||
- [get](get.md) explicit type conversion using the `json_serializer`'s `from_json()` method
|
- [`get`](get.md) - explicit type conversion using the `json_serializer`'s `from_json()` method
|
||||||
- [get_to](get_to.md) explicit type conversion into a variable using the `json_serializer`'s `from_json()` method
|
- [`get_to`](get_to.md) - explicit type conversion into a variable using the `json_serializer`'s `from_json()` method
|
||||||
- [Arbitrary Type Conversions](../../features/arbitrary_types.md) - the article on converting between JSON values and arbitrary types
|
- [Arbitrary Type Conversions](../../features/arbitrary_types.md) - the article on converting between JSON values and arbitrary types
|
||||||
|
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the `JSONSerializer` template parameter
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
- Since version 2.0.0.
|
- Added in version 2.1.0.
|
||||||
@@ -56,9 +56,9 @@ string elements the JSON value can store which is `1`.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [size](size.md) returns the number of elements
|
- [`size`](size.md) - returns the number of elements
|
||||||
- [array_t](array_t.md) the type used to store JSON arrays
|
- [`array_t`](array_t.md) - the type used to store JSON arrays
|
||||||
- [object_t](object_t.md) the type used to store JSON objects
|
- [`object_t`](object_t.md) - the type used to store JSON objects
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -70,9 +70,10 @@ object operation (looking up a key, or adding one to the patch): logarithmic for
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396)
|
- [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396) - specification of JSON Merge Patch
|
||||||
- [merge_patch](merge_patch.md) applies a JSON Merge Patch
|
- [`merge_patch`](merge_patch.md) - applies a JSON Merge Patch
|
||||||
- [diff](diff.md) creates a diff as a JSON Patch
|
- [`diff`](diff.md) - creates a diff as a JSON Patch
|
||||||
|
- [JSON Merge Patch](../../features/merge_patch.md) - the article on JSON Merge Patch
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -65,12 +65,13 @@ returned by `#!cpp (*this)[key]`); it is read as it was when `merge_patch()` was
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396)
|
- [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396) - specification of JSON Merge Patch
|
||||||
- [patch](patch.md) apply a JSON patch
|
- [`patch`](patch.md) - apply a JSON patch
|
||||||
- [merge_diff](merge_diff.md) creates a diff as a JSON Merge Patch
|
- [`merge_diff`](merge_diff.md) - creates a diff as a JSON Merge Patch
|
||||||
|
- [JSON Merge Patch](../../features/merge_patch.md) - the article on JSON Merge Patch
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
- Added in version 3.0.0.
|
- Added in version 3.1.0.
|
||||||
- Fixed use of freed or relocated memory when `apply_patch` is `#!cpp *this` or refers to a value contained in
|
- Fixed use of freed or relocated memory when `apply_patch` is `#!cpp *this` or refers to a value contained in
|
||||||
`#!cpp *this`, in version 3.13.0.
|
`#!cpp *this`, in version 3.13.0.
|
||||||
@@ -48,8 +48,11 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [**NLOHMANN_JSON_VERSION_MAJOR**/**NLOHMANN_JSON_VERSION_MINOR**/**NLOHMANN_JSON_VERSION_PATCH**](../macros/nlohmann_json_version_major.md)
|
- [`NLOHMANN_JSON_VERSION_MAJOR`](../macros/nlohmann_json_version_major.md) /
|
||||||
\- library version information
|
[`NLOHMANN_JSON_VERSION_MINOR`](../macros/nlohmann_json_version_major.md) /
|
||||||
|
[`NLOHMANN_JSON_VERSION_PATCH`](../macros/nlohmann_json_version_major.md) - library version information
|
||||||
|
- [Integration](../../integration/index.md) - integrate the library
|
||||||
|
- [Supported Macros](../../features/macros.md) - guide to all supported macros
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -84,10 +84,11 @@ Floating-point number values are stored directly inside a `basic_json` type.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [number_integer_t](number_integer_t.md) the type used to store JSON integer numbers
|
- [`number_integer_t`](number_integer_t.md) - the type used to store JSON integer numbers
|
||||||
- [number_unsigned_t](number_unsigned_t.md) the type used to store JSON unsigned integer numbers
|
- [`number_unsigned_t`](number_unsigned_t.md) - the type used to store JSON unsigned integer numbers
|
||||||
- [is_number_float](is_number_float.md) checks whether the JSON value is a floating-point number
|
- [`is_number_float`](is_number_float.md) - checks whether the JSON value is a floating-point number
|
||||||
- [Number Handling](../../features/types/number_handling.md) - the article on number handling
|
- [Number Handling](../../features/types/number_handling.md) - the article on number handling
|
||||||
|
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the number template parameters
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -80,10 +80,11 @@ Integer number values are stored directly inside a `basic_json` type.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [number_unsigned_t](number_unsigned_t.md) the type used to store JSON unsigned integer numbers
|
- [`number_unsigned_t`](number_unsigned_t.md) - the type used to store JSON unsigned integer numbers
|
||||||
- [number_float_t](number_float_t.md) the type used to store JSON floating-point numbers
|
- [`number_float_t`](number_float_t.md) - the type used to store JSON floating-point numbers
|
||||||
- [is_number_integer](is_number_integer.md) checks whether the JSON value is a signed integer number
|
- [`is_number_integer`](is_number_integer.md) - checks whether the JSON value is a signed integer number
|
||||||
- [Number Handling](../../features/types/number_handling.md) - the article on number handling
|
- [Number Handling](../../features/types/number_handling.md) - the article on number handling
|
||||||
|
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the number template parameters
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -82,10 +82,11 @@ Integer number values are stored directly inside a `basic_json` type.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [number_integer_t](number_integer_t.md) the type used to store JSON integer numbers
|
- [`number_integer_t`](number_integer_t.md) - the type used to store JSON integer numbers
|
||||||
- [number_float_t](number_float_t.md) the type used to store JSON floating-point numbers
|
- [`number_float_t`](number_float_t.md) - the type used to store JSON floating-point numbers
|
||||||
- [is_number_unsigned](is_number_unsigned.md) checks whether the JSON value is an unsigned integer number
|
- [`is_number_unsigned`](is_number_unsigned.md) - checks whether the JSON value is an unsigned integer number
|
||||||
- [Number Handling](../../features/types/number_handling.md) - the article on number handling
|
- [Number Handling](../../features/types/number_handling.md) - the article on number handling
|
||||||
|
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the number template parameters
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,10 @@ and [`default_object_comparator_t`](default_object_comparator_t.md) otherwise.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [object_t](object_t.md) the type used to store JSON objects
|
- [`object_t`](object_t.md) - the type used to store JSON objects
|
||||||
- [default_object_comparator_t](default_object_comparator_t.md) the fallback comparator used when `object_t` has no `key_compare` member type
|
- [`default_object_comparator_t`](default_object_comparator_t.md) - the fallback comparator used when `object_t` has no `key_compare` member type
|
||||||
|
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the `ObjectType` template parameter
|
||||||
|
- [Object order](../../features/object_order.md) - preserve the insertion order of keys
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -125,10 +125,12 @@ the object is silently converted as an array of key-value pairs, which is incorr
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [array_t](array_t.md) the type used to store JSON arrays
|
- [`array_t`](array_t.md) - the type used to store JSON arrays
|
||||||
- [string_t](string_t.md) the type used to store JSON strings
|
- [`string_t`](string_t.md) - the type used to store JSON strings
|
||||||
- [object_comparator_t](object_comparator_t.md) the comparator used to order object keys
|
- [`object_comparator_t`](object_comparator_t.md) - the comparator used to order object keys
|
||||||
- [Object Order](../../features/object_order.md) - the article on object key ordering
|
- [Object Order](../../features/object_order.md) - the article on object key ordering
|
||||||
|
- [Types](../../features/types/index.md) - how objects are stored
|
||||||
|
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the `ObjectType` template parameter
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -123,11 +123,12 @@ interpreted as `object_t::value_type` or `std::initializer_list<basic_json>`, se
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [emplace_back](emplace_back.md) add a value to an array
|
- [`emplace_back`](emplace_back.md) - add a value to an array
|
||||||
- [push_back](push_back.md) add a value to an array/object
|
- [`push_back`](push_back.md) - add a value to an array/object
|
||||||
|
- [Modifying values](../../features/modifying_values.md) - the article on modifying values
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
1. Since version 1.0.0.
|
1. Added in version 1.0.0.
|
||||||
2. Since version 1.0.0.
|
2. Added in version 1.0.0.
|
||||||
3. Since version 2.0.0.
|
3. Added in version 2.0.0.
|
||||||
@@ -45,8 +45,9 @@ Linear.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [basic_json](basic_json.md) create a JSON value
|
- [`basic_json`](basic_json.md) - create a JSON value
|
||||||
- [swap](swap.md) exchanges the contents of two JSON values
|
- [`swap`](swap.md) - exchanges the contents of two JSON values
|
||||||
|
- [Creating JSON values](../../features/creating_values.md) - ways to create and assign JSON values
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -271,23 +271,25 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- documentation on [unchecked access](../../features/element_access/unchecked_access.md)
|
- [Unchecked access](../../features/element_access/unchecked_access.md) - element access without range checking
|
||||||
- documentation on [runtime assertions](../../features/assertions.md)
|
- [Runtime assertions](../../features/assertions.md) - assertions guarding against undefined behavior
|
||||||
- see [`at`](at.md) for access by reference with range checking
|
- [`at`](at.md) - access by reference with range checking
|
||||||
- see [`value`](value.md) for access with default value
|
- [`value`](value.md) - access with default value
|
||||||
- [basic_json_view::operator[]](../basic_json_view/operator%5B%5D.md) - the same access on a zero-copy view (a duplicate
|
- [`basic_json_view::operator[]`](../basic_json_view/operator%5B%5D.md) - the same access on a zero-copy view (a duplicate
|
||||||
key resolves to the first member, whereas `parse()` keeps the last; a missing key gives a discarded view instead of
|
key resolves to the first member, whereas `parse()` keeps the last; a missing key gives a discarded view instead of
|
||||||
undefined behavior)
|
undefined behavior)
|
||||||
|
- [Element Access](../../features/element_access/index.md) - overview of all ways to access elements
|
||||||
|
- [JSON Pointer](../../features/json_pointer.md) - access nested values with a pointer
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
1. Added in version 1.0.0. Fixed in version 3.13.0 to throw `#!cpp std::length_error` instead of emptying the array and
|
1. Added in version 1.0.0. Fixed in version 3.13.0 to throw `#!cpp std::length_error` instead of emptying the array and
|
||||||
accessing it out of bounds when `idx` equals the maximum value of `size_type`. A missing index in the const version
|
accessing it out of bounds when `idx` equals the maximum value of `size_type`. A missing index in the const version
|
||||||
is guarded by a runtime assertion since version 3.13.0.
|
is guarded by a runtime assertion since version 3.13.0.
|
||||||
2. Added in version 1.0.0. Added overloads for `T* key` in version 1.1.0. Removed overloads for `T* key` (replaced by 3)
|
2. Added in version 1.0.0. Added overloads for `T* key` in version 1.1.0. The `T* key` overloads forward to
|
||||||
in version 3.11.0.
|
overload 3 since version 3.11.0.
|
||||||
3. Added in version 3.11.0. Fixed in version 3.13.0 to consistently accept `std::string_view`-convertible keys, as
|
3. Added in version 3.11.0. Support for keys convertible to `std::string_view` added in version 3.13.0, consistently
|
||||||
already supported by [`at`](at.md), [`value`](value.md), [`find`](find.md), and other lookup functions.
|
across the lookup functions.
|
||||||
4. Added in version 2.0.0. A missing array index in the const version is guarded by a runtime assertion since
|
4. Added in version 2.0.0. A missing array index in the const version is guarded by a runtime assertion since
|
||||||
version 3.13.0. Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) instead of
|
version 3.13.0. Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) instead of
|
||||||
[`out_of_range.404`](../../home/exceptions.md#jsonexceptionout_of_range404) for a one-character array index that is not
|
[`out_of_range.404`](../../home/exceptions.md#jsonexceptionout_of_range404) for a one-character array index that is not
|
||||||
|
|||||||
@@ -84,11 +84,11 @@ Linear in the size of the JSON value.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [get](get.md) get a value (explicit conversion)
|
- [`get`](get.md) - get a value (explicit conversion)
|
||||||
- [Converting values](../../features/conversions.md) - the type conversions article
|
- [Converting values](../../features/conversions.md) - the type conversions article
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
- Since version 1.0.0.
|
- Added in version 1.0.0.
|
||||||
- Macros `JSON_EXPLICIT`/[`JSON_USE_IMPLICIT_CONVERSIONS`](../macros/json_use_implicit_conversions.md) added
|
- Macros `JSON_EXPLICIT`/[`JSON_USE_IMPLICIT_CONVERSIONS`](../macros/json_use_implicit_conversions.md) added
|
||||||
in version 3.9.0.
|
in version 3.9.0.
|
||||||
@@ -168,9 +168,9 @@ Linear.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [operator!=](operator_ne.md) compare for inequality
|
- [`operator!=`](operator_ne.md) - compare for inequality
|
||||||
- [operator<=>](operator_spaceship.md) comparison: 3-way (C++20)
|
- [`operator<=>`](operator_spaceship.md) - comparison: 3-way (C++20)
|
||||||
- [basic_json_view::operator==](../basic_json_view/operator_eq.md) - the same comparison on a zero-copy view, without
|
- [`basic_json_view::operator==`](../basic_json_view/operator_eq.md) - the same comparison on a zero-copy view, without
|
||||||
building a `basic_json` value for it
|
building a `basic_json` value for it
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|||||||
Loaded 100 of 971 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user