mirror of
https://github.com/nlohmann/json.git
synced 2026-07-06 18:45:09 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 42f4df1159 | |||
| c78d9dc386 | |||
| 530ab84ed6 |
+8
-8
@@ -3,15 +3,15 @@ arm_container:
|
||||
|
||||
check_task:
|
||||
check_script:
|
||||
# the gcc image ships an outdated CMake, so fetch a recent prebuilt binary
|
||||
# instead of compiling CMake from source
|
||||
- wget -q https://github.com/Kitware/CMake/releases/download/v4.3.4/cmake-4.3.4-linux-aarch64.tar.gz
|
||||
- tar xfz cmake-4.3.4-linux-aarch64.tar.gz
|
||||
- export PATH="$(pwd)/cmake-4.3.4-linux-aarch64/bin:$PATH"
|
||||
- cmake --version
|
||||
- wget https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2.tar.gz
|
||||
- tar xfz cmake-3.20.2.tar.gz
|
||||
- cd cmake-3.20.2
|
||||
- ./configure
|
||||
- make cmake ctest -j4
|
||||
- cd ..
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake .. -DJSON_FastTests=ON
|
||||
- ../cmake-3.20.2/bin/cmake .. -DJSON_FastTests=ON
|
||||
- make -j4
|
||||
- cd tests
|
||||
- ctest -j4
|
||||
- ../../cmake-3.20.2/bin/ctest -j4
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ sentimentBotReplyComment: >
|
||||
|
||||
# *Required* Comment to reply with
|
||||
requestInfoReplyComment: >
|
||||
We would appreciate it if you could provide us with more info about this issue or pull request! Please check the [issue template](https://github.com/nlohmann/json/issues/new/choose) and the [pull request template](https://github.com/nlohmann/json/blob/develop/.github/PULL_REQUEST_TEMPLATE.md).
|
||||
We would appreciate it if you could provide us with more info about this issue or pull request! Please check the [issue template](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE.md) and the [pull request template](https://github.com/nlohmann/json/blob/develop/.github/PULL_REQUEST_TEMPLATE.md).
|
||||
|
||||
# *OPTIONAL* Label to be added to Issues and Pull Requests with insufficient information given
|
||||
requestInfoLabelToAdd: "state: needs more info"
|
||||
|
||||
@@ -4,10 +4,6 @@ updates:
|
||||
directory: /
|
||||
schedule:
|
||||
interval: daily
|
||||
groups:
|
||||
codeql-action:
|
||||
patterns:
|
||||
- "github/codeql-action/*"
|
||||
|
||||
- package-ecosystem: pip
|
||||
directory: /docs/mkdocs
|
||||
|
||||
+2
-2
@@ -23,11 +23,11 @@ labels:
|
||||
|
||||
- label: "CI"
|
||||
files:
|
||||
- ".github/workflows/.*"
|
||||
- "github/workflows/.*"
|
||||
|
||||
- label: "CI"
|
||||
files:
|
||||
- ".github/external_ci/.*"
|
||||
- "github/external_ci/.*"
|
||||
|
||||
- label: "S"
|
||||
size-below: 10
|
||||
|
||||
@@ -11,7 +11,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
@@ -34,65 +34,43 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: Checkout pull request
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
path: main
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
persist-credentials: false
|
||||
|
||||
- name: Checkout tools
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
path: tools
|
||||
ref: develop
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install astyle
|
||||
run: |
|
||||
python3 -mvenv venv
|
||||
venv/bin/pip3 install -r $MAIN_DIR/tools/astyle/requirements.txt
|
||||
|
||||
- name: Regenerate amalgamation and formatting
|
||||
- name: Check amalgamation
|
||||
run: |
|
||||
cd $MAIN_DIR
|
||||
|
||||
rm -fr $INCLUDE_DIR/json.hpp~ $INCLUDE_DIR/json_fwd.hpp~
|
||||
cp $INCLUDE_DIR/json.hpp $INCLUDE_DIR/json.hpp~
|
||||
cp $INCLUDE_DIR/json_fwd.hpp $INCLUDE_DIR/json_fwd.hpp~
|
||||
|
||||
python3 $TOOL_DIR/amalgamate.py -c $TOOL_DIR/config_json.json -s .
|
||||
python3 $TOOL_DIR/amalgamate.py -c $TOOL_DIR/config_json_fwd.json -s .
|
||||
echo "Format (1)"
|
||||
${{ github.workspace }}/venv/bin/astyle --project=tools/astyle/.astylerc --suffix=none --quiet $INCLUDE_DIR/json.hpp $INCLUDE_DIR/json_fwd.hpp
|
||||
|
||||
${{ github.workspace }}/venv/bin/astyle --project=tools/astyle/.astylerc --suffix=none --quiet \
|
||||
$INCLUDE_DIR/json.hpp $INCLUDE_DIR/json_fwd.hpp
|
||||
diff $INCLUDE_DIR/json.hpp~ $INCLUDE_DIR/json.hpp
|
||||
diff $INCLUDE_DIR/json_fwd.hpp~ $INCLUDE_DIR/json_fwd.hpp
|
||||
|
||||
${{ github.workspace }}/venv/bin/astyle --project=tools/astyle/.astylerc --suffix=none --quiet \
|
||||
$(find docs/examples include tests -type f \( -name '*.hpp' -o -name '*.cpp' -o -name '*.cu' \) -not -path 'tests/thirdparty/*' -not -path 'tests/abi/include/nlohmann/*' | sort)
|
||||
|
||||
- name: Build patch and check for differences
|
||||
id: diff
|
||||
run: |
|
||||
cd $MAIN_DIR
|
||||
mkdir -p ${{ github.workspace }}/patch
|
||||
git diff --patch --no-color > ${{ github.workspace }}/patch/amalgamation.patch
|
||||
if [ -s ${{ github.workspace }}/patch/amalgamation.patch ]; then
|
||||
echo "The source code has not been amalgamated/formatted correctly. Diff:"
|
||||
cat ${{ github.workspace }}/patch/amalgamation.patch
|
||||
echo "has_diff=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "has_diff=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
# Uploaded so contributors can fix their PR with `git apply amalgamation.patch`
|
||||
# instead of installing the pinned astyle version locally.
|
||||
- name: Upload patch
|
||||
if: steps.diff.outputs.has_diff == 'true'
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: amalgamation-patch
|
||||
path: patch/amalgamation.patch
|
||||
|
||||
- name: Fail if not amalgamated/formatted
|
||||
if: steps.diff.outputs.has_diff == 'true'
|
||||
run: exit 1
|
||||
${{ github.workspace }}/venv/bin/astyle --project=tools/astyle/.astylerc --suffix=orig $(find docs/examples include tests -type f \( -name '*.hpp' -o -name '*.cpp' -o -name '*.cu' \) -not -path 'tests/thirdparty/*' -not -path 'tests/abi/include/nlohmann/*' | sort)
|
||||
echo Check
|
||||
find $MAIN_DIR -name '*.orig' -exec false {} \+
|
||||
|
||||
@@ -9,13 +9,10 @@ jobs:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
# The OSS-Fuzz CIFuzz actions are referenced via @master as recommended by
|
||||
# the OSS-Fuzz documentation; the project does not publish tags or releases
|
||||
# to pin to. See https://google.github.io/oss-fuzz/getting-started/continuous-integration/
|
||||
- name: Build Fuzzers
|
||||
id: build
|
||||
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
|
||||
|
||||
@@ -27,25 +27,23 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
|
||||
uses: github/codeql-action/init@9e0d7b8d25671d64c341c19c0152d693099fb5ba # v4.35.5
|
||||
with:
|
||||
languages: c-cpp
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
|
||||
uses: github/codeql-action/autobuild@9e0d7b8d25671d64c341c19c0152d693099fb5ba # v4.35.5
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
|
||||
uses: github/codeql-action/analyze@9e0d7b8d25671d64c341c19c0152d693099fb5ba # v4.35.5
|
||||
|
||||
@@ -19,12 +19,11 @@ jobs:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: 'Download artifact'
|
||||
id: download
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
script: |
|
||||
@@ -44,13 +43,7 @@ jobs:
|
||||
});
|
||||
var fs = require('fs');
|
||||
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
|
||||
|
||||
var hasPatch = artifacts.data.artifacts.some((artifact) => artifact.name == "amalgamation-patch");
|
||||
core.setOutput('has_patch', String(hasPatch));
|
||||
# Extract the untrusted PR artifact into a dedicated empty directory and
|
||||
# read only the two expected files by fixed path afterwards. This avoids a
|
||||
# malicious archive overwriting workspace files or escaping via ../ paths.
|
||||
- run: unzip -o pr.zip -d ./pr_artifact
|
||||
- run: unzip pr.zip
|
||||
|
||||
- name: 'Comment on PR'
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
@@ -58,19 +51,8 @@ jobs:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
var fs = require('fs');
|
||||
// Both values come from a fork-triggered workflow and are therefore
|
||||
// attacker-controlled. Validate them strictly before use to prevent
|
||||
// Markdown/mention injection and bogus REST API filters.
|
||||
const author = fs.readFileSync('./pr_artifact/author', 'utf8').trim();
|
||||
if (!/^[A-Za-z0-9-]{1,39}$/.test(author)) {
|
||||
core.setFailed(`Refusing to proceed: untrusted author value '${author}' is not a valid GitHub username.`);
|
||||
return;
|
||||
}
|
||||
const issue_number = Number(fs.readFileSync('./pr_artifact/number', 'utf8').trim());
|
||||
if (!Number.isInteger(issue_number) || issue_number <= 0) {
|
||||
core.setFailed('Refusing to proceed: untrusted PR number is not a positive integer.');
|
||||
return;
|
||||
}
|
||||
const author = fs.readFileSync('./author')
|
||||
const issue_number = Number(fs.readFileSync('./number'));
|
||||
const opts = github.rest.issues.listForRepo.endpoint.merge({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
@@ -88,20 +70,12 @@ jobs:
|
||||
break
|
||||
}
|
||||
}
|
||||
const hasPatch = '${{ steps.download.outputs.has_patch }}' === 'true';
|
||||
const runUrl = '${{ github.event.workflow_run.html_url }}';
|
||||
|
||||
await github.rest.issues.createComment({
|
||||
issue_number: issue_number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: '## 🔴 Amalgamation check failed! 🔴\nThe source code has not been amalgamated and/or formatted correctly.'
|
||||
+ (hasPatch ? '\n\n📎 A ready-to-apply patch is attached to the [failed workflow run](' + runUrl + ') as the `amalgamation-patch` artifact.'
|
||||
+ ' Download it, then apply it locally from the repository root with:'
|
||||
+ '\n\n```shell\ngit apply amalgamation.patch\n```\n\n'
|
||||
+ 'This does not require installing astyle yourself.'
|
||||
: '')
|
||||
+ (first ? '\n\n@' + author + ' Please read and follow the [Contribution Guidelines]'
|
||||
body: '## 🔴 Amalgamation check failed! 🔴\nThe source code has not been amalgamated.'
|
||||
+ (first ? ' @' + author + ' Please read and follow the [Contribution Guidelines]'
|
||||
+ '(https://github.com/nlohmann/json/blob/develop/.github/CONTRIBUTING.md#files-to-change).'
|
||||
: '')
|
||||
})
|
||||
|
||||
@@ -17,13 +17,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: 'Checkout Repository'
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: 'Dependency Review'
|
||||
uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0
|
||||
|
||||
@@ -27,14 +27,12 @@ jobs:
|
||||
security-events: write
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: flawfinder_scan
|
||||
uses: david-a-wheeler/flawfinder@c4216b74cf2639ffa98503768bd6e4299b5440c9 # v2.0.20
|
||||
@@ -43,6 +41,6 @@ jobs:
|
||||
output: 'flawfinder_results.sarif'
|
||||
|
||||
- name: Upload analysis results to GitHub Security tab
|
||||
uses: github/codeql-action/upload-sarif@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
|
||||
uses: github/codeql-action/upload-sarif@9e0d7b8d25671d64c341c19c0152d693099fb5ba # v4
|
||||
with:
|
||||
sarif_file: ${{github.workspace}}/flawfinder_results.sarif
|
||||
|
||||
@@ -17,10 +17,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: srvaroa/labeler@bf262763a8a8e191f5847873aecc0f29df84f957 # v1.14.0
|
||||
- uses: srvaroa/labeler@e8fbb2561481ef6e711a770f0234e9379dc76892 # master
|
||||
env:
|
||||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||
|
||||
@@ -17,6 +17,60 @@ permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
# macos-11 is deprecated
|
||||
# macos-11:
|
||||
# runs-on: macos-11
|
||||
# strategy:
|
||||
# matrix:
|
||||
# xcode: ['11.7', '12.4', '12.5.1', '13.0']
|
||||
# env:
|
||||
# DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||
#
|
||||
# steps:
|
||||
# - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
# - name: Run CMake
|
||||
# run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
|
||||
# - name: Build
|
||||
# run: cmake --build build --parallel 10
|
||||
# - name: Test
|
||||
# run: cd build ; ctest -j 10 --output-on-failure
|
||||
|
||||
# macos-12 is deprecated (https://github.com/actions/runner-images/issues/10721)
|
||||
# macos-12:
|
||||
# runs-on: macos-12 # https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md
|
||||
# strategy:
|
||||
# matrix:
|
||||
# xcode: ['13.1', '13.2.1', '13.3.1', '13.4.1', '14.0', '14.0.1', '14.1']
|
||||
# env:
|
||||
# DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||
#
|
||||
# steps:
|
||||
# - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
# - name: Run CMake
|
||||
# run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
|
||||
# - name: Build
|
||||
# run: cmake --build build --parallel 10
|
||||
# - name: Test
|
||||
# run: cd build ; ctest -j 10 --output-on-failure
|
||||
|
||||
# macos-13 is deprecated (https://github.com/actions/runner-images/issues/13046)
|
||||
# macos-13:
|
||||
# runs-on: macos-13 # https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md
|
||||
# strategy:
|
||||
# matrix:
|
||||
# xcode: ['14.1', '14.2', '14.3', '14.3.1', '15.0.1', '15.1', '15.2']
|
||||
# env:
|
||||
# DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||
#
|
||||
# steps:
|
||||
# - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
# - name: Run CMake
|
||||
# run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
|
||||
# - name: Build
|
||||
# run: cmake --build build --parallel 10
|
||||
# - name: Test
|
||||
# run: cd build ; ctest -j 10 --output-on-failure
|
||||
|
||||
macos-14:
|
||||
runs-on: macos-14 # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md
|
||||
strategy:
|
||||
@@ -26,9 +80,7 @@ jobs:
|
||||
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
|
||||
- name: Build
|
||||
@@ -45,9 +97,7 @@ jobs:
|
||||
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
|
||||
- name: Build
|
||||
@@ -62,9 +112,7 @@ jobs:
|
||||
standard: [11, 14, 17, 20, 23, 26]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_TestStandards=${{ matrix.standard }}
|
||||
- name: Build
|
||||
|
||||
@@ -27,11 +27,11 @@ jobs:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Install virtual environment
|
||||
run: make install_venv -C docs/mkdocs
|
||||
|
||||
@@ -36,12 +36,12 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
@@ -76,6 +76,6 @@ jobs:
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
|
||||
uses: github/codeql-action/upload-sarif@9e0d7b8d25671d64c341c19c0152d693099fb5ba # v4.35.5
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
||||
@@ -32,36 +32,23 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
# Checkout project source
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
# Scan code using project's configuration on https://semgrep.dev/manage
|
||||
- uses: returntocorp/semgrep-action@713efdd345f3035192eaa63f56867b88e63e4e5d
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
# The former returntocorp/semgrep-action is deprecated (the org was renamed
|
||||
# to semgrep/*); the maintained approach is to install the CLI and invoke
|
||||
# it directly. We use `semgrep scan` (not `semgrep ci`, which requires a
|
||||
# login token): with no SEMGREP_APP_TOKEN configured this is exactly what
|
||||
# the old action fell back to, running community rules with no token.
|
||||
# SEMGREP_APP_TOKEN is still passed through so registry auth works if a
|
||||
# token is ever added.
|
||||
- name: Install Semgrep
|
||||
run: python3 -m pip install --user semgrep
|
||||
|
||||
# `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.
|
||||
- name: Run Semgrep
|
||||
run: semgrep scan --config auto --sarif --output=semgrep.sarif
|
||||
continue-on-error: true
|
||||
env:
|
||||
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
|
||||
publishToken: ${{ secrets.SEMGREP_APP_TOKEN }}
|
||||
publishDeployment: ${{ secrets.SEMGREP_DEPLOYMENT_ID }}
|
||||
generateSarif: "1"
|
||||
|
||||
# Upload SARIF file generated in previous step
|
||||
- name: Upload SARIF file
|
||||
uses: github/codeql-action/upload-sarif@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
|
||||
uses: github/codeql-action/upload-sarif@9e0d7b8d25671d64c341c19c0152d693099fb5ba # v4
|
||||
with:
|
||||
sarif_file: semgrep.sarif
|
||||
if: always()
|
||||
|
||||
@@ -16,11 +16,11 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/stale@eb5cf3af3ac0a1aa4c9c45633dd1ae542a27a899 # v10.3.0
|
||||
- uses: actions/stale@b5d41d4e1d5dceea10e7104786b73624c18a190f # v10.2.0
|
||||
with:
|
||||
stale-issue-label: 'state: stale'
|
||||
stale-pr-label: 'state: stale'
|
||||
|
||||
+31
-100
@@ -21,11 +21,9 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
container: gcc:latest
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@f5b8fbb4d77cec1acc5a5f9f0df4beffaf5d98d9 # v4.3.4
|
||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -35,9 +33,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v2.4.0
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -50,17 +46,15 @@ jobs:
|
||||
target: [ci_test_amalgamation, 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:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: Install Valgrind
|
||||
run: sudo apt-get update ; sudo apt-get install -y valgrind
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@f5b8fbb4d77cec1acc5a5f9f0df4beffaf5d98d9 # v4.3.4
|
||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -75,11 +69,9 @@ jobs:
|
||||
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@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@f5b8fbb4d77cec1acc5a5f9f0df4beffaf5d98d9 # v4.3.4
|
||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -94,11 +86,9 @@ jobs:
|
||||
steps:
|
||||
- name: Install build-essential
|
||||
run: apt-get update ; apt-get install -y build-essential unzip wget git libssl-dev
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@f5b8fbb4d77cec1acc5a5f9f0df4beffaf5d98d9 # v4.3.4
|
||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -108,13 +98,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Install dependencies and de_DE locale
|
||||
run: |
|
||||
sudo apt-get clean
|
||||
@@ -145,9 +133,7 @@ jobs:
|
||||
compiler: ['4.8', '4.9', '5', '6']
|
||||
container: ghcr.io/nlohmann/json-ci:v2.4.0
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Run CMake
|
||||
run: CXX=g++-${{ matrix.compiler }} cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -161,11 +147,9 @@ jobs:
|
||||
compiler: ['7', '8', '9', '10', '11', '12', '13', '14', '15', 'latest']
|
||||
container: gcc:${{ matrix.compiler }}
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@f5b8fbb4d77cec1acc5a5f9f0df4beffaf5d98d9 # v4.3.4
|
||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -178,11 +162,9 @@ jobs:
|
||||
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', 'latest']
|
||||
container: silkeh/clang:${{ matrix.compiler }}
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@f5b8fbb4d77cec1acc5a5f9f0df4beffaf5d98d9 # v4.3.4
|
||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
||||
- name: Set env FORCE_STDCPPFS_FLAG 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' }}
|
||||
@@ -198,11 +180,9 @@ jobs:
|
||||
matrix:
|
||||
standard: [11, 14, 17, 20, 23, 26]
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@f5b8fbb4d77cec1acc5a5f9f0df4beffaf5d98d9 # v4.3.4
|
||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -218,11 +198,9 @@ jobs:
|
||||
steps:
|
||||
- name: Install git and unzip
|
||||
run: apt-get update ; apt-get install -y git unzip
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@f5b8fbb4d77cec1acc5a5f9f0df4beffaf5d98d9 # v4.3.4
|
||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build with libc++
|
||||
@@ -236,9 +214,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v2.4.0
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -251,24 +227,9 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
container: ${{ matrix.container }}
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
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@f5b8fbb4d77cec1acc5a5f9f0df4beffaf5d98d9 # v4.3.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++
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -278,9 +239,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v2.2.0
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -288,45 +247,19 @@ jobs:
|
||||
. /opt/intel/oneapi/setvars.sh
|
||||
cmake --build build --target ci_icpc
|
||||
|
||||
ci_icpx:
|
||||
runs-on: ubuntu-latest
|
||||
container: intel/oneapi-hpckit:latest
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@f5b8fbb4d77cec1acc5a5f9f0df4beffaf5d98d9 # v4.3.4
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
run: cmake --build build --target ci_icpx
|
||||
|
||||
ci_nvhpc:
|
||||
runs-on: ubuntu-latest
|
||||
container: nvcr.io/nvidia/nvhpc:25.5-devel-cuda12.9-ubuntu22.04
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@f5b8fbb4d77cec1acc5a5f9f0df4beffaf5d98d9 # v4.3.4
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
run: cmake --build build --target ci_nvhpc
|
||||
|
||||
ci_emscripten:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: Install emscripten
|
||||
uses: mymindstorm/setup-emsdk@4528d102f7230f0e7b276855c01ea1159be0e984 # v16
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@f5b8fbb4d77cec1acc5a5f9f0df4beffaf5d98d9 # v4.3.4
|
||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -GNinja
|
||||
- name: Build
|
||||
@@ -339,13 +272,11 @@ jobs:
|
||||
target: [ci_test_examples, ci_test_build_documentation]
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
|
||||
@@ -24,9 +24,7 @@ jobs:
|
||||
architecture: [x64, x86]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Set up MinGW
|
||||
uses: egor-tensin/setup-mingw@41b837e47d7f85214629d255b9c4bc3fcbe9fd63 # v3.0
|
||||
with:
|
||||
@@ -49,9 +47,7 @@ jobs:
|
||||
runs-on: windows-2022
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Set extra CXX_FLAGS for latest std_version
|
||||
id: cxxflags
|
||||
run: |
|
||||
@@ -74,68 +70,6 @@ jobs:
|
||||
- name: Test
|
||||
run: cd build ; ctest -j 10 -C ${{ matrix.build_type }} --output-on-failure
|
||||
|
||||
# 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:
|
||||
strategy:
|
||||
matrix:
|
||||
build_type: [Debug, Release]
|
||||
architecture: [Win32, x64]
|
||||
std_version: [default, latest]
|
||||
|
||||
runs-on: windows-2025
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@f5b8fbb4d77cec1acc5a5f9f0df4beffaf5d98d9 # v4.3.4
|
||||
- name: Set extra CXX_FLAGS for latest std_version
|
||||
# /wd5285 silences C5285 emitted by the bundled third-party doctest.h, which
|
||||
# specializes std::tuple (newly diagnosed by the VS2026 v145 toolset)
|
||||
run: |
|
||||
if [ "${{ matrix.std_version }}" = "latest" ]; then
|
||||
echo "flags=/permissive- /std:c++latest /utf-8 /W4 /WX /wd5285" >> $GITHUB_ENV
|
||||
else
|
||||
echo "flags=/W4 /WX /wd5285" >> $GITHUB_ENV
|
||||
fi
|
||||
shell: bash
|
||||
- name: Run CMake (Release)
|
||||
run: cmake -S . -B build -G "Visual Studio 18 2026" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="$env:flags"
|
||||
if: matrix.build_type == 'Release'
|
||||
shell: pwsh
|
||||
- name: Run CMake (Debug)
|
||||
run: cmake -S . -B build -G "Visual Studio 18 2026" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON -DCMAKE_CXX_FLAGS="$env:flags"
|
||||
if: matrix.build_type == 'Debug'
|
||||
shell: pwsh
|
||||
- name: Build
|
||||
run: cmake --build build --config ${{ matrix.build_type }} --parallel 10
|
||||
- name: Test
|
||||
run: cd build ; ctest -j 10 -C ${{ matrix.build_type }} --output-on-failure
|
||||
|
||||
# Native ARM64 Windows runner with the MSVC ARM64 toolset. The windows-11-arm
|
||||
# label is only available for public repositories.
|
||||
msvc-arm64:
|
||||
strategy:
|
||||
matrix:
|
||||
build_type: [Debug, Release]
|
||||
|
||||
runs-on: windows-11-arm
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
- name: Run CMake (Release)
|
||||
run: cmake -S . -B build -G "Visual Studio 17 2022" -A ARM64 -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/W4 /WX"
|
||||
if: matrix.build_type == 'Release'
|
||||
shell: pwsh
|
||||
- name: Run CMake (Debug)
|
||||
run: cmake -S . -B build -G "Visual Studio 17 2022" -A ARM64 -DJSON_BuildTests=On -DJSON_FastTests=ON -DCMAKE_CXX_FLAGS="/W4 /WX"
|
||||
if: matrix.build_type == 'Debug'
|
||||
shell: pwsh
|
||||
- name: Build
|
||||
run: cmake --build build --config ${{ matrix.build_type }} --parallel 10
|
||||
- name: Test
|
||||
run: cd build ; ctest -j 10 -C ${{ matrix.build_type }} --output-on-failure
|
||||
|
||||
clang:
|
||||
runs-on: windows-2022
|
||||
strategy:
|
||||
@@ -143,9 +77,7 @@ jobs:
|
||||
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:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Install Clang
|
||||
run: curl -fsSL -o LLVM${{ matrix.version }}.exe https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ matrix.version }}/LLVM-${{ matrix.version }}-win64.exe ; 7z x LLVM${{ matrix.version }}.exe -y -o"C:/Program Files/LLVM"
|
||||
- name: Set up MinGW
|
||||
@@ -173,9 +105,7 @@ jobs:
|
||||
architecture: [Win32, x64]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -T ClangCL -DJSON_BuildTests=On
|
||||
- name: Build
|
||||
@@ -184,18 +114,9 @@ jobs:
|
||||
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure
|
||||
|
||||
ci_module_cpp20:
|
||||
runs-on: windows-2022
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
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@f5b8fbb4d77cec1acc5a5f9f0df4beffaf5d98d9 # v4.3.4
|
||||
with:
|
||||
cmakeVersion: 4.3.4
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Run CMake (Debug)
|
||||
run: cmake -S . -B build -G "Visual Studio 17 2022" -DJSON_CI=ON -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4 /WX"
|
||||
- name: Build
|
||||
|
||||
+12
-13
@@ -20,11 +20,7 @@ endif()
|
||||
##
|
||||
##
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
|
||||
|
||||
if (POLICY CMP0077)
|
||||
# Allow CMake 3.13+ to override options when using FetchContent / add_subdirectory.
|
||||
cmake_policy(SET CMP0077 NEW)
|
||||
endif ()
|
||||
include(ExternalProject)
|
||||
|
||||
# ---- C++ Modules Support (optional) ----
|
||||
option(NLOHMANN_JSON_BUILD_MODULES "Build C++ modules support" OFF)
|
||||
@@ -42,7 +38,12 @@ endif()
|
||||
## OPTIONS
|
||||
##
|
||||
|
||||
# VERSION_GREATER_EQUAL is not available in older CMake (< 3.7)
|
||||
if (POLICY CMP0077)
|
||||
# Allow CMake 3.13+ to override options when using FetchContent / add_subdirectory.
|
||||
cmake_policy(SET CMP0077 NEW)
|
||||
endif ()
|
||||
|
||||
# VERSION_GREATER_EQUAL is not available in CMake 3.1
|
||||
if(${MAIN_PROJECT} AND (${CMAKE_VERSION} VERSION_EQUAL 3.13 OR ${CMAKE_VERSION} VERSION_GREATER 3.13))
|
||||
set(JSON_BuildTests_INIT ON)
|
||||
else()
|
||||
@@ -97,7 +98,7 @@ if (NOT JSON_ImplicitConversions)
|
||||
endif()
|
||||
|
||||
if (JSON_DisableEnumSerialization)
|
||||
message(STATUS "Enum integer serialization is disabled (JSON_DISABLE_ENUM_SERIALIZATION=1)")
|
||||
message(STATUS "Enum integer serialization is disabled (JSON_DISABLE_ENUM_SERIALIZATION=0)")
|
||||
endif()
|
||||
|
||||
if (JSON_LegacyDiscardedValueComparison)
|
||||
@@ -163,7 +164,7 @@ if (MSVC)
|
||||
endif()
|
||||
|
||||
# Install a pkg-config file, so other tools can find this.
|
||||
configure_file(
|
||||
CONFIGURE_FILE(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkg-config.pc.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
|
||||
@ONLY
|
||||
@@ -173,11 +174,9 @@ configure_file(
|
||||
## TESTS
|
||||
## create and configure the unit test target
|
||||
##
|
||||
# Only build tests when JSON_BuildTests is set and testing has not been
|
||||
# disabled by a parent project via BUILD_TESTING (see the CTest module, which
|
||||
# also calls enable_testing()).
|
||||
if (JSON_BuildTests AND (NOT DEFINED BUILD_TESTING OR BUILD_TESTING))
|
||||
if (JSON_BuildTests)
|
||||
include(CTest)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
@@ -213,7 +212,7 @@ if(JSON_Install)
|
||||
install(
|
||||
FILES ${NLOHMANN_NATVIS_FILE}
|
||||
DESTINATION .
|
||||
)
|
||||
)
|
||||
endif()
|
||||
export(
|
||||
TARGETS ${NLOHMANN_JSON_TARGET_NAME}
|
||||
|
||||
@@ -9,30 +9,6 @@ This file describes the source for supporting files; that is, files that are not
|
||||
|
||||
## Continuous Integration
|
||||
|
||||
### `.github/workflows`
|
||||
|
||||
The [GitHub Actions](https://docs.github.com/en/actions) workflows that build, test, and analyze the library. Each file in this folder defines one workflow:
|
||||
|
||||
- `ubuntu.yml`, `macos.yml`, `windows.yml` — build and run the test suite on Linux, macOS, and Windows.
|
||||
- `check_amalgamation.yml` — verify that the single-header amalgamation in `single_include` is up to date on pull requests.
|
||||
- `comment_check_amalgamation.yml` — comment on a pull request when the amalgamation check failed.
|
||||
- `cifuzz.yml` — run short fuzzing sessions via [OSS-Fuzz CIFuzz](https://google.github.io/oss-fuzz/getting-started/continuous-integration/) on pull requests.
|
||||
- `codeql-analysis.yml` — run [CodeQL](https://codeql.github.com) code scanning.
|
||||
- `flawfinder.yml` — run the [Flawfinder](https://dwheeler.com/flawfinder/) static analysis.
|
||||
- `semgrep.yml` — run [Semgrep](https://semgrep.dev) static analysis.
|
||||
- `scorecards.yml` — run the [OpenSSF Scorecard](https://securityscorecards.dev) supply-chain security checks.
|
||||
- `dependency-review.yml` — scan dependency changes in pull requests for known vulnerabilities.
|
||||
- `labeler.yml` — the "Pull Request Labeler" workflow (see `.github/labeler.yml`).
|
||||
- `stale.yml` — comment on and close stale issues and pull requests.
|
||||
- `publish_documentation.yml` — build and publish the documentation on every merge to the `develop` branch.
|
||||
|
||||
Further documentation:
|
||||
|
||||
- [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions)
|
||||
|
||||
> [!IMPORTANT]
|
||||
> The folder `.github/workflows` is predetermined by GitHub.
|
||||
|
||||
### `.cirrus.yml`
|
||||
|
||||
Configuration file for the pipeline at [Cirrus CI](https://cirrus-ci.com/github/nlohmann/json).
|
||||
@@ -147,7 +123,7 @@ Further documentation:
|
||||
> [!IMPORTANT]
|
||||
> The folder `.github/ISSUE_TEMPLATE` is predetermined by GitHub.
|
||||
|
||||
### `.github/ISSUE_TEMPLATE/config.yml`
|
||||
### `.github/ISSUE_TEMPLATE/config.yaml`
|
||||
|
||||
Issue template chooser configuration. The file is used to configure the dialog when a new issue is created.
|
||||
|
||||
@@ -156,7 +132,7 @@ Further documentation:
|
||||
- [Configuring issue templates for your repository](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository)
|
||||
|
||||
> [!IMPORTANT]
|
||||
> The filename `.github/ISSUE_TEMPLATE/config.yml` is predetermined by GitHub.
|
||||
> The filename `.github/ISSUE_TEMPLATE/config.yaml` is predetermined by GitHub.
|
||||
|
||||
### `.github/labeler.yml`
|
||||
|
||||
@@ -189,7 +165,7 @@ Further documentation:
|
||||
- [Adding a security policy to your repository](https://docs.github.com/en/code-security/getting-started/adding-a-security-policy-to-your-repository)
|
||||
|
||||
> [!IMPORTANT]
|
||||
> The filename `.github/SECURITY.md` is predetermined by GitHub.
|
||||
> The filename `.github/SECURITY.yml` is predetermined by GitHub.
|
||||
|
||||
> [!NOTE]
|
||||
> The file is part of the documentation and is included in `docs/mkdocs/docs/community/security_policy.md`.
|
||||
@@ -258,16 +234,6 @@ make BUILD.bazel
|
||||
|
||||
### `meson.build`
|
||||
|
||||
The build definition for the [Meson](https://mesonbuild.com) build system.
|
||||
|
||||
### `Package.swift`
|
||||
|
||||
The package manifest for the [Swift Package Manager](https://www.swift.org/package-manager/).
|
||||
|
||||
### `MODULE.bazel`
|
||||
|
||||
The module definition for [Bazel](https://bazel.build)'s [Bzlmod](https://bazel.build/external/module) dependency system. It complements `BUILD.bazel` and replaces the previously used `WORKSPACE.bazel`.
|
||||
|
||||
Further documentation:
|
||||
|
||||
- [Bazel modules](https://bazel.build/external/module)
|
||||
### `WORKSPACE.bazel`
|
||||
|
||||
@@ -205,7 +205,7 @@ json.tar.xz:
|
||||
# We use `-X` to make the resulting ZIP file reproducible, see
|
||||
# <https://content.pivotal.io/blog/barriers-to-deterministic-reproducible-zip-files>.
|
||||
include.zip: BUILD.bazel
|
||||
zip -9 --recurse-paths -X include.zip $(SRCS) $(AMALGAMATED_FILE) $(AMALGAMATED_FWD_FILE) BUILD.bazel MODULE.bazel meson.build LICENSE.MIT
|
||||
zip -9 --recurse-paths -X include.zip $(SRCS) $(AMALGAMATED_FILE) $(AMALGAMATED_FWD_FILE) BUILD.bazel WORKSPACE.bazel meson.build LICENSE.MIT
|
||||
|
||||
# Create the files for a release and add signatures and hashes.
|
||||
release: include.zip json.tar.xz
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
[](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:json)
|
||||
[](https://wandbox.org/permlink/1mp10JbaANo6FUc7)
|
||||
[](https://json.nlohmann.me)
|
||||
[](https://raw.githubusercontent.com/nlohmann/json/develop/LICENSE.MIT)
|
||||
[](https://raw.githubusercontent.com/nlohmann/json/master/LICENSE.MIT)
|
||||
[](https://github.com/nlohmann/json/releases)
|
||||
[](https://repology.org/project/nlohmann-json/versions)
|
||||
[](https://github.com/nlohmann/json/releases)
|
||||
@@ -70,7 +70,7 @@ Other aspects were not so important to us:
|
||||
|
||||
- **Speed**. There are certainly [faster JSON libraries](https://github.com/miloyip/nativejson-benchmark#parsing-time) out there. However, if your goal is to speed up your development by adding JSON support with a single header, then this library is the way to go. If you know how to use a `std::vector` or `std::map`, you are already set.
|
||||
|
||||
See the [contribution guidelines](https://github.com/nlohmann/json/blob/develop/.github/CONTRIBUTING.md#please-dont) for more information.
|
||||
See the [contribution guidelines](https://github.com/nlohmann/json/blob/master/.github/CONTRIBUTING.md#please-dont) for more information.
|
||||
|
||||
## Sponsors
|
||||
|
||||
@@ -429,8 +429,6 @@ struct MyIterator {
|
||||
using reference = const char&;
|
||||
using iterator_category = std::input_iterator_tag;
|
||||
|
||||
explicit MyIterator(MyContainer* tgt = nullptr) : target(tgt) {}
|
||||
|
||||
MyIterator& operator++() {
|
||||
target->advance();
|
||||
return *this;
|
||||
@@ -452,12 +450,12 @@ MyIterator begin(MyContainer& tgt) {
|
||||
}
|
||||
|
||||
MyIterator end(const MyContainer&) {
|
||||
return MyIterator{};
|
||||
return {};
|
||||
}
|
||||
|
||||
void foo() {
|
||||
MyContainer c;
|
||||
json j = json::parse(begin(c), end(c));
|
||||
json j = json::parse(c);
|
||||
}
|
||||
```
|
||||
|
||||
@@ -758,9 +756,9 @@ int i = 42;
|
||||
json jn = i;
|
||||
auto f = jn.get<double>();
|
||||
// NOT RECOMMENDED
|
||||
double f2 = jn;
|
||||
double f2 = jb;
|
||||
double f3;
|
||||
f3 = jn;
|
||||
f3 = jb;
|
||||
|
||||
// etc.
|
||||
```
|
||||
@@ -1467,7 +1465,7 @@ I deeply appreciate the help of the following people.
|
||||
57. [Jared Grubb](https://github.com/jaredgrubb) supported the implementation of user-defined types.
|
||||
58. [EnricoBilla](https://github.com/EnricoBilla) noted a typo in an example.
|
||||
59. [Martin Hořeňovský](https://github.com/horenmar) found a way for a 2x speedup for the compilation time of the test suite.
|
||||
60. [ukhegg](https://github.com/ukhegg) proposed an improvement for the examples section.
|
||||
60. [ukhegg](https://github.com/ukhegg) found proposed an improvement for the examples section.
|
||||
61. [rswanson-ihi](https://github.com/rswanson-ihi) noted a typo in the README.
|
||||
62. [Mihai Stan](https://github.com/stanmihai4) fixed a bug in the comparison with `nullptr`s.
|
||||
63. [Tushar Maheshwari](https://github.com/tusharpm) added [cotire](https://github.com/sakra/cotire) support to speed up the compilation.
|
||||
@@ -1841,7 +1839,7 @@ The library supports **Unicode input** as follows:
|
||||
This library does not support comments by default. It does so for three reasons:
|
||||
|
||||
1. Comments are not part of the [JSON specification](https://tools.ietf.org/html/rfc8259). You may argue that `//` or `/* */` are allowed in JavaScript, but JSON is not JavaScript.
|
||||
2. This was not an oversight: Douglas Crockford [wrote on this](https://news.ycombinator.com/item?id=3912149) in May 2012:
|
||||
2. This was not an oversight: Douglas Crockford [wrote on this](https://plus.google.com/118095276221607585885/posts/RK8qyGVaGSr) in May 2012:
|
||||
|
||||
> I removed comments from JSON because I saw people were using them to hold parsing directives, a practice which would have destroyed interoperability. I know that the lack of comments makes some people sad, but it shouldn't.
|
||||
>
|
||||
@@ -1849,7 +1847,7 @@ This library does not support comments by default. It does so for three reasons:
|
||||
|
||||
3. It is dangerous for interoperability if some libraries would add comment support while others don't. Please check [The Harmful Consequences of the Robustness Principle](https://tools.ietf.org/html/draft-iab-protocol-maintenance-01) on this.
|
||||
|
||||
However, you can set parameter `ignore_comments` to true in the `parse` function to ignore `//` or `/* */` comments. Comments will then be treated as whitespace.
|
||||
However, you can set set parameter `ignore_comments` to true in the `parse` function to ignore `//` or `/* */` comments. Comments will then be treated as whitespace.
|
||||
|
||||
### Trailing commas
|
||||
|
||||
|
||||
@@ -701,48 +701,6 @@ add_custom_target(ci_icpc
|
||||
COMMENT "Compile and test with ICPC"
|
||||
)
|
||||
|
||||
add_custom_target(ci_icpx
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DCMAKE_BUILD_TYPE=Debug -GNinja
|
||||
-DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx
|
||||
-DJSON_BuildTests=ON -DJSON_FastTests=ON
|
||||
-S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_icpx
|
||||
COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_icpx
|
||||
COMMAND cd ${PROJECT_BINARY_DIR}/build_icpx && ${CMAKE_CTEST_COMMAND} --parallel ${N} --exclude-regex "test-unicode" --output-on-failure
|
||||
COMMENT "Compile and test with ICPX (Intel oneAPI DPC++/C++)"
|
||||
)
|
||||
|
||||
###############################################################################
|
||||
# NVIDIA HPC SDK C++ Compiler
|
||||
###############################################################################
|
||||
|
||||
# nvc++ defaults to a relaxed, non-IEEE floating-point model that flushes denormals
|
||||
# to zero and does not honor NaN ordering; -Kieee restores strict IEEE 754 behavior
|
||||
# (needed for the dtoa/grisu and NaN-comparison code paths).
|
||||
#
|
||||
# The following tests are excluded as they trigger known nvc++ 25.5 defects (not
|
||||
# library bugs); see https://github.com/nlohmann/json for tracking. Only the
|
||||
# affected language-standard variants are excluded so coverage is otherwise kept:
|
||||
# - test-comparison_cpp20, test-comparison_legacy_cpp20
|
||||
# miscompiles cross-type/<=> comparison (e.g. `-17 <= null`)
|
||||
# - test-constructor1_cpp11
|
||||
# std::initializer_list lifetime bug -> SIGSEGV
|
||||
# - test-deserialization_cpp20
|
||||
# mangles the UTF-8 u8"" string literal in the char8_t (C++20) section
|
||||
add_custom_target(ci_nvhpc
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DCMAKE_BUILD_TYPE=Debug -GNinja
|
||||
-DCMAKE_C_COMPILER=nvc -DCMAKE_CXX_COMPILER=nvc++
|
||||
-DCMAKE_CXX_FLAGS=-Kieee
|
||||
-DJSON_BuildTests=ON -DJSON_FastTests=ON
|
||||
-S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_nvhpc
|
||||
COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_nvhpc
|
||||
# the pipes are escaped so the surrounding shell passes them to ctest verbatim
|
||||
# instead of treating them as shell pipe operators
|
||||
COMMAND cd ${PROJECT_BINARY_DIR}/build_nvhpc && ${CMAKE_CTEST_COMMAND} --parallel ${N} --exclude-regex "test-unicode\\|test-comparison_cpp20\\|test-comparison_legacy_cpp20\\|test-constructor1_cpp11\\|test-deserialization_cpp20" --output-on-failure
|
||||
COMMENT "Compile and test with NVIDIA HPC SDK (nvc++)"
|
||||
)
|
||||
|
||||
###############################################################################
|
||||
# REUSE
|
||||
###############################################################################
|
||||
|
||||
@@ -12,7 +12,7 @@ else()
|
||||
# create a header with the path to the downloaded test data
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/include/test_data.hpp "#define TEST_DATA_DIRECTORY \"${CMAKE_BINARY_DIR}/test_files\"\n")
|
||||
|
||||
# download test data from the GitHub tag source archive
|
||||
# download test data from GitHub release
|
||||
ExternalProject_Add(download_test_data_project
|
||||
URL "${JSON_TEST_DATA_URL}/archive/refs/tags/v${JSON_TEST_DATA_VERSION}.zip"
|
||||
SOURCE_DIR "${CMAKE_BINARY_DIR}/test_files"
|
||||
@@ -32,17 +32,13 @@ endif()
|
||||
|
||||
# determine the operating system (for debug and support purposes)
|
||||
find_program(UNAME_COMMAND uname)
|
||||
find_program(VER_COMMAND ver)
|
||||
find_program(LSB_RELEASE_COMMAND lsb_release)
|
||||
find_program(SW_VERS_COMMAND sw_vers)
|
||||
set(OS_VERSION_STRINGS "${CMAKE_SYSTEM}")
|
||||
if (CMAKE_HOST_WIN32)
|
||||
# "ver" is a cmd.exe builtin rather than a standalone executable, so it
|
||||
# cannot be located with find_program and must be invoked through cmd
|
||||
execute_process(COMMAND cmd /c ver OUTPUT_VARIABLE VER_COMMAND_RESULT ERROR_QUIET)
|
||||
string(STRIP "${VER_COMMAND_RESULT}" VER_COMMAND_RESULT)
|
||||
if (VER_COMMAND_RESULT)
|
||||
set(OS_VERSION_STRINGS "${OS_VERSION_STRINGS}; ${VER_COMMAND_RESULT}")
|
||||
endif()
|
||||
if (VER_COMMAND)
|
||||
execute_process(COMMAND ${VER_COMMAND} OUTPUT_VARIABLE VER_COMMAND_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
set(OS_VERSION_STRINGS "${OS_VERSION_STRINGS}; ${VER_COMMAND_RESULT}")
|
||||
endif()
|
||||
if (SW_VERS_COMMAND)
|
||||
execute_process(COMMAND ${SW_VERS_COMMAND} OUTPUT_VARIABLE SW_VERS_COMMAND_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
|
||||
|
||||
+4
-4
@@ -35,8 +35,6 @@ foreach(feature ${CMAKE_CXX_COMPILE_FEATURES})
|
||||
set(compiler_supports_cpp_20 TRUE)
|
||||
elseif (${feature} STREQUAL cxx_std_23)
|
||||
set(compiler_supports_cpp_23 TRUE)
|
||||
elseif (${feature} STREQUAL cxx_std_26)
|
||||
set(compiler_supports_cpp_26 TRUE)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
@@ -94,6 +92,7 @@ function(json_test_set_test_options tests)
|
||||
target_compile_options(${test_interface} INTERFACE ${args_COMPILE_OPTIONS})
|
||||
target_link_libraries (${test_interface} INTERFACE ${args_LINK_LIBRARIES})
|
||||
target_link_options(${test_interface} INTERFACE ${args_LINK_OPTIONS})
|
||||
#set_target_properties(${test_interface} PROPERTIES JSON_TEST_PROPERTIES "${args_TEST_PROPERTIES}")
|
||||
set_property(DIRECTORY PROPERTY
|
||||
${test_interface}_TEST_PROPERTIES "${args_TEST_PROPERTIES}"
|
||||
)
|
||||
@@ -103,6 +102,7 @@ endfunction()
|
||||
|
||||
# for internal use by _json_test_add_test()
|
||||
function(_json_test_apply_test_properties test_target properties_target)
|
||||
#get_target_property(test_properties ${properties_target} JSON_TEST_PROPERTIES)
|
||||
get_property(test_properties DIRECTORY PROPERTY ${properties_target}_TEST_PROPERTIES)
|
||||
if(test_properties)
|
||||
set_tests_properties(${test_target} PROPERTIES ${test_properties})
|
||||
@@ -213,10 +213,10 @@ function(json_test_add_test_for file)
|
||||
|
||||
if("${args_NAME}" STREQUAL "")
|
||||
get_filename_component(file_basename ${file} NAME_WE)
|
||||
string(REGEX REPLACE "unit-(.+)" "test-\\1" test_name ${file_basename})
|
||||
string(REGEX REPLACE "unit-([^$]+)" "test-\\1" test_name ${file_basename})
|
||||
else()
|
||||
set(test_name ${args_NAME})
|
||||
if(NOT test_name MATCHES "test-.+")
|
||||
if(NOT test_name MATCHES "test-[^$]+")
|
||||
message(FATAL_ERROR "Test name must start with 'test-'.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -30,8 +30,7 @@ class (either explicitly or via the conversion operators).
|
||||
|
||||
## Return value
|
||||
|
||||
1. (none) -- the converted value is written to the output parameter `val`.
|
||||
2. the JSON value `j` converted to `TargetType`
|
||||
Copy of the JSON value, converted to `ValueType`
|
||||
|
||||
## Examples
|
||||
|
||||
|
||||
@@ -101,7 +101,6 @@ A UTF-8 byte order mark is silently ignored.
|
||||
## See also
|
||||
|
||||
- [parse](parse.md) - deserialize from a compatible input
|
||||
- [sax_parse](sax_parse.md) - parse input using the SAX interface
|
||||
- [operator>>](../operator_gtgt.md) - deserialize from stream
|
||||
|
||||
## Version history
|
||||
@@ -109,7 +108,7 @@ A UTF-8 byte order mark is silently ignored.
|
||||
- Added in version 3.0.0.
|
||||
- Ignoring comments via `ignore_comments` added in version 3.9.0.
|
||||
- Changed [runtime assertion](../../features/assertions.md) in case of `FILE*` null pointers to exception in version 3.12.0.
|
||||
- Added `ignore_trailing_commas` in version 3.12.x.
|
||||
- Added `ignore_trailing_commas` in version 3.12.1.
|
||||
|
||||
!!! warning "Deprecation"
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ This function is only needed to express two edge cases that cannot be realized w
|
||||
|
||||
- [`basic_json(initializer_list_t)`](basic_json.md) - create a JSON value from an initializer list
|
||||
- [`object`](object.md) - create a JSON object value from an initializer list
|
||||
- [Creating JSON values](../../features/creating_values.md) - the article on creating JSON values
|
||||
|
||||
## Version history
|
||||
|
||||
|
||||
@@ -82,8 +82,6 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
||||
key of an object which cannot be found. See the example below.
|
||||
- Throws [`out_of_range.404`](../../home/exceptions.md#jsonexceptionout_of_range404) if the JSON pointer `ptr` can
|
||||
not be resolved. See the example below.
|
||||
- Throws [`out_of_range.410`](../../home/exceptions.md#jsonexceptionout_of_range410) if an array index in the passed
|
||||
JSON pointer `ptr` exceeds the range of `size_type` (e.g., on 32-bit platforms).
|
||||
|
||||
## Complexity
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ The type used to store JSON booleans.
|
||||
[RFC 8259](https://tools.ietf.org/html/rfc8259) implicitly describes a boolean as a type which differentiates the two
|
||||
literals `#!json true` and `#!json false`.
|
||||
|
||||
To store boolean values in C++, a type is defined by the template parameter `BooleanType` which chooses the type to use.
|
||||
To store objects in C++, a type is defined by the template parameter `BooleanType` which chooses the type to use.
|
||||
|
||||
## Notes
|
||||
|
||||
|
||||
@@ -48,7 +48,11 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
||||
|
||||
1. The function does not throw exceptions.
|
||||
2. The function does not throw exceptions.
|
||||
3. The function does not throw exceptions.
|
||||
3. The function can throw the following exceptions:
|
||||
- Throws [`parse_error.106`](../../home/exceptions.md#jsonexceptionparse_error106) if an array index begins with
|
||||
`0`.
|
||||
- Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) if an array index was not a
|
||||
number.
|
||||
|
||||
## Complexity
|
||||
|
||||
@@ -107,11 +111,6 @@ Logarithmic in the size of the JSON object.
|
||||
--8<-- "examples/contains__json_pointer.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [find](find.md) find a value in an object
|
||||
- [count](count.md) returns the number of occurrences of a key
|
||||
|
||||
## Version history
|
||||
|
||||
1. Added in version 3.11.0.
|
||||
|
||||
@@ -72,11 +72,6 @@ This method always returns `0` when executed on a JSON type that is not an objec
|
||||
--8<-- "examples/count__keytype.c++17.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [find](find.md) find a value in an object
|
||||
- [contains](contains.md) checks whether a key exists
|
||||
|
||||
## Version history
|
||||
|
||||
1. Added in version 3.11.0.
|
||||
|
||||
@@ -10,7 +10,7 @@ Returns an iterator to the reverse-beginning; that is, the last element.
|
||||
|
||||
## Return value
|
||||
|
||||
reverse iterator to the last element
|
||||
reverse iterator to the first element
|
||||
|
||||
## Exception safety
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ Constant.
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows an example for `crend()`.
|
||||
The following code shows an example for `eend()`.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/crend.cpp"
|
||||
|
||||
@@ -56,9 +56,6 @@ Currently, only `remove`, `add`, and `replace` operations are generated.
|
||||
## See also
|
||||
|
||||
- [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902)
|
||||
- [patch](patch.md) applies a JSON Patch
|
||||
- [patch_inplace](patch_inplace.md) applies a JSON Patch in place
|
||||
- [merge_patch](merge_patch.md) applies a JSON Merge Patch
|
||||
|
||||
## Version history
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ and `ensure_ascii` parameters.
|
||||
|
||||
`error_handler` (in)
|
||||
: how to react on decoding errors; there are three possible values (see [`error_handler_t`](error_handler_t.md):
|
||||
`strict` (throws an exception in case a decoding error occurs; default), `replace` (replace invalid UTF-8 sequences
|
||||
with U+FFFD), and `ignore` (ignore invalid UTF-8 sequences during serialization; all valid bytes are copied to the
|
||||
output unchanged, and invalid bytes are dropped)).
|
||||
`strict` (throws and exception in case a decoding error occurs; default), `replace` (replace invalid UTF-8 sequences
|
||||
with U+FFFD), and `ignore` (ignore invalid UTF-8 sequences during serialization; all bytes are copied to the output
|
||||
unchanged)).
|
||||
|
||||
## Return value
|
||||
|
||||
@@ -71,12 +71,6 @@ Binary values are serialized as an object containing two keys:
|
||||
--8<-- "examples/dump.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [to_string](to_string.md) returns a string representation of a JSON value
|
||||
- [operator<<](../operator_ltlt.md) serialize to stream
|
||||
- [Serialization](../../features/serialization.md) - the serialization article
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
|
||||
@@ -29,10 +29,6 @@ iterators (including the `end()` iterator) and all references to the elements ar
|
||||
a pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and
|
||||
a `#!cpp bool` denoting whether the insertion took place.
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
|
||||
|
||||
## Exceptions
|
||||
|
||||
Throws [`type_error.311`](../../home/exceptions.md#jsonexceptiontype_error311) when called on a type other than JSON
|
||||
@@ -60,12 +56,6 @@ Logarithmic in the size of the container, O(log(`size()`)).
|
||||
--8<-- "examples/emplace.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [emplace_back](emplace_back.md) add a value to an array
|
||||
- [insert](insert.md) add values to an array/object
|
||||
- [Modifying values](../../features/modifying_values.md) - the article on modifying values
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 2.0.8.
|
||||
|
||||
@@ -58,7 +58,6 @@ Amortized constant.
|
||||
|
||||
- [operator+=](operator+=.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
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
||||
4. See 3.
|
||||
5. The function can throw the following exceptions:
|
||||
- Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) when called on a type other than
|
||||
JSON array; example: `"cannot use erase() with null"`
|
||||
JSON object; example: `"cannot use erase() with null"`
|
||||
- Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) when `idx >= size()`; example:
|
||||
`"array index 17 is out of range"`
|
||||
|
||||
@@ -202,12 +202,6 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
||||
--8<-- "examples/erase__size_type.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [clear](clear.md) clears the contents
|
||||
- [insert](insert.md) add values to an array/object
|
||||
- [Modifying values](../../features/modifying_values.md) - the article on modifying values
|
||||
|
||||
## Version history
|
||||
|
||||
1. Added in version 1.0.0. Added support for binary types in version 3.8.0.
|
||||
|
||||
@@ -18,7 +18,7 @@ replace
|
||||
: replace invalid UTF-8 sequences with U+FFFD (� REPLACEMENT CHARACTER)
|
||||
|
||||
ignore
|
||||
: ignore invalid UTF-8 sequences; all valid bytes are copied to the output unchanged, and invalid bytes are dropped
|
||||
: ignore invalid UTF-8 sequences; all bytes are copied to the output unchanged
|
||||
|
||||
## Examples
|
||||
|
||||
|
||||
@@ -78,7 +78,6 @@ This method always returns `end()` when executed on a JSON type that is not an o
|
||||
|
||||
## See also
|
||||
|
||||
- [count](count.md) returns the number of occurrences of a key
|
||||
- [contains](contains.md) checks whether a key exists
|
||||
|
||||
## Version history
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
# format_as(basic_json)
|
||||
|
||||
```cpp
|
||||
template <typename BasicJsonType>
|
||||
std::string format_as(const BasicJsonType& j);
|
||||
```
|
||||
|
||||
This function implements the [`format_as`](https://fmt.dev/latest/api/#formatting-user-defined-types)
|
||||
customization point used by the [{fmt}](https://github.com/fmtlib/fmt) library (fmtlib). It has no
|
||||
dependency on any `fmt` header and no effect at all unless a caller's translation unit also includes
|
||||
`fmt` and calls `fmt::format`/`fmt::print` on a JSON value.
|
||||
|
||||
## Template parameters
|
||||
|
||||
`BasicJsonType`
|
||||
: a specialization of [`basic_json`](index.md)
|
||||
|
||||
## Return value
|
||||
|
||||
string containing the serialization of the JSON value (same as [`dump()`](dump.md))
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
|
||||
|
||||
## Exceptions
|
||||
|
||||
Throws [`type_error.316`](../../home/exceptions.md#jsonexceptiontype_error316) if a string stored inside the JSON value
|
||||
is not UTF-8 encoded
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear.
|
||||
|
||||
## Possible implementation
|
||||
|
||||
```cpp
|
||||
template <typename BasicJsonType>
|
||||
std::string format_as(const BasicJsonType& j)
|
||||
{
|
||||
return j.dump();
|
||||
}
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
!!! warning "Version-dependent effect on fmt"
|
||||
|
||||
`fmt` only picks up a `format_as` overload that returns a `std::string` in fmt **10.0.0 through
|
||||
11.0.2**. Starting with fmt **11.1.0**, `fmt` restricts automatic `format_as` pickup to overloads that
|
||||
return an arithmetic type, so this function has no effect there (it is simply unused, not a compile
|
||||
error).
|
||||
|
||||
If you use fmt \>= 11.1.0, or want the same pretty-print spec support that
|
||||
[`std::formatter<basic_json>`](std_formatter.md) has (`#!cpp "{:#}"`, a width to set the indent such
|
||||
as `#!cpp "{:2}"`/`#!cpp "{:#2}"`, and fill-and-align to pick the indent character such as
|
||||
`#!cpp "{:.>#}"`), define your own `fmt::formatter` specialization mirroring the same logic:
|
||||
|
||||
```cpp
|
||||
--8<-- "../../../tests/fmt_formatter/project/main.cpp:formatter_recipe"
|
||||
```
|
||||
|
||||
This recipe isn't shipped by the library itself, since doing so would make `fmt` a build dependency
|
||||
(see the FAQ entry on
|
||||
[using JSON values with `std::format` or `fmt`](../../home/faq.md#using-json-values-with-stdformat-or-fmt)
|
||||
for more background) — but it *is* compiled and exercised against a real, current `fmt` release as
|
||||
part of the library's own test suite (`tests/fmt_formatter`, via CMake `FetchContent`), so it's kept in
|
||||
sync with `std::formatter<basic_json>` and verified to actually work, not just illustrative.
|
||||
|
||||
## Examples
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows how the library's `format_as()` function integrates with `fmt::format`,
|
||||
allowing argument-dependent lookup.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/format_as.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/format_as.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [dump](dump.md)
|
||||
- [std::formatter<basic_json>](std_formatter.md) - the `std::format` (C++20) equivalent
|
||||
- [Serialization](../../features/serialization.md) - the serialization article
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.12.x.
|
||||
@@ -67,8 +67,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
|
||||
- Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string could not be parsed
|
||||
successfully
|
||||
- Throws [out_of_range.408](../../home/exceptions.md#jsonexceptionout_of_range408) if the size of an optimized container
|
||||
or n-dimensional array cannot be represented by `std::size_t`
|
||||
|
||||
## Complexity
|
||||
|
||||
@@ -90,14 +88,6 @@ Linear in the size of the input.
|
||||
--8<-- "examples/from_bjdata.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [to_bjdata](to_bjdata.md) create a BJData serialization of a JSON value
|
||||
- [from_cbor](from_cbor.md) create a JSON value from an input in CBOR format
|
||||
- [from_msgpack](from_msgpack.md) create a JSON value from an input in MessagePack format
|
||||
- [from_bson](from_bson.md) create a JSON value from an input in BSON format
|
||||
- [from_ubjson](from_ubjson.md) create a JSON value from an input in UBJSON format
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.11.0.
|
||||
|
||||
@@ -62,12 +62,8 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va
|
||||
|
||||
## Exceptions
|
||||
|
||||
- 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
|
||||
- Throws [`parse_error.112`](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs (e.g., an
|
||||
invalid string or byte array length)
|
||||
- Throws [`parse_error.114`](../../home/exceptions.md#jsonexceptionparse_error114) if an unsupported BSON record type is
|
||||
encountered
|
||||
Throws [`parse_error.114`](../../home/exceptions.md#jsonexceptionparse_error114) if an unsupported BSON record type is
|
||||
encountered.
|
||||
|
||||
## Complexity
|
||||
|
||||
@@ -96,7 +92,6 @@ Linear in the size of the input.
|
||||
- [from_cbor](from_cbor.md) for the related CBOR format
|
||||
- [from_msgpack](from_msgpack.md) for the related MessagePack format
|
||||
- [from_ubjson](from_ubjson.md) for the related UBJSON format
|
||||
- [from_bjdata](from_bjdata.md) for the related BJData format
|
||||
|
||||
## Version history
|
||||
|
||||
|
||||
@@ -96,14 +96,6 @@ Linear in the size of the input.
|
||||
--8<-- "examples/from_cbor.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [to_cbor](to_cbor.md) create a CBOR serialization of a JSON value
|
||||
- [from_msgpack](from_msgpack.md) create a JSON value from an input in MessagePack format
|
||||
- [from_bson](from_bson.md) create a JSON value from an input in BSON format
|
||||
- [from_ubjson](from_ubjson.md) create a JSON value from an input in UBJSON format
|
||||
- [from_bjdata](from_bjdata.md) create a JSON value from an input in BJData format
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 2.0.9.
|
||||
|
||||
@@ -89,14 +89,6 @@ Linear in the size of the input.
|
||||
--8<-- "examples/from_msgpack.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [to_msgpack](to_msgpack.md) create a MessagePack serialization of a JSON value
|
||||
- [from_cbor](from_cbor.md) create a JSON value from an input in CBOR format
|
||||
- [from_bson](from_bson.md) create a JSON value from an input in BSON format
|
||||
- [from_ubjson](from_ubjson.md) create a JSON value from an input in UBJSON format
|
||||
- [from_bjdata](from_bjdata.md) create a JSON value from an input in BJData format
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 2.0.9.
|
||||
@@ -109,7 +101,7 @@ Linear in the size of the input.
|
||||
- Overload (2) replaces calls to `from_msgpack` with a pointer and a length as first two parameters, which has been
|
||||
deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like
|
||||
`#!cpp from_msgpack(ptr, len, ...);` with `#!cpp from_msgpack(ptr, ptr+len, ...);`.
|
||||
- Overload (2) replaces calls to `from_msgpack` with a pair of iterators as their first parameter, which has been
|
||||
- Overload (2) replaces calls to `from_cbor` with a pair of iterators as their first parameter, which has been
|
||||
deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like
|
||||
`#!cpp from_msgpack({ptr, ptr+len}, ...);` with `#!cpp from_msgpack(ptr, ptr+len, ...);`.
|
||||
|
||||
|
||||
@@ -65,10 +65,8 @@ 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
|
||||
the end of the file was not reached when `strict` was set to true
|
||||
- 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
|
||||
- Throws [out_of_range.408](../../home/exceptions.md#jsonexceptionout_of_range408) if the size of an optimized container
|
||||
or n-dimensional array cannot be represented by `std::size_t`
|
||||
|
||||
## Complexity
|
||||
|
||||
@@ -90,14 +88,6 @@ Linear in the size of the input.
|
||||
--8<-- "examples/from_ubjson.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [to_ubjson](to_ubjson.md) create a UBJSON serialization of a JSON value
|
||||
- [from_cbor](from_cbor.md) create a JSON value from an input in CBOR format
|
||||
- [from_msgpack](from_msgpack.md) create a JSON value from an input in MessagePack format
|
||||
- [from_bson](from_bson.md) create a JSON value from an input in BSON format
|
||||
- [from_bjdata](from_bjdata.md) create a JSON value from an input in BJData format
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.1.0.
|
||||
|
||||
@@ -88,32 +88,12 @@ constexpr const PointerType get_ptr() const noexcept;
|
||||
|
||||
Depends on what `json_serializer<ValueType>` `from_json()` method throws
|
||||
|
||||
## Complexity
|
||||
|
||||
Depends on the `json_serializer<ValueType>::from_json()` implementation for overloads (1) and (2); constant for
|
||||
overload (3).
|
||||
|
||||
## Notes
|
||||
|
||||
!!! danger "Undefined behavior for pointers"
|
||||
!!! danger "Undefined behavior"
|
||||
|
||||
Writing data to the pointee (overload 3) of the result yields an undefined state.
|
||||
|
||||
!!! danger "Undefined behavior for numeric conversions"
|
||||
|
||||
Conversions between numeric types are performed by the corresponding
|
||||
`from_json()` implementation using the target C++ type. When converting
|
||||
between numeric types, the library does not check whether the source
|
||||
value is representable by the target type.
|
||||
|
||||
If the source value is outside the range of the target type, the behavior
|
||||
is the same as the corresponding C++ conversion. In particular, converting
|
||||
a floating-point value to an integer type that cannot represent the value
|
||||
results in undefined behavior.
|
||||
|
||||
See [Number conversion](../../features/types/number_handling.md#number-conversion)
|
||||
for more information.
|
||||
|
||||
## Examples
|
||||
|
||||
??? example
|
||||
@@ -149,14 +129,6 @@ overload (3).
|
||||
--8<-- "examples/get__PointerType.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [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_ref](get_ref.md) get a reference to the stored value
|
||||
- [operator ValueType](operator_ValueType.md) get a value via implicit conversion
|
||||
- [Converting values](../../features/conversions.md) - the type conversions article
|
||||
|
||||
## Version history
|
||||
|
||||
1. Since version 2.1.0.
|
||||
|
||||
@@ -40,11 +40,6 @@ Constant.
|
||||
--8<-- "examples/get_binary.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [get](get.md) get a value (explicit conversion)
|
||||
- [get_ref](get_ref.md) get a reference to the stored value
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.8.0.
|
||||
|
||||
@@ -34,10 +34,6 @@ the input parameter, allowing chaining calls
|
||||
|
||||
Depends on what `json_serializer<ValueType>` `from_json()` method throws
|
||||
|
||||
## Complexity
|
||||
|
||||
Depends on the `json_serializer<ValueType>::from_json()` implementation.
|
||||
|
||||
## Examples
|
||||
|
||||
??? example
|
||||
@@ -57,13 +53,6 @@ Depends on the `json_serializer<ValueType>::from_json()` implementation.
|
||||
--8<-- "examples/get_to.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [get](get.md) get a value (explicit conversion)
|
||||
- [get_ref](get_ref.md) get a reference 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
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 3.3.0.
|
||||
|
||||
@@ -301,7 +301,6 @@ Access to the JSON value
|
||||
- [**operator<<(std::ostream&)**](../operator_ltlt.md) - serialize to stream
|
||||
- [**operator>>(std::istream&)**](../operator_gtgt.md) - deserialize from stream
|
||||
- [**to_string**](to_string.md) - user-defined `to_string` function for JSON values
|
||||
- [**format_as**](format_as.md) - user-defined `format_as` function for JSON values (fmt support)
|
||||
|
||||
## Literals
|
||||
|
||||
@@ -309,7 +308,6 @@ Access to the JSON value
|
||||
|
||||
## Helper classes
|
||||
|
||||
- [**std::formatter<basic_json>**](std_formatter.md) - make JSON values formattable with `std::format`
|
||||
- [**std::hash<basic_json>**](std_hash.md) - return a hash value for a JSON object
|
||||
- [**std::swap<basic_json>**](std_swap.md) - exchanges the values of two JSON objects
|
||||
|
||||
|
||||
@@ -96,8 +96,8 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
||||
5. The function can throw the following exceptions:
|
||||
- Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than
|
||||
objects; example: `"cannot use insert() with string"`
|
||||
- Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if `first` or `last`
|
||||
do not point to an object; example: `"iterators first and last must point to objects"`
|
||||
- Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an
|
||||
iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"`
|
||||
- Throws [`invalid_iterator.210`](../../home/exceptions.md#jsonexceptioninvalid_iterator210) if `first` and `last`
|
||||
do not belong to the same JSON value; example: `"iterators do not fit"`
|
||||
|
||||
@@ -181,13 +181,6 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
||||
--8<-- "examples/insert__range_object.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [emplace](emplace.md) add a value to an object
|
||||
- [emplace_back](emplace_back.md) add a value to an array
|
||||
- [push_back](push_back.md) add a value to an array/object
|
||||
- [update](update.md) merges objects
|
||||
|
||||
## Version history
|
||||
|
||||
1. Added in version 1.0.0.
|
||||
|
||||
@@ -66,7 +66,6 @@ classDiagram
|
||||
|
||||
## See also
|
||||
|
||||
- [`exception`](exception.md) for the base class of all exceptions thrown by the library
|
||||
- [List of iterator errors](../../home/exceptions.md#iterator-errors)
|
||||
- [`parse_error`](parse_error.md) for exceptions indicating a parse error
|
||||
- [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type
|
||||
|
||||
@@ -45,13 +45,11 @@ Constant.
|
||||
|
||||
When a value is discarded by a callback function (see [`parser_callback_t`](parser_callback_t.md)) during parsing,
|
||||
then it is removed when it is part of a structured value. For instance, if the second value of an array is discarded,
|
||||
instead of `#!json [null, discarded, false]`, the array `#!json [null, false]` is returned. If the top-level value
|
||||
itself is discarded by the callback, the `parse` call returns a `#!json null` value.
|
||||
instead of `#!json [null, discarded, false]`, the array `#!json [null, false]` is returned. Only if the top-level
|
||||
value is discarded, the return value of the `parse` call is discarded.
|
||||
|
||||
After a successful parse, this function always returns `#!cpp false`: discarded values can only occur during parsing and
|
||||
are either removed when inside a structured value or replaced by `#!json null` at the top level. The exception is parsing
|
||||
with `allow_exceptions` set to `#!cpp false`: a parse error then yields a discarded value for which this function returns
|
||||
`#!cpp true` (see [`parse`](parse.md)).
|
||||
This function will always be `#!cpp false` for JSON values after parsing. That is, discarded values can only occur
|
||||
during parsing, but will be removed when inside a structured value or replaced by null in other cases.
|
||||
|
||||
## Examples
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ unsigned) and floating-point values.
|
||||
|
||||
## Return value
|
||||
|
||||
`#!cpp true` if type is number (regardless whether integer, unsigned integer, or floating-point), `#!cpp false` otherwise.
|
||||
`#!cpp true` if type is number (regardless whether integer, unsigned integer, or floating-type), `#!cpp false` otherwise.
|
||||
|
||||
## Exception safety
|
||||
|
||||
|
||||
@@ -84,11 +84,6 @@ When iterating over an array, `key()` will return the index of the element as st
|
||||
--8<-- "examples/items.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [begin](begin.md) returns an iterator to the first element
|
||||
- [end](end.md) returns an iterator to one past the last element
|
||||
|
||||
## Version history
|
||||
|
||||
- Added `iterator_wrapper` in version 3.0.0.
|
||||
|
||||
@@ -13,7 +13,7 @@ JSON object holding version information
|
||||
|
||||
| key | description |
|
||||
|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `compiler` | Information on the used compiler. It is an object with the following keys: `c++` (the used C++ standard), `family` (the compiler family; possible values are `clang`, `icc`, `gcc`, `ilecpp`, `msvc`, `pgcpp`, `sunpro`, and `unknown`), and `version` (the compiler version). On HP aCC compilers, `compiler` is instead the plain string `hp`. |
|
||||
| `compiler` | Information on the used compiler. It is an object with the following keys: `c++` (the used C++ standard), `family` (the compiler family; possible values are `clang`, `icc`, `gcc`, `ilecpp`, `msvc`, `pgcpp`, `sunpro`, and `unknown`), and `version` (the compiler version). |
|
||||
| `copyright` | The copyright line for the library as string. |
|
||||
| `name` | The name of the library as string. |
|
||||
| `platform` | The used platform as string. Possible values are `win32`, `linux`, `apple`, `unix`, and `unknown`. |
|
||||
|
||||
@@ -32,6 +32,7 @@ With the default values for `NumberIntegerType` (`std::int64_t`), the default va
|
||||
- The restrictions about leading zeros are not enforced in C++. Instead, leading zeros in integer literals lead to an
|
||||
interpretation as an octal number. Internally, the value will be stored as a decimal number. For instance, the C++
|
||||
integer literal `010` will be serialized to `8`. During deserialization, leading zeros yield an error.
|
||||
- Not-a-number (NaN) values will be serialized to `null`.
|
||||
|
||||
#### Limits
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ With the default values for `NumberUnsignedType` (`std::uint64_t`), the default
|
||||
- The restrictions about leading zeros are not enforced in C++. Instead, leading zeros in integer literals lead to an
|
||||
interpretation as an octal number. Internally, the value will be stored as a decimal number. For instance, the C++
|
||||
integer literal `010` will be serialized to `8`. During deserialization, leading zeros yield an error.
|
||||
- Not-a-number (NaN) values will be serialized to `null`.
|
||||
|
||||
#### Limits
|
||||
|
||||
@@ -44,7 +45,7 @@ when used in a constructor. During deserialization, too large or small integer n
|
||||
as [`number_integer_t`](number_integer_t.md) or [`number_float_t`](number_float_t.md).
|
||||
|
||||
[RFC 8259](https://tools.ietf.org/html/rfc8259) further states:
|
||||
> Note that when such software is used, numbers that are integers and are in the range $[-2^{53}+1, 2^{53}-1]$ are
|
||||
> Note that when such software is used, numbers that are integers and are in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are
|
||||
> interoperable in the sense that implementations will agree exactly on their numeric values.
|
||||
|
||||
As this range is a subrange (when considered in conjunction with the `number_integer_t` type) of the exactly supported
|
||||
|
||||
@@ -57,7 +57,6 @@ the initializer list constructor `basic_json(initializer_list_t, bool, value_t)`
|
||||
|
||||
- [`basic_json(initializer_list_t)`](basic_json.md) - create a JSON value from an initializer list
|
||||
- [`array`](array.md) - create a JSON array value from an initializer list
|
||||
- [Creating JSON values](../../features/creating_values.md) - the article on creating JSON values
|
||||
|
||||
## Version history
|
||||
|
||||
|
||||
@@ -50,12 +50,9 @@ invalidates all iterators and all references.
|
||||
|
||||
## Exceptions
|
||||
|
||||
1. Throws [`type_error.308`](../../home/exceptions.md#jsonexceptiontype_error308) when called on a type other than
|
||||
JSON array or null; example: `"cannot use push_back() with number"`
|
||||
2. Throws [`type_error.308`](../../home/exceptions.md#jsonexceptiontype_error308) when called on a type other than
|
||||
JSON object or null; example: `"cannot use push_back() with number"`
|
||||
3. Throws [`type_error.308`](../../home/exceptions.md#jsonexceptiontype_error308) when called on a type other than
|
||||
JSON array or null; example: `"cannot use push_back() with number"`
|
||||
All functions can throw the following exception:
|
||||
- Throws [`type_error.308`](../../home/exceptions.md#jsonexceptiontype_error308) when called on a type other than
|
||||
JSON array or null; example: `"cannot use operator+=() with number"`
|
||||
|
||||
## Complexity
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@ basic_json& operator=(basic_json other) noexcept (
|
||||
std::is_nothrow_move_constructible<value_t>::value &&
|
||||
std::is_nothrow_move_assignable<value_t>::value &&
|
||||
std::is_nothrow_move_constructible<json_value>::value &&
|
||||
std::is_nothrow_move_assignable<json_value>::value &&
|
||||
std::is_nothrow_move_assignable<json_base_class_t>::value
|
||||
std::is_nothrow_move_assignable<json_value>::value
|
||||
);
|
||||
```
|
||||
|
||||
@@ -18,10 +17,6 @@ constructor, destructor, and the `swap()` member function.
|
||||
`other` (in)
|
||||
: value to copy from
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown while copying `other`, there are no changes to `#!cpp *this`.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear.
|
||||
@@ -43,11 +38,6 @@ Linear.
|
||||
--8<-- "examples/basic_json__copyassignment.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [basic_json](basic_json.md) create a JSON value
|
||||
- [swap](swap.md) exchanges the contents of two JSON values
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
|
||||
@@ -83,8 +83,6 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
||||
in the passed JSON pointer `ptr` for the const version.
|
||||
- Throws [`out_of_range.404`](../../home/exceptions.md#jsonexceptionout_of_range404) if the JSON pointer `ptr` can
|
||||
not be resolved.
|
||||
- Throws [`out_of_range.410`](../../home/exceptions.md#jsonexceptionout_of_range410) if an array index in the passed
|
||||
JSON pointer `ptr` exceeds the range of `size_type` (e.g., on 32-bit platforms).
|
||||
|
||||
## Complexity
|
||||
|
||||
@@ -97,10 +95,7 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
||||
|
||||
!!! danger "Undefined behavior and runtime assertions"
|
||||
|
||||
The following cases apply to the **const** overloads; the non-const overloads instead insert the missing element
|
||||
(see the notes below).
|
||||
|
||||
1. If the element at index `idx` does not exist, the behavior is undefined.
|
||||
1. If the element with key `idx` does not exist, the behavior is undefined.
|
||||
2. If the element with key `key` does not exist, the behavior is undefined and is **guarded by a
|
||||
[runtime assertion](../../features/assertions.md)**!
|
||||
|
||||
|
||||
@@ -75,11 +75,6 @@ Linear in the size of the JSON value.
|
||||
--8<-- "examples/operator__ValueType.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [get](get.md) get a value (explicit conversion)
|
||||
- [Converting values](../../features/conversions.md) - the type conversions article
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 1.0.0.
|
||||
|
||||
@@ -20,7 +20,7 @@ class basic_json {
|
||||
```
|
||||
|
||||
1. Compares two JSON values for equality according to the following rules:
|
||||
- Two JSON values are equal if (1) neither value is discarded, and (2) they are of the same type and their stored
|
||||
- Two JSON values are equal if (1) neither value is discarded, or (2) they are of the same type and their stored
|
||||
values are the same according to their respective `operator==`.
|
||||
- Integer and floating-point numbers are automatically converted before comparison.
|
||||
|
||||
@@ -79,13 +79,13 @@ Linear.
|
||||
}
|
||||
```
|
||||
|
||||
Or you can define your own equality function like this:
|
||||
Or you can self-defined operator equal function like this:
|
||||
|
||||
```cpp
|
||||
bool my_equal(const_reference lhs, const_reference rhs)
|
||||
{
|
||||
const auto lhs_type = lhs.type();
|
||||
const auto rhs_type = rhs.type();
|
||||
const auto lhs_type lhs.type();
|
||||
const auto rhs_type rhs.type();
|
||||
if (lhs_type == rhs_type)
|
||||
{
|
||||
switch(lhs_type)
|
||||
@@ -162,11 +162,6 @@ Linear.
|
||||
--8<-- "examples/operator__equal__nullptr_t.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [operator!=](operator_ne.md) compare for inequality
|
||||
- [operator<=>](operator_spaceship.md) comparison: 3-way (C++20)
|
||||
|
||||
## Version history
|
||||
|
||||
1. Added in version 1.0.0. Added C++20 member functions in version 3.11.0.
|
||||
|
||||
@@ -35,7 +35,7 @@ bool operator>=(ScalarType lhs, const const_reference rhs) noexcept; // (2)
|
||||
|
||||
## Return value
|
||||
|
||||
whether `lhs` is greater than or equal to `rhs`
|
||||
whether `lhs` is less than or equal to `rhs`
|
||||
|
||||
## Exception safety
|
||||
|
||||
|
||||
@@ -66,7 +66,6 @@ classDiagram
|
||||
|
||||
## See also
|
||||
|
||||
- [`exception`](exception.md) for the base class of all exceptions thrown by the library
|
||||
- [List of other errors](../../home/exceptions.md#further-exceptions)
|
||||
- [`parse_error`](parse_error.md) for exceptions indicating a parse error
|
||||
- [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators
|
||||
|
||||
@@ -67,7 +67,6 @@ classDiagram
|
||||
|
||||
## See also
|
||||
|
||||
- [`exception`](exception.md) for the base class of all exceptions thrown by the library
|
||||
- [List of out-of-range errors](../../home/exceptions.md#out-of-range)
|
||||
- [`parse_error`](parse_error.md) for exceptions indicating a parse error
|
||||
- [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators
|
||||
|
||||
@@ -81,6 +81,9 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va
|
||||
|
||||
- Throws [`parse_error.101`](../../home/exceptions.md#jsonexceptionparse_error101) in case of an unexpected token, or
|
||||
empty input like a null `FILE*` or `char*` pointer.
|
||||
- Throws [`parse_error.102`](../../home/exceptions.md#jsonexceptionparse_error102) if `to_unicode` fails or surrogate
|
||||
error.
|
||||
- Throws [`parse_error.103`](../../home/exceptions.md#jsonexceptionparse_error103) if `to_unicode` fails.
|
||||
|
||||
## Complexity
|
||||
|
||||
@@ -92,9 +95,6 @@ super-linear complexity.
|
||||
|
||||
A UTF-8 byte order mark is silently ignored.
|
||||
|
||||
Invalid Unicode escapes and unpaired surrogates in the input are reported as
|
||||
[`parse_error.101`](../../home/exceptions.md#jsonexceptionparse_error101) with a detailed message.
|
||||
|
||||
## Examples
|
||||
|
||||
??? example "Parsing from a character array"
|
||||
@@ -183,7 +183,7 @@ Invalid Unicode escapes and unpaired surrogates in the input are reported as
|
||||
|
||||
??? example "Effect of `allow_exceptions` parameter"
|
||||
|
||||
The example below demonstrates the effect of the `allow_exceptions` parameter in the `parse()` function.
|
||||
The example below demonstrates the effect of the `allow_exceptions` parameter in the ´parse()` function.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/parse__allow_exceptions.cpp"
|
||||
@@ -226,7 +226,6 @@ Invalid Unicode escapes and unpaired surrogates in the input are reported as
|
||||
## See also
|
||||
|
||||
- [accept](accept.md) - check if the input is valid JSON
|
||||
- [sax_parse](sax_parse.md) - parse input using the SAX interface
|
||||
- [operator>>](../operator_gtgt.md) - deserialize from stream
|
||||
|
||||
## Version history
|
||||
@@ -235,7 +234,7 @@ Invalid Unicode escapes and unpaired surrogates in the input are reported as
|
||||
- Overload for contiguous containers (1) added in version 2.0.3.
|
||||
- Ignoring comments via `ignore_comments` added in version 3.9.0.
|
||||
- Changed [runtime assertion](../../features/assertions.md) in case of `FILE*` null pointers to exception in version 3.12.0.
|
||||
- Added `ignore_trailing_commas` in version 3.12.x.
|
||||
- Added `ignore_trailing_commas` in version 3.12.1.
|
||||
|
||||
!!! warning "Deprecation"
|
||||
|
||||
|
||||
@@ -75,7 +75,6 @@ or the end of file. This also holds true when reading a byte vector for binary f
|
||||
|
||||
## See also
|
||||
|
||||
- [`exception`](exception.md) for the base class of all exceptions thrown by the library
|
||||
- [List of parse errors](../../home/exceptions.md#parse-errors)
|
||||
- [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators
|
||||
- [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type
|
||||
|
||||
@@ -24,11 +24,6 @@ The parser callback distinguishes the following events:
|
||||
|
||||

|
||||
|
||||
## See also
|
||||
|
||||
- [parser_callback_t](parser_callback_t.md) callback function type for the parser
|
||||
- [parse](parse.md) deserialize from a compatible input
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
|
||||
@@ -68,11 +68,6 @@ the latter case, it is either skipped completely or replaced by an empty discard
|
||||
--8<-- "examples/parse__string__parser_callback_t.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [parse](parse.md) deserialize from a compatible input
|
||||
- [parse_event_t](parse_event_t.md) enumeration of parser events
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
|
||||
@@ -32,9 +32,7 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va
|
||||
could not be resolved successfully in the current JSON value; example: `"key baz not found"`.
|
||||
- Throws [`out_of_range.405`](../../home/exceptions.md#jsonexceptionout_of_range405) if JSON pointer has no parent
|
||||
("add", "remove", "move")
|
||||
- Throws [`out_of_range.411`](../../home/exceptions.md#jsonexceptionout_of_range411) if an "add" operation's target
|
||||
location has a parent that is neither an object nor an array.
|
||||
- Throws [`other_error.501`](../../home/exceptions.md#jsonexceptionother_error501) if "test" operation was
|
||||
- Throws [`out_of_range.501`](../../home/exceptions.md#jsonexceptionother_error501) if "test" operation was
|
||||
unsuccessful.
|
||||
|
||||
## Complexity
|
||||
@@ -73,5 +71,3 @@ is thrown. In any case, the original value is not changed: the patch is applied
|
||||
## Version history
|
||||
|
||||
- Added in version 2.0.0.
|
||||
- Added [`out_of_range.411`](../../home/exceptions.md#jsonexceptionout_of_range411) and stopped relying on an internal assertion when an "add" operation's
|
||||
target location has a non-object/non-array parent in version 3.12.x.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# <small>nlohmann::basic_json::</small>patch_inplace
|
||||
|
||||
```cpp
|
||||
void patch_inplace(const basic_json& json_patch);
|
||||
void patch_inplace(const basic_json& json_patch) const;
|
||||
```
|
||||
|
||||
[JSON Patch](http://jsonpatch.com) defines a JSON document structure for expressing a sequence of operations to apply to
|
||||
@@ -28,9 +28,7 @@ No guarantees, value may be corrupted by an unsuccessful patch operation.
|
||||
could not be resolved successfully in the current JSON value; example: `"key baz not found"`.
|
||||
- Throws [`out_of_range.405`](../../home/exceptions.md#jsonexceptionout_of_range405) if JSON pointer has no parent
|
||||
("add", "remove", "move")
|
||||
- Throws [`out_of_range.411`](../../home/exceptions.md#jsonexceptionout_of_range411) if an "add" operation's target
|
||||
location has a parent that is neither an object nor an array.
|
||||
- Throws [`other_error.501`](../../home/exceptions.md#jsonexceptionother_error501) if "test" operation was
|
||||
- Throws [`out_of_range.501`](../../home/exceptions.md#jsonexceptionother_error501) if "test" operation was
|
||||
unsuccessful.
|
||||
|
||||
## Complexity
|
||||
@@ -64,11 +62,9 @@ function throws an exception.
|
||||
|
||||
- [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902)
|
||||
- [RFC 6901 (JSON Pointer)](https://tools.ietf.org/html/rfc6901)
|
||||
- [patch](patch.md) applies a JSON Patch
|
||||
- [patch](patch.md) applies a JSON Merge Patch
|
||||
- [merge_patch](merge_patch.md) applies a JSON Merge Patch
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.11.0.
|
||||
- Added [`out_of_range.411`](../../home/exceptions.md#jsonexceptionout_of_range411) and stopped relying on an internal assertion when an "add" operation's
|
||||
target location has a non-object/non-array parent in version 3.12.x.
|
||||
|
||||
@@ -46,12 +46,9 @@ invalidates all iterators and all references.
|
||||
|
||||
## Exceptions
|
||||
|
||||
1. Throws [`type_error.308`](../../home/exceptions.md#jsonexceptiontype_error308) when called on a type other than
|
||||
JSON array or null; example: `"cannot use push_back() with number"`
|
||||
2. Throws [`type_error.308`](../../home/exceptions.md#jsonexceptiontype_error308) when called on a type other than
|
||||
JSON object or null; example: `"cannot use push_back() with number"`
|
||||
3. Throws [`type_error.308`](../../home/exceptions.md#jsonexceptiontype_error308) when called on a type other than
|
||||
JSON array or null; example: `"cannot use push_back() with number"`
|
||||
All functions can throw the following exception:
|
||||
- Throws [`type_error.308`](../../home/exceptions.md#jsonexceptiontype_error308) when called on a type other than
|
||||
JSON array or null; example: `"cannot use push_back() with number"`
|
||||
|
||||
## Complexity
|
||||
|
||||
@@ -115,7 +112,6 @@ invalidates all iterators and all references.
|
||||
|
||||
- [emplace_back](emplace_back.md) add a value to an array
|
||||
- [operator+=](operator+=.md) add a value to an array/object
|
||||
- [Modifying values](../../features/modifying_values.md) - the article on modifying values
|
||||
|
||||
## Version history
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ Returns an iterator to the reverse-beginning; that is, the last element.
|
||||
|
||||
## Return value
|
||||
|
||||
reverse iterator to the last element
|
||||
reverse iterator to the first element
|
||||
|
||||
## Exception safety
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ Constant.
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows an example for `rend()`.
|
||||
The following code shows an example for `eend()`.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/rend.cpp"
|
||||
|
||||
@@ -43,11 +43,10 @@ The SAX event lister must follow the interface of [`json_sax`](../json_sax/index
|
||||
iterators.
|
||||
|
||||
`IteratorType`
|
||||
: a compatible iterator type for overload (2); a pair of character iterators whose `value_type` is an integral type
|
||||
with a size of 1, 2, or 4 bytes (interpreted respectively as UTF-8, UTF-16, and UTF-32)
|
||||
: Description
|
||||
|
||||
`SAX`
|
||||
: a class fulfilling the SAX event listener interface; see [`json_sax`](../json_sax/index.md)
|
||||
: Description
|
||||
|
||||
## Parameters
|
||||
|
||||
@@ -90,6 +89,10 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va
|
||||
|
||||
- Throws [`parse_error.101`](../../home/exceptions.md#jsonexceptionparse_error101) in case of an unexpected token, or
|
||||
empty input like a null `FILE*` or `char*` pointer.
|
||||
- Throws [`parse_error.102`](../../home/exceptions.md#jsonexceptionparse_error102) if `to_unicode` fails or surrogate
|
||||
error.
|
||||
- Throws [`parse_error.103`](../../home/exceptions.md#jsonexceptionparse_error103) if `to_unicode` fails.
|
||||
- Throws [`other_error.502`](../../home/exceptions.md#jsonexceptionother_error502) if `sax` is a null pointer.
|
||||
|
||||
## Complexity
|
||||
|
||||
@@ -117,16 +120,12 @@ A UTF-8 byte order mark is silently ignored.
|
||||
--8<-- "examples/sax_parse.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [parse](parse.md) - deserialize from a compatible input
|
||||
- [accept](accept.md) - check if the input is valid JSON
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.2.0.
|
||||
- Ignoring comments via `ignore_comments` added in version 3.9.0.
|
||||
- Added `ignore_trailing_commas` in version 3.12.x.
|
||||
- Added `ignore_trailing_commas` in version 3.12.1.
|
||||
- Added `json.exception.other_error.502` exception in version 3.12.1.
|
||||
|
||||
!!! warning "Deprecation"
|
||||
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
# <small>std::</small>formatter<nlohmann::basic_json\>
|
||||
|
||||
```cpp
|
||||
namespace std {
|
||||
template <>
|
||||
struct formatter<nlohmann::basic_json, char>;
|
||||
}
|
||||
```
|
||||
|
||||
Specialization to make JSON values formattable with [`std::format`](https://en.cppreference.com/w/cpp/utility/format/format)
|
||||
(and the other members of C++20's `<format>` header, such as `std::format_to`).
|
||||
|
||||
A subset of the [standard format spec grammar](https://en.cppreference.com/w/cpp/utility/format/spec) is
|
||||
supported, repurposed for JSON pretty-printing; any other spec component (sign, the `0` flag, precision,
|
||||
`L`, a dynamic width such as `#!cpp "{:{}}"`, or a trailing type character) throws
|
||||
[`std::format_error`](https://en.cppreference.com/w/cpp/utility/format/format_error):
|
||||
|
||||
- `#!cpp "{}"` serializes the value the same way as [`dump()`](dump.md) (compact, no whitespace).
|
||||
- `#!cpp "{:#}"` ("alternate form") serializes the value the same way as `#!cpp dump(4)` (pretty-printed
|
||||
with an indent of 4).
|
||||
- A width, with or without `#!cpp "#"` (e.g. `#!cpp "{:2}"` or `#!cpp "{:#2}"`), serializes the value the
|
||||
same way as `#!cpp dump(width)` — a width on its own implies pretty-printing, since an indent size has
|
||||
no meaning for compact output.
|
||||
- `fill-and-align` (e.g. `#!cpp "{:.>#}"` or `#!cpp "{:.>3}"`) picks a custom indent character, the same
|
||||
way as `#!cpp dump(indent, indent_char)`. The alignment direction itself (`#!cpp '<'`, `#!cpp '>'`,
|
||||
`#!cpp '^'`) has no separate meaning for JSON values — only the fill character before it is used, and
|
||||
any of the three directions is accepted.
|
||||
|
||||
This specialization is only available for `#!cpp char`-based JSON values and only if the standard library
|
||||
provides `<format>`, controlled by the [`JSON_HAS_STD_FORMAT`](../macros/json_has_std_format.md) macro.
|
||||
|
||||
## Examples
|
||||
|
||||
??? example
|
||||
|
||||
The example shows how to format JSON values with `std::format`.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/std_formatter.c++20.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/std_formatter.c++20.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [dump](dump.md) - serialization
|
||||
- [operator<<(std::ostream&)](../operator_ltlt.md) - serialize to stream
|
||||
- [format_as](format_as.md) - customization point used by `fmt::format` (fmtlib)
|
||||
- [Serialization](../../features/serialization.md) - the serialization article
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.12.x.
|
||||
@@ -16,14 +16,6 @@ Exchanges the values of two JSON objects.
|
||||
`j2` (in, out)
|
||||
: value to be replaced by `j1`
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Possible implementation
|
||||
|
||||
```cpp
|
||||
|
||||
@@ -9,7 +9,7 @@ The type used to store JSON strings.
|
||||
[RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON strings as follows:
|
||||
> A string is a sequence of zero or more Unicode characters.
|
||||
|
||||
To store strings in C++, a type is defined by the template parameter described below. Unicode values are split by the
|
||||
To store objects in C++, a type is defined by the template parameter described below. Unicode values are split by the
|
||||
JSON class into byte-sized characters during deserialization.
|
||||
|
||||
## Template parameters
|
||||
|
||||
@@ -2,20 +2,10 @@
|
||||
|
||||
```cpp
|
||||
// (1)
|
||||
void swap(reference other) noexcept (
|
||||
std::is_nothrow_move_constructible<value_t>::value &&
|
||||
std::is_nothrow_move_assignable<value_t>::value &&
|
||||
std::is_nothrow_move_constructible<json_value>::value &&
|
||||
std::is_nothrow_move_assignable<json_value>::value
|
||||
);
|
||||
void swap(reference other) noexcept;
|
||||
|
||||
// (2)
|
||||
friend void swap(reference left, reference right) noexcept (
|
||||
std::is_nothrow_move_constructible<value_t>::value &&
|
||||
std::is_nothrow_move_assignable<value_t>::value &&
|
||||
std::is_nothrow_move_constructible<json_value>::value &&
|
||||
std::is_nothrow_move_assignable<json_value>::value
|
||||
);
|
||||
void swap(reference left, reference right) noexcept;
|
||||
|
||||
// (3)
|
||||
void swap(array_t& other);
|
||||
@@ -66,15 +56,15 @@ void swap(typename binary_t::container_type& other);
|
||||
1. No-throw guarantee: this function never throws exceptions.
|
||||
2. No-throw guarantee: this function never throws exceptions.
|
||||
3. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than
|
||||
arrays; example: `"cannot use swap(array_t&) with boolean"`
|
||||
arrays; example: `"cannot use swap() with boolean"`
|
||||
4. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than
|
||||
objects; example: `"cannot use swap(object_t&) with boolean"`
|
||||
objects; example: `"cannot use swap() with boolean"`
|
||||
5. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than
|
||||
strings; example: `"cannot use swap(string_t&) with boolean"`
|
||||
strings; example: `"cannot use swap() with boolean"`
|
||||
6. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than
|
||||
binaries; example: `"cannot use swap(binary_t&) with boolean"`
|
||||
binaries; example: `"cannot use swap() with boolean"`
|
||||
7. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than
|
||||
binaries; example: `"cannot use swap(binary_t::container_type&) with boolean"`
|
||||
binaries; example: `"cannot use swap() with boolean"`
|
||||
|
||||
## Complexity
|
||||
|
||||
@@ -138,7 +128,7 @@ Constant.
|
||||
--8<-- "examples/swap__string_t.output"
|
||||
```
|
||||
|
||||
??? example "Example: Swap binary (6)"
|
||||
??? example "Example: Swap string (6)"
|
||||
|
||||
The example below shows how binary values can be swapped with `swap()`.
|
||||
|
||||
@@ -155,8 +145,6 @@ Constant.
|
||||
## See also
|
||||
|
||||
- [std::swap<basic_json\>](std_swap.md)
|
||||
- [operator=](operator=.md) copy assignment
|
||||
- [basic_json](basic_json.md) create a JSON value
|
||||
|
||||
## Version history
|
||||
|
||||
|
||||
@@ -72,14 +72,6 @@ Linear in the size of the JSON value `j`.
|
||||
--8<-- "examples/to_bjdata.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [from_bjdata](from_bjdata.md) create a JSON value from an input in BJData format
|
||||
- [to_cbor](to_cbor.md) create a CBOR serialization of a JSON value
|
||||
- [to_msgpack](to_msgpack.md) create a MessagePack serialization of a JSON value
|
||||
- [to_bson](to_bson.md) create a BSON serialization of a JSON value
|
||||
- [to_ubjson](to_ubjson.md) create a UBJSON serialization of a JSON value
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.11.0.
|
||||
|
||||
@@ -34,13 +34,6 @@ The exact mapping and its limitations are described on a [dedicated page](../../
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
|
||||
|
||||
## Exceptions
|
||||
|
||||
- Throws [`type_error.317`](../../home/exceptions.md#jsonexceptiontype_error317) if the top-level type of the JSON value
|
||||
is not an object; example: `"to serialize to BSON, top-level type must be object, but is string"`
|
||||
- Throws [`out_of_range.409`](../../home/exceptions.md#jsonexceptionout_of_range409) if a key in the JSON object contains
|
||||
a null byte (code point U+0000); example: `"BSON key cannot contain code point U+0000 (at byte 2)"`
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the size of the JSON value `j`.
|
||||
@@ -61,14 +54,6 @@ Linear in the size of the JSON value `j`.
|
||||
--8<-- "examples/to_bson.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [from_bson](from_bson.md) create a JSON value from an input in BSON format
|
||||
- [to_cbor](to_cbor.md) create a CBOR serialization of a JSON value
|
||||
- [to_msgpack](to_msgpack.md) create a MessagePack serialization of a JSON value
|
||||
- [to_ubjson](to_ubjson.md) create a UBJSON serialization of a JSON value
|
||||
- [to_bjdata](to_bjdata.md) create a BJData serialization of a JSON value
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.4.0.
|
||||
|
||||
@@ -55,14 +55,6 @@ Linear in the size of the JSON value `j`.
|
||||
--8<-- "examples/to_cbor.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [from_cbor](from_cbor.md) create a JSON value from an input in CBOR format
|
||||
- [to_msgpack](to_msgpack.md) create a MessagePack serialization of a JSON value
|
||||
- [to_bson](to_bson.md) create a BSON serialization of a JSON value
|
||||
- [to_ubjson](to_ubjson.md) create a UBJSON serialization of a JSON value
|
||||
- [to_bjdata](to_bjdata.md) create a BJData serialization of a JSON value
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 2.0.9.
|
||||
|
||||
@@ -54,14 +54,6 @@ Linear in the size of the JSON value `j`.
|
||||
--8<-- "examples/to_msgpack.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [from_msgpack](from_msgpack.md) create a JSON value from an input in MessagePack format
|
||||
- [to_cbor](to_cbor.md) create a CBOR serialization of a JSON value
|
||||
- [to_bson](to_bson.md) create a BSON serialization of a JSON value
|
||||
- [to_ubjson](to_ubjson.md) create a UBJSON serialization of a JSON value
|
||||
- [to_bjdata](to_bjdata.md) create a BJData serialization of a JSON value
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 2.0.9.
|
||||
|
||||
@@ -59,7 +59,6 @@ std::string to_string(const BasicJsonType& j)
|
||||
## See also
|
||||
|
||||
- [dump](dump.md)
|
||||
- [Serialization](../../features/serialization.md) - the serialization article
|
||||
|
||||
## Version history
|
||||
|
||||
|
||||
@@ -65,14 +65,6 @@ Linear in the size of the JSON value `j`.
|
||||
--8<-- "examples/to_ubjson.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [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
|
||||
- [to_msgpack](to_msgpack.md) create a MessagePack serialization of a JSON value
|
||||
- [to_bson](to_bson.md) create a BSON serialization of a JSON value
|
||||
- [to_bjdata](to_bjdata.md) create a BJData serialization of a JSON value
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.1.0.
|
||||
|
||||
@@ -67,7 +67,6 @@ classDiagram
|
||||
|
||||
## See also
|
||||
|
||||
- [`exception`](exception.md) for the base class of all exceptions thrown by the library
|
||||
- [List of type errors](../../home/exceptions.md#type-errors)
|
||||
- [`parse_error`](parse_error.md) for exceptions indicating a parse error
|
||||
- [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators
|
||||
|
||||
@@ -25,10 +25,6 @@ The function can throw the following exceptions:
|
||||
|
||||
- Throws [`type_error.314`](../../home/exceptions.md#jsonexceptiontype_error314) if value is not an object
|
||||
- Throws [`type_error.315`](../../home/exceptions.md#jsonexceptiontype_error315) if object values are not primitive
|
||||
- Throws [`type_error.313`](../../home/exceptions.md#jsonexceptiontype_error313) if a key (JSON pointer) leads to a
|
||||
conflicting nesting; example: `"invalid value to unflatten"`
|
||||
- Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) if an array index in a key is not a
|
||||
number; example: `"array index 'one' is not a number"`
|
||||
|
||||
## Complexity
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@ void update(const_iterator first, const_iterator last, bool merge_objects = fals
|
||||
When `merge_objects` is `#!c false` (default), existing keys are overwritten. When `merge_objects` is `#!c true`,
|
||||
recursively merges objects with common keys.
|
||||
|
||||
If the JSON value is `#!json null`, it is implicitly converted to an empty object before the values are inserted.
|
||||
|
||||
The function is motivated by Python's [dict.update](https://docs.python.org/3.6/library/stdtypes.html#dict.update)
|
||||
function.
|
||||
|
||||
@@ -30,8 +28,8 @@ iterators (including the `end()` iterator) and all references to the elements ar
|
||||
: JSON object to read values from
|
||||
|
||||
`merge_objects` (in)
|
||||
: when `#!c true`, keys that exist in both objects and whose value in the source is itself an object are merged
|
||||
recursively; all other values are overwritten as usual (default: `#!c false`)
|
||||
: when `#!c true`, existing keys are not overwritten, but contents of objects are merged recursively (default:
|
||||
`#!c false`)
|
||||
|
||||
`first` (in)
|
||||
: the beginning of the range of elements to insert
|
||||
@@ -39,10 +37,6 @@ iterators (including the `end()` iterator) and all references to the elements ar
|
||||
`last` (in)
|
||||
: the end of the range of elements to insert
|
||||
|
||||
## Exception safety
|
||||
|
||||
Basic guarantee: if an exception is thrown during the operation, the JSON value may be partially modified.
|
||||
|
||||
## Exceptions
|
||||
|
||||
1. The function can throw the following exceptions:
|
||||
@@ -51,6 +45,8 @@ Basic guarantee: if an exception is thrown during the operation, the JSON value
|
||||
2. The function can throw the following exceptions:
|
||||
- Throws [`type_error.312`](../../home/exceptions.md#jsonexceptiontype_error312) if called on JSON values other than
|
||||
objects; example: `"cannot use update() with string"`
|
||||
- Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an
|
||||
iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"`
|
||||
- Throws [`invalid_iterator.210`](../../home/exceptions.md#jsonexceptioninvalid_iterator210) if `first` and `last`
|
||||
do not belong to the same JSON value; example: `"iterators do not fit"`
|
||||
|
||||
@@ -145,12 +141,6 @@ Basic guarantee: if an exception is thrown during the operation, the JSON value
|
||||
}
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [insert](insert.md) add values to an array/object
|
||||
- [merge_patch](merge_patch.md) applies a JSON Merge Patch
|
||||
- [Modifying values](../../features/modifying_values.md) - the article on modifying values
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.0.0.
|
||||
|
||||
@@ -94,12 +94,8 @@ changes to any JSON value.
|
||||
3. The function can throw the following exceptions:
|
||||
- Throws [`type_error.302`](../../home/exceptions.md#jsonexceptiontype_error302) if `default_value` does not match
|
||||
the type of the value at `ptr`
|
||||
- Throws [`type_error.306`](../../home/exceptions.md#jsonexceptiontype_error306) if the JSON value is not an array
|
||||
or object; in that case, using `value()` with a JSON pointer makes no sense.
|
||||
- Throws [`parse_error.106`](../../home/exceptions.md#jsonexceptionparse_error106) if an array index in the passed
|
||||
JSON pointer `ptr` begins with '0'.
|
||||
- Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) if an array index in the passed
|
||||
JSON pointer `ptr` is not a number.
|
||||
- Throws [`type_error.306`](../../home/exceptions.md#jsonexceptiontype_error306) if the JSON value is not an object;
|
||||
in that case, using `value()` with a key makes no sense.
|
||||
|
||||
## Complexity
|
||||
|
||||
@@ -184,4 +180,4 @@ changes to any JSON value.
|
||||
|
||||
1. Added in version 1.0.0. Changed parameter `default_value` type from `const ValueType&` to `ValueType&&` in version 3.11.0.
|
||||
2. Added in version 3.11.0. Made `ValueType` the first template parameter in version 3.11.2.
|
||||
3. Added in version 2.0.2. Extended to work with arrays in version 3.12.x.
|
||||
3. Added in version 2.0.2.
|
||||
|
||||
@@ -24,7 +24,7 @@ specific naming scheme in order to override the binary type.
|
||||
- [(constructor)](byte_container_with_subtype.md)
|
||||
- **operator==** - comparison: equal
|
||||
- **operator!=** - comparison: not equal
|
||||
- [**set_subtype**](set_subtype.md) - sets the binary subtype
|
||||
- [**set_subtype**](subtype.md) - sets the binary subtype
|
||||
- [**subtype**](subtype.md) - return the binary subtype
|
||||
- [**has_subtype**](has_subtype.md) - return whether the value has a subtype
|
||||
- [**clear_subtype**](clear_subtype.md) - clears the binary subtype
|
||||
|
||||
@@ -35,5 +35,3 @@ Constant.
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.12.x.
|
||||
|
||||
@@ -10,10 +10,6 @@ Returns the parent of this JSON pointer.
|
||||
|
||||
Parent of this JSON pointer; in case this JSON pointer is the root, the root itself is returned.
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the length of the JSON pointer.
|
||||
@@ -34,11 +30,6 @@ Linear in the length of the JSON pointer.
|
||||
--8<-- "examples/json_pointer__parent_pointer.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [pop_back](pop_back.md) remove the last reference token
|
||||
- [back](back.md) return the last reference token
|
||||
|
||||
## Version history
|
||||
|
||||
Added in version 3.6.0.
|
||||
|
||||
@@ -31,5 +31,3 @@ Linear in the number of reference tokens in the `json_pointer`.
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.12.x.
|
||||
|
||||
@@ -34,5 +34,3 @@ Linear in the number of reference tokens in the `json_pointer`.
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.12.x.
|
||||
|
||||
@@ -9,7 +9,7 @@ The beginning of an array was read.
|
||||
## Parameters
|
||||
|
||||
`elements` (in)
|
||||
: number of array elements, or `#!cpp std::numeric_limits<std::size_t>::max()` if unknown
|
||||
: number of object elements or `#!cpp -1` if unknown
|
||||
|
||||
## Return value
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ The beginning of an object was read.
|
||||
## Parameters
|
||||
|
||||
`elements` (in)
|
||||
: number of object elements, or `#!cpp std::numeric_limits<std::size_t>::max()` if unknown
|
||||
: number of object elements or `#!cpp -1` if unknown
|
||||
|
||||
## Return value
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ header. See also the [macro overview page](../../features/macros.md).
|
||||
- [**JSON_HAS_CPP_11**<br>**JSON_HAS_CPP_14**<br>**JSON_HAS_CPP_17**<br>**JSON_HAS_CPP_20**](json_has_cpp_11.md) - set supported C++ standard
|
||||
- [**JSON_HAS_FILESYSTEM**<br>**JSON_HAS_EXPERIMENTAL_FILESYSTEM**](json_has_filesystem.md) - control `std::filesystem` support
|
||||
- [**JSON_HAS_RANGES**](json_has_ranges.md) - control `std::ranges` support
|
||||
- [**JSON_HAS_STD_FORMAT**](json_has_std_format.md) - control `std::format`/`std::formatter` support
|
||||
- [**JSON_HAS_THREE_WAY_COMPARISON**](json_has_three_way_comparison.md) - control 3-way comparison support
|
||||
- [**JSON_NO_IO**](json_no_io.md) - switch off functions relying on certain C++ I/O headers
|
||||
- [**JSON_SKIP_UNSUPPORTED_COMPILER_CHECK**](json_skip_unsupported_compiler_check.md) - do not warn about unsupported compilers
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user