mirror of
https://github.com/nlohmann/json.git
synced 2026-10-28 16:55:41 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8fb114e45f | ||
|
|
d1235cecc9 |
No files matched your search
+7
-36
@@ -1,33 +1,3 @@
|
|||||||
# Style or vendor rule sets that do not fit a header-only library:
|
|
||||||
# altera-*, fuchsia-*, llvmlibc-*, android-cloexec-fopen, boost-use-ranges, llvm-header-guard,
|
|
||||||
# llvm-include-order, llvm-prefer-static-over-anonymous-namespace, llvm-use-ranges,
|
|
||||||
# misc-use-anonymous-namespace, google-runtime-float, google-runtime-int, hicpp-signed-bitwise,
|
|
||||||
# bugprone-signed-bitwise, hicpp-explicit-conversions, google-explicit-constructor,
|
|
||||||
# cppcoreguidelines-explicit-constructor, misc-explicit-constructor (implicit conversions are the
|
|
||||||
# API), readability-trailing-comma,
|
|
||||||
# hicpp-avoid-goto / cppcoreguidelines-avoid-goto, hicpp-no-array-decay,
|
|
||||||
# hicpp-uppercase-literal-suffix, readability-uppercase-literal-suffix, modernize-use-trailing-return-type.
|
|
||||||
# Constructs the library needs on purpose (the library supports C++11 and legacy compilers):
|
|
||||||
# cppcoreguidelines-macro-usage, cppcoreguidelines-avoid-do-while (macros),
|
|
||||||
# cppcoreguidelines-pro-bounds-*, cppcoreguidelines-pro-type-reinterpret-cast,
|
|
||||||
# cppcoreguidelines-pro-type-union-access (parsers, serializers, basic_json's value union),
|
|
||||||
# cppcoreguidelines-avoid-const-or-ref-data-members, cppcoreguidelines-rvalue-reference-param-not-moved,
|
|
||||||
# cppcoreguidelines-avoid-non-const-global-variables, misc-non-private-member-variables-in-classes,
|
|
||||||
# misc-no-recursion (value walks are recursive, bounded by detail::recursion_depth_limit()),
|
|
||||||
# modernize-type-traits, modernize-use-constraints, modernize-use-ranges, modernize-use-std-numbers,
|
|
||||||
# modernize-use-designated-initializers, modernize-use-nodiscard, modernize-concat-nested-namespaces,
|
|
||||||
# readability-redundant-typename, readability-redundant-parentheses,
|
|
||||||
# readability-redundant-access-specifiers, readability-simplify-boolean-expr,
|
|
||||||
# readability-use-concise-preprocessor-directives, modernize-use-string-view,
|
|
||||||
# modernize-use-integer-sign-comparison (needs std::cmp_less; the flagged
|
|
||||||
# static_cast<std::size_t>(end - pos) < n comparisons are deliberate)
|
|
||||||
# (all need a newer standard or compiler than C++11, or would change macro-generated or
|
|
||||||
# deliberately explicit code).
|
|
||||||
# Too noisy to be useful (numeric parsing/formatting code, doctest, tests):
|
|
||||||
# bugprone-easily-swappable-parameters, cppcoreguidelines-avoid-magic-numbers, readability-magic-numbers,
|
|
||||||
# readability-identifier-length, readability-function-cognitive-complexity, performance-enum-size,
|
|
||||||
# concurrency-mt-unsafe, misc-confusable-identifiers, misc-include-cleaner (run on its own for
|
|
||||||
# the consumer headers in cmake/ci.cmake).
|
|
||||||
# portability-avoid-pragma-once: kept disabled on purpose. #pragma once is accepted
|
# portability-avoid-pragma-once: kept disabled on purpose. #pragma once is accepted
|
||||||
# by every supported compiler, and tools/amalgamate/amalgamate.py strips it from
|
# by every supported compiler, and tools/amalgamate/amalgamate.py strips it from
|
||||||
# single_include, so there is nothing left to fix here.
|
# single_include, so there is nothing left to fix here.
|
||||||
@@ -40,14 +10,14 @@ Checks: '*,
|
|||||||
-android-cloexec-fopen,
|
-android-cloexec-fopen,
|
||||||
-boost-use-ranges,
|
-boost-use-ranges,
|
||||||
-bugprone-easily-swappable-parameters,
|
-bugprone-easily-swappable-parameters,
|
||||||
-bugprone-signed-bitwise,
|
-cert-err58-cpp,
|
||||||
|
-clang-analyzer-webkit.NoUncountedMemberChecker,
|
||||||
-concurrency-mt-unsafe,
|
-concurrency-mt-unsafe,
|
||||||
-cppcoreguidelines-avoid-const-or-ref-data-members,
|
-cppcoreguidelines-avoid-const-or-ref-data-members,
|
||||||
-cppcoreguidelines-avoid-do-while,
|
-cppcoreguidelines-avoid-do-while,
|
||||||
-cppcoreguidelines-avoid-goto,
|
-cppcoreguidelines-avoid-goto,
|
||||||
-cppcoreguidelines-avoid-magic-numbers,
|
-cppcoreguidelines-avoid-magic-numbers,
|
||||||
-cppcoreguidelines-avoid-non-const-global-variables,
|
-cppcoreguidelines-avoid-non-const-global-variables,
|
||||||
-cppcoreguidelines-explicit-constructor,
|
|
||||||
-cppcoreguidelines-macro-usage,
|
-cppcoreguidelines-macro-usage,
|
||||||
-cppcoreguidelines-pro-bounds-avoid-unchecked-container-access,
|
-cppcoreguidelines-pro-bounds-avoid-unchecked-container-access,
|
||||||
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||||
@@ -56,15 +26,19 @@ Checks: '*,
|
|||||||
-cppcoreguidelines-pro-type-reinterpret-cast,
|
-cppcoreguidelines-pro-type-reinterpret-cast,
|
||||||
-cppcoreguidelines-pro-type-union-access,
|
-cppcoreguidelines-pro-type-union-access,
|
||||||
-cppcoreguidelines-rvalue-reference-param-not-moved,
|
-cppcoreguidelines-rvalue-reference-param-not-moved,
|
||||||
|
-cppcoreguidelines-virtual-class-destructor,
|
||||||
-fuchsia-default-arguments-calls,
|
-fuchsia-default-arguments-calls,
|
||||||
-fuchsia-default-arguments-declarations,
|
-fuchsia-default-arguments-declarations,
|
||||||
-fuchsia-overloaded-operator,
|
-fuchsia-overloaded-operator,
|
||||||
-google-explicit-constructor,
|
-google-explicit-constructor,
|
||||||
|
-google-readability-function-size,
|
||||||
-google-runtime-float,
|
-google-runtime-float,
|
||||||
-google-runtime-int,
|
-google-runtime-int,
|
||||||
-hicpp-avoid-goto,
|
-hicpp-avoid-goto,
|
||||||
-hicpp-explicit-conversions,
|
-hicpp-explicit-conversions,
|
||||||
|
-hicpp-function-size,
|
||||||
-hicpp-no-array-decay,
|
-hicpp-no-array-decay,
|
||||||
|
-hicpp-no-assembler,
|
||||||
-hicpp-signed-bitwise,
|
-hicpp-signed-bitwise,
|
||||||
-hicpp-uppercase-literal-suffix,
|
-hicpp-uppercase-literal-suffix,
|
||||||
-llvm-header-guard,
|
-llvm-header-guard,
|
||||||
@@ -74,7 +48,6 @@ Checks: '*,
|
|||||||
-llvmlibc-*,
|
-llvmlibc-*,
|
||||||
-misc-use-anonymous-namespace,
|
-misc-use-anonymous-namespace,
|
||||||
-misc-confusable-identifiers,
|
-misc-confusable-identifiers,
|
||||||
-misc-explicit-constructor,
|
|
||||||
-misc-include-cleaner,
|
-misc-include-cleaner,
|
||||||
-misc-no-recursion,
|
-misc-no-recursion,
|
||||||
-misc-non-private-member-variables-in-classes,
|
-misc-non-private-member-variables-in-classes,
|
||||||
@@ -82,22 +55,20 @@ Checks: '*,
|
|||||||
-modernize-type-traits,
|
-modernize-type-traits,
|
||||||
-modernize-use-constraints,
|
-modernize-use-constraints,
|
||||||
-modernize-use-designated-initializers,
|
-modernize-use-designated-initializers,
|
||||||
-modernize-use-integer-sign-comparison,
|
|
||||||
-modernize-use-nodiscard,
|
-modernize-use-nodiscard,
|
||||||
-modernize-use-ranges,
|
-modernize-use-ranges,
|
||||||
-modernize-use-string-view,
|
|
||||||
-modernize-use-std-numbers,
|
-modernize-use-std-numbers,
|
||||||
-modernize-use-trailing-return-type,
|
-modernize-use-trailing-return-type,
|
||||||
-performance-enum-size,
|
-performance-enum-size,
|
||||||
-portability-avoid-pragma-once,
|
-portability-avoid-pragma-once,
|
||||||
-readability-function-cognitive-complexity,
|
-readability-function-cognitive-complexity,
|
||||||
|
-readability-function-size,
|
||||||
-readability-identifier-length,
|
-readability-identifier-length,
|
||||||
-readability-magic-numbers,
|
-readability-magic-numbers,
|
||||||
-readability-redundant-access-specifiers,
|
-readability-redundant-access-specifiers,
|
||||||
-readability-redundant-parentheses,
|
-readability-redundant-parentheses,
|
||||||
-readability-redundant-typename,
|
-readability-redundant-typename,
|
||||||
-readability-simplify-boolean-expr,
|
-readability-simplify-boolean-expr,
|
||||||
-readability-trailing-comma,
|
|
||||||
-readability-uppercase-literal-suffix,
|
-readability-uppercase-literal-suffix,
|
||||||
-readability-use-concise-preprocessor-directives'
|
-readability-use-concise-preprocessor-directives'
|
||||||
|
|
||||||
|
|||||||
@@ -154,15 +154,6 @@ and each page's title (H1) and declaration by
|
|||||||
[`docs/docset/generate_docset.py`](https://github.com/nlohmann/json/blob/develop/docs/docset/generate_docset.py);
|
[`docs/docset/generate_docset.py`](https://github.com/nlohmann/json/blob/develop/docs/docset/generate_docset.py);
|
||||||
`make build` reports API pages that cannot be classified.
|
`make build` reports API pages that cannot be classified.
|
||||||
|
|
||||||
A pull request that changes only the documentation, Markdown files, GitHub metadata, or license files skips the
|
|
||||||
compiler workflows (Ubuntu, macOS, Windows); the documentation and license checks still run. See
|
|
||||||
[`tools/check_path_filters`](https://github.com/nlohmann/json/tree/develop/tools/check_path_filters) for the list of
|
|
||||||
skipped files and what to do when a compiler job starts reading one of them.
|
|
||||||
|
|
||||||
Most compiler jobs run only once a maintainer adds the label "🚀 ready to merge" to a pull request; until then, a
|
|
||||||
smaller set of jobs runs on every push. See
|
|
||||||
[How CI runs](https://json.nlohmann.me/community/quality_assurance/#how-ci-runs) for the sets and when they run.
|
|
||||||
|
|
||||||
### Amalgamate the source code
|
### Amalgamate the source code
|
||||||
|
|
||||||
The single-header files
|
The single-header files
|
||||||
|
|||||||
@@ -29,6 +29,13 @@ updates:
|
|||||||
- dependency-name: mermaid
|
- dependency-name: mermaid
|
||||||
update-types: ["version-update:semver-major"]
|
update-types: ["version-update:semver-major"]
|
||||||
|
|
||||||
|
- package-ecosystem: pip
|
||||||
|
directory: /.github/requirements
|
||||||
|
schedule:
|
||||||
|
interval: daily
|
||||||
|
cooldown:
|
||||||
|
default-days: 7
|
||||||
|
|
||||||
- package-ecosystem: pip
|
- package-ecosystem: pip
|
||||||
directory: /tools/astyle
|
directory: /tools/astyle
|
||||||
schedule:
|
schedule:
|
||||||
@@ -36,7 +43,7 @@ updates:
|
|||||||
cooldown:
|
cooldown:
|
||||||
default-days: 7
|
default-days: 7
|
||||||
ignore:
|
ignore:
|
||||||
# astyle is deliberately pinned (see tools/astyle/requirements.txt): newer versions
|
# astyle is deliberately pinned (see tools/astyle/requirements.in): newer versions
|
||||||
# reformat the code, and the pinned version defines the formatting CI enforces
|
# reformat the code, and the pinned version defines the formatting CI enforces
|
||||||
- dependency-name: astyle
|
- dependency-name: astyle
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
meson==1.12.1
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#
|
||||||
|
# This file is autogenerated by pip-compile with Python 3.14
|
||||||
|
# by the following command:
|
||||||
|
#
|
||||||
|
# pip-compile --generate-hashes --no-emit-index-url --output-file=.github/requirements/meson.txt --strip-extras .github/requirements/meson.in
|
||||||
|
#
|
||||||
|
meson==1.12.1 \
|
||||||
|
--hash=sha256:930bc7542cbd9f57009e182fd014eba48cf1a0180a7b9006d2d32d8f168d8b02 \
|
||||||
|
--hash=sha256:ab0a6ca09f8ef70c564c8241fb5a23957886a0b53fb58412b5e07eaf07dba743
|
||||||
|
# via -r .github/requirements/meson.in
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
semgrep==1.182.1
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -67,10 +67,10 @@ jobs:
|
|||||||
- name: Install astyle
|
- name: Install astyle
|
||||||
run: |
|
run: |
|
||||||
python3 -mvenv venv
|
python3 -mvenv venv
|
||||||
venv/bin/pip3 install -r $MAIN_DIR/tools/astyle/requirements.txt
|
venv/bin/pip3 install --require-hashes -r $MAIN_DIR/tools/astyle/requirements.txt
|
||||||
|
|
||||||
- name: Install generate_natvis dependencies
|
- name: Install generate_natvis dependencies
|
||||||
run: pip3 install -r $NATVIS_TOOL_DIR/requirements.txt
|
run: pip3 install --require-hashes -r $MAIN_DIR/tools/generate_natvis/requirements.txt
|
||||||
|
|
||||||
- name: Regenerate the tools/macro_builder tables in macro_scope.hpp
|
- name: Regenerate the tools/macro_builder tables in macro_scope.hpp
|
||||||
run: |
|
run: |
|
||||||
@@ -163,9 +163,9 @@ jobs:
|
|||||||
python3 $GENERATOR --list-tags
|
python3 $GENERATOR --list-tags
|
||||||
TAG_COUNT=$(python3 $GENERATOR --list-tags | wc -l)
|
TAG_COUNT=$(python3 $GENERATOR --list-tags | wc -l)
|
||||||
|
|
||||||
python3 $GENERATOR --abi-tags diag,_dp,_ns --abi-tags _diag --output $RUNNER_TEMP/abi_tags.natvis
|
python3 $GENERATOR --abi-tags diag,_dp,_vns --abi-tags _diag --output $RUNNER_TEMP/abi_tags.natvis
|
||||||
grep -q '<!-- Namespace nlohmann::json_abi_diag_dp_ns -->' $RUNNER_TEMP/abi_tags.natvis
|
grep -q '<!-- Namespace nlohmann::json_abi_diag_dp_vns -->' $RUNNER_TEMP/abi_tags.natvis
|
||||||
grep -q '<!-- Namespace nlohmann::json_abi_diag_dp_ns_v[0-9_]* -->' $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 ))
|
test $(grep -c '<!-- Namespace ' $RUNNER_TEMP/abi_tags.natvis) -eq $(( $(grep -c '<!-- Namespace ' nlohmann_json.natvis) + 2 ))
|
||||||
|
|
||||||
python3 $GENERATOR --all --output $RUNNER_TEMP/all.natvis
|
python3 $GENERATOR --all --output $RUNNER_TEMP/all.natvis
|
||||||
|
|||||||
@@ -31,3 +31,12 @@ jobs:
|
|||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
- name: 'Dependency Review'
|
- name: 'Dependency Review'
|
||||||
uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0
|
uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0
|
||||||
|
with:
|
||||||
|
# Semgrep pins mcp==1.29.0 and opentelemetry-api~=1.37.0 exactly
|
||||||
|
# (.github/requirements/semgrep.txt), so these cannot be upgraded
|
||||||
|
# until Semgrep lifts its pins. They do not apply to our use: CI
|
||||||
|
# only runs `semgrep scan` on the checkout and never starts the MCP
|
||||||
|
# server (GHSA-84m7-p3x7-pcfv, StreamableHTTP sessions) or parses
|
||||||
|
# incoming trace context (GHSA-xcq7-p3pf-p88h, tracestate parsing).
|
||||||
|
# Remove the entries once a Semgrep release allows the fixed versions.
|
||||||
|
allow-ghsas: GHSA-84m7-p3x7-pcfv, GHSA-xcq7-p3pf-p88h
|
||||||
@@ -43,8 +43,7 @@ jobs:
|
|||||||
- name: flawfinder_scan
|
- name: flawfinder_scan
|
||||||
uses: david-a-wheeler/flawfinder@c4216b74cf2639ffa98503768bd6e4299b5440c9 # v2.0.20
|
uses: david-a-wheeler/flawfinder@c4216b74cf2639ffa98503768bd6e4299b5440c9 # v2.0.20
|
||||||
with:
|
with:
|
||||||
# single_include/ is generated from include/ and would report every finding twice
|
arguments: '--sarif ./'
|
||||||
arguments: "--sarif --exclude '*/single_include/*' ./"
|
|
||||||
output: 'flawfinder_results.sarif'
|
output: 'flawfinder_results.sarif'
|
||||||
|
|
||||||
- name: Upload analysis results to GitHub Security tab
|
- name: Upload analysis results to GitHub Security tab
|
||||||
|
|||||||
@@ -7,60 +7,25 @@ on:
|
|||||||
- master
|
- master
|
||||||
- release/*
|
- release/*
|
||||||
pull_request:
|
pull_request:
|
||||||
# labeled: the "🚀 ready to merge" label starts the full set (see below)
|
|
||||||
types: [opened, synchronize, reopened, labeled]
|
|
||||||
# Skip pull requests that change only files no job here reads. The list is checked by
|
|
||||||
# tools/check_path_filters/check_path_filters.py (repository_checks.yml); change both together.
|
|
||||||
paths:
|
|
||||||
- '**'
|
|
||||||
- '!docs/**'
|
|
||||||
- '!**.md'
|
|
||||||
- '!.github/*'
|
|
||||||
- '!.github/ISSUE_TEMPLATE/**'
|
|
||||||
- '!.github/external_ci/**'
|
|
||||||
- '!.github/workflows/**'
|
|
||||||
- '!.reuse/**'
|
|
||||||
- '!LICENSES/**'
|
|
||||||
- '!CITATION.cff'
|
|
||||||
- '!REUSE.toml'
|
|
||||||
# read by tools/check_build_options in the ci_meson_install job (ubuntu.yml)
|
|
||||||
- 'docs/mkdocs/docs/integration/package_managers.md'
|
|
||||||
# built by the swiftpm job (macos.yml)
|
|
||||||
- 'docs/mkdocs/docs/integration/swift/**'
|
|
||||||
- '.github/workflows/macos.yml'
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
# A run triggered by any other label gets a group of its own, so it does not
|
|
||||||
# cancel the run of the last push; its jobs are skipped.
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.event_name == 'schedule' && 'nightly' || github.ref || github.run_id }}${{ github.event.action == 'labeled' && github.event.label.name != '🚀 ready to merge' && format('-{0}', github.run_id) || '' }}
|
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
|
|
||||||
# The jobs are split into a PR set and a full set like in ubuntu.yml (see "How
|
|
||||||
# CI runs" in docs/mkdocs/docs/community/quality_assurance.md): the PR set runs
|
|
||||||
# on every push; the full set after the PR set passed, on pushes and on pull
|
|
||||||
# requests with the "🚀 ready to merge" label. tools/ci_jobs checks that every
|
|
||||||
# job belongs to exactly one set.
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
###########################################################################
|
|
||||||
# PR set
|
|
||||||
###########################################################################
|
|
||||||
|
|
||||||
macos-15:
|
macos-15:
|
||||||
if: &pr_set ${{ github.event_name != 'schedule' && (github.event.action != 'labeled' || github.event.label.name == '🚀 ready to merge') }}
|
|
||||||
runs-on: macos-15 # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md
|
runs-on: macos-15 # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
xcode: ['16.0', '16.4', '26.3']
|
xcode: ['16.0', '16.1', '16.2', '16.3', '16.4', '26.0.1', '26.1.1', '26.2', '26.3']
|
||||||
env:
|
env:
|
||||||
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||||
|
|
||||||
steps: &xcode_steps
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
@@ -72,11 +37,10 @@ jobs:
|
|||||||
run: cd build ; ctest -j 10 --output-on-failure
|
run: cd build ; ctest -j 10 --output-on-failure
|
||||||
|
|
||||||
macos-26:
|
macos-26:
|
||||||
if: *pr_set
|
|
||||||
runs-on: macos-26 # https://github.com/actions/runner-images/blob/main/images/macos/macos-26-arm64-Readme.md
|
runs-on: macos-26 # https://github.com/actions/runner-images/blob/main/images/macos/macos-26-arm64-Readme.md
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
xcode: ['26.6']
|
xcode: ['26.4.1', '26.5', '26.6']
|
||||||
env:
|
env:
|
||||||
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||||
|
|
||||||
@@ -92,13 +56,12 @@ jobs:
|
|||||||
run: cd build ; ctest -j 10 --output-on-failure
|
run: cd build ; ctest -j 10 --output-on-failure
|
||||||
|
|
||||||
xcode_standards:
|
xcode_standards:
|
||||||
if: *pr_set
|
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
standard: [14]
|
standard: [11, 14, 17, 20, 23, 26]
|
||||||
|
|
||||||
steps: &xcode_standards_steps
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
@@ -110,7 +73,6 @@ jobs:
|
|||||||
run: cd build ; ctest -j 10 --output-on-failure
|
run: cd build ; ctest -j 10 --output-on-failure
|
||||||
|
|
||||||
swiftpm:
|
swiftpm:
|
||||||
if: *pr_set
|
|
||||||
runs-on: macos-15
|
runs-on: macos-15
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
@@ -144,42 +106,3 @@ jobs:
|
|||||||
EOF
|
EOF
|
||||||
cd /tmp/json-swiftpm-consumer
|
cd /tmp/json-swiftpm-consumer
|
||||||
swift build
|
swift build
|
||||||
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
# full set: starts after the PR set passed
|
|
||||||
###########################################################################
|
|
||||||
|
|
||||||
macos-15_full:
|
|
||||||
needs: &pr_set_jobs [macos-15, macos-26, xcode_standards, swiftpm]
|
|
||||||
if: &full_set ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, '🚀 ready to merge') }}
|
|
||||||
runs-on: macos-15 # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
xcode: ['16.1', '16.2', '16.3', '26.0.1', '26.1.1', '26.2']
|
|
||||||
env:
|
|
||||||
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
|
||||||
|
|
||||||
steps: *xcode_steps
|
|
||||||
|
|
||||||
macos-26_full:
|
|
||||||
needs: *pr_set_jobs
|
|
||||||
if: *full_set
|
|
||||||
runs-on: macos-26 # https://github.com/actions/runner-images/blob/main/images/macos/macos-26-arm64-Readme.md
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
xcode: ['26.4.1', '26.5']
|
|
||||||
env:
|
|
||||||
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
|
||||||
|
|
||||||
steps: *xcode_steps
|
|
||||||
|
|
||||||
xcode_standards_full:
|
|
||||||
needs: *pr_set_jobs
|
|
||||||
if: *full_set
|
|
||||||
runs-on: macos-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
standard: [11, 17, 20, 23, 26]
|
|
||||||
|
|
||||||
steps: *xcode_standards_steps
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
name: Repository checks
|
|
||||||
|
|
||||||
# Checks that concern files the compiler workflows (ubuntu.yml, macos.yml,
|
|
||||||
# windows.yml) skip with their path filter: the documentation, the license
|
|
||||||
# information, and the CI configuration itself. This workflow has no path filter.
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- develop
|
|
||||||
- master
|
|
||||||
- release/*
|
|
||||||
pull_request:
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check_ci_configuration:
|
|
||||||
runs-on: ubuntu-26.04
|
|
||||||
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: Check the path filters of the compiler workflows
|
|
||||||
run: python3 tools/check_path_filters/check_path_filters.py
|
|
||||||
- name: Check the job sets of the compiler workflows and their documentation
|
|
||||||
run: |
|
|
||||||
python3 -m venv venv
|
|
||||||
venv/bin/pip install --quiet -r tools/ci_jobs/requirements.txt
|
|
||||||
venv/bin/python tools/ci_jobs/ci_jobs.py
|
|
||||||
|
|
||||||
ci_reuse_compliance:
|
|
||||||
runs-on: ubuntu-26.04
|
|
||||||
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: Get latest CMake and ninja
|
|
||||||
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
|
||||||
- name: Run CMake
|
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
|
||||||
- name: Build
|
|
||||||
run: cmake --build build --target ci_reuse_compliance
|
|
||||||
|
|
||||||
ci_test_documentation:
|
|
||||||
runs-on: ubuntu-26.04
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
target: [ci_test_examples, ci_test_build_documentation, ci_test_documentation_mermaid]
|
|
||||||
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
|
|
||||||
# the git-revision-date-localized plugin needs the history; a shallow clone makes the strict build fail
|
|
||||||
fetch-depth: ${{ matrix.target == 'ci_test_build_documentation' && '0' || '1' }}
|
|
||||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
|
||||||
if: matrix.target == 'ci_test_documentation_mermaid'
|
|
||||||
with:
|
|
||||||
node-version: 24
|
|
||||||
- name: Run CMake
|
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
|
||||||
- name: Build
|
|
||||||
run: cmake --build build --target ${{ matrix.target }}
|
|
||||||
@@ -53,7 +53,7 @@ jobs:
|
|||||||
# SEMGREP_APP_TOKEN is still passed through so registry auth works if a
|
# SEMGREP_APP_TOKEN is still passed through so registry auth works if a
|
||||||
# token is ever added.
|
# token is ever added.
|
||||||
- name: Install Semgrep
|
- name: Install Semgrep
|
||||||
run: python3 -m pip install --user semgrep==1.168.0
|
run: python3 -m pip install --user --require-hashes -r .github/requirements/semgrep.txt
|
||||||
|
|
||||||
# `semgrep scan --sarif` always exits 0 even with findings; continue-on-error
|
# `semgrep scan --sarif` always exits 0 even with findings; continue-on-error
|
||||||
# is a safety net so the SARIF upload still runs if the scan itself errors.
|
# is a safety net so the SARIF upload still runs if the scan itself errors.
|
||||||
|
|||||||
+263
-423
@@ -7,62 +7,17 @@ on:
|
|||||||
- master
|
- master
|
||||||
- release/*
|
- release/*
|
||||||
pull_request:
|
pull_request:
|
||||||
# labeled: the "🚀 ready to merge" label starts the full set (see below)
|
|
||||||
types: [opened, synchronize, reopened, labeled]
|
|
||||||
# Skip pull requests that change only files no job here reads. The list is checked by
|
|
||||||
# tools/check_path_filters/check_path_filters.py (repository_checks.yml); change both together.
|
|
||||||
paths:
|
|
||||||
- '**'
|
|
||||||
- '!docs/**'
|
|
||||||
- '!**.md'
|
|
||||||
- '!.github/*'
|
|
||||||
- '!.github/ISSUE_TEMPLATE/**'
|
|
||||||
- '!.github/external_ci/**'
|
|
||||||
- '!.github/workflows/**'
|
|
||||||
- '!.reuse/**'
|
|
||||||
- '!LICENSES/**'
|
|
||||||
- '!CITATION.cff'
|
|
||||||
- '!REUSE.toml'
|
|
||||||
# read by tools/check_build_options in the ci_meson_install job (ubuntu.yml)
|
|
||||||
- 'docs/mkdocs/docs/integration/package_managers.md'
|
|
||||||
# built by the swiftpm job (macos.yml)
|
|
||||||
- 'docs/mkdocs/docs/integration/swift/**'
|
|
||||||
- '.github/workflows/ubuntu.yml'
|
|
||||||
schedule:
|
|
||||||
# the nightly set (see below), on develop
|
|
||||||
- cron: '0 2 * * *'
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
# A run triggered by any other label gets a group of its own, so it does not
|
|
||||||
# cancel the run of the last push; its jobs are skipped.
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.event_name == 'schedule' && 'nightly' || github.ref || github.run_id }}${{ github.event.action == 'labeled' && github.event.label.name != '🚀 ready to merge' && format('-{0}', github.run_id) || '' }}
|
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
# The jobs are split into three sets (see "How CI runs" in
|
|
||||||
# docs/mkdocs/docs/community/quality_assurance.md):
|
|
||||||
#
|
|
||||||
# - PR set: every pull request push and every push; chosen because these jobs
|
|
||||||
# caught 92 % of the failing commits in Sep/Oct 2026.
|
|
||||||
# - full set: after the PR set passed, on pushes and on pull requests with the
|
|
||||||
# "🚀 ready to merge" label; every remaining compiler, version and standard.
|
|
||||||
# - nightly set: slow tools and rare compilers, nightly on develop, on pushes
|
|
||||||
# to master and release/*, and when started by hand.
|
|
||||||
#
|
|
||||||
# A matrix whose entries belong to different sets is split into one job per
|
|
||||||
# set; the jobs share their steps through YAML anchors. tools/ci_jobs checks
|
|
||||||
# that every job belongs to exactly one set.
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
###########################################################################
|
|
||||||
# PR set
|
|
||||||
###########################################################################
|
|
||||||
|
|
||||||
ci_test_gcc:
|
ci_test_gcc:
|
||||||
if: &pr_set ${{ github.event_name != 'schedule' && (github.event.action != 'labeled' || github.event.label.name == '🚀 ready to merge') }}
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: gcc:latest
|
container: gcc:latest
|
||||||
steps:
|
steps:
|
||||||
@@ -77,7 +32,6 @@ jobs:
|
|||||||
run: cmake --build build --target ci_test_gcc
|
run: cmake --build build --target ci_test_gcc
|
||||||
|
|
||||||
ci_meson_install:
|
ci_meson_install:
|
||||||
if: *pr_set
|
|
||||||
runs-on: ubuntu-26.04
|
runs-on: ubuntu-26.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
@@ -88,7 +42,7 @@ jobs:
|
|||||||
- name: Check that Meson and pkg-config offer the CMake options
|
- name: Check that Meson and pkg-config offer the CMake options
|
||||||
run: make check_build_options
|
run: make check_build_options
|
||||||
- name: Install Meson
|
- name: Install Meson
|
||||||
run: pip install meson
|
run: pip install --require-hashes -r .github/requirements/meson.txt
|
||||||
- name: Install with Meson
|
- name: Install with Meson
|
||||||
run: |
|
run: |
|
||||||
meson setup build-meson --prefix=${{ github.workspace }}/install
|
meson setup build-meson --prefix=${{ github.workspace }}/install
|
||||||
@@ -122,342 +76,7 @@ jobs:
|
|||||||
cmake -S tests/cmake_import/project -B build-import-split -DCMAKE_PREFIX_PATH=${{ github.workspace }}/install-split
|
cmake -S tests/cmake_import/project -B build-import-split -DCMAKE_PREFIX_PATH=${{ github.workspace }}/install-split
|
||||||
cmake --build build-import-split
|
cmake --build build-import-split
|
||||||
|
|
||||||
ci_static_analysis_ubuntu:
|
|
||||||
if: *pr_set
|
|
||||||
runs-on: ubuntu-26.04
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
target: [ci_cpplint]
|
|
||||||
steps: &static_analysis_ubuntu_steps
|
|
||||||
- name: Harden Runner
|
|
||||||
uses: step-security/harden-runner@ccd8616d44fd3846e67624a50d5aad6d37bf2d25 # v2.22.1
|
|
||||||
with:
|
|
||||||
egress-policy: audit
|
|
||||||
|
|
||||||
- name: Install Valgrind
|
|
||||||
if: matrix.target == 'ci_test_valgrind'
|
|
||||||
run: sudo apt-get update ; sudo apt-get install -y valgrind
|
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: Get latest CMake and ninja
|
|
||||||
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
|
||||||
- name: Run CMake
|
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
|
||||||
- name: Build
|
|
||||||
run: cmake --build build --target ${{ matrix.target }}
|
|
||||||
|
|
||||||
ci_static_analysis_clang:
|
|
||||||
if: *pr_set
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container: silkeh/clang:22
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
target: [ci_test_clang, ci_clang_tidy, ci_test_clang_sanitizer, ci_single_binaries]
|
|
||||||
steps: &static_analysis_clang_steps
|
|
||||||
- name: Install git, clang-tools, iwyu (ci_single_binaries), and unzip
|
|
||||||
run: apt-get update ; apt-get install -y git clang-tools iwyu unzip
|
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: Get latest CMake and ninja
|
|
||||||
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
|
||||||
- name: Run CMake
|
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
|
||||||
- name: Build
|
|
||||||
run: cmake --build build --target ${{ matrix.target }}
|
|
||||||
|
|
||||||
ci_cmake_options:
|
|
||||||
if: *pr_set
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container: ubuntu:24.04
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
target: [ci_test_diagnostics, ci_test_diagnostic_positions, ci_test_noexceptions, ci_test_noglobaludls]
|
|
||||||
steps: &cmake_options_steps
|
|
||||||
- name: Install build-essential
|
|
||||||
run: apt-get update ; apt-get install -y build-essential unzip wget git
|
|
||||||
# the CMake 3.5.0 release binary that ci_cmake_flags downloads links
|
|
||||||
# against libidn.so.11, which Ubuntu 24.04 no longer ships
|
|
||||||
- name: Install libidn11 for CMake 3.5.0
|
|
||||||
if: matrix.target == 'ci_cmake_flags'
|
|
||||||
run: |
|
|
||||||
wget -q http://archive.ubuntu.com/ubuntu/pool/main/libi/libidn/libidn11_1.33-2.2ubuntu2_amd64.deb
|
|
||||||
dpkg -i libidn11_1.33-2.2ubuntu2_amd64.deb
|
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: Get latest CMake and ninja
|
|
||||||
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
|
||||||
- name: Run CMake
|
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
|
||||||
- name: Build
|
|
||||||
run: cmake --build build --target ${{ matrix.target }}
|
|
||||||
|
|
||||||
ci_test_compilers_gcc_old:
|
|
||||||
if: *pr_set
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
compiler: ['4.8']
|
|
||||||
# official gcc:4.8/4.9/5/6 images fail to check out code (too old for
|
|
||||||
# actions/checkout); install the old compilers on top of official ubuntu:20.04
|
|
||||||
# instead, mirroring what the (now retired) custom json-ci image did.
|
|
||||||
container: ubuntu:20.04
|
|
||||||
steps: &compilers_gcc_old_steps
|
|
||||||
- name: Install g++-${{ matrix.compiler }}
|
|
||||||
run: |
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y --no-install-recommends software-properties-common ca-certificates gnupg make git
|
|
||||||
# add-apt-repository resolves the PPA through the Launchpad API,
|
|
||||||
# which intermittently times out or fails the team lookup (the plain
|
|
||||||
# "deb ..." sources below never hit Launchpad and never flake).
|
|
||||||
# Retry with backoff so a transient Launchpad blip does not fail CI.
|
|
||||||
for attempt in 1 2 3 4 5; do
|
|
||||||
add-apt-repository -y ppa:ubuntu-toolchain-r/test && break
|
|
||||||
echo "::warning::add-apt-repository ppa:ubuntu-toolchain-r/test failed (attempt ${attempt}/5); retrying"
|
|
||||||
sleep $((attempt * 10))
|
|
||||||
done
|
|
||||||
apt-add-repository -y "deb http://archive.ubuntu.com/ubuntu/ bionic main"
|
|
||||||
apt-add-repository -y "deb http://archive.ubuntu.com/ubuntu/ bionic universe"
|
|
||||||
apt-add-repository -y "deb http://archive.ubuntu.com/ubuntu/ xenial main"
|
|
||||||
apt-add-repository -y "deb http://archive.ubuntu.com/ubuntu/ xenial universe"
|
|
||||||
apt-add-repository -y "deb http://archive.ubuntu.com/ubuntu/ xenial-updates main"
|
|
||||||
apt-add-repository -y "deb http://archive.ubuntu.com/ubuntu/ xenial-updates universe"
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y --no-install-recommends g++-${{ matrix.compiler }}
|
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: Get latest CMake and ninja
|
|
||||||
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
|
||||||
- name: Run CMake
|
|
||||||
run: CXX=g++-${{ matrix.compiler }} cmake -S . -B build -DJSON_CI=On
|
|
||||||
- name: Build
|
|
||||||
run: cmake --build build --target ci_test_compiler_g++-${{ matrix.compiler }}
|
|
||||||
|
|
||||||
ci_test_compilers_clang:
|
|
||||||
if: *pr_set
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
compiler: ['3.4']
|
|
||||||
container: silkeh/clang:${{ matrix.compiler }}
|
|
||||||
steps: &compilers_clang_steps
|
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: Get latest CMake and ninja
|
|
||||||
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
|
||||||
- name: Disable filesystem support (std::filesystem is unusable) for clang 7 / 8 / 9 / 10
|
|
||||||
run: echo "JSON_FORCED_GLOBAL_COMPILE_OPTIONS=-DJSON_HAS_FILESYSTEM=0;-DJSON_HAS_EXPERIMENTAL_FILESYSTEM=0" >> "$GITHUB_ENV"
|
|
||||||
if: ${{ matrix.compiler == '7' || matrix.compiler == '8' || matrix.compiler == '9' || matrix.compiler == '10' }}
|
|
||||||
- name: Run CMake
|
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
|
||||||
- name: Build
|
|
||||||
run: cmake --build build --target ci_test_compiler_default
|
|
||||||
|
|
||||||
ci_test_standards_gcc:
|
|
||||||
if: *pr_set
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container: gcc:latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
standard: [26]
|
|
||||||
steps: &standards_gcc_steps
|
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: Get latest CMake and ninja
|
|
||||||
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
|
||||||
- name: Run CMake
|
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
|
||||||
- name: Build
|
|
||||||
run: cmake --build build --target ci_test_gcc_cxx${{ matrix.standard }}
|
|
||||||
|
|
||||||
ci_test_standards_clang:
|
|
||||||
if: *pr_set
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container: silkeh/clang:latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
standard: [26]
|
|
||||||
stdlib: [libcxx]
|
|
||||||
steps: &standards_clang_steps
|
|
||||||
- name: Install git and unzip
|
|
||||||
run: apt-get update ; apt-get install -y git unzip
|
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: Get latest CMake and ninja
|
|
||||||
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
|
||||||
- name: Run CMake
|
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
|
||||||
- name: Build with libc++
|
|
||||||
run: cmake --build build --target ci_test_clang_libcxx_cxx${{ matrix.standard }}
|
|
||||||
if: ${{ matrix.stdlib == 'libcxx' }}
|
|
||||||
- name: Build with libstdc++
|
|
||||||
run: cmake --build build --target ci_test_clang_cxx${{ matrix.standard }}
|
|
||||||
if: ${{ matrix.stdlib == 'libstdcxx' }}
|
|
||||||
|
|
||||||
ci_emscripten:
|
|
||||||
if: *pr_set
|
|
||||||
runs-on: ubuntu-26.04
|
|
||||||
steps:
|
|
||||||
- name: Harden Runner
|
|
||||||
uses: step-security/harden-runner@ccd8616d44fd3846e67624a50d5aad6d37bf2d25 # v2.22.1
|
|
||||||
with:
|
|
||||||
egress-policy: audit
|
|
||||||
|
|
||||||
- name: Install emscripten
|
|
||||||
uses: mymindstorm/setup-emsdk@4528d102f7230f0e7b276855c01ea1159be0e984 # v16
|
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: Get latest CMake and ninja
|
|
||||||
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
|
||||||
- name: Run CMake
|
|
||||||
run: cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -GNinja
|
|
||||||
- name: Build
|
|
||||||
run: cmake --build build
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
# full set: starts after the PR set passed
|
|
||||||
###########################################################################
|
|
||||||
|
|
||||||
ci_static_analysis_ubuntu_full:
|
|
||||||
needs: &pr_set_jobs [ci_test_gcc, ci_meson_install, ci_static_analysis_ubuntu, ci_static_analysis_clang, ci_cmake_options, ci_test_compilers_gcc_old, ci_test_compilers_clang, ci_test_standards_gcc, ci_test_standards_clang, ci_emscripten]
|
|
||||||
if: &full_set ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, '🚀 ready to merge') }}
|
|
||||||
runs-on: ubuntu-26.04
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
target: [ci_test_single_header, ci_cppcheck, ci_reproducible_tests, ci_non_git_tests, ci_offline_testdata]
|
|
||||||
steps: *static_analysis_ubuntu_steps
|
|
||||||
|
|
||||||
ci_static_analysis_clang_full:
|
|
||||||
needs: *pr_set_jobs
|
|
||||||
if: *full_set
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container: silkeh/clang:22
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
target: [ci_clang_analyze]
|
|
||||||
steps: *static_analysis_clang_steps
|
|
||||||
|
|
||||||
ci_cmake_options_full:
|
|
||||||
needs: *pr_set_jobs
|
|
||||||
if: *full_set
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container: ubuntu:24.04
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
target: [ci_cmake_flags, ci_test_noimplicitconversions, ci_test_legacycomparison, ci_test_disableenumserialization, ci_test_disabletuplereferenceconversion, ci_test_skiplibraryversioncheck, ci_test_simdutf, ci_test_strict_nul_handling, ci_test_delete_deprecated_functions, ci_test_no_thread_local]
|
|
||||||
steps: *cmake_options_steps
|
|
||||||
|
|
||||||
ci_test_compilers_gcc_old_full:
|
|
||||||
needs: *pr_set_jobs
|
|
||||||
if: *full_set
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
compiler: ['4.9', '5', '6']
|
|
||||||
container: ubuntu:20.04
|
|
||||||
steps: *compilers_gcc_old_steps
|
|
||||||
|
|
||||||
ci_test_compilers_gcc_full:
|
|
||||||
needs: *pr_set_jobs
|
|
||||||
if: *full_set
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
# older GCC docker images (4, 5, 6) fail to check out code
|
|
||||||
compiler: ['7', '8', '9', '10', '11', '12', '13', '14', '15', '16', 'latest']
|
|
||||||
container: gcc:${{ matrix.compiler }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: Get latest CMake and ninja
|
|
||||||
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
|
||||||
- name: Run CMake
|
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
|
||||||
- name: Build
|
|
||||||
run: cmake --build build --target ci_test_compiler_default
|
|
||||||
|
|
||||||
ci_test_compilers_clang_full:
|
|
||||||
needs: *pr_set_jobs
|
|
||||||
if: *full_set
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
compiler: ['3.5', '3.6', '3.7', '3.8', '3.9', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15-bullseye', '16', '17', '18', '19', '20', '21', '22', 'latest']
|
|
||||||
container: silkeh/clang:${{ matrix.compiler }}
|
|
||||||
steps: *compilers_clang_steps
|
|
||||||
|
|
||||||
ci_test_standards_gcc_full:
|
|
||||||
needs: *pr_set_jobs
|
|
||||||
if: *full_set
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container: gcc:latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
standard: [11, 14, 17, 20, 23]
|
|
||||||
steps: *standards_gcc_steps
|
|
||||||
|
|
||||||
ci_test_standards_clang_full:
|
|
||||||
needs: *pr_set_jobs
|
|
||||||
if: *full_set
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container: silkeh/clang:latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
standard: [11, 14, 17, 20, 23, 26]
|
|
||||||
stdlib: [libcxx, libstdcxx]
|
|
||||||
exclude:
|
|
||||||
# in the PR set
|
|
||||||
- standard: 26
|
|
||||||
stdlib: libcxx
|
|
||||||
steps: *standards_clang_steps
|
|
||||||
|
|
||||||
ci_module_cpp20:
|
|
||||||
needs: *pr_set_jobs
|
|
||||||
if: *full_set
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
container: ['gcc:latest', 'silkeh/clang:latest']
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container: ${{ matrix.container }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
# The module test uses `import std;`, which needs CMake's experimental
|
|
||||||
# import-std support. Its opt-in token is CMake-version-specific, so pin
|
|
||||||
# CMake to the version whose token is set in tests/module_cpp20/CMakeLists.txt.
|
|
||||||
- name: Get pinned CMake and ninja
|
|
||||||
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
|
||||||
with:
|
|
||||||
cmakeVersion: 4.3.4
|
|
||||||
# Clang: the std library module is provided by libc++ (the image's libstdc++
|
|
||||||
# ships none), and the image's libc++ module manifest has a broken relative
|
|
||||||
# path — repoint it at the real module sources.
|
|
||||||
- name: Use libc++ and fix its module manifest path (Clang)
|
|
||||||
if: matrix.container == 'silkeh/clang:latest'
|
|
||||||
run: |
|
|
||||||
echo "CXXFLAGS=-stdlib=libc++" >> "$GITHUB_ENV"
|
|
||||||
mkdir -p /usr/lib/share && ln -sf /usr/lib/llvm-*/share/libc++ /usr/lib/share/libc++
|
|
||||||
- name: Run CMake
|
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
|
||||||
- name: Build
|
|
||||||
run: cmake --build build --target ci_module_cpp20
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
# nightly set
|
|
||||||
###########################################################################
|
|
||||||
|
|
||||||
ci_infer:
|
ci_infer:
|
||||||
if: &nightly_set ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref != 'refs/heads/develop') }}
|
|
||||||
runs-on: ubuntu-26.04
|
runs-on: ubuntu-26.04
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
@@ -486,16 +105,76 @@ jobs:
|
|||||||
path: ${{ github.workspace }}/build/build_infer/infer-out/report.txt
|
path: ${{ github.workspace }}/build/build_infer/infer-out/report.txt
|
||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
|
|
||||||
ci_static_analysis_ubuntu_nightly:
|
ci_static_analysis_ubuntu:
|
||||||
if: *nightly_set
|
|
||||||
runs-on: ubuntu-26.04
|
runs-on: ubuntu-26.04
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
target: [ci_test_valgrind]
|
target: [ci_test_single_header, ci_cppcheck, ci_cpplint, ci_reproducible_tests, ci_non_git_tests, ci_offline_testdata, ci_reuse_compliance, ci_test_valgrind]
|
||||||
steps: *static_analysis_ubuntu_steps
|
steps:
|
||||||
|
- name: Harden Runner
|
||||||
|
uses: step-security/harden-runner@ccd8616d44fd3846e67624a50d5aad6d37bf2d25 # v2.22.1
|
||||||
|
with:
|
||||||
|
egress-policy: audit
|
||||||
|
|
||||||
|
- name: Install Valgrind
|
||||||
|
if: matrix.target == 'ci_test_valgrind'
|
||||||
|
run: sudo apt-get update ; sudo apt-get install -y valgrind
|
||||||
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Get latest CMake and ninja
|
||||||
|
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
||||||
|
- name: Run CMake
|
||||||
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build build --target ${{ matrix.target }}
|
||||||
|
|
||||||
|
ci_static_analysis_clang:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: silkeh/clang:22
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
target: [ci_test_clang, ci_clang_tidy, ci_test_clang_sanitizer, ci_clang_analyze, ci_single_binaries]
|
||||||
|
steps:
|
||||||
|
- name: Install git, clang-tools, iwyu (ci_single_binaries), and unzip
|
||||||
|
run: apt-get update ; apt-get install -y git clang-tools iwyu unzip
|
||||||
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Get latest CMake and ninja
|
||||||
|
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
||||||
|
- name: Run CMake
|
||||||
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build build --target ${{ matrix.target }}
|
||||||
|
|
||||||
|
ci_cmake_options:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: ubuntu:24.04
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
target: [ci_cmake_flags, ci_test_diagnostics, ci_test_diagnostic_positions, ci_test_noexceptions, ci_test_noimplicitconversions, ci_test_legacycomparison, ci_test_noglobaludls, ci_test_disableenumserialization, ci_test_disabletuplereferenceconversion, ci_test_skiplibraryversioncheck, ci_test_simdutf, ci_test_strict_nul_handling, ci_test_delete_deprecated_functions, ci_test_no_thread_local]
|
||||||
|
steps:
|
||||||
|
- name: Install build-essential
|
||||||
|
run: apt-get update ; apt-get install -y build-essential unzip wget git
|
||||||
|
# the CMake 3.5.0 release binary that ci_cmake_flags downloads links
|
||||||
|
# against libidn.so.11, which Ubuntu 24.04 no longer ships
|
||||||
|
- name: Install libidn11 for CMake 3.5.0
|
||||||
|
if: matrix.target == 'ci_cmake_flags'
|
||||||
|
run: |
|
||||||
|
wget -q http://archive.ubuntu.com/ubuntu/pool/main/libi/libidn/libidn11_1.33-2.2ubuntu2_amd64.deb
|
||||||
|
dpkg -i libidn11_1.33-2.2ubuntu2_amd64.deb
|
||||||
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Get latest CMake and ninja
|
||||||
|
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
||||||
|
- name: Run CMake
|
||||||
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build build --target ${{ matrix.target }}
|
||||||
|
|
||||||
ci_test_coverage:
|
ci_test_coverage:
|
||||||
if: *nightly_set
|
|
||||||
runs-on: ubuntu-26.04
|
runs-on: ubuntu-26.04
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
@@ -529,8 +208,128 @@ jobs:
|
|||||||
path-to-lcov: ${{ github.workspace }}/build/json.info.filtered.noexcept
|
path-to-lcov: ${{ github.workspace }}/build/json.info.filtered.noexcept
|
||||||
fail-on-error: false
|
fail-on-error: false
|
||||||
|
|
||||||
|
ci_test_compilers_gcc_old:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
compiler: ['4.8', '4.9', '5', '6']
|
||||||
|
# official gcc:4.8/4.9/5/6 images fail to check out code (too old for
|
||||||
|
# actions/checkout); install the old compilers on top of official ubuntu:20.04
|
||||||
|
# instead, mirroring what the (now retired) custom json-ci image did.
|
||||||
|
container: ubuntu:20.04
|
||||||
|
steps:
|
||||||
|
- name: Install g++-${{ matrix.compiler }}
|
||||||
|
run: |
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y --no-install-recommends software-properties-common ca-certificates gnupg make git
|
||||||
|
# add-apt-repository resolves the PPA through the Launchpad API,
|
||||||
|
# which intermittently times out or fails the team lookup (the plain
|
||||||
|
# "deb ..." sources below never hit Launchpad and never flake).
|
||||||
|
# Retry with backoff so a transient Launchpad blip does not fail CI.
|
||||||
|
for attempt in 1 2 3 4 5; do
|
||||||
|
add-apt-repository -y ppa:ubuntu-toolchain-r/test && break
|
||||||
|
echo "::warning::add-apt-repository ppa:ubuntu-toolchain-r/test failed (attempt ${attempt}/5); retrying"
|
||||||
|
sleep $((attempt * 10))
|
||||||
|
done
|
||||||
|
apt-add-repository -y "deb http://archive.ubuntu.com/ubuntu/ bionic main"
|
||||||
|
apt-add-repository -y "deb http://archive.ubuntu.com/ubuntu/ bionic universe"
|
||||||
|
apt-add-repository -y "deb http://archive.ubuntu.com/ubuntu/ xenial main"
|
||||||
|
apt-add-repository -y "deb http://archive.ubuntu.com/ubuntu/ xenial universe"
|
||||||
|
apt-add-repository -y "deb http://archive.ubuntu.com/ubuntu/ xenial-updates main"
|
||||||
|
apt-add-repository -y "deb http://archive.ubuntu.com/ubuntu/ xenial-updates universe"
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y --no-install-recommends g++-${{ matrix.compiler }}
|
||||||
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Get latest CMake and ninja
|
||||||
|
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
||||||
|
- name: Run CMake
|
||||||
|
run: CXX=g++-${{ matrix.compiler }} cmake -S . -B build -DJSON_CI=On
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build build --target ci_test_compiler_g++-${{ matrix.compiler }}
|
||||||
|
|
||||||
|
ci_test_compilers_gcc:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
# older GCC docker images (4, 5, 6) fail to check out code
|
||||||
|
compiler: ['7', '8', '9', '10', '11', '12', '13', '14', '15', '16', 'latest']
|
||||||
|
container: gcc:${{ matrix.compiler }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Get latest CMake and ninja
|
||||||
|
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
||||||
|
- name: Run CMake
|
||||||
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build build --target ci_test_compiler_default
|
||||||
|
|
||||||
|
ci_test_compilers_clang:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
compiler: ['3.4', '3.5', '3.6', '3.7', '3.8', '3.9', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15-bullseye', '16', '17', '18', '19', '20', '21', '22', 'latest']
|
||||||
|
container: silkeh/clang:${{ matrix.compiler }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Get latest CMake and ninja
|
||||||
|
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
||||||
|
- name: Disable filesystem support (std::filesystem is unusable) for clang 7 / 8 / 9 / 10
|
||||||
|
run: echo "JSON_FORCED_GLOBAL_COMPILE_OPTIONS=-DJSON_HAS_FILESYSTEM=0;-DJSON_HAS_EXPERIMENTAL_FILESYSTEM=0" >> "$GITHUB_ENV"
|
||||||
|
if: ${{ matrix.compiler == '7' || matrix.compiler == '8' || matrix.compiler == '9' || matrix.compiler == '10' }}
|
||||||
|
- name: Run CMake
|
||||||
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build build --target ci_test_compiler_default
|
||||||
|
|
||||||
|
ci_test_standards_gcc:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: gcc:latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
standard: [11, 14, 17, 20, 23, 26]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Get latest CMake and ninja
|
||||||
|
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
||||||
|
- name: Run CMake
|
||||||
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build build --target ci_test_gcc_cxx${{ matrix.standard }}
|
||||||
|
|
||||||
|
ci_test_standards_clang:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: silkeh/clang:latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
standard: [11, 14, 17, 20, 23, 26]
|
||||||
|
stdlib: [libcxx, libstdcxx]
|
||||||
|
steps:
|
||||||
|
- name: Install git and unzip
|
||||||
|
run: apt-get update ; apt-get install -y git unzip
|
||||||
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Get latest CMake and ninja
|
||||||
|
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
||||||
|
- name: Run CMake
|
||||||
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
|
- name: Build with libc++
|
||||||
|
run: cmake --build build --target ci_test_clang_libcxx_cxx${{ matrix.standard }}
|
||||||
|
if: ${{ matrix.stdlib == 'libcxx' }}
|
||||||
|
- name: Build with libstdc++
|
||||||
|
run: cmake --build build --target ci_test_clang_cxx${{ matrix.standard }}
|
||||||
|
if: ${{ matrix.stdlib == 'libstdcxx' }}
|
||||||
|
|
||||||
ci_cuda_example:
|
ci_cuda_example:
|
||||||
if: *nightly_set
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
@@ -553,8 +352,37 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build build --target ci_cuda_example
|
run: cmake --build build --target ci_cuda_example
|
||||||
|
|
||||||
|
ci_module_cpp20:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
container: ['gcc:latest', 'silkeh/clang:latest']
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: ${{ matrix.container }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
# The module test uses `import std;`, which needs CMake's experimental
|
||||||
|
# import-std support. Its opt-in token is CMake-version-specific, so pin
|
||||||
|
# CMake to the version whose token is set in tests/module_cpp20/CMakeLists.txt.
|
||||||
|
- name: Get pinned CMake and ninja
|
||||||
|
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
||||||
|
with:
|
||||||
|
cmakeVersion: 4.3.4
|
||||||
|
# Clang: the std library module is provided by libc++ (the image's libstdc++
|
||||||
|
# ships none), and the image's libc++ module manifest has a broken relative
|
||||||
|
# path — repoint it at the real module sources.
|
||||||
|
- name: Use libc++ and fix its module manifest path (Clang)
|
||||||
|
if: matrix.container == 'silkeh/clang:latest'
|
||||||
|
run: |
|
||||||
|
echo "CXXFLAGS=-stdlib=libc++" >> "$GITHUB_ENV"
|
||||||
|
mkdir -p /usr/lib/share && ln -sf /usr/lib/llvm-*/share/libc++ /usr/lib/share/libc++
|
||||||
|
- name: Run CMake
|
||||||
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build build --target ci_module_cpp20
|
||||||
|
|
||||||
ci_icpc:
|
ci_icpc:
|
||||||
if: *nightly_set
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# Intel discontinued the classic icc/icpc compiler in oneAPI 2024.0; this is
|
# Intel discontinued the classic icc/icpc compiler in oneAPI 2024.0; this is
|
||||||
# Intel's own last officially published image that still includes it.
|
# Intel's own last officially published image that still includes it.
|
||||||
@@ -574,7 +402,6 @@ jobs:
|
|||||||
run: cmake --build build --target ci_icpc
|
run: cmake --build build --target ci_icpc
|
||||||
|
|
||||||
ci_icpx:
|
ci_icpx:
|
||||||
if: *nightly_set
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: intel/oneapi-hpckit:latest
|
container: intel/oneapi-hpckit:latest
|
||||||
steps:
|
steps:
|
||||||
@@ -589,7 +416,6 @@ jobs:
|
|||||||
run: cmake --build build --target ci_icpx
|
run: cmake --build build --target ci_icpx
|
||||||
|
|
||||||
ci_nvhpc:
|
ci_nvhpc:
|
||||||
if: *nightly_set
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: nvcr.io/nvidia/nvhpc:25.5-devel-cuda12.9-ubuntu22.04
|
container: nvcr.io/nvidia/nvhpc:25.5-devel-cuda12.9-ubuntu22.04
|
||||||
steps:
|
steps:
|
||||||
@@ -603,10 +429,54 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build build --target ci_nvhpc
|
run: cmake --build build --target ci_nvhpc
|
||||||
|
|
||||||
|
ci_emscripten:
|
||||||
|
runs-on: ubuntu-26.04
|
||||||
|
steps:
|
||||||
|
- name: Harden Runner
|
||||||
|
uses: step-security/harden-runner@ccd8616d44fd3846e67624a50d5aad6d37bf2d25 # v2.22.1
|
||||||
|
with:
|
||||||
|
egress-policy: audit
|
||||||
|
|
||||||
|
- name: Install emscripten
|
||||||
|
uses: mymindstorm/setup-emsdk@4528d102f7230f0e7b276855c01ea1159be0e984 # v16
|
||||||
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Get latest CMake and ninja
|
||||||
|
uses: lukka/get-cmake@a89e43e22a96abafcd7a62db652a65ecd33052c9 # v4.4.4
|
||||||
|
- name: Run CMake
|
||||||
|
run: cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -GNinja
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build build
|
||||||
|
|
||||||
|
ci_test_documentation:
|
||||||
|
runs-on: ubuntu-26.04
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
target: [ci_test_examples, ci_test_build_documentation, ci_test_documentation_mermaid]
|
||||||
|
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
|
||||||
|
# the git-revision-date-localized plugin needs the history; a shallow clone makes the strict build fail
|
||||||
|
fetch-depth: ${{ matrix.target == 'ci_test_build_documentation' && '0' || '1' }}
|
||||||
|
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||||
|
if: matrix.target == 'ci_test_documentation_mermaid'
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
- name: Run CMake
|
||||||
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build build --target ${{ matrix.target }}
|
||||||
|
|
||||||
# Native Linux ARM64 runner with the latest GCC. The ubuntu-24.04-arm label is
|
# Native Linux ARM64 runner with the latest GCC. The ubuntu-24.04-arm label is
|
||||||
# only available for public repositories.
|
# only available for public repositories.
|
||||||
ci_test_arm64:
|
ci_test_arm64:
|
||||||
if: *nightly_set
|
|
||||||
runs-on: ubuntu-24.04-arm
|
runs-on: ubuntu-24.04-arm
|
||||||
container: gcc:latest
|
container: gcc:latest
|
||||||
steps:
|
steps:
|
||||||
@@ -621,33 +491,3 @@ jobs:
|
|||||||
run: cmake -S . -B build -DJSON_CI=On
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build build --target ci_test_compiler_default
|
run: cmake --build build --target ci_test_compiler_default
|
||||||
|
|
||||||
# A failure of a scheduled run opens an issue, or comments on the open one.
|
|
||||||
nightly_report:
|
|
||||||
needs: [ci_infer, ci_static_analysis_ubuntu_nightly, ci_test_coverage, ci_cuda_example, ci_icpc, ci_icpx, ci_nvhpc, ci_test_arm64]
|
|
||||||
if: ${{ always() && github.event_name == 'schedule' && contains(needs.*.result, 'failure') }}
|
|
||||||
runs-on: ubuntu-26.04
|
|
||||||
permissions:
|
|
||||||
issues: write
|
|
||||||
steps:
|
|
||||||
- name: Harden Runner
|
|
||||||
uses: step-security/harden-runner@ccd8616d44fd3846e67624a50d5aad6d37bf2d25 # v2.22.1
|
|
||||||
with:
|
|
||||||
egress-policy: audit
|
|
||||||
|
|
||||||
- name: Open or update the nightly failure issue
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ github.token }}
|
|
||||||
GH_REPO: ${{ github.repository }}
|
|
||||||
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
|
||||||
WORKFLOW: ${{ github.workflow }}
|
|
||||||
SHA: ${{ github.sha }}
|
|
||||||
run: |
|
|
||||||
title="Nightly CI failure (${WORKFLOW})"
|
|
||||||
body="The nightly run of ${WORKFLOW} on ${SHA:0:10} failed: ${RUN_URL}"
|
|
||||||
number=$(gh issue list --state open --search "in:title \"${title}\"" --json number,title --jq "map(select(.title == \"${title}\")) | .[0].number // empty")
|
|
||||||
if [ -n "$number" ]; then
|
|
||||||
gh issue comment "$number" --body "$body"
|
|
||||||
else
|
|
||||||
gh issue create --title "$title" --body "$body"
|
|
||||||
fi
|
|
||||||
+33
-215
@@ -7,62 +7,23 @@ on:
|
|||||||
- master
|
- master
|
||||||
- release/*
|
- release/*
|
||||||
pull_request:
|
pull_request:
|
||||||
# labeled: the "🚀 ready to merge" label starts the full set (see below)
|
|
||||||
types: [opened, synchronize, reopened, labeled]
|
|
||||||
# Skip pull requests that change only files no job here reads. The list is checked by
|
|
||||||
# tools/check_path_filters/check_path_filters.py (repository_checks.yml); change both together.
|
|
||||||
paths:
|
|
||||||
- '**'
|
|
||||||
- '!docs/**'
|
|
||||||
- '!**.md'
|
|
||||||
- '!.github/*'
|
|
||||||
- '!.github/ISSUE_TEMPLATE/**'
|
|
||||||
- '!.github/external_ci/**'
|
|
||||||
- '!.github/workflows/**'
|
|
||||||
- '!.reuse/**'
|
|
||||||
- '!LICENSES/**'
|
|
||||||
- '!CITATION.cff'
|
|
||||||
- '!REUSE.toml'
|
|
||||||
# read by tools/check_build_options in the ci_meson_install job (ubuntu.yml)
|
|
||||||
- 'docs/mkdocs/docs/integration/package_managers.md'
|
|
||||||
# built by the swiftpm job (macos.yml)
|
|
||||||
- 'docs/mkdocs/docs/integration/swift/**'
|
|
||||||
- '.github/workflows/windows.yml'
|
|
||||||
schedule:
|
|
||||||
# the nightly set (see below), on develop
|
|
||||||
- cron: '0 2 * * *'
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
# A run triggered by any other label gets a group of its own, so it does not
|
|
||||||
# cancel the run of the last push; its jobs are skipped.
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.event_name == 'schedule' && 'nightly' || github.ref || github.run_id }}${{ github.event.action == 'labeled' && github.event.label.name != '🚀 ready to merge' && format('-{0}', github.run_id) || '' }}
|
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
|
||||||
# The jobs are split into three sets like in ubuntu.yml (see "How CI runs" in
|
|
||||||
# docs/mkdocs/docs/community/quality_assurance.md): the PR set runs on every
|
|
||||||
# push; the full set after the PR set passed, on pushes and on pull requests
|
|
||||||
# with the "🚀 ready to merge" label; the nightly set nightly on develop, on
|
|
||||||
# pushes to master and release/*, and when started by hand. tools/ci_jobs
|
|
||||||
# checks that every job belongs to exactly one set.
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
###########################################################################
|
|
||||||
# PR set
|
|
||||||
###########################################################################
|
|
||||||
|
|
||||||
mingw:
|
mingw:
|
||||||
if: &pr_set ${{ github.event_name != 'schedule' && (github.event.action != 'labeled' || github.event.label.name == '🚀 ready to merge') }}
|
|
||||||
runs-on: windows-2022
|
runs-on: windows-2022
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
architecture: [x86]
|
architecture: [x64, x86]
|
||||||
|
|
||||||
steps: &mingw_steps
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
@@ -79,26 +40,15 @@ jobs:
|
|||||||
run: cd build ; ctest -j 10 -C Debug --output-on-failure
|
run: cd build ; ctest -j 10 -C Debug --output-on-failure
|
||||||
|
|
||||||
msvc:
|
msvc:
|
||||||
if: *pr_set
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
build_type: [Debug, Release]
|
||||||
- build_type: Debug
|
architecture: [Win32, x64]
|
||||||
architecture: x64
|
std_version: [default, latest]
|
||||||
std_version: default
|
|
||||||
- build_type: Release
|
|
||||||
architecture: x64
|
|
||||||
std_version: default
|
|
||||||
- build_type: Debug
|
|
||||||
architecture: Win32
|
|
||||||
std_version: default
|
|
||||||
- build_type: Release
|
|
||||||
architecture: Win32
|
|
||||||
std_version: latest
|
|
||||||
|
|
||||||
runs-on: windows-2022
|
runs-on: windows-2022
|
||||||
|
|
||||||
steps: &msvc_steps
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
@@ -127,20 +77,15 @@ jobs:
|
|||||||
# Visual Studio 2026 (v145 toolset) on the windows-2025 image. The "Visual Studio
|
# Visual Studio 2026 (v145 toolset) on the windows-2025 image. The "Visual Studio
|
||||||
# 18 2026" generator requires CMake 4.2+, so a recent CMake is fetched explicitly.
|
# 18 2026" generator requires CMake 4.2+, so a recent CMake is fetched explicitly.
|
||||||
msvc-vs2026:
|
msvc-vs2026:
|
||||||
if: *pr_set
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
build_type: [Debug, Release]
|
||||||
- build_type: Debug
|
architecture: [Win32, x64]
|
||||||
architecture: x64
|
std_version: [default, latest]
|
||||||
std_version: latest
|
|
||||||
- build_type: Release
|
|
||||||
architecture: Win32
|
|
||||||
std_version: default
|
|
||||||
|
|
||||||
runs-on: windows-2025
|
runs-on: windows-2025
|
||||||
|
|
||||||
steps: &msvc_vs2026_steps
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
@@ -172,14 +117,13 @@ jobs:
|
|||||||
# Native ARM64 Windows runner with the MSVC ARM64 toolset. The windows-11-arm
|
# Native ARM64 Windows runner with the MSVC ARM64 toolset. The windows-11-arm
|
||||||
# label is only available for public repositories.
|
# label is only available for public repositories.
|
||||||
msvc-arm64:
|
msvc-arm64:
|
||||||
if: *pr_set
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
build_type: [Debug]
|
build_type: [Debug, Release]
|
||||||
|
|
||||||
runs-on: windows-11-arm
|
runs-on: windows-11-arm
|
||||||
|
|
||||||
steps: &msvc_arm64_steps
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
@@ -197,13 +141,12 @@ jobs:
|
|||||||
run: cd build ; ctest -j 10 -C ${{ matrix.build_type }} --output-on-failure
|
run: cd build ; ctest -j 10 -C ${{ matrix.build_type }} --output-on-failure
|
||||||
|
|
||||||
clang:
|
clang:
|
||||||
if: *pr_set
|
|
||||||
runs-on: windows-2022
|
runs-on: windows-2022
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
version: [20.1.8]
|
version: [11.0.1, 12.0.1, 13.0.1, 14.0.6, 15.0.7, 16.0.6, 18.1.8, 19.1.7, 20.1.8]
|
||||||
|
|
||||||
steps: &clang_steps
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
@@ -246,8 +189,24 @@ jobs:
|
|||||||
- name: Test
|
- name: Test
|
||||||
run: cd build ; ctest -j 10 -C Debug --output-on-failure
|
run: cd build ; ctest -j 10 -C Debug --output-on-failure
|
||||||
|
|
||||||
|
clang-cl:
|
||||||
|
runs-on: windows-2022
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
architecture: [Win32, x64]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Run CMake
|
||||||
|
run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -T ClangCL -DJSON_BuildTests=On
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build build --config Debug --parallel 10
|
||||||
|
- name: Test
|
||||||
|
run: cd build ; ctest -j 10 -C Debug --output-on-failure
|
||||||
|
|
||||||
ci_module_cpp20:
|
ci_module_cpp20:
|
||||||
if: *pr_set
|
|
||||||
runs-on: windows-2022
|
runs-on: windows-2022
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
@@ -266,145 +225,4 @@ jobs:
|
|||||||
run: cmake -S . -B build -G "Visual Studio 17 2022" -DJSON_CI=ON -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /EHsc /W4 /WX"
|
run: cmake -S . -B build -G "Visual Studio 17 2022" -DJSON_CI=ON -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /EHsc /W4 /WX"
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build build --config Debug --target ci_module_cpp20
|
run: cmake --build build --config Debug --target ci_module_cpp20
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
# full set: starts after the PR set passed
|
|
||||||
###########################################################################
|
|
||||||
|
|
||||||
msvc_full:
|
|
||||||
needs: &pr_set_jobs [mingw, msvc, msvc-vs2026, msvc-arm64, clang, ci_module_cpp20]
|
|
||||||
if: &full_set ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, '🚀 ready to merge') }}
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
build_type: [Debug, Release]
|
|
||||||
architecture: [Win32, x64]
|
|
||||||
std_version: [default, latest]
|
|
||||||
exclude:
|
|
||||||
# in the PR set
|
|
||||||
- build_type: Debug
|
|
||||||
architecture: x64
|
|
||||||
std_version: default
|
|
||||||
- build_type: Release
|
|
||||||
architecture: x64
|
|
||||||
std_version: default
|
|
||||||
- build_type: Debug
|
|
||||||
architecture: Win32
|
|
||||||
std_version: default
|
|
||||||
- build_type: Release
|
|
||||||
architecture: Win32
|
|
||||||
std_version: latest
|
|
||||||
|
|
||||||
runs-on: windows-2022
|
|
||||||
|
|
||||||
steps: *msvc_steps
|
|
||||||
|
|
||||||
# Visual Studio 2026 (v145 toolset) on the windows-2025 image. The "Visual Studio
|
|
||||||
# 18 2026" generator requires CMake 4.2+, so a recent CMake is fetched explicitly.
|
|
||||||
msvc-vs2026_full:
|
|
||||||
needs: *pr_set_jobs
|
|
||||||
if: *full_set
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
build_type: [Debug, Release]
|
|
||||||
architecture: [Win32, x64]
|
|
||||||
std_version: [default, latest]
|
|
||||||
exclude:
|
|
||||||
# in the PR set
|
|
||||||
- build_type: Debug
|
|
||||||
architecture: x64
|
|
||||||
std_version: latest
|
|
||||||
- build_type: Release
|
|
||||||
architecture: Win32
|
|
||||||
std_version: default
|
|
||||||
|
|
||||||
runs-on: windows-2025
|
|
||||||
|
|
||||||
steps: *msvc_vs2026_steps
|
|
||||||
|
|
||||||
# Native ARM64 Windows runner with the MSVC ARM64 toolset. The windows-11-arm
|
|
||||||
# label is only available for public repositories.
|
|
||||||
msvc-arm64_full:
|
|
||||||
needs: *pr_set_jobs
|
|
||||||
if: *full_set
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
build_type: [Release]
|
|
||||||
|
|
||||||
runs-on: windows-11-arm
|
|
||||||
|
|
||||||
steps: *msvc_arm64_steps
|
|
||||||
|
|
||||||
clang_full:
|
|
||||||
needs: *pr_set_jobs
|
|
||||||
if: *full_set
|
|
||||||
runs-on: windows-2022
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
version: [11.0.1, 12.0.1, 13.0.1, 14.0.6, 15.0.7, 16.0.6, 18.1.8, 19.1.7]
|
|
||||||
|
|
||||||
steps: *clang_steps
|
|
||||||
|
|
||||||
clang-cl_full:
|
|
||||||
needs: *pr_set_jobs
|
|
||||||
if: *full_set
|
|
||||||
runs-on: windows-2022
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
architecture: [Win32, x64]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: Run CMake
|
|
||||||
run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -T ClangCL -DJSON_BuildTests=On
|
|
||||||
- name: Build
|
|
||||||
run: cmake --build build --config Debug --parallel 10
|
|
||||||
- name: Test
|
|
||||||
run: cd build ; ctest -j 10 -C Debug --output-on-failure
|
|
||||||
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
# nightly set
|
|
||||||
###########################################################################
|
|
||||||
|
|
||||||
mingw_nightly:
|
|
||||||
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref != 'refs/heads/develop') }}
|
|
||||||
runs-on: windows-2022
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
architecture: [x64]
|
|
||||||
|
|
||||||
steps: *mingw_steps
|
|
||||||
|
|
||||||
# A failure of a scheduled run opens an issue, or comments on the open one.
|
|
||||||
nightly_report:
|
|
||||||
needs: [mingw_nightly]
|
|
||||||
if: ${{ always() && github.event_name == 'schedule' && contains(needs.*.result, 'failure') }}
|
|
||||||
runs-on: ubuntu-26.04
|
|
||||||
permissions:
|
|
||||||
issues: write
|
|
||||||
steps:
|
|
||||||
- name: Harden Runner
|
|
||||||
uses: step-security/harden-runner@ccd8616d44fd3846e67624a50d5aad6d37bf2d25 # v2.22.1
|
|
||||||
with:
|
|
||||||
egress-policy: audit
|
|
||||||
|
|
||||||
- name: Open or update the nightly failure issue
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ github.token }}
|
|
||||||
GH_REPO: ${{ github.repository }}
|
|
||||||
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
|
||||||
WORKFLOW: ${{ github.workflow }}
|
|
||||||
SHA: ${{ github.sha }}
|
|
||||||
run: |
|
|
||||||
title="Nightly CI failure (${WORKFLOW})"
|
|
||||||
body="The nightly run of ${WORKFLOW} on ${SHA:0:10} failed: ${RUN_URL}"
|
|
||||||
number=$(gh issue list --state open --search "in:title \"${title}\"" --json number,title --jq "map(select(.title == \"${title}\")) | .[0].number // empty")
|
|
||||||
if [ -n "$number" ]; then
|
|
||||||
gh issue comment "$number" --body "$body"
|
|
||||||
else
|
|
||||||
gh issue create --title "$title" --body "$body"
|
|
||||||
fi
|
|
||||||
@@ -90,7 +90,6 @@ cc_library(
|
|||||||
"include/nlohmann/detail/view/simd.hpp",
|
"include/nlohmann/detail/view/simd.hpp",
|
||||||
"include/nlohmann/detail/view/string_ref.hpp",
|
"include/nlohmann/detail/view/string_ref.hpp",
|
||||||
"include/nlohmann/detail/view/value.hpp",
|
"include/nlohmann/detail/view/value.hpp",
|
||||||
"include/nlohmann/detail/view/view_mode.hpp",
|
|
||||||
"include/nlohmann/json.hpp",
|
"include/nlohmann/json.hpp",
|
||||||
"include/nlohmann/json_fwd.hpp",
|
"include/nlohmann/json_fwd.hpp",
|
||||||
"include/nlohmann/json_literals.hpp",
|
"include/nlohmann/json_literals.hpp",
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ The "Check amalgamation" workflow fails if the file is out of date.
|
|||||||
|
|
||||||
The file covers the namespace variants with up to two ABI tags. A Natvis file for other configurations can be
|
The file covers the namespace variants with up to two ABI tags. A Natvis file for other configurations can be
|
||||||
generated with the `--abi-tags` or `--all` options, for example
|
generated with the `--abi-tags` or `--all` options, for example
|
||||||
`make natvis NATVIS_ARGS="--abi-tags _diag,_dp,_ns --output my_nlohmann_json.natvis"`; see
|
`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`
|
[`tools/generate_natvis`](tools/generate_natvis/README.md). With MSVC, CMake adds the file to the `nlohmann_json`
|
||||||
target and installs it.
|
target and installs it.
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ $(AMALGAMATED_VIEW_FILE): $(SRCS)
|
|||||||
tools/amalgamate/amalgamate.py -c tools/amalgamate/config_json_view.json -s . --verbose=yes
|
tools/amalgamate/amalgamate.py -c tools/amalgamate/config_json_view.json -s . --verbose=yes
|
||||||
|
|
||||||
NATVIS_VENV=tools/generate_natvis/venv
|
NATVIS_VENV=tools/generate_natvis/venv
|
||||||
# extra options for generate_natvis.py, e.g. NATVIS_ARGS="--abi-tags _diag,_dp,_ns --output my.natvis"
|
# extra options for generate_natvis.py, e.g. NATVIS_ARGS="--abi-tags _diag,_dp,_vns --output my.natvis"
|
||||||
NATVIS_ARGS=
|
NATVIS_ARGS=
|
||||||
|
|
||||||
# regenerate nlohmann_json.natvis from the ABI tags and version in include/nlohmann/detail/abi_macros.hpp
|
# regenerate nlohmann_json.natvis from the ABI tags and version in include/nlohmann/detail/abi_macros.hpp
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ The `json` class provides an API for manipulating a JSON value. To create a `jso
|
|||||||
```cpp
|
```cpp
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ If using modules (enabled with `NLOHMANN_JSON_BUILD_MODULES`), this example beco
|
|||||||
import std;
|
import std;
|
||||||
import nlohmann.json;
|
import nlohmann.json;
|
||||||
|
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
@@ -842,7 +842,7 @@ assert(p == p2);
|
|||||||
To make this work with one of your types, you only need to provide two functions:
|
To make this work with one of your types, you only need to provide two functions:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
namespace ns {
|
namespace ns {
|
||||||
void to_json(json& j, const person& p) {
|
void to_json(json& j, const person& p) {
|
||||||
@@ -1257,7 +1257,7 @@ See the page [quality assurance](https://json.nlohmann.me/community/quality_assu
|
|||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
// for convenience
|
// for convenience
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
```
|
```
|
||||||
|
|
||||||
to the files you want to process JSON and set the necessary switches to enable C++11 (e.g., `-std=c++11` for GCC and Clang).
|
to the files you want to process JSON and set the necessary switches to enable C++11 (e.g., `-std=c++11` for GCC and Clang).
|
||||||
|
|||||||
@@ -341,14 +341,13 @@ 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.sha256(url.encode()).hexdigest()[:12]
|
digest = hashlib.sha1(url.encode(), usedforsecurity=False).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)
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class (either explicitly or via the conversion operators).
|
|||||||
|
|
||||||
## Return value
|
## Return value
|
||||||
|
|
||||||
1. (none) — the converted value is written to the output parameter `val`.
|
1. (none) -- the converted value is written to the output parameter `val`.
|
||||||
2. the JSON value `j` converted to `TargetType`
|
2. the JSON value `j` converted to `TargetType`
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
@@ -67,9 +67,7 @@ class (either explicitly or via the conversion operators).
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [`to_json`](to_json.md) - convert a C++ value to JSON
|
- [to_json](to_json.md)
|
||||||
- [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,14 +30,6 @@ 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,9 +36,7 @@ This function is usually called by the constructors of the [basic_json](../basic
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [`from_json`](from_json.md) - convert JSON to a C++ value
|
- [from_json](from_json.md)
|
||||||
- [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,9 +23,6 @@ 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.
|
||||||
|
|
||||||
@@ -38,12 +35,9 @@ 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` or a `std::string_view` (C++17)
|
- a `std::string`
|
||||||
- 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.
|
||||||
@@ -131,37 +125,17 @@ 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
|
||||||
|
|
||||||
@@ -177,9 +151,6 @@ 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"
|
||||||
|
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ Linear in the size of `init`.
|
|||||||
This function is only needed to express two edge cases that cannot be realized with the initializer list constructor
|
This function is only needed to express two edge cases that cannot be realized with the initializer list constructor
|
||||||
([`basic_json(initializer_list_t, bool, value_t)`](basic_json.md)). These cases are:
|
([`basic_json(initializer_list_t, bool, value_t)`](basic_json.md)). These cases are:
|
||||||
|
|
||||||
1. creating an array whose elements are all pairs whose first element is a string — in this case, the initializer list
|
1. creating an array whose elements are all pairs whose first element is a string -- in this case, the initializer list
|
||||||
constructor would create an object, taking the first elements as keys
|
constructor would create an object, taking the first elements as keys
|
||||||
2. creating an empty array — passing the empty initializer list to the initializer list constructor yields an empty
|
2. creating an empty array -- passing the empty initializer list to the initializer list constructor yields an empty
|
||||||
object
|
object
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|||||||
@@ -69,12 +69,10 @@ 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,8 +46,7 @@ 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
|
||||||
|
|
||||||
|
|||||||
@@ -90,8 +90,7 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
|||||||
1. Constant.
|
1. Constant.
|
||||||
2. Logarithmic in the size of the container.
|
2. Logarithmic in the size of the container.
|
||||||
3. Logarithmic in the size of the container.
|
3. Logarithmic in the size of the container.
|
||||||
4. Linear in the number of reference tokens of `ptr`; for each of them, logarithmic in the size of the object, or
|
4. Logarithmic in the size of the container.
|
||||||
constant for an array.
|
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
@@ -231,19 +230,18 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [Checked access](../../features/element_access/checked_access.md) - element access with range checking
|
- documentation on [checked access](../../features/element_access/checked_access.md)
|
||||||
- [`operator[]`](operator%5B%5D.md) - unchecked access by reference
|
- [`operator[]`](operator%5B%5D.md) for unchecked access by reference
|
||||||
- [`value`](value.md) - access with default value
|
- [`value`](value.md) for 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. Support for keys convertible to `std::string_view` added in version 3.13.0, consistently
|
3. Added in version 3.11.0. Fixed in version 3.13.0 to consistently accept `std::string_view`-convertible keys, as
|
||||||
across the lookup functions.
|
already supported by [`operator[]`](operator[].md), [`value`](value.md), [`find`](find.md), and other lookup
|
||||||
|
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,11 +57,10 @@ 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.
|
||||||
- Binary values are supported since version 3.8.0.
|
- Adjusted code to return reference to binary values in version 3.8.0.
|
||||||
@@ -52,7 +52,7 @@ basic_json(basic_json&& other) noexcept;
|
|||||||
The postcondition of this constructor can be restored by calling [`clear()`](clear.md).
|
The postcondition of this constructor can be restored by calling [`clear()`](clear.md).
|
||||||
|
|
||||||
2. Create a `#!json null` JSON value. It either takes a null pointer as parameter (explicitly creating `#!json null`)
|
2. Create a `#!json null` JSON value. It either takes a null pointer as parameter (explicitly creating `#!json null`)
|
||||||
or no parameter (implicitly creating `#!json null`). The passed null pointer itself is not read — it is only used to
|
or no parameter (implicitly creating `#!json null`). The passed null pointer itself is not read -- it is only used to
|
||||||
choose the right constructor.
|
choose the right constructor.
|
||||||
|
|
||||||
3. This is a "catch all" constructor for all compatible JSON types; that is, types for which a `to_json()` method
|
3. This is a "catch all" constructor for all compatible JSON types; that is, types for which a `to_json()` method
|
||||||
@@ -113,22 +113,19 @@ 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.
|
||||||
@@ -476,25 +473,24 @@ 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. Added in version 1.0.0.
|
1. Since version 1.0.0.
|
||||||
2. Added in version 1.0.0.
|
2. Since version 1.0.0.
|
||||||
3. Added in version 2.1.0.
|
3. Since version 2.1.0.
|
||||||
4. Added in version 3.1.2. Explicit for different string types if `JSON_USE_IMPLICIT_CONVERSIONS` is `0` since
|
4. Since version 3.2.0. Explicit for different string types if `JSON_USE_IMPLICIT_CONVERSIONS` is `0` since
|
||||||
version 3.13.0.
|
version 3.13.0.
|
||||||
5. Added in version 1.0.0.
|
5. Since version 1.0.0.
|
||||||
6. Added in version 1.0.0.
|
6. Since version 1.0.0.
|
||||||
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
|
7. Since 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. Added in version 1.0.0.
|
8. Since version 1.0.0.
|
||||||
9. Added in version 1.0.0.
|
9. Since version 1.0.0.
|
||||||
@@ -7,12 +7,7 @@ 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
|
||||||
|
|
||||||
@@ -44,12 +39,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,11 +63,10 @@ initialization of a binary array type, for backwards compatibility and so it doe
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [Binary formats](../../features/binary_formats/index.md) - formats that can store binary values
|
- [binary_t](binary_t.md) type for binary values
|
||||||
- [`binary_t`](binary_t.md) - type for binary values
|
- [get_binary](get_binary.md) get a reference to the stored binary value
|
||||||
- [`get_binary`](get_binary.md) - get a reference to the stored binary value
|
- [is_binary](is_binary.md) return whether the value is binary
|
||||||
- [`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
|
||||||
- [`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
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ represent a byte array in modern C++.
|
|||||||
[`byte_container_with_subtype`](../byte_container_with_subtype/index.md) derives directly from it. Its
|
[`byte_container_with_subtype`](../byte_container_with_subtype/index.md) derives directly from it. Its
|
||||||
`value_type` must additionally be exactly one byte wide (e.g., `std::uint8_t`/`char`/`std::byte`): the binary
|
`value_type` must additionally be exactly one byte wide (e.g., `std::uint8_t`/`char`/`std::byte`): the binary
|
||||||
serializers (CBOR, MessagePack, BSON, UBJSON) read and write the container's raw bytes via
|
serializers (CBOR, MessagePack, BSON, UBJSON) read and write the container's raw bytes via
|
||||||
`reinterpret_cast`, which is only correct for byte-sized elements — a container like
|
`reinterpret_cast`, which is only correct for byte-sized elements -- a container like
|
||||||
`#!cpp std::vector<std::intptr_t>` will not work as `BinaryType`. The elements must be stored contiguously, and
|
`#!cpp std::vector<std::intptr_t>` will not work as `BinaryType`. The elements must be stored contiguously, and
|
||||||
the binary readers additionally require `resize()` and `operator[]`. See
|
the binary readers additionally require `resize()` and `operator[]`. See
|
||||||
[Template Parameter Requirements](../../features/types/template_parameters.md#binarytype) for the full list.
|
[Template Parameter Requirements](../../features/types/template_parameters.md#binarytype) for the full list.
|
||||||
@@ -90,9 +90,8 @@ type `#!cpp binary_t*` must be dereferenced.
|
|||||||
|
|
||||||
- MessagePack
|
- MessagePack
|
||||||
- If a subtype is given and the binary array contains exactly 1, 2, 4, 8, or 16 elements, the fixext family (fixext1,
|
- If a subtype is given and the binary array contains exactly 1, 2, 4, 8, or 16 elements, the fixext family (fixext1,
|
||||||
fixext2, fixext4, fixext8, fixext16) is used. For other sizes, the ext family (ext8, ext16, ext32) is used. The
|
fixext2, fixext4, fixext8) is used. For other sizes, the ext family (ext8, ext16, ext32) is used. The subtype is
|
||||||
subtype is then written as the signed 8-bit ext type: subtypes 128 to 255 map to the negative (reserved) ext
|
then added as a signed 8-bit integer.
|
||||||
types, and on reading the ext type is exposed as an unsigned subtype from 0 to 255.
|
|
||||||
- If no subtype is given, the bin family (bin8, bin16, bin32) is used.
|
- If no subtype is given, the bin family (bin8, bin16, bin32) is used.
|
||||||
|
|
||||||
- BSON
|
- BSON
|
||||||
@@ -118,9 +117,7 @@ type `#!cpp binary_t*` must be dereferenced.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
|
- [byte_container_with_subtype](../byte_container_with_subtype/index.md)
|
||||||
- [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
|
||||||
|
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
# <small>nlohmann::basic_json::</small>bjdata_version_t
|
|
||||||
|
|
||||||
```cpp
|
|
||||||
enum class bjdata_version_t
|
|
||||||
{
|
|
||||||
draft2,
|
|
||||||
draft3
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
This enumeration is used in [`to_bjdata`](to_bjdata.md) to choose the version of the BJData specification to write:
|
|
||||||
|
|
||||||
draft2
|
|
||||||
: BJData Draft 2 (the default). Binary values are written as arrays of `U` integers, and ND-arrays with
|
|
||||||
`"_ArrayType_": "byte"` are written as regular objects, since the `B` marker is not part of Draft 2.
|
|
||||||
|
|
||||||
draft3
|
|
||||||
: BJData Draft 3. Binary values are written as `B` elements: as an optimized binary array (`[$B#`) if both `use_size`
|
|
||||||
and `use_type` are set, and as an array of `B`-prefixed elements otherwise. ND-arrays with
|
|
||||||
`"_ArrayType_": "byte"` are written as packed arrays (`[$B#[...]`).
|
|
||||||
|
|
||||||
Only the writer is affected by the version. [`from_bjdata`](from_bjdata.md) reads the markers of both drafts.
|
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
??? example
|
|
||||||
|
|
||||||
The example below shows how the different values of the `bjdata_version_t` influence the serialization of a binary
|
|
||||||
value with [`to_bjdata`](to_bjdata.md).
|
|
||||||
|
|
||||||
```cpp
|
|
||||||
--8<-- "examples/bjdata_version_t.cpp"
|
|
||||||
```
|
|
||||||
|
|
||||||
Output:
|
|
||||||
|
|
||||||
```json
|
|
||||||
--8<-- "examples/bjdata_version_t.output"
|
|
||||||
```
|
|
||||||
|
|
||||||
## See also
|
|
||||||
|
|
||||||
- [to_bjdata](to_bjdata.md) serializes a JSON value to BJData
|
|
||||||
- [BJData](../../features/binary_formats/bjdata.md) - the article on the BJData format
|
|
||||||
|
|
||||||
## Version history
|
|
||||||
|
|
||||||
- Added in version 3.12.0.
|
|
||||||
@@ -47,9 +47,7 @@ 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,12 +6,7 @@ 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
|
||||||
|
|
||||||
@@ -43,11 +38,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
|
||||||
|
|
||||||
|
|||||||
@@ -15,13 +15,11 @@ error
|
|||||||
: report a parse error in case of a tag (the `from_cbor` overloads throw a `parse_error` exception by default)
|
: report a parse error in case of a tag (the `from_cbor` overloads throw a `parse_error` exception by default)
|
||||||
|
|
||||||
ignore
|
ignore
|
||||||
: ignore tags (also in front of a text string map key)
|
: ignore tags
|
||||||
|
|
||||||
store
|
store
|
||||||
: store tagged byte strings (for bytes 0xd8..0xdb) as binary values with the tag as subtype; other tagged values are
|
: store tagged byte strings (for bytes 0xd8..0xdb) as binary values with the tag as subtype; other tagged values are
|
||||||
read as if the tag were ignored. If several tags precede a byte string, only the tag directly in front of it is
|
read as if the tag were ignored. If several tags precede a byte string, only the innermost one is stored.
|
||||||
stored, and only when it has the form 0xd8..0xdb (a tag 0..23 written as 0xc0..0xd7 is skipped). Tags in front of a
|
|
||||||
text string map key are skipped.
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
@@ -42,9 +40,8 @@ store
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
|
- [from_cbor](from_cbor.md) deserializes a JSON value from CBOR
|
||||||
- [`from_cbor`](from_cbor.md) - deserializes a JSON value from CBOR
|
- [input_format_t](input_format_t.md) the enumeration of supported input formats
|
||||||
- [`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
|
- [CBOR](../../features/binary_formats/cbor.md) - the article on the CBOR format
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|||||||
@@ -6,12 +6,7 @@ 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
|
||||||
|
|
||||||
@@ -43,11 +38,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,9 +54,8 @@ 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
|
||||||
|
|
||||||
|
|||||||
@@ -61,18 +61,11 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
|||||||
|
|
||||||
## Complexity
|
## Complexity
|
||||||
|
|
||||||
1. Logarithmic in the size of the JSON object.
|
Logarithmic in the size of the JSON object.
|
||||||
2. Logarithmic in the size of the JSON object.
|
|
||||||
3. At most one lookup per reference token of `ptr`, each logarithmic in the size of the container at that level:
|
|
||||||
O(*n* log *m*) for *n* reference tokens and containers of size at most *m*.
|
|
||||||
4. Deleted; a call with an integral argument does not compile.
|
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
- Overloads (1) and (2) always return `#!cpp false` when executed on a JSON type that is not an object. Overload (3)
|
- This method always returns `#!cpp false` when executed on a JSON type that is not an object.
|
||||||
also works on arrays and on primitive values: the empty JSON pointer resolves in every JSON value (so
|
|
||||||
`#!cpp json(1).contains(""_json_pointer)` returns `#!cpp true`), and `#!cpp json({1, 2}).contains("/1"_json_pointer)`
|
|
||||||
returns `#!cpp true`.
|
|
||||||
- This method can be executed on any JSON value type.
|
- This method can be executed on any JSON value type.
|
||||||
- Calling this function with an integer argument (for example, `#!cpp contains(0)`) does not compile: such an argument
|
- Calling this function with an integer argument (for example, `#!cpp contains(0)`) does not compile: such an argument
|
||||||
would otherwise implicitly convert to a null `#!cpp const char*` and, from there, cause undefined behavior when
|
would otherwise implicitly convert to a null `#!cpp const char*` and, from there, cause undefined behavior when
|
||||||
@@ -141,16 +134,16 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
|||||||
|
|
||||||
## 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. Support for keys
|
2. Added in version 3.6.0. Extended template `KeyType` to support comparable types in version 3.11.0. Fixed in
|
||||||
convertible to `std::string_view` added in version 3.13.0, consistently across the lookup functions.
|
version 3.13.0 to consistently accept `std::string_view`-convertible keys, as already supported by
|
||||||
|
[`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 to support comparable key types in version 3.11.0. Support for keys convertible to
|
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
|
||||||
`std::string_view` added in version 3.13.0, consistently across the lookup functions.
|
consistently accept `std::string_view`-convertible keys, as already supported by [`operator[]`](operator[].md),
|
||||||
|
[`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,13 +6,7 @@ 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
|
||||||
|
|
||||||
@@ -44,9 +38,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,13 +7,7 @@ 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
|
||||||
|
|
||||||
@@ -45,9 +39,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,10 +32,8 @@ 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
|
||||||
|
|
||||||
|
|||||||
@@ -2,28 +2,17 @@
|
|||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
static basic_json diff(const basic_json& source,
|
static basic_json diff(const basic_json& source,
|
||||||
const basic_json& target,
|
const basic_json& target);
|
||||||
const string_t& path = "");
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Creates a [JSON Patch](http://jsonpatch.com) so that value `source` can be changed into the value `target` by calling
|
Creates a [JSON Patch](http://jsonpatch.com) so that value `source` can be changed into the value `target` by calling
|
||||||
[`patch`](patch.md) function.
|
[`patch`](patch.md) function.
|
||||||
|
|
||||||
For two JSON values `source` and `target`, the following code yields `#!cpp true`:
|
For two JSON values `source` and `target`, the following code always yields `#!cpp true`:
|
||||||
```cpp
|
```cpp
|
||||||
source.patch(diff(source, target)) == target;
|
source.patch(diff(source, target)) == target;
|
||||||
```
|
```
|
||||||
|
|
||||||
The equality holds up to [`operator==`](operator_eq.md), so it has the following exceptions:
|
|
||||||
|
|
||||||
- A value that is not equal to itself cannot round-trip. This applies to `NaN` (also nested in an array or object) and
|
|
||||||
to [discarded](is_discarded.md) values: `diff` emits a `replace` operation for them. A `NaN` in the patch is
|
|
||||||
serialized as `#!json null`, so a patch that was dumped and parsed again would set `#!json null`.
|
|
||||||
- Numbers that compare equal produce no operation, even if their types differ or if one is zero and the other is
|
|
||||||
negative zero: `diff(1, 1.0)` (integer and floating-point), `diff(1u, 1)` (unsigned and signed integer) and
|
|
||||||
`diff(0.0, -0.0)` (positive and negative zero) all return `#!json []`. The patched value is then the `source` and
|
|
||||||
keeps its number type and sign.
|
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
|
||||||
`source` (in)
|
`source` (in)
|
||||||
@@ -32,12 +21,6 @@ The equality holds up to [`operator==`](operator_eq.md), so it has the following
|
|||||||
`target` (in)
|
`target` (in)
|
||||||
: JSON value to compare against
|
: JSON value to compare against
|
||||||
|
|
||||||
`path` (in)
|
|
||||||
: a prefix that is put verbatim in front of the `path` member of every operation (default: `""`, which addresses the
|
|
||||||
root of the value). The prefix is neither escaped nor validated: `#!cpp diff(1, 2, "abc")` yields an operation with
|
|
||||||
the `path` `abc`, which is not a valid JSON Pointer. Use it with a valid JSON Pointer such as `/root` and escape
|
|
||||||
`~` and `/` in its reference tokens (see [JSON Pointer](../../features/json_pointer.md)).
|
|
||||||
|
|
||||||
## Return value
|
## Return value
|
||||||
|
|
||||||
a JSON patch to convert the `source` to `target`
|
a JSON patch to convert the `source` to `target`
|
||||||
@@ -48,32 +31,11 @@ Strong guarantee: `source` and `target` are never modified.
|
|||||||
|
|
||||||
## Complexity
|
## Complexity
|
||||||
|
|
||||||
Linear in the total number of values (including nested ones) in `source` and `target`, times the cost of a key-based
|
Linear in the lengths of `source` and `target`.
|
||||||
object operation (looking up a key in an object): logarithmic for [`json`](../json.md), and linear for
|
|
||||||
[`ordered_json`](../ordered_json.md) (see [`ordered_map` complexity](../ordered_map.md#complexity)). For
|
|
||||||
`ordered_json`, diffing two objects with `n` and `m` members therefore takes O((n+m)²) when their keys do not line up
|
|
||||||
(e.g., a key was added or the keys are in a different order). The size of the patch is proportional to the number of
|
|
||||||
operations times the length of their paths, so a small change deep inside a value yields a long `path`.
|
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
- Currently, only `remove`, `add`, and `replace` operations are generated.
|
Currently, only `remove`, `add`, and `replace` operations are generated.
|
||||||
- The patch is correct, but not guaranteed to be minimal. For instance, `diff([1,2,3], [0,1,2,3])` yields three
|
|
||||||
`replace` operations and one `add` operation instead of a single insertion.
|
|
||||||
- Differences between two arrays are reported index by index. Elements that were added at the end of the array are added
|
|
||||||
with `add` operations on the path `/-` (appended in order), and elements that were removed are removed with `remove`
|
|
||||||
operations from the highest index down to the lowest, so that the remaining indices stay valid.
|
|
||||||
- For objects, the operations for the members of `source` come first (`replace`, `remove`, or the operations for nested
|
|
||||||
values, in the iteration order of `source`), followed by `add` operations for the members that only `target` has.
|
|
||||||
- For [`ordered_json`](../ordered_json.md), objects with the same keys in a different order are different. As a patch
|
|
||||||
cannot reorder members, `diff` removes all keys of the `source` object and adds them again in the order of the
|
|
||||||
`target`.
|
|
||||||
- If `source` and `target` differ as a whole (e.g., different types), the patch consists of a single `replace`
|
|
||||||
operation for the root of the value, i.e., with the `path` `""` (or the given `path` prefix).
|
|
||||||
- The `value` members of the patch hold copies of values of `target`. A [binary](../../features/binary_values.md) value
|
|
||||||
has no JSON representation: when a patch that contains one is serialized, it becomes an object such as
|
|
||||||
`#!json {"bytes":[1,3],"subtype":null}`, so a parsed patch no longer holds a binary value (and would set that object
|
|
||||||
instead).
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
@@ -93,12 +55,11 @@ operations times the length of their paths, so a small change deep inside a valu
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) - specification of JSON Patch
|
- [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902)
|
||||||
- [`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
|
||||||
|
|
||||||
- Added in version 2.0.8.
|
- Since 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
|
||||||
|
|
||||||
- Added in version 2.0.8.
|
- Since version 2.0.8.
|
||||||
- Returns reference since 3.7.0.
|
- Returns reference since 3.7.0.
|
||||||
@@ -41,7 +41,7 @@ bool empty() const noexcept
|
|||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
This function does not return whether a string stored as JSON value is empty — it returns whether the JSON container
|
This function does not return whether a string stored as JSON value is empty -- it returns whether the JSON container
|
||||||
itself is empty which is `#!cpp false` in the case of a string.
|
itself is empty which is `#!cpp false` in the case of a string.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
@@ -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,12 +7,7 @@ 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
|
||||||
|
|
||||||
@@ -44,11 +39,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,9 +60,8 @@ 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) - overview of the supported conversions
|
- [JSON_DIAGNOSTIC_POSITIONS](../macros/json_diagnostic_positions.md) for an overview of the diagnostic positions
|
||||||
- [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,6 +213,7 @@ 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. Support for keys convertible to `std::string_view` added in version 3.13.0, consistently
|
4. Added in version 3.11.0. Fixed in version 3.13.0 to consistently accept `std::string_view`-convertible keys, as
|
||||||
across the lookup functions.
|
already supported by [`operator[]`](operator[].md), [`at`](at.md), [`value`](value.md), and other lookup
|
||||||
|
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,9 +40,6 @@ 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
|
||||||
@@ -83,12 +80,8 @@ constructor.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [List of exceptions](../../home/exceptions.md) - overview of all exceptions thrown by the library
|
[List of exceptions](../../home/exceptions.md)
|
||||||
- [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
|
||||||
|
|
||||||
- Added in version 3.0.0.
|
- Since 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. Support for keys convertible to
|
2. Added in version 1.0.0. Changed to support comparable types in version 3.11.0. Fixed in version 3.13.0 to
|
||||||
`std::string_view` added in version 3.13.0, consistently across the lookup functions.
|
consistently accept `std::string_view`-convertible keys, as already supported by [`operator[]`](operator[].md),
|
||||||
|
[`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,8 +58,7 @@ 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) - serialize a JSON value to a string
|
- [dump](dump.md)
|
||||||
- [`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
|
||||||
|
|||||||
@@ -82,11 +82,8 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va
|
|||||||
- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs
|
- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs
|
||||||
- Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string could not be parsed
|
- Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string could not be parsed
|
||||||
successfully, or if a string value or object key is not valid UTF-8 and `error_handler` is `strict`
|
successfully, or if a string value or object key is not valid UTF-8 and `error_handler` is `strict`
|
||||||
- Throws [parse_error.115](../../home/exceptions.md#jsonexceptionparse_error115) if the text of a high-precision
|
|
||||||
number (`H`) is not a valid number
|
|
||||||
- Throws [out_of_range.408](../../home/exceptions.md#jsonexceptionout_of_range408) if the size of an optimized container
|
- Throws [out_of_range.408](../../home/exceptions.md#jsonexceptionout_of_range408) if the size of an optimized container
|
||||||
cannot be represented by `std::size_t` or exceeds the container's `max_size()`, or if the product of the dimensions of
|
or n-dimensional array cannot be represented by `std::size_t`
|
||||||
an n-dimensional array overflows
|
|
||||||
|
|
||||||
## Complexity
|
## Complexity
|
||||||
|
|
||||||
@@ -110,16 +107,12 @@ Linear in the size of the input.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [BJData](../../features/binary_formats/bjdata.md) - the format, its byte layout and how values are mapped
|
- [to_bjdata](to_bjdata.md) create a BJData serialization of a JSON value
|
||||||
- [Binary formats](../../features/binary_formats/index.md) - overview and comparison of the supported binary formats
|
- [from_cbor](from_cbor.md) create a JSON value from an input in CBOR format
|
||||||
- [Parsing untrusted input](../../features/parsing/untrusted_input.md) - limits and safe handling of hostile data
|
- [from_msgpack](from_msgpack.md) create a JSON value from an input in MessagePack format
|
||||||
- [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
|
- [from_bson](from_bson.md) create a JSON value from an input in BSON format
|
||||||
- [`to_bjdata`](to_bjdata.md) - create a BJData 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_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_bon8`](from_bon8.md) - create a JSON value from an input in BON8 format
|
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -74,11 +74,6 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va
|
|||||||
- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs, for instance
|
- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs, for instance
|
||||||
an invalid byte, a string that is not valid UTF-8, or an object key that is not a string
|
an invalid byte, a string that is not valid UTF-8, or an object key that is not a string
|
||||||
|
|
||||||
The UTF-8 validity of strings is always checked, independent of
|
|
||||||
[`JSON_STRICT_BINARY_UTF8`](../macros/json_strict_binary_utf8.md), because the end of a BON8 string is determined from
|
|
||||||
its encoding. Duplicate object keys are accepted; the last value wins (see
|
|
||||||
[BON8](../../features/binary_formats/bon8.md)).
|
|
||||||
|
|
||||||
## Complexity
|
## Complexity
|
||||||
|
|
||||||
Linear in the size of the input.
|
Linear in the size of the input.
|
||||||
@@ -101,15 +96,12 @@ Linear in the size of the input.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [BON8](../../features/binary_formats/bon8.md) - the format, its byte layout and how values are mapped
|
- [to_bon8](to_bon8.md) create a BON8 serialization of a JSON value
|
||||||
- [Binary formats](../../features/binary_formats/index.md) - overview and comparison of the supported binary formats
|
- [from_cbor](from_cbor.md) create a JSON value from an input in CBOR format
|
||||||
- [Parsing untrusted input](../../features/parsing/untrusted_input.md) - limits and safe handling of hostile data
|
- [from_msgpack](from_msgpack.md) create a JSON value from an input in MessagePack format
|
||||||
- [`to_bon8`](to_bon8.md) - create a BON8 serialization of a JSON value
|
- [from_bson](from_bson.md) create a JSON value from an input in BSON format
|
||||||
- [`from_cbor`](from_cbor.md) - create a JSON value from an input in CBOR format
|
- [from_ubjson](from_ubjson.md) create a JSON value from an input in UBJSON format
|
||||||
- [`from_msgpack`](from_msgpack.md) - create a JSON value from an input in MessagePack format
|
- [from_bjdata](from_bjdata.md) create a JSON value from an input in BJData 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
|
||||||
|
|
||||||
|
|||||||
@@ -80,8 +80,7 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va
|
|||||||
- Throws [`parse_error.110`](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or
|
- Throws [`parse_error.110`](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or
|
||||||
the end of the input was not reached when `strict` was set to true
|
the end of the input was not reached when `strict` was set to true
|
||||||
- Throws [`parse_error.112`](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs (e.g., an
|
- Throws [`parse_error.112`](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs (e.g., an
|
||||||
invalid string or byte array length, an invalid inner length of a binary value with subtype `0x02`, or a document size
|
invalid string or byte array length)
|
||||||
that does not match the content; `strict` does not affect the document size checks)
|
|
||||||
- Throws [`parse_error.114`](../../home/exceptions.md#jsonexceptionparse_error114) if an unsupported BSON record type is
|
- Throws [`parse_error.114`](../../home/exceptions.md#jsonexceptionparse_error114) if an unsupported BSON record type is
|
||||||
encountered
|
encountered
|
||||||
- Throws [`parse_error.113`](../../home/exceptions.md#jsonexceptionparse_error113) if a string value or object key is
|
- Throws [`parse_error.113`](../../home/exceptions.md#jsonexceptionparse_error113) if a string value or object key is
|
||||||
@@ -109,17 +108,13 @@ Linear in the size of the input.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [BSON](../../features/binary_formats/bson.md) - the format, its byte layout and how values are mapped
|
- [BSON specification](http://bsonspec.org/spec.html)
|
||||||
- [Binary formats](../../features/binary_formats/index.md) - overview and comparison of the supported binary formats
|
- [to_bson](to_bson.md) for the analogous serialization
|
||||||
- [Parsing untrusted input](../../features/parsing/untrusted_input.md) - limits and safe handling of hostile data
|
- [from_cbor](from_cbor.md) for the related CBOR format
|
||||||
- [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
|
- [from_msgpack](from_msgpack.md) for the related MessagePack format
|
||||||
- [BSON specification](http://bsonspec.org/spec.html) - specification of the BSON format
|
- [from_ubjson](from_ubjson.md) for the related UBJSON format
|
||||||
- [`to_bson`](to_bson.md) - the analogous serialization
|
- [from_bjdata](from_bjdata.md) for the related BJData format
|
||||||
- [`from_cbor`](from_cbor.md) - the related CBOR format
|
- [from_bon8](from_bon8.md) for the related BON8 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
|
||||||
|
|
||||||
|
|||||||
@@ -32,10 +32,8 @@ The exact mapping and its limitations are described on a [dedicated page](../../
|
|||||||
|
|
||||||
- an `std::istream` object
|
- an `std::istream` object
|
||||||
- a `FILE` pointer
|
- a `FILE` pointer
|
||||||
- a C-style array of characters (its terminating NUL is read as trailing data: `parse_error.110` unless `strict` is
|
- a C-style array of characters
|
||||||
`false`)
|
- a pointer to a null-terminated string of single byte characters
|
||||||
- a pointer to a null-terminated string of single byte characters (read up to the first 0x00 byte, which is a valid
|
|
||||||
CBOR byte)
|
|
||||||
- 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`)
|
||||||
|
|
||||||
@@ -91,14 +89,8 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va
|
|||||||
- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if unsupported features from CBOR were
|
- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if unsupported features from CBOR were
|
||||||
used in the given input or if the input is not valid CBOR
|
used in the given input or if the input is not valid CBOR
|
||||||
- Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a map key is not a string (keys of
|
- Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a map key is not a string (keys of
|
||||||
other types are not supported, as JSON object keys are always strings), if the head of a string or byte string is
|
other types are not supported, as JSON object keys are always strings), or if a string value or object key is not
|
||||||
malformed (including a chunk of the wrong type or an indefinite-length string nested inside an indefinite-length
|
valid UTF-8 and `error_handler` is `strict`
|
||||||
string), or if a string value or object key (or one chunk of an indefinite-length string) is not valid UTF-8 and
|
|
||||||
`error_handler` is `strict`
|
|
||||||
- Throws [out_of_range.408](../../home/exceptions.md#jsonexceptionout_of_range408) if an array or map announces
|
|
||||||
a length that `std::size_t` cannot hold, or that equals `std::size_t(-1)` (for example `9B FF FF FF FF FF FF FF FF`)
|
|
||||||
- Throws [out_of_range.406](../../home/exceptions.md#jsonexceptionout_of_range406) if a floating-point number does not
|
|
||||||
fit into `number_float_t`
|
|
||||||
|
|
||||||
## Complexity
|
## Complexity
|
||||||
|
|
||||||
@@ -122,16 +114,12 @@ Linear in the size of the input.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [CBOR](../../features/binary_formats/cbor.md) - the format, its byte layout and how values are mapped
|
- [to_cbor](to_cbor.md) create a CBOR serialization of a JSON value
|
||||||
- [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_cbor`](to_cbor.md) - create a CBOR serialization of a JSON value
|
- [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_bon8](from_bon8.md) create a JSON value from an input in BON8 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,16 +107,12 @@ Linear in the size of the input.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [MessagePack](../../features/binary_formats/messagepack.md) - the format, its byte layout and how values are mapped
|
- [to_msgpack](to_msgpack.md) create a MessagePack serialization of a JSON value
|
||||||
- [Binary formats](../../features/binary_formats/index.md) - overview and comparison of the supported binary formats
|
- [from_cbor](from_cbor.md) create a JSON value from an input in CBOR 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_msgpack`](to_msgpack.md) - create a MessagePack serialization of a JSON value
|
- [from_bjdata](from_bjdata.md) create a JSON value from an input in BJData format
|
||||||
- [`from_cbor`](from_cbor.md) - create a JSON value from an input in CBOR format
|
- [from_bon8](from_bon8.md) create a JSON value from an input in BON8 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
|
||||||
|
|
||||||
|
|||||||
@@ -79,18 +79,11 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va
|
|||||||
|
|
||||||
- Throws [parse_error.110](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or
|
- Throws [parse_error.110](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or
|
||||||
the end of the file was not reached when `strict` was set to true
|
the end of the file was not reached when `strict` was set to true
|
||||||
- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if an invalid type marker is read
|
- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs
|
||||||
(including a type marker after `$` of an optimized container, even if its count is 0), or if `$` is not followed by `#`
|
|
||||||
- Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string could not be parsed
|
- Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string could not be parsed
|
||||||
successfully (negative or non-integer length, `C` followed by a byte above 0x7F), if the count of an optimized
|
successfully, or if a string value or object key is not valid UTF-8 and `error_handler` is `strict`
|
||||||
container is negative, or if a string value or object key is not valid UTF-8 and `error_handler` is `strict`
|
- Throws [out_of_range.408](../../home/exceptions.md#jsonexceptionout_of_range408) if the size of an optimized container
|
||||||
- Throws [parse_error.115](../../home/exceptions.md#jsonexceptionparse_error115) if the text of a high-precision number
|
or n-dimensional array cannot be represented by `std::size_t`
|
||||||
(`H`) is not a valid JSON number
|
|
||||||
- Throws [out_of_range.406](../../home/exceptions.md#jsonexceptionout_of_range406) if a high-precision number, or a
|
|
||||||
float64 when `number_float_t` is `float`, does not fit into `number_float_t`
|
|
||||||
- Throws [out_of_range.408](../../home/exceptions.md#jsonexceptionout_of_range408) if the count of an optimized
|
|
||||||
container exceeds the capacity of the container (or of `std::size_t`), or if an optimized array of `Z`, `T`, or `F` has
|
|
||||||
more than 1,048,576 elements
|
|
||||||
|
|
||||||
## Complexity
|
## Complexity
|
||||||
|
|
||||||
@@ -114,16 +107,12 @@ Linear in the size of the input.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [UBJSON](../../features/binary_formats/ubjson.md) - the format, its byte layout and how values are mapped
|
- [to_ubjson](to_ubjson.md) create a UBJSON serialization of a JSON value
|
||||||
- [Binary formats](../../features/binary_formats/index.md) - overview and comparison of the supported binary formats
|
- [from_cbor](from_cbor.md) create a JSON value from an input in CBOR format
|
||||||
- [Parsing untrusted input](../../features/parsing/untrusted_input.md) - limits and safe handling of hostile data
|
- [from_msgpack](from_msgpack.md) create a JSON value from an input in MessagePack format
|
||||||
- [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
|
- [from_bson](from_bson.md) create a JSON value from an input in BSON format
|
||||||
- [`to_ubjson`](to_ubjson.md) - create a UBJSON serialization of a JSON value
|
- [from_bjdata](from_bjdata.md) create a JSON value from an input in BJData format
|
||||||
- [`from_cbor`](from_cbor.md) - create a JSON value from an input in CBOR format
|
- [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_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,12 +50,11 @@ 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.
|
||||||
- Binary values are supported since version 3.8.0.
|
- Adjusted code to return reference to binary values in version 3.8.0.
|
||||||
@@ -178,17 +178,16 @@ 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. Added in version 2.1.0.
|
1. Since version 2.1.0.
|
||||||
2. Added in version 2.1.0. Extended to work with other specializations of `basic_json` in version 3.1.2.
|
2. Since version 2.1.0. Extended to work with other specializations of `basic_json` in version 3.2.0.
|
||||||
3. Added in version 1.0.0.
|
3. Since 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,11 +42,8 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
|
- [get](get.md) get a value (explicit conversion)
|
||||||
- [`binary`](binary.md) - create a binary value
|
- [get_ref](get_ref.md) get a reference to the stored 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 nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@@ -86,8 +86,7 @@ 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,10 +60,9 @@ 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,14 +68,13 @@ 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
|
||||||
|
|
||||||
- Added in version 3.3.0.
|
- Since 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,22 +44,6 @@ 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),
|
||||||
@@ -121,7 +105,6 @@ The class satisfies the following concept requirements:
|
|||||||
- [**json_pointer**](../json_pointer/index.md) - JSON Pointer implementation
|
- [**json_pointer**](../json_pointer/index.md) - JSON Pointer implementation
|
||||||
- [**json_serializer**](json_serializer.md) - type of the serializer to for conversions from/to JSON
|
- [**json_serializer**](json_serializer.md) - type of the serializer to for conversions from/to JSON
|
||||||
- [**error_handler_t**](error_handler_t.md) - type to choose behavior on decoding errors
|
- [**error_handler_t**](error_handler_t.md) - type to choose behavior on decoding errors
|
||||||
- [**bjdata_version_t**](bjdata_version_t.md) - type to choose the BJData version to write
|
|
||||||
- [**cbor_tag_handler_t**](cbor_tag_handler_t.md) - type to choose how to handle CBOR tags
|
- [**cbor_tag_handler_t**](cbor_tag_handler_t.md) - type to choose how to handle CBOR tags
|
||||||
- **initializer_list_t** - type for initializer lists of `basic_json` values
|
- **initializer_list_t** - type for initializer lists of `basic_json` values
|
||||||
- [**input_format_t**](input_format_t.md) - type to choose the format to parse
|
- [**input_format_t**](input_format_t.md) - type to choose the format to parse
|
||||||
@@ -189,7 +172,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
|
||||||
@@ -218,7 +201,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
|
||||||
|
|
||||||
@@ -359,15 +342,7 @@ 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,9 +53,8 @@ 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,11 +185,10 @@ 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,9 +40,6 @@ 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
|
||||||
@@ -69,15 +66,13 @@ base class, and the highlighted box is `basic_json::invalid_iterator`.</p>
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [`exception`](exception.md) - the base class of all exceptions thrown by the library
|
- [`exception`](exception.md) for the base class of all exceptions thrown by the library
|
||||||
- [List of iterator errors](../../home/exceptions.md#iterator-errors) - overview of iterator errors (`invalid_iterator`)
|
- [List of iterator errors](../../home/exceptions.md#iterator-errors)
|
||||||
- [`parse_error`](parse_error.md) - exceptions indicating a parse error
|
- [`parse_error`](parse_error.md) for exceptions indicating a parse error
|
||||||
- [`type_error`](type_error.md) - exceptions indicating executing a member function with a wrong type
|
- [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type
|
||||||
- [`out_of_range`](out_of_range.md) - exceptions indicating access out of the defined range
|
- [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range
|
||||||
- [`other_error`](other_error.md) - exceptions indicating other library errors
|
- [`other_error`](other_error.md) for 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
|
||||||
|
|
||||||
- Added in version 3.0.0.
|
- Since version 3.0.0.
|
||||||
@@ -36,12 +36,11 @@ 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,11 +36,10 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
|
- [is_primitive](is_primitive.md) checks whether the JSON value is primitive
|
||||||
- [`is_primitive`](is_primitive.md) - checks whether the JSON value is primitive
|
- [binary_t](binary_t.md) the type used to store binary values
|
||||||
- [`binary_t`](binary_t.md) - the type used to store binary values
|
- [get_binary](get_binary.md) returns a reference to the stored binary value
|
||||||
- [`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
|
||||||
- [`basic_json_view::is_binary`](../basic_json_view/is_binary.md) - the same check on a zero-copy view
|
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
|||||||
@@ -36,10 +36,9 @@ 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,9 +87,8 @@ 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,12 +36,11 @@ 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,12 +46,10 @@ 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,12 +37,10 @@ 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,12 +37,10 @@ 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,12 +40,10 @@ 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,12 +36,11 @@ 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,14 +56,13 @@ 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,11 +36,10 @@ 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,11 +54,10 @@ 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
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ using element_type = decltype(*j_object.items().begin());
|
|||||||
```
|
```
|
||||||
|
|
||||||
The per-element type (`iteration_proxy_value`) lives in the library's internal `detail` namespace and is
|
The per-element type (`iteration_proxy_value`) lives in the library's internal `detail` namespace and is
|
||||||
intentionally unspecified as a stable, named type — `decltype` is the supported way to obtain it, but its exact
|
intentionally unspecified as a stable, named type -- `decltype` is the supported way to obtain it, but its exact
|
||||||
name/definition may change between versions.
|
name/definition may change between versions.
|
||||||
|
|
||||||
## Return value
|
## Return value
|
||||||
@@ -97,16 +97,15 @@ 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 in version 3.1.0 as the replacement of the static function `iterator_wrapper`, which was available since
|
- Added `iterator_wrapper` in version 3.0.0.
|
||||||
version 1.0.0 and is deprecated since version 3.1.0.
|
- Added `items` and deprecated `iterator_wrapper` in 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,12 +44,11 @@ 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
|
||||||
|
|
||||||
- Added in version 2.1.0.
|
- Since version 2.0.0.
|
||||||
@@ -33,7 +33,7 @@ constant complexity.
|
|||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
This function does not return the maximal length of a string stored as JSON value — it returns the maximal number of
|
This function does not return the maximal length of a string stored as JSON value -- it returns the maximal number of
|
||||||
string elements the JSON value can store which is `1`.
|
string elements the JSON value can store which is `1`.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
@@ -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,10 +70,9 @@ 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) - specification of JSON Merge Patch
|
- [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396)
|
||||||
- [`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
|
||||||
|
|
||||||
|
|||||||
@@ -39,33 +39,13 @@ Basic guarantee: if an exception is thrown during the operation, the JSON value
|
|||||||
|
|
||||||
## Complexity
|
## Complexity
|
||||||
|
|
||||||
Linear in the total number of values (including nested ones) in `apply_patch`, times the cost of a key-based object
|
Linear in the lengths of `apply_patch`.
|
||||||
operation (looking up, adding, or erasing a member): logarithmic for [`json`](../json.md), and linear for
|
|
||||||
[`ordered_json`](../ordered_json.md) (see [`ordered_map` complexity](../ordered_map.md#complexity)). For
|
|
||||||
`ordered_json`, patching an object that has `n` members with a patch that has `m` members therefore takes O(n·m). The
|
|
||||||
cost also includes one copy of `apply_patch` (see the notes below).
|
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
- `apply_patch` may be `#!cpp *this` itself or refer to a value contained in `#!cpp *this` (for example, a subobject
|
`apply_patch` may be `#!cpp *this` itself or refer to a value contained in `#!cpp *this` (for example, a subobject
|
||||||
returned by `#!cpp (*this)[key]`); it is read as it was when `merge_patch()` was called, before any modification of
|
returned by `#!cpp (*this)[key]`); it is read as it was when `merge_patch()` was called, before any modification of
|
||||||
`#!cpp *this`. To make this possible, the function copies `apply_patch` before it modifies `#!cpp *this`, so the cost
|
`#!cpp *this`.
|
||||||
includes one copy of the patch.
|
|
||||||
- A merge patch uses `#!json null` to remove a member, so it cannot set a member to `#!json null`: applying
|
|
||||||
`#!json {"a":null}` to `#!json {"a":1}` gives `#!json {}`.
|
|
||||||
- Arrays are not merged: an array in the patch replaces the target value as a whole, and a `#!json null` inside an
|
|
||||||
array is kept as an element. `#!json null` members of the target that the patch does not mention are preserved.
|
|
||||||
- A `#!json null` in the patch only removes a member; it does not prevent the creation of the enclosing objects.
|
|
||||||
Applying `#!json {"a":{"b":null}}` to `#!json {}` gives `#!json {"a":{}}` (see example 15 in Appendix A of the RFC).
|
|
||||||
- If `apply_patch` is not an object, it replaces the target as a whole. In particular, a `#!json null` patch turns the
|
|
||||||
target into `#!json null`. If `apply_patch` is an object and the target is not, the target is first replaced by an
|
|
||||||
empty object, so applying `#!json {}` to `#!json 1` gives `#!json {}`.
|
|
||||||
- A merge patch cannot express every change; for example, it cannot reorder array elements or remove a specific array
|
|
||||||
element. Use [JSON Patch](../../features/json_patch.md) ([RFC 6902](https://tools.ietf.org/html/rfc6902)) for that.
|
|
||||||
[`merge_diff`](merge_diff.md) has a matching limitation, see its notes.
|
|
||||||
- A [discarded](is_discarded.md) value is treated like any other non-object value: a discarded
|
|
||||||
`apply_patch` turns the target into a discarded value, and an object patch replaces a discarded target by an object
|
|
||||||
as described above.
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
@@ -85,13 +65,12 @@ cost also includes one copy of `apply_patch` (see the notes below).
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396) - specification of JSON Merge Patch
|
- [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396)
|
||||||
- [`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.1.0.
|
- Added in version 3.0.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,11 +48,8 @@ Constant.
|
|||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [`NLOHMANN_JSON_VERSION_MAJOR`](../macros/nlohmann_json_version_major.md) /
|
- [**NLOHMANN_JSON_VERSION_MAJOR**/**NLOHMANN_JSON_VERSION_MINOR**/**NLOHMANN_JSON_VERSION_PATCH**](../macros/nlohmann_json_version_major.md)
|
||||||
[`NLOHMANN_JSON_VERSION_MINOR`](../macros/nlohmann_json_version_major.md) /
|
\- library version information
|
||||||
[`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,11 +84,10 @@ 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,11 +80,10 @@ 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,11 +82,10 @@ 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,10 +27,8 @@ 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
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ To store objects in C++, a type is defined by the template parameters described
|
|||||||
`ObjectType`
|
`ObjectType`
|
||||||
: the container to store objects. Its template parameters must have the same order and meaning as those of
|
: the container to store objects. Its template parameters must have the same order and meaning as those of
|
||||||
`std::map`; in particular, the third parameter is a comparator. `#!cpp std::unordered_map`, whose third parameter
|
`std::map`; in particular, the third parameter is a comparator. `#!cpp std::unordered_map`, whose third parameter
|
||||||
is a hash function, therefore needs an adapter — see
|
is a hash function, therefore needs an adapter -- see
|
||||||
[Template Parameter Requirements](../../features/types/template_parameters.md#objecttype) for the full list of
|
[Template Parameter Requirements](../../features/types/template_parameters.md#objecttype) for the full list of
|
||||||
requirements, an adapter example, and the containers that are known to work.
|
requirements, an adapter example, and the containers that are known to work.
|
||||||
|
|
||||||
@@ -125,12 +125,10 @@ 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,12 +123,11 @@ 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. Added in version 1.0.0.
|
1. Since version 1.0.0.
|
||||||
2. Added in version 1.0.0.
|
2. Since version 1.0.0.
|
||||||
3. Added in version 2.0.0.
|
3. Since version 2.0.0.
|
||||||
Loaded 100 of 956 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user