diff --git a/.github/workflows/nlohmannunittests.yml b/.github/workflows/nlohmannunittests.yml
index 88849d35..795c5eaa 100644
--- a/.github/workflows/nlohmannunittests.yml
+++ b/.github/workflows/nlohmannunittests.yml
@@ -41,4 +41,4 @@ jobs:
bazelisk-cache: true
- name: Run Bazel Test
- run: bazel test //nlohmann_json/tests/src:all_nlohmann_tests
+ run: bazel test //nlohmann_json/tests/src:all
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 47cb9540..899c4f59 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -103,4 +103,9 @@
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
+ "files.associations": {
+ "type_traits": "cpp",
+ "cstddef": "cpp",
+ "functional": "cpp"
+ },
}
diff --git a/.yamlfmt b/.yamlfmt
index 25ed669f..4550fec2 100644
--- a/.yamlfmt
+++ b/.yamlfmt
@@ -7,3 +7,5 @@ exclude:
- nlohmann_json/.github/ISSUE_TEMPLATE/bug.yaml
- nlohmann_json/docs/mkdocs/mkdocs.yml
- nlohmann_json/.clang-tidy
+ - nlohmann_json/.github
+ - nlohmann_json/.cirrus.yml
diff --git a/nlohmann_json/.cirrus.yml b/nlohmann_json/.cirrus.yml
index b2a78390..be633150 100644
--- a/nlohmann_json/.cirrus.yml
+++ b/nlohmann_json/.cirrus.yml
@@ -3,15 +3,15 @@ arm_container:
check_task:
check_script:
- - 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-3.20.2/bin/cmake .. -DJSON_FastTests=ON
- - make -j4
- - cd tests
- - ../../cmake-3.20.2/bin/ctest -j4
+ - 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-3.20.2/bin/cmake .. -DJSON_FastTests=ON
+ - make -j4
+ - cd tests
+ - ../../cmake-3.20.2/bin/ctest -j4
diff --git a/nlohmann_json/.clang-tidy b/nlohmann_json/.clang-tidy
index 4587c964..c3a1244c 100644
--- a/nlohmann_json/.clang-tidy
+++ b/nlohmann_json/.clang-tidy
@@ -1,5 +1,4 @@
# TODO: The first three checks are only removed to get the CI going. They have to be addressed at some point.
-# TODO: portability-avoid-pragma-once: should be fixed eventually
Checks: '*,
@@ -60,7 +59,6 @@ Checks: '*,
-modernize-use-std-numbers,
-modernize-use-trailing-return-type,
-performance-enum-size,
- -portability-avoid-pragma-once,
-readability-function-cognitive-complexity,
-readability-function-size,
-readability-identifier-length,
diff --git a/nlohmann_json/.github/CONTRIBUTING.md b/nlohmann_json/.github/CONTRIBUTING.md
index 5dfb74b5..ad9820fc 100644
--- a/nlohmann_json/.github/CONTRIBUTING.md
+++ b/nlohmann_json/.github/CONTRIBUTING.md
@@ -1,7 +1,7 @@
# Contribution Guidelines
Thank you for your interest in contributing to this project! What began as an exercise to explore the exciting features
-of C++11 has evolved into a [widely used](https://json.nlohmann.me/home/customers/) JSON library. I truly appreciate all
+of C++11 has evolved into a [widely-used](https://json.nlohmann.me/home/customers/) JSON library. I truly appreciate all
the contributions from the community, whether it's proposing features, identifying bugs, or fixing mistakes! To ensure
that our collaboration is efficient and effective, please follow these guidelines.
@@ -21,7 +21,7 @@ Clearly describe the issue:
- If it is a bug, please describe how to **reproduce** it. If possible, attach a _complete example_ which demonstrates
the error. Please also state what you **expected** to happen instead of the error.
-- If you propose a change or addition, try to give an **example** what the improved code could look like or how to use
+- If you propose a change or addition, try to give an **example** how the improved code could look like or how to use
it.
- If you found a compilation error, please tell us which **compiler** (version and operating system) you used and paste
the (relevant part of) the error messages to the ticket.
@@ -66,21 +66,21 @@ certification that he or she has the right to submit the patch for inclusion int
### Describe your changes
-This library is primarily maintained as a spare-time project. As such, I cannot make any guarantee how quickly changes
+This library is primarily maintained as a spare-time project. As such, I can not make any guarantee how quickly changes
are merged and released. Therefore, it is very important to make the review as smooth as possible by explaining not only
_what_ you changed, but _why_. This rationale can be very valuable down the road when improvements or bugs are discussed
years later.
-### Reference an existing issue
+### Reference existing issues
[Link a pull request to an issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue)
-to clarify that a fix is forthcoming and which issue can be closed after merging. Only a few cases (e.g., fixing typos)
-do not require prior discussions.
+to clarify that a fix is forthcoming and which issue can be closed after merging. Only few cases (e.g., fixing typos)
+don’t require prior discussions.
### Write tests
The library has an extensive test suite that currently covers [100 %](https://coveralls.io/github/nlohmann/json) of the
-library's code. These tests are crucial to maintain API stability and give future contributors confidence that they do
+library's code. These test are crucial to maintain API stability and give future contributors confidence that they do
not accidentally break things. As Titus Winters aptly put it:
> If you liked it, you should have put a test on it.
@@ -118,14 +118,14 @@ exception into account.
#### Coverage
If test coverage decreases, an automatic warning comment will be posted on the pull request. You can access a code
-coverage report as an artifact to the “Ubuntu” workflow.
+coverage report as artifact to the “Ubuntu” workflow.
### Update the documentation
The [main documentation](https://json.nlohmann.me) of the library is generated from the files
[`docs/mkdocs/docs`](https://github.com/nlohmann/json/blob/develop/docs/mkdocs/docs). This folder contains dedicated
pages for [certain features](https://github.com/nlohmann/json/tree/develop/docs/mkdocs/docs/features), a list of
-[all exceptions](https://github.com/nlohmann/json/blob/develop/docs/mkdocs/docs/home/exceptions.md), and
+[all exceptions](https://github.com/nlohmann/json/blob/develop/docs/mkdocs/docs/home/exceptions.md), and an
[extensive API documentation](https://github.com/nlohmann/json/tree/develop/docs/mkdocs/docs/api) with details on every
public API function.
@@ -136,7 +136,7 @@ make install_venv -C docs/mkdocs
make serve -C docs/mkdocs
```
-The documentation will then be available at . See the documentation of
+The documentation will then available at . See the documentation of
[mkdocs](https://www.mkdocs.org) and [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) for more
information.
@@ -184,8 +184,8 @@ API of the 3.x.y version is broken. This includes:
Although these guidelines may seem restrictive, they are essential for maintaining the library’s utility.
Breaking changes may be introduced when they are guarded with a feature macro such as
-[`JSON_USE_IMPLICIT_CONVERSIONS`](https://json.nlohmann.me/api/macros/json_use_implicit_conversions/) which allows
-selectively changing the behavior of the library. In next steps, the current behavior can then be deprecated. Using
+[`JSON_USE_IMPLICIT_CONVERSIONS`](https://json.nlohmann.me/api/macros/json_use_implicit_conversions/) which allows to
+selectively change the behavior of the library. In next steps, the current behavior can then be deprecated. Using
feature macros then allows users to test their code against the library in the next major release.
### Break C++11 language conformance
@@ -211,7 +211,7 @@ The following areas really need contribution and are always welcomed:
- Extending the **continuous integration** toward more exotic compilers such as Android NDK, Intel's Compiler, or the
bleeding-edge versions Clang.
- Improving the efficiency of the **JSON parser**. The current parser is implemented as a naive recursive descent parser
- with hand-coded string handling. More sophisticated approaches like LALR parsers would be really appreciated. That
+ with hand coded string handling. More sophisticated approaches like LALR parsers would be really appreciated. That
said, parser generators like Bison or ANTLR do not play nice with single-header files -- I really would like to keep
the parser inside the `json.hpp` header, and I am not aware of approaches similar to [`re2c`](http://re2c.org) for
parsing.
diff --git a/nlohmann_json/.github/PULL_REQUEST_TEMPLATE.md b/nlohmann_json/.github/PULL_REQUEST_TEMPLATE.md
index 53709532..4bb90e75 100644
--- a/nlohmann_json/.github/PULL_REQUEST_TEMPLATE.md
+++ b/nlohmann_json/.github/PULL_REQUEST_TEMPLATE.md
@@ -1,4 +1,4 @@
-[Describe your pull request here. Please read the text below the line and make sure you follow the checklist.]
+[Describe your pull request here. Please read the text below the line, and make sure you follow the checklist.]
- [ ] The changes are described in detail, both the what and why.
- [ ] If applicable, an [existing issue](https://github.com/nlohmann/json/issues) is referenced.
diff --git a/nlohmann_json/.github/config.yml b/nlohmann_json/.github/config.yml
index 7aa59307..4e321747 100644
--- a/nlohmann_json/.github/config.yml
+++ b/nlohmann_json/.github/config.yml
@@ -8,6 +8,7 @@ sentimentBotToxicityThreshold: .7
sentimentBotReplyComment: >
Please be sure to review the [code of conduct](https://github.com/nlohmann/json/blob/develop/.github/CODE_OF_CONDUCT.md) and be respectful of other users. cc/ @nlohmann
+
# Configuration for request-info - https://github.com/behaviorbot/request-info
# *Required* Comment to reply with
diff --git a/nlohmann_json/.github/external_ci/appveyor.yml b/nlohmann_json/.github/external_ci/appveyor.yml
index d99b8e56..5c6b47a3 100644
--- a/nlohmann_json/.github/external_ci/appveyor.yml
+++ b/nlohmann_json/.github/external_ci/appveyor.yml
@@ -1,4 +1,4 @@
-version: "{build}"
+version: '{build}'
# only build PRs and commits to develop branch
# (see https://help.appveyor.com/discussions/questions/55079-two-builds-per-commit-to-pull-request)
diff --git a/nlohmann_json/.github/labeler.yml b/nlohmann_json/.github/labeler.yml
index 6b64013a..024d3e6d 100644
--- a/nlohmann_json/.github/labeler.yml
+++ b/nlohmann_json/.github/labeler.yml
@@ -1,38 +1,38 @@
version: 1
labels:
- - label: "documentation"
- files:
- - "README.md"
-
- - label: "documentation"
- files:
- - "docs/.*"
-
- - label: "tests"
- files:
- - "tests/.*"
-
- - label: "CMake"
- files:
- - ".*CMakeLists.txt"
-
- - label: "CMake"
- files:
- - "cmake/.*"
-
- - label: "CI"
- files:
- - "github/workflows/.*"
-
- - label: "CI"
- files:
- - "github/external_ci/.*"
-
- - label: "S"
- size-below: 10
- - label: "M"
- size-above: 9
- size-below: 100
- - label: "L"
- size-above: 100
+- label: "documentation"
+ files:
+ - "README.md"
+
+- label: "documentation"
+ files:
+ - "docs/.*"
+
+- label: "tests"
+ files:
+ - "tests/.*"
+
+- label: "CMake"
+ files:
+ - ".*CMakeLists.txt"
+
+- label: "CMake"
+ files:
+ - "cmake/.*"
+
+- label: "CI"
+ files:
+ - "github/workflows/.*"
+
+- label: "CI"
+ files:
+ - "github/external_ci/.*"
+
+- label: "S"
+ size-below: 10
+- label: "M"
+ size-above: 9
+ size-below: 100
+- label: "L"
+ size-above: 100
diff --git a/nlohmann_json/.github/workflows/check_amalgamation.yml b/nlohmann_json/.github/workflows/check_amalgamation.yml
index 4cd4bbc0..906a5c5b 100644
--- a/nlohmann_json/.github/workflows/check_amalgamation.yml
+++ b/nlohmann_json/.github/workflows/check_amalgamation.yml
@@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
- uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
+ uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
with:
egress-policy: audit
@@ -34,7 +34,7 @@ jobs:
steps:
- name: Harden Runner
- uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
+ uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
with:
egress-policy: audit
diff --git a/nlohmann_json/.github/workflows/cifuzz.yml b/nlohmann_json/.github/workflows/cifuzz.yml
index 7a5ca506..256d4986 100644
--- a/nlohmann_json/.github/workflows/cifuzz.yml
+++ b/nlohmann_json/.github/workflows/cifuzz.yml
@@ -8,28 +8,28 @@ jobs:
Fuzzing:
runs-on: ubuntu-latest
steps:
- - name: Harden Runner
- uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
- with:
- egress-policy: audit
+ - name: Harden Runner
+ uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
+ with:
+ egress-policy: audit
- - name: Build Fuzzers
- id: build
- uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@57fe4475324c5506adbfecdcdd2917f65c86ee9e # master
- with:
- oss-fuzz-project-name: "json"
- dry-run: false
- language: c++
- - name: Run Fuzzers
- uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@57fe4475324c5506adbfecdcdd2917f65c86ee9e # master
- with:
- oss-fuzz-project-name: "json"
- fuzz-seconds: 300
- dry-run: false
- language: c++
- - name: Upload Crash
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
- if: failure() && steps.build.outcome == 'success'
- with:
- name: artifacts
- path: ./out/artifacts
+ - name: Build Fuzzers
+ id: build
+ uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@57fe4475324c5506adbfecdcdd2917f65c86ee9e # master
+ with:
+ oss-fuzz-project-name: 'json'
+ dry-run: false
+ language: c++
+ - name: Run Fuzzers
+ uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@57fe4475324c5506adbfecdcdd2917f65c86ee9e # master
+ with:
+ oss-fuzz-project-name: 'json'
+ fuzz-seconds: 300
+ dry-run: false
+ language: c++
+ - name: Upload Crash
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
+ if: failure() && steps.build.outcome == 'success'
+ with:
+ name: artifacts
+ path: ./out/artifacts
diff --git a/nlohmann_json/.github/workflows/codeql-analysis.yml b/nlohmann_json/.github/workflows/codeql-analysis.yml
index b607a17c..b7af3212 100644
--- a/nlohmann_json/.github/workflows/codeql-analysis.yml
+++ b/nlohmann_json/.github/workflows/codeql-analysis.yml
@@ -8,9 +8,9 @@ on:
- release/*
pull_request:
schedule:
- - cron: "0 19 * * 1"
+ - cron: '0 19 * * 1'
workflow_dispatch:
-
+
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
@@ -20,29 +20,30 @@ permissions:
jobs:
CodeQL-Build:
+
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- - name: Harden Runner
- uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
- with:
- egress-policy: audit
-
- - name: Checkout repository
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
-
- # Initializes the CodeQL tools for scanning.
- - name: Initialize CodeQL
- uses: github/codeql-action/init@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
- 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@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
-
- - name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
+ - name: Harden Runner
+ uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
+ with:
+ egress-policy: audit
+
+ - name: Checkout repository
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+
+ # Initializes the CodeQL tools for scanning.
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@fc7e4a0fa01c3cca5fd6a1fddec5c0740c977aa2 # v3.28.14
+ 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@fc7e4a0fa01c3cca5fd6a1fddec5c0740c977aa2 # v3.28.14
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@fc7e4a0fa01c3cca5fd6a1fddec5c0740c977aa2 # v3.28.14
diff --git a/nlohmann_json/.github/workflows/comment_check_amalgamation.yml b/nlohmann_json/.github/workflows/comment_check_amalgamation.yml
index fc690da4..4308ed10 100644
--- a/nlohmann_json/.github/workflows/comment_check_amalgamation.yml
+++ b/nlohmann_json/.github/workflows/comment_check_amalgamation.yml
@@ -19,11 +19,11 @@ jobs:
pull-requests: write
steps:
- name: Harden Runner
- uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
+ uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
with:
egress-policy: audit
- - name: "Download artifact"
+ - name: 'Download artifact'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
@@ -44,7 +44,8 @@ jobs:
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
- run: unzip pr.zip
- - name: "Comment on PR"
+
+ - name: 'Comment on PR'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/nlohmann_json/.github/workflows/dependency-review.yml b/nlohmann_json/.github/workflows/dependency-review.yml
index 4f44295f..70f08cee 100644
--- a/nlohmann_json/.github/workflows/dependency-review.yml
+++ b/nlohmann_json/.github/workflows/dependency-review.yml
@@ -6,7 +6,7 @@
# PRs introducing known-vulnerable packages will be blocked from merging.
#
# Source repository: https://github.com/actions/dependency-review-action
-name: "Dependency Review"
+name: 'Dependency Review'
on: [pull_request]
permissions:
@@ -17,11 +17,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
- uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
+ uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
with:
egress-policy: audit
- - name: "Checkout Repository"
+ - name: 'Checkout Repository'
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- - name: "Dependency Review"
- uses: actions/dependency-review-action@da24556b548a50705dd671f47852072ea4c105d9 # v4.7.1
+ - name: 'Dependency Review'
+ uses: actions/dependency-review-action@ce3cf9537a52e8119d91fd484ab5b8a807627bf8 # v4.6.0
diff --git a/nlohmann_json/.github/workflows/labeler.yml b/nlohmann_json/.github/workflows/labeler.yml
index edeb9012..a71bd0f4 100644
--- a/nlohmann_json/.github/workflows/labeler.yml
+++ b/nlohmann_json/.github/workflows/labeler.yml
@@ -17,10 +17,10 @@ jobs:
steps:
- name: Harden Runner
- uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
+ uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
with:
egress-policy: audit
- - uses: srvaroa/labeler@e7bef2249506ba9cbbd3ca5cee256abd9f930b04 # master
+ - uses: srvaroa/labeler@e216fb40e2e6d3b17d90fb1d950f98bee92f65ce # master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
diff --git a/nlohmann_json/.github/workflows/macos.yml b/nlohmann_json/.github/workflows/macos.yml
index 34c63a9a..dc99a2dd 100644
--- a/nlohmann_json/.github/workflows/macos.yml
+++ b/nlohmann_json/.github/workflows/macos.yml
@@ -17,47 +17,47 @@ 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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.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-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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.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:
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"]
+ 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
@@ -74,7 +74,7 @@ jobs:
runs-on: macos-14 # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md
strategy:
matrix:
- xcode: ["15.3", "15.4"]
+ xcode: ['15.3', '15.4']
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
@@ -91,7 +91,7 @@ jobs:
runs-on: macos-15 # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md
strategy:
matrix:
- xcode: ["16.0", "16.1", "16.2", "16.3"]
+ xcode: ['16.0', '16.1', '16.2']
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
diff --git a/nlohmann_json/.github/workflows/publish_documentation.yml b/nlohmann_json/.github/workflows/publish_documentation.yml
index 21566519..c0e85ab1 100644
--- a/nlohmann_json/.github/workflows/publish_documentation.yml
+++ b/nlohmann_json/.github/workflows/publish_documentation.yml
@@ -27,7 +27,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Harden Runner
- uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
+ uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
with:
egress-policy: audit
diff --git a/nlohmann_json/.github/workflows/scorecards.yml b/nlohmann_json/.github/workflows/scorecards.yml
index ca0f8454..a95e5fa8 100644
--- a/nlohmann_json/.github/workflows/scorecards.yml
+++ b/nlohmann_json/.github/workflows/scorecards.yml
@@ -10,7 +10,7 @@ on:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- - cron: "20 7 * * 2"
+ - cron: '20 7 * * 2'
push:
branches: ["develop"]
@@ -36,7 +36,7 @@ jobs:
steps:
- name: Harden Runner
- uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
+ uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
with:
egress-policy: audit
@@ -46,7 +46,7 @@ jobs:
persist-credentials: false
- name: "Run analysis"
- uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
+ uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
with:
results_file: results.sarif
results_format: sarif
@@ -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@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
+ uses: github/codeql-action/upload-sarif@fc7e4a0fa01c3cca5fd6a1fddec5c0740c977aa2 # v3.28.14
with:
sarif_file: results.sarif
diff --git a/nlohmann_json/.github/workflows/stale.yml b/nlohmann_json/.github/workflows/stale.yml
index 49de023e..f00a973d 100644
--- a/nlohmann_json/.github/workflows/stale.yml
+++ b/nlohmann_json/.github/workflows/stale.yml
@@ -1,7 +1,7 @@
-name: "Comment and close stale issues and PR"
+name: 'Comment and close stale issues and PR'
on:
schedule:
- - cron: "0 0 * * *"
+ - cron: '0 0 * * *'
permissions:
contents: read
@@ -16,18 +16,18 @@ jobs:
steps:
- name: Harden Runner
- uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
+ uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
with:
egress-policy: audit
- uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
with:
- stale-issue-label: "state: stale"
- stale-pr-label: "state: stale"
- exempt-issue-labels: "pinned,security"
+ stale-issue-label: 'state: stale'
+ stale-pr-label: 'state: stale'
+ exempt-issue-labels: 'pinned,security'
stale-issue-message: 'This issue has been marked as stale because it has been open for 90 days without activity. If this issue is still relevant, please add a comment or remove the "stale" label. Otherwise, it will be closed in 10 days. Thank you for helping us prioritize our work!'
- stale-pr-message: "This pull request has been marked as stale because it has had no activity for 30 days. While we won’t close it automatically, we encourage you to update or comment if it is still relevant. Keeping pull requests active and up-to-date helps us review and merge changes more efficiently. Thank you for your contributions!"
- close-issue-message: "This issue has been closed after being marked as stale for 10 days without any further activity. If this was done in error or the issue is still relevant, please feel free to reopen it or create a new issue. We appreciate your understanding and contributions."
+ stale-pr-message: 'This pull request has been marked as stale because it has had no activity for 30 days. While we won’t close it automatically, we encourage you to update or comment if it is still relevant. Keeping pull requests active and up-to-date helps us review and merge changes more efficiently. Thank you for your contributions!'
+ close-issue-message: 'This issue has been closed after being marked as stale for 10 days without any further activity. If this was done in error or the issue is still relevant, please feel free to reopen it or create a new issue. We appreciate your understanding and contributions.'
days-before-stale: 90
days-before-pr-stale: 30
days-before-close: 10
diff --git a/nlohmann_json/.github/workflows/ubuntu.yml b/nlohmann_json/.github/workflows/ubuntu.yml
index 831eebf6..87d0d799 100644
--- a/nlohmann_json/.github/workflows/ubuntu.yml
+++ b/nlohmann_json/.github/workflows/ubuntu.yml
@@ -23,7 +23,7 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get latest CMake and ninja
- uses: lukka/get-cmake@6b3e96a9bc9976b8b546346fdd102effedae0ca8 # v4.02
+ uses: lukka/get-cmake@28983e0d3955dba2bb0a6810caae0c6cf268ec0c # v4.0.0
- name: Run CMake
run: cmake -S . -B build -DJSON_CI=On
- name: Build
@@ -46,7 +46,7 @@ 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@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
+ uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
with:
egress-policy: audit
@@ -54,7 +54,7 @@ jobs:
run: sudo apt-get update ; sudo apt-get install -y valgrind
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get latest CMake and ninja
- uses: lukka/get-cmake@6b3e96a9bc9976b8b546346fdd102effedae0ca8 # v4.02
+ uses: lukka/get-cmake@28983e0d3955dba2bb0a6810caae0c6cf268ec0c # v4.0.0
- name: Run CMake
run: cmake -S . -B build -DJSON_CI=On
- name: Build
@@ -71,7 +71,7 @@ jobs:
run: apt-get update ; apt-get install -y git clang-tools iwyu unzip
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get latest CMake and ninja
- uses: lukka/get-cmake@6b3e96a9bc9976b8b546346fdd102effedae0ca8 # v4.02
+ uses: lukka/get-cmake@28983e0d3955dba2bb0a6810caae0c6cf268ec0c # v4.0.0
- name: Run CMake
run: cmake -S . -B build -DJSON_CI=On
- name: Build
@@ -88,7 +88,7 @@ jobs:
run: apt-get update ; apt-get install -y build-essential unzip wget git libssl-dev
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get latest CMake and ninja
- uses: lukka/get-cmake@6b3e96a9bc9976b8b546346fdd102effedae0ca8 # v4.02
+ uses: lukka/get-cmake@28983e0d3955dba2bb0a6810caae0c6cf268ec0c # v4.0.0
- name: Run CMake
run: cmake -S . -B build -DJSON_CI=On
- name: Build
@@ -98,7 +98,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
- uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
+ uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
with:
egress-policy: audit
@@ -143,12 +143,12 @@ jobs:
strategy:
matrix:
# older GCC docker images (4, 5, 6) fail to check out code
- compiler: ['7', '8', '9', '10', '11', '12', '13', '14', '15', 'latest']
+ compiler: ['7', '8', '9', '10', '11', '12', '13', '14', 'latest']
container: gcc:${{ matrix.compiler }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get latest CMake and ninja
- uses: lukka/get-cmake@6b3e96a9bc9976b8b546346fdd102effedae0ca8 # v4.02
+ uses: lukka/get-cmake@28983e0d3955dba2bb0a6810caae0c6cf268ec0c # v4.0.0
- name: Run CMake
run: cmake -S . -B build -DJSON_CI=On
- name: Build
@@ -165,7 +165,7 @@ jobs:
run: apt-get update ; apt-get install -y unzip git
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get latest CMake and ninja
- uses: lukka/get-cmake@6b3e96a9bc9976b8b546346fdd102effedae0ca8 # v4.02
+ uses: lukka/get-cmake@28983e0d3955dba2bb0a6810caae0c6cf268ec0c # v4.0.0
- 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' }}
@@ -183,7 +183,7 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get latest CMake and ninja
- uses: lukka/get-cmake@6b3e96a9bc9976b8b546346fdd102effedae0ca8 # v4.02
+ uses: lukka/get-cmake@28983e0d3955dba2bb0a6810caae0c6cf268ec0c # v4.0.0
- name: Run CMake
run: cmake -S . -B build -DJSON_CI=On
- name: Build
@@ -201,7 +201,7 @@ jobs:
run: apt-get update ; apt-get install -y git unzip
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get latest CMake and ninja
- uses: lukka/get-cmake@6b3e96a9bc9976b8b546346fdd102effedae0ca8 # v4.02
+ uses: lukka/get-cmake@28983e0d3955dba2bb0a6810caae0c6cf268ec0c # v4.0.0
- name: Run CMake
run: cmake -S . -B build -DJSON_CI=On
- name: Build with libc++
@@ -221,21 +221,6 @@ jobs:
- name: Build
run: cmake --build build --target ci_cuda_example
- ci_module_cpp20:
- strategy:
- matrix:
- container: ['gcc:latest', 'silkeh/clang:latest']
- runs-on: ubuntu-latest
- container: ${{ matrix.container }}
- steps:
- - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- - name: Get latest CMake and ninja
- uses: lukka/get-cmake@6b3e96a9bc9976b8b546346fdd102effedae0ca8 # v4.02
- - name: Run CMake
- run: cmake -S . -B build -DJSON_CI=On
- - name: Build
- run: cmake --build build --target ci_module_cpp20
-
ci_icpc:
runs-on: ubuntu-latest
container: ghcr.io/nlohmann/json-ci:v2.2.0
@@ -248,24 +233,6 @@ jobs:
. /opt/intel/oneapi/setvars.sh
cmake --build build --target ci_icpc
- ci_emscripten:
- runs-on: ubuntu-latest
- steps:
- - name: Harden Runner
- uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
- with:
- egress-policy: audit
-
- - name: Install emscripten
- uses: mymindstorm/setup-emsdk@v14
- - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- - name: Get latest CMake and ninja
- uses: lukka/get-cmake@6b3e96a9bc9976b8b546346fdd102effedae0ca8 # v4.02
- - name: Run CMake
- run: cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -GNinja
- - name: Build
- run: cmake --build build
-
ci_test_documentation:
runs-on: ubuntu-latest
strategy:
@@ -273,7 +240,7 @@ jobs:
target: [ci_test_examples, ci_test_build_documentation]
steps:
- name: Harden Runner
- uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
+ uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
with:
egress-policy: audit
diff --git a/nlohmann_json/.github/workflows/windows.yml b/nlohmann_json/.github/workflows/windows.yml
index 124b089d..4e21d995 100644
--- a/nlohmann_json/.github/workflows/windows.yml
+++ b/nlohmann_json/.github/workflows/windows.yml
@@ -37,48 +37,69 @@ jobs:
- name: Test
run: cd build ; ctest -j 10 -C Debug --output-on-failure
- msvc:
+ msvc2019:
+ runs-on: windows-2019
strategy:
matrix:
- runs_on: [windows-2019, windows-2022]
build_type: [Debug, Release]
architecture: [Win32, x64]
- std_version: [default, latest]
- runs-on: ${{ matrix.runs_on }}
+ steps:
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+ - name: Run CMake
+ run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/W4 /WX"
+ if: matrix.build_type == 'Release'
+ - name: Run CMake
+ run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON -DCMAKE_CXX_FLAGS="/W4 /WX"
+ if: matrix.build_type == 'Debug'
+ - 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
+
+ msvc2019_latest:
+ runs-on: windows-2019
steps:
- - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- - name: Set generator
- id: generator
- run: |
- if [ "${{ matrix.runs_on }}" = "windows-2019" ]; then
- echo "generator=Visual Studio 16 2019" >> $GITHUB_ENV
- else
- echo "generator=Visual Studio 17 2022" >> $GITHUB_ENV
- fi
- shell: bash
- - name: Set extra CXX_FLAGS for latest std_version
- id: cxxflags
- run: |
- if [ "${{ matrix.std_version }}" = "latest" ]; then
- echo "flags=/permissive- /std:c++latest /utf-8 /W4 /WX" >> $GITHUB_ENV
- else
- echo "flags=/W4 /WX" >> $GITHUB_ENV
- fi
- shell: bash
- - name: Run CMake (Release)
- run: cmake -S . -B build -G "$env:generator" -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 "$env:generator" -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
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+ - name: Run CMake
+ run: cmake -S . -B build -G "Visual Studio 16 2019" -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4 /WX"
+ - name: Build
+ run: cmake --build build --config Release --parallel 10
+ - name: Test
+ run: cd build ; ctest -j 10 -C Release --output-on-failure
+
+ msvc2022:
+ runs-on: windows-2022
+ strategy:
+ matrix:
+ build_type: [Debug, Release]
+ architecture: [Win32, x64]
+
+ steps:
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+ - name: Run CMake
+ run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/W4 /WX"
+ if: matrix.build_type == 'Release'
+ - name: Run CMake
+ run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON -DCMAKE_CXX_FLAGS="/W4 /WX"
+ if: matrix.build_type == 'Debug'
+ - 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
+
+ msvc2022_latest:
+ runs-on: windows-2022
+
+ steps:
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+ - name: Run CMake
+ run: cmake -S . -B build -G "Visual Studio 17 2022" -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4 /WX"
+ - name: Build
+ run: cmake --build build --config Release --parallel 10
+ - name: Test
+ run: cd build ; ctest -j 10 -C Release --output-on-failure
clang:
runs-on: windows-2019
@@ -97,7 +118,7 @@ jobs:
- name: Test
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure
- clang-cl-12:
+ clang-cl-11:
runs-on: windows-2019
strategy:
matrix:
diff --git a/nlohmann_json/BUILD.bazel b/nlohmann_json/BUILD.bazel
index 49866c2c..de0ff714 100644
--- a/nlohmann_json/BUILD.bazel
+++ b/nlohmann_json/BUILD.bazel
@@ -69,3 +69,12 @@ cc_library(
visibility = ["//visibility:public"],
alwayslink = True,
)
+
+cc_library(
+ name = "singleheader-json",
+ hdrs = [
+ "single_include/nlohmann/json.hpp",
+ ],
+ includes = ["single_include"],
+ visibility = ["//visibility:public"],
+)
diff --git a/nlohmann_json/FILES.md b/nlohmann_json/FILES.md
index 91326ab6..a7a35f7f 100644
--- a/nlohmann_json/FILES.md
+++ b/nlohmann_json/FILES.md
@@ -92,7 +92,7 @@ Further documentation:
### `.github/dependabot.yml`
-The configuration of [dependabot](https://github.com/dependabot) which ensures the dependencies (GitHub actions and Python packages used in the CI) remain up to date.
+The configuration of [dependabot](https://github.com/dependabot) which ensures the dependencies (GitHub actions and Python packages used in the CI) remain up-to-date.
Further documentation:
@@ -185,7 +185,7 @@ Further documentation:
### `.reuse/dep5`
-The file defines the licenses of certain third-party components in the repository. The root `Makefile` contains a target `reuse` that checks for compliance.
+The file defines the licenses of certain third-party component in the repository. The root `Makefile` contains a target `reuse` that checks for compliance.
Further documentation:
@@ -212,7 +212,7 @@ Further information:
### `LICENSES`
-A folder that contains every license of all license files (library and third-party code).
+A folder that contains every license of all licenses files (library and third-party code).
Further documentation:
diff --git a/nlohmann_json/README.md b/nlohmann_json/README.md
index 8a48d07c..f97afeb4 100644
--- a/nlohmann_json/README.md
+++ b/nlohmann_json/README.md
@@ -19,7 +19,6 @@
[](https://isitmaintained.com/project/nlohmann/json "Average time to resolve an issue")
[](https://bestpractices.coreinfrastructure.org/projects/289)
[](https://scorecard.dev/viewer/?uri=github.com/nlohmann/json)
-[](https://cloudback.it)
[](https://github.com/sponsors/nlohmann)
[](https://api.reuse.software/info/github.com/nlohmann/json)
[](https://discord.gg/6mrGXKvX7y)
@@ -31,7 +30,7 @@
- [Examples](#examples)
- [Read JSON from a file](#read-json-from-a-file)
- [Creating `json` objects from JSON literals](#creating-json-objects-from-json-literals)
- - [JSON as a first-class data type](#json-as-a-first-class-data-type)
+ - [JSON as first-class data type](#json-as-first-class-data-type)
- [Serialization / Deserialization](#serialization--deserialization)
- [STL-like access](#stl-like-access)
- [Conversion from STL containers](#conversion-from-stl-containers)
@@ -58,7 +57,7 @@
There are myriads of [JSON](https://json.org) libraries out there, and each may even have its reason to exist. Our class had these design goals:
-- **Intuitive syntax**. In languages such as Python, JSON feels like a first-class data type. We used all the operator magic of modern C++ to achieve the same feeling in your code. Check out the [examples below](#examples) and you'll know what I mean.
+- **Intuitive syntax**. In languages such as Python, JSON feels like a first class data type. We used all the operator magic of modern C++ to achieve the same feeling in your code. Check out the [examples below](#examples) and you'll know what I mean.
- **Trivial integration**. Our whole code consists of a single header file [`json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp). That's it. No library, no subproject, no dependencies, no complex build system. The class is written in vanilla C++11. All in all, everything should require no adjustment of your compiler flags or project settings. The library is also included in all popular [package managers](https://json.nlohmann.me/integration/package_managers/).
@@ -108,7 +107,7 @@ Thanks everyone!
:bug: If you found a **bug**, please check the [**FAQ**](https://json.nlohmann.me/home/faq/) if it is a known issue or the result of a design decision. Please also have a look at the [**issue list**](https://github.com/nlohmann/json/issues) before you [**create a new issue**](https://github.com/nlohmann/json/issues/new/choose). Please provide as much information as possible to help us understand and reproduce your issue.
-There is also a [**docset**](https://github.com/Kapeli/Dash-User-Contributions/tree/master/docsets/JSON_for_Modern_C%2B%2B) for the documentation browsers [Dash](https://kapeli.com/dash), [Velocity](https://velocity.silverlakesoftware.com), and [Zeal](https://zealdocs.org) that contains the full [documentation](https://json.nlohmann.me) as an offline resource.
+There is also a [**docset**](https://github.com/Kapeli/Dash-User-Contributions/tree/master/docsets/JSON_for_Modern_C%2B%2B) for the documentation browsers [Dash](https://kapeli.com/dash), [Velocity](https://velocity.silverlakesoftware.com), and [Zeal](https://zealdocs.org) that contains the full [documentation](https://json.nlohmann.me) as offline resource.
## Quick reference
@@ -137,7 +136,7 @@ There is also a [**docset**](https://github.com/Kapeli/Dash-User-Contributions/t
Here are some examples to give you an idea how to use the class.
-Besides the examples below, you may want to:
+Beside the examples below, you may want to:
→ Check the [documentation](https://json.nlohmann.me/)\
→ Browse the [standalone example files](https://github.com/nlohmann/json/tree/develop/docs/mkdocs/docs/examples)\
@@ -196,7 +195,7 @@ json ex3 = {
};
```
-### JSON as a first-class data type
+### JSON as first-class data type
Here are some examples to give you an idea how to use the class.
@@ -225,13 +224,13 @@ With this library, you could write:
// create an empty structure (null)
json j;
-// add a number stored as double (note the implicit conversion of j to an object)
+// add a number that is stored as double (note the implicit conversion of j to an object)
j["pi"] = 3.141;
-// add a Boolean stored as bool
+// add a Boolean that is stored as bool
j["happy"] = true;
-// add a string stored as std::string
+// add a string that is stored as std::string
j["name"] = "Niels";
// add another null object by passing nullptr
@@ -240,7 +239,7 @@ j["nothing"] = nullptr;
// add an object inside the object
j["answer"]["everything"] = 42;
-// add an array stored as std::vector (using an initializer list)
+// add an array that is stored as std::vector (using an initializer list)
j["list"] = { 1, 0, 2 };
// add another object (using an initializer list of pairs)
@@ -350,7 +349,7 @@ std::cout << j_string << " == " << serialized_string << std::endl;
Note the library only supports UTF-8. When you store strings with different encodings in the library, calling [`dump()`](https://json.nlohmann.me/api/basic_json/dump/) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers.
-#### To/from streams (e.g., files, string streams)
+#### To/from streams (e.g. files, string streams)
You can also use streams to serialize and deserialize:
@@ -383,7 +382,7 @@ Please note that setting the exception bit for `failbit` is inappropriate for th
#### Read from iterator range
-You can also parse JSON from an iterator range; that is, from any container accessible by iterators whose `value_type` is an integral type of 1, 2, or 4 bytes, which will be interpreted as UTF-8, UTF-16, and UTF-32 respectively. For instance, a `std::vector`, or a `std::list`:
+You can also parse JSON from an iterator range; that is, from any container accessible by iterators whose `value_type` is an integral type of 1, 2 or 4 bytes, which will be interpreted as UTF-8, UTF-16 and UTF-32 respectively. For instance, a `std::vector`, or a `std::list`:
```cpp
std::vector v = {'t', 'r', 'u', 'e'};
@@ -487,7 +486,7 @@ To implement your own SAX handler, proceed as follows:
2. Create an object of your SAX interface class, e.g. `my_sax`.
3. Call `bool json::sax_parse(input, &my_sax)`; where the first parameter can be any input like a string or an input stream and the second parameter is a pointer to your SAX interface.
-Note the `sax_parse` function only returns a `bool` indicating the result of the last executed SAX event. It does not return a `json` value - it is up to you to decide what to do with the SAX events. Furthermore, no exceptions are thrown in case of a parse error -- it is up to you what to do with the exception object passed to your `parse_error` implementation. Internally, the SAX interface is used for the DOM parser (class `json_sax_dom_parser`) as well as the acceptor (`json_sax_acceptor`), see file [`json_sax.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/input/json_sax.hpp).
+Note the `sax_parse` function only returns a `bool` indicating the result of the last executed SAX event. It does not return a `json` value - it is up to you to decide what to do with the SAX events. Furthermore, no exceptions are thrown in case of a parse error - it is up to you what to do with the exception object passed to your `parse_error` implementation. Internally, the SAX interface is used for the DOM parser (class `json_sax_dom_parser`) as well as the acceptor (`json_sax_acceptor`), see file [`json_sax.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/input/json_sax.hpp).
### STL-like access
@@ -619,7 +618,7 @@ json j_umset(c_umset); // both entries for "one" are used
// maybe ["one", "two", "one", "four"]
```
-Likewise, any associative key-value containers (`std::map`, `std::multimap`, `std::unordered_map`, `std::unordered_multimap`) whose keys can construct an `std::string` and whose values can be used to construct JSON values (see examples above) can be used to create a JSON object. Note that in case of multimaps, only one key is used in the JSON object and the value depends on the internal order of the STL container.
+Likewise, any associative key-value containers (`std::map`, `std::multimap`, `std::unordered_map`, `std::unordered_multimap`) whose keys can construct an `std::string` and whose values can be used to construct JSON values (see examples above) can be used to create a JSON object. Note that in case of multimaps only one key is used in the JSON object and the value depends on the internal order of the STL container.
```cpp
std::map c_map { {"one", 1}, {"two", 2}, {"three", 3} };
@@ -641,7 +640,7 @@ json j_ummap(c_ummap); // only one entry for key "three" is used
### JSON Pointer and JSON Patch
-The library supports **JSON Pointer** ([RFC 6901](https://tools.ietf.org/html/rfc6901)) as an alternative means to address structured values. On top of this, **JSON Patch** ([RFC 6902](https://tools.ietf.org/html/rfc6902)) allows describing differences between two JSON values -- effectively allowing patch and diff operations known from Unix.
+The library supports **JSON Pointer** ([RFC 6901](https://tools.ietf.org/html/rfc6901)) as alternative means to address structured values. On top of this, **JSON Patch** ([RFC 6902](https://tools.ietf.org/html/rfc6902)) allows describing differences between two JSON values - effectively allowing patch and diff operations known from Unix.
```cpp
// a JSON value
@@ -874,7 +873,7 @@ namespace ns {
This requires a bit more advanced technique. But first, let's see how this conversion mechanism works:
-The library uses **JSON Serializers** to convert types to JSON.
+The library uses **JSON Serializers** to convert types to json.
The default serializer for `nlohmann::json` is `nlohmann::adl_serializer` (ADL means [Argument-Dependent Lookup](https://en.cppreference.com/w/cpp/language/adl)).
It is implemented like this (simplified):
@@ -924,7 +923,7 @@ namespace nlohmann {
#### How can I use `get()` for non-default constructible/non-copyable types?
-There is a way if your type is [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible). You will need to specialize the `adl_serializer` as well, but with a special `from_json` overload:
+There is a way, if your type is [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible). You will need to specialize the `adl_serializer` as well, but with a special `from_json` overload:
```cpp
struct move_only_type {
@@ -1013,7 +1012,7 @@ struct bad_serializer
### Specializing enum conversion
-By default, enum values are serialized to JSON as integers. In some cases, this could result in undesired behavior. If an enum is modified or re-ordered after data has been serialized to JSON, the later deserialized JSON data may be undefined or a different enum value than was originally intended.
+By default, enum values are serialized to JSON as integers. In some cases this could result in undesired behavior. If an enum is modified or re-ordered after data has been serialized to JSON, the later de-serialized JSON data may be undefined or a different enum value than was originally intended.
It is possible to more precisely specify how a given enum is mapped to and from JSON as shown below:
@@ -1169,7 +1168,7 @@ Please note:
The code compiles successfully with [Android NDK](https://developer.android.com/ndk/index.html?hl=ml), Revision 9 - 11 (and possibly later) and [CrystaX's Android NDK](https://www.crystax.net/en/android/ndk) version 10.
-- For GCC running on MinGW or Android SDK, the error `'to_string' is not a member of 'std'` (or similarly, for `strtod` or `strtof`) may occur. Note this is not an issue with the code, but rather with the compiler itself. On Android, see above to build with a newer environment. For MinGW, please refer to [this site](https://tehsausage.com/mingw-to-string) and [this discussion](https://github.com/nlohmann/json/issues/136) for information on how to fix this bug. For Android NDK using `APP_STL := gnustl_static`, please refer to [this discussion](https://github.com/nlohmann/json/issues/219).
+- For GCC running on MinGW or Android SDK, the error `'to_string' is not a member of 'std'` (or similarly, for `strtod` or `strtof`) may occur. Note this is not an issue with the code, but rather with the compiler itself. On Android, see above to build with a newer environment. For MinGW, please refer to [this site](https://tehsausage.com/mingw-to-string) and [this discussion](https://github.com/nlohmann/json/issues/136) for information on how to fix this bug. For Android NDK using `APP_STL := gnustl_static`, please refer to [this discussion](https://github.com/nlohmann/json/issues/219).
- Unsupported versions of GCC and Clang are rejected by `#error` directives. This can be switched off by defining `JSON_SKIP_UNSUPPORTED_COMPILER_CHECK`. Note that you can expect no support in this case.
@@ -1188,7 +1187,7 @@ using json = nlohmann::json;
to the files you want to process JSON and set the necessary switches to enable C++11 (e.g., `-std=c++11` for GCC and Clang).
-You can further use file [`include/nlohmann/json_fwd.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/json_fwd.hpp) for forward-declarations. The installation of `json_fwd.hpp` (as part of cmake's install step) can be achieved by setting `-DJSON_MultipleHeaders=ON`.
+You can further use file [`include/nlohmann/json_fwd.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/json_fwd.hpp) for forward-declarations. The installation of json_fwd.hpp (as part of cmake's install step), can be achieved by setting `-DJSON_MultipleHeaders=ON`.
### CMake
@@ -1250,7 +1249,7 @@ FetchContent_MakeAvailable(json)
target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json)
```
-**Note**: It is recommended to use the URL approach described above, which is supported as of version 3.10.0. See
+**Note**: It is recommended to use the URL approach described above which is supported as of version 3.10.0. See
for more information.
#### Supporting Both
@@ -1372,13 +1371,13 @@ I deeply appreciate the help of the following people.
9. [Florian Weber](https://github.com/Florianjw) fixed a bug in and improved the performance of the comparison operators.
10. [Eric Cornelius](https://github.com/EricMCornelius) pointed out a bug in the handling with NaN and infinity values. He also improved the performance of the string escaping.
11. [易思龙](https://github.com/likebeta) implemented a conversion from anonymous enums.
-12. [kepkin](https://github.com/kepkin) patiently pushed forward the support for Microsoft Visual Studio.
+12. [kepkin](https://github.com/kepkin) patiently pushed forward the support for Microsoft Visual studio.
13. [gregmarr](https://github.com/gregmarr) simplified the implementation of reverse iterators and helped with numerous hints and improvements. In particular, he pushed forward the implementation of user-defined types.
14. [Caio Luppi](https://github.com/caiovlp) fixed a bug in the Unicode handling.
15. [dariomt](https://github.com/dariomt) fixed some typos in the examples.
16. [Daniel Frey](https://github.com/d-frey) cleaned up some pointers and implemented exception-safe memory allocation.
17. [Colin Hirsch](https://github.com/ColinH) took care of a small namespace issue.
-18. [Huu Nguyen](https://github.com/whoshuu) corrected a variable name in the documentation.
+18. [Huu Nguyen](https://github.com/whoshuu) correct a variable name in the documentation.
19. [Silverweed](https://github.com/silverweed) overloaded `parse()` to accept an rvalue reference.
20. [dariomt](https://github.com/dariomt) fixed a subtlety in MSVC type support and implemented the `get_ref()` function to get a reference to stored values.
21. [ZahlGraf](https://github.com/ZahlGraf) added a workaround that allows compilation using Android NDK.
@@ -1413,7 +1412,7 @@ I deeply appreciate the help of the following people.
50. [Jared Grubb](https://github.com/jaredgrubb) silenced a nasty documentation warning.
51. [Yixin Zhang](https://github.com/qwename) fixed an integer overflow check.
52. [Bosswestfalen](https://github.com/Bosswestfalen) merged two iterator classes into a smaller one.
-53. [Daniel599](https://github.com/Daniel599) helped to get Travis to execute the tests with Clang's sanitizers.
+53. [Daniel599](https://github.com/Daniel599) helped to get Travis execute the tests with Clang's sanitizers.
54. [Jonathan Lee](https://github.com/vjon) fixed an example in the README file.
55. [gnzlbg](https://github.com/gnzlbg) supported the implementation of user-defined types.
56. [Alexej Harm](https://github.com/qis) helped to get the user-defined types working with Visual Studio.
@@ -1434,7 +1433,7 @@ I deeply appreciate the help of the following people.
71. [Vincent Thiery](https://github.com/vthiery) maintains a package for the Conan package manager.
72. [Steffen](https://github.com/koemeet) fixed a potential issue with MSVC and `std::min`.
73. [Mike Tzou](https://github.com/Chocobo1) fixed some typos.
-74. [amrcode](https://github.com/amrcode) noted misleading documentation about comparison of floats.
+74. [amrcode](https://github.com/amrcode) noted a misleading documentation about comparison of floats.
75. [Oleg Endo](https://github.com/olegendo) reduced the memory consumption by replacing `` with ``.
76. [dan-42](https://github.com/dan-42) cleaned up the CMake files to simplify including/reusing of the library.
77. [Nikita Ofitserov](https://github.com/himikof) allowed for moving values from initializer lists.
@@ -1461,13 +1460,13 @@ I deeply appreciate the help of the following people.
98. [Vadim Evard](https://github.com/Pipeliner) fixed a Markdown issue in the README.
99. [zerodefect](https://github.com/zerodefect) fixed a compiler warning.
100. [Kert](https://github.com/kaidokert) allowed to template the string type in the serialization and added the possibility to override the exceptional behavior.
-101. [mark-99](https://github.com/mark-99) helped fix an ICC error.
+101. [mark-99](https://github.com/mark-99) helped fixing an ICC error.
102. [Patrik Huber](https://github.com/patrikhuber) fixed links in the README file.
103. [johnfb](https://github.com/johnfb) found a bug in the implementation of CBOR's indefinite length strings.
104. [Paul Fultz II](https://github.com/pfultz2) added a note on the cget package manager.
105. [Wilson Lin](https://github.com/wla80) made the integration section of the README more concise.
106. [RalfBielig](https://github.com/ralfbielig) detected and fixed a memory leak in the parser callback.
-107. [agrianius](https://github.com/agrianius) allowed dumping JSON to an alternative string type.
+107. [agrianius](https://github.com/agrianius) allowed to dump JSON to an alternative string type.
108. [Kevin Tonon](https://github.com/ktonon) overworked the C++11 compiler checks in CMake.
109. [Axel Huebl](https://github.com/ax3l) simplified a CMake check and added support for the [Spack package manager](https://spack.io).
110. [Carlos O'Ryan](https://github.com/coryan) fixed a typo.
@@ -1516,12 +1515,12 @@ I deeply appreciate the help of the following people.
153. [Ivor Wanders](https://github.com/iwanders) helped to reduce the CMake requirement to version 3.1.
154. [njlr](https://github.com/njlr) updated the Buckaroo instructions.
155. [Lion](https://github.com/lieff) fixed a compilation issue with GCC 7 on CentOS.
-156. [Isaac Nickaein](https://github.com/nickaein) improved the integer serialization performance and implemented the `contains()` function.
+156. [Isaac Nickaein](https://github.com/nickaein) improved the integer serialization performance and implemented the `contains()` function.
157. [past-due](https://github.com/past-due) suppressed an unfixable warning.
158. [Elvis Oric](https://github.com/elvisoric) improved Meson support.
159. [Matěj Plch](https://github.com/Afforix) fixed an example in the README.
160. [Mark Beckwith](https://github.com/wythe) fixed a typo.
-161. [scinart](https://github.com/scinart) fixed a bug in the serializer.
+161. [scinart](https://github.com/scinart) fixed bug in the serializer.
162. [Patrick Boettcher](https://github.com/pboettch) implemented `push_back()` and `pop_back()` for JSON Pointers.
163. [Bruno Oliveira](https://github.com/nicoddemus) added support for Conda.
164. [Michele Caini](https://github.com/skypjack) fixed links in the README.
@@ -1563,7 +1562,7 @@ I deeply appreciate the help of the following people.
200. [Alexander “weej” Jones](https://github.com/alex-weej) fixed an example in the README.
201. [Antoine Cœur](https://github.com/Coeur) fixed some typos in the documentation.
202. [jothepro](https://github.com/jothepro) updated links to the Hunter package.
-203. [Dave Lee](https://github.com/kastiglione) fixed a link in the README.
+203. [Dave Lee](https://github.com/kastiglione) fixed link in the README.
204. [Joël Lamotte](https://github.com/Klaim) added instruction for using Build2's package manager.
205. [Paul Jurczak](https://github.com/pauljurczak) fixed an example in the README.
206. [Sonu Lohani](https://github.com/sonulohani) fixed a warning.
@@ -1606,7 +1605,7 @@ I deeply appreciate the help of the following people.
243. [raduteo](https://github.com/raduteo) fixed a warning.
244. [David Pfahler](https://github.com/theShmoo) added the possibility to compile the library without I/O support.
245. [Morten Fyhn Amundsen](https://github.com/mortenfyhn) fixed a typo.
-246. [jpl-mac](https://github.com/jpl-mac) allowed treating the library as a system header in CMake.
+246. [jpl-mac](https://github.com/jpl-mac) allowed to treat the library as a system header in CMake.
247. [Jason Dsouza](https://github.com/jasmcaus) fixed the indentation of the CMake file.
248. [offa](https://github.com/offa) added a link to Conan Center to the documentation.
249. [TotalCaesar659](https://github.com/TotalCaesar659) updated the links in the documentation to use HTTPS.
@@ -1648,7 +1647,7 @@ I deeply appreciate the help of the following people.
285. [Wolf Vollprecht](https://github.com/wolfv) added the `patch_inplace` function.
286. [Jake Zimmerman](https://github.com/jez) highlighted common usage patterns in the README file.
287. [NN](https://github.com/NN---) added the Visual Studio output directory to `.gitignore`.
-288. [Romain Reignier](https://github.com/romainreignier) improved the performance of the vector output adapter.
+288. [Romain Reignier](https://github.com/romainreignier) improved the performance the vector output adapter.
289. [Mike](https://github.com/Mike-Leo-Smith) fixed the `std::iterator_traits`.
290. [Richard Hozák](https://github.com/zxey) added macro `JSON_NO_ENUM` to disable default enum conversions.
291. [vakokako](https://github.com/vakokako) fixed tests when compiling with C++20.
@@ -1695,9 +1694,9 @@ I deeply appreciate the help of the following people.
332. [taro](https://github.com/tarolling) fixed a typo in the `CODEOWNERS` file.
333. [Ikko Eltociear Ashimine](https://github.com/eltociear) fixed a typo.
334. [Felix Yan](https://github.com/felixonmars) fixed a typo in the README.
-335. [HO-COOH](https://github.com/HO-COOH) fixed a parenthesis in the documentation.
+335. [HO-COOH](https://github.com/HO-COOH) fixed a parentheses in the documentation.
336. [Ivor Wanders](https://github.com/iwanders) fixed the examples to catch exception by `const&`.
-337. [miny1233](https://github.com/miny1233) fixed a parenthesis in the documentation.
+337. [miny1233](https://github.com/miny1233) fixed a parentheses in the documentation.
338. [tomalakgeretkal](https://github.com/tomalakgeretkal) fixed a compilation error.
339. [alferov](https://github.com/ALF-ONE) fixed a compilation error.
340. [Craig Scott](https://github.com/craigscott-crascit) fixed a deprecation warning in CMake.
@@ -1780,7 +1779,7 @@ The library itself consists of a single header file licensed under the MIT licen
The library supports **Unicode input** as follows:
-- Only **UTF-8** encoded input is supported, which is the default encoding for JSON according to [RFC 8259](https://tools.ietf.org/html/rfc8259.html#section-8.1).
+- Only **UTF-8** encoded input is supported which is the default encoding for JSON according to [RFC 8259](https://tools.ietf.org/html/rfc8259.html#section-8.1).
- `std::u16string` and `std::u32string` can be parsed, assuming UTF-16 and UTF-32 encoding, respectively. These encodings are not supported when reading from files or other input containers.
- Other encodings such as Latin-1 or ISO 8859-1 are **not** supported and will yield parse or serialization errors.
- [Unicode noncharacters](https://www.unicode.org/faq/private_use.html#nonchar1) will not be replaced by the library.
@@ -1802,17 +1801,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 set parameter `ignore_comments` to true in the `parse` function to ignore `//` or `/* */` comments. Comments will then be treated as whitespace.
-
-### Trailing commas
-
-The JSON specification does not allow trailing commas in arrays and objects, and hence this library is treating them as parsing errors by default.
-
-Like comments, you can set parameter `ignore_trailing_commas` to true in the `parse` function to ignore trailing commas in arrays and objects. Note that a single comma as the only content of the array or object (`[,]` or `{,}`) is not allowed, and multiple trailing commas (`[1,,]`) are not allowed either.
-
-This library does not add trailing commas when serializing JSON data.
-
-For more information, see [JSON With Commas and Comments (JWCC)](https://nigeltao.github.io/blog/2021/json-with-commas-comments.html).
+However, you can pass set parameter `ignore_comments` to true in the `parse` function to ignore `//` or `/* */` comments. Comments will then be treated as whitespace.
### Order of object keys
diff --git a/nlohmann_json/cmake/ci.cmake b/nlohmann_json/cmake/ci.cmake
index 316d6efe..1247e918 100644
--- a/nlohmann_json/cmake/ci.cmake
+++ b/nlohmann_json/cmake/ci.cmake
@@ -659,17 +659,6 @@ add_custom_target(ci_cuda_example
COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_cuda_example
)
-###############################################################################
-# C++ 20 modules
-###############################################################################
-
-add_custom_target(ci_module_cpp20
- COMMAND ${CMAKE_COMMAND}
- -DCMAKE_BUILD_TYPE=Debug -GNinja
- -S${PROJECT_SOURCE_DIR}/tests/module_cpp20 -B${PROJECT_BINARY_DIR}/ci_module_cpp20
- COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/ci_module_cpp20
-)
-
###############################################################################
# Intel C++ Compiler
###############################################################################
diff --git a/nlohmann_json/cmake/detect_libcpp_version.cpp b/nlohmann_json/cmake/detect_libcpp_version.cpp
deleted file mode 100644
index a39322fc..00000000
--- a/nlohmann_json/cmake/detect_libcpp_version.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Detect used C++ Standard Library
- *
- * This file is compiled and run via try_run in download_test_data.cmake.
- */
-
-#include
-
-// see https://en.cppreference.com/w/cpp/header/ciso646
-#if __cplusplus >= 202002L
- #include
-#else
- #include
-#endif
-
-int main()
-{
-#if defined(_LIBCPP_VERSION)
- std::printf("LLVM C++ Standard Library (libc++), _LIBCPP_VERSION=%d", _LIBCPP_VERSION);
-#elif defined(__GLIBCXX__)
- std::printf("GNU C++ Standard Library (libstdc++), __GLIBCXX__=%d", __GLIBCXX__);
-#elif defined(_MSVC_STL_VERSION)
- std::printf("Microsoft C++ Standard Library (MSVC STL), _MSVC_STL_VERSION=%d", _MSVC_STL_VERSION);
-#elif defined(_LIBCUDACXX_VERSION)
- std::printf("NVIDIA C++ Standard Library (libcudacxx), _LIBCUDACXX_VERSION=%d", _LIBCUDACXX_VERSION);
-#elif defined(EASTL_VERSION)
- std::printf("Electronic Arts Standard Template Library (EASTL), EASTL_VERSION=%d", EASTL_VERSION);
-#else
- std::printf("unknown");
-#endif
-}
diff --git a/nlohmann_json/cmake/download_test_data.cmake b/nlohmann_json/cmake/download_test_data.cmake
index 14376f4c..1bb998da 100644
--- a/nlohmann_json/cmake/download_test_data.cmake
+++ b/nlohmann_json/cmake/download_test_data.cmake
@@ -54,18 +54,3 @@ else()
endif()
string(REGEX REPLACE "[ ]*\n" "; " CXX_VERSION_RESULT "${CXX_VERSION_RESULT}")
message(STATUS "Compiler: ${CXX_VERSION_RESULT}")
-
-# determine used C++ standard library (for debug and support purposes)
-if(NOT DEFINED LIBCPP_VERSION_OUTPUT_CACHED)
- try_run(RUN_RESULT_VAR COMPILE_RESULT_VAR
- "${CMAKE_BINARY_DIR}" SOURCES "${CMAKE_SOURCE_DIR}/cmake/detect_libcpp_version.cpp"
- RUN_OUTPUT_VARIABLE LIBCPP_VERSION_OUTPUT COMPILE_OUTPUT_VARIABLE LIBCPP_VERSION_COMPILE_OUTPUT
- )
- if(NOT LIBCPP_VERSION_OUTPUT)
- set(LIBCPP_VERSION_OUTPUT "Unknown")
- message(AUTHOR_WARNING "Failed to compile cmake/detect_libcpp_version to detect the used C++ standard library. This does not affect the library or the test cases. Please still create an issue at https://github.com/nlohmann/json to investigate this.\n${LIBCPP_VERSION_COMPILE_OUTPUT}")
- endif()
- set(LIBCPP_VERSION_OUTPUT_CACHED "${LIBCPP_VERSION_OUTPUT}" CACHE STRING "Detected C++ standard library version")
-endif()
-
-message(STATUS "C++ standard library: ${LIBCPP_VERSION_OUTPUT_CACHED}")
diff --git a/nlohmann_json/cmake/gcc_flags.cmake b/nlohmann_json/cmake/gcc_flags.cmake
index 34c168ce..848630f3 100644
--- a/nlohmann_json/cmake/gcc_flags.cmake
+++ b/nlohmann_json/cmake/gcc_flags.cmake
@@ -1,13 +1,13 @@
-# Warning flags determined for GCC 15.1.0 with https://github.com/nlohmann/gcc_flags:
+# Warning flags determined for GCC 14.2.0 with https://github.com/nlohmann/gcc_flags:
# Ignored GCC warnings:
-# -Wno-abi-tag We do not care about ABI tags.
-# -Wno-aggregate-return The library uses aggregate returns.
-# -Wno-long-long The library uses the long long type to interface with system functions.
-# -Wno-namespaces The library uses namespaces.
-# -Wno-nrvo Doctest triggers this warning.
-# -Wno-padded We do not care about padding warnings.
-# -Wno-system-headers We do not care about warnings in system headers.
-# -Wno-templates The library uses templates.
+# -Wno-abi-tag We do not care about ABI tags.
+# -Wno-aggregate-return The library uses aggregate returns.
+# -Wno-long-long The library uses the long long type to interface with system functions.
+# -Wno-namespaces The library uses namespaces.
+# -Wno-nrvo Doctest triggers this warning.
+# -Wno-padded We do not care about padding warnings.
+# -Wno-system-headers We do not care about warnings in system headers.
+# -Wno-templates The library uses templates.
set(GCC_CXXFLAGS
-pedantic
@@ -65,7 +65,6 @@ set(GCC_CXXFLAGS
-Wanalyzer-tainted-offset
-Wanalyzer-tainted-size
-Wanalyzer-too-complex
- -Wanalyzer-undefined-behavior-ptrdiff
-Wanalyzer-undefined-behavior-strtok
-Wanalyzer-unsafe-call-within-signal-handler
-Wanalyzer-use-after-free
@@ -124,7 +123,6 @@ set(GCC_CXXFLAGS
-Wcoverage-invalid-line-number
-Wcoverage-mismatch
-Wcoverage-too-many-conditions
- -Wcoverage-too-many-paths
-Wcpp
-Wctad-maybe-unsupported
-Wctor-dtor-privacy
@@ -132,7 +130,6 @@ set(GCC_CXXFLAGS
-Wdangling-pointer=2
-Wdangling-reference
-Wdate-time
- -Wdefaulted-function-deleted
-Wdelete-incomplete
-Wdelete-non-virtual-dtor
-Wdeprecated
@@ -141,8 +138,6 @@ set(GCC_CXXFLAGS
-Wdeprecated-declarations
-Wdeprecated-enum-enum-conversion
-Wdeprecated-enum-float-conversion
- -Wdeprecated-literal-operator
- -Wdeprecated-variadic-comma-omission
-Wdisabled-optimization
-Wdiv-by-zero
-Wdouble-promotion
@@ -162,21 +157,20 @@ set(GCC_CXXFLAGS
-Wfloat-conversion
-Wfloat-equal
-Wformat -Wformat-contains-nul
- -Wformat -Wformat-diag
-Wformat -Wformat-extra-args
-Wformat -Wformat-nonliteral
- -Wformat -Wformat-overflow=2
-Wformat -Wformat-security
- -Wformat -Wformat-signedness
- -Wformat -Wformat-truncation=2
-Wformat -Wformat-y2k
-Wformat -Wformat-zero-length
+ -Wformat-diag
+ -Wformat-overflow=2
+ -Wformat-signedness
+ -Wformat-truncation=2
-Wformat=2
-Wframe-address
-Wfree-nonheap-object
-Wglobal-module
-Whardened
- -Wheader-guard
-Whsa
-Wif-not-aligned
-Wignored-attributes
@@ -203,7 +197,6 @@ set(GCC_CXXFLAGS
-Wno-long-long
-Wlto-type-mismatch
-Wmain
- -Wmaybe-musttail-local-addr
-Wmaybe-uninitialized
-Wmemset-elt-size
-Wmemset-transposed-args
@@ -222,7 +215,6 @@ set(GCC_CXXFLAGS
-Wmultichar
-Wmultiple-inheritance
-Wmultistatement-macros
- -Wmusttail-local-addr
-Wno-namespaces
-Wnarrowing
-Wnoexcept
@@ -253,7 +245,6 @@ set(GCC_CXXFLAGS
-Wpmf-conversions
-Wpointer-arith
-Wpointer-compare
- -Wpragma-once-outside-header
-Wpragmas
-Wprio-ctor-dtor
-Wpsabi
@@ -285,12 +276,10 @@ set(GCC_CXXFLAGS
-Wsizeof-pointer-div
-Wsizeof-pointer-memaccess
-Wstack-protector
- -Wstrict-aliasing
-Wstrict-aliasing=3
-Wstrict-null-sentinel
-Wstrict-overflow
-Wstring-compare
- -Wstringop-overflow
-Wstringop-overflow=4
-Wstringop-overread
-Wstringop-truncation
@@ -315,12 +304,8 @@ set(GCC_CXXFLAGS
-Wsynth
-Wno-system-headers
-Wtautological-compare
- -Wtemplate-body
- -Wtemplate-id-cdtor
- -Wtemplate-names-tu-local
-Wno-templates
-Wterminate
- -Wtrailing-whitespace
-Wtrampolines
-Wtrigraphs
-Wtrivial-auto-var-init
diff --git a/nlohmann_json/cmake/requirements/requirements-cpplint.txt b/nlohmann_json/cmake/requirements/requirements-cpplint.txt
index 6aabac21..abb438cc 100644
--- a/nlohmann_json/cmake/requirements/requirements-cpplint.txt
+++ b/nlohmann_json/cmake/requirements/requirements-cpplint.txt
@@ -1 +1 @@
-cpplint==2.0.2
+cpplint==2.0.1
diff --git a/nlohmann_json/docs/mkdocs/docs/api/adl_serializer/index.md b/nlohmann_json/docs/mkdocs/docs/api/adl_serializer/index.md
index e83b66de..95f35cdd 100644
--- a/nlohmann_json/docs/mkdocs/docs/api/adl_serializer/index.md
+++ b/nlohmann_json/docs/mkdocs/docs/api/adl_serializer/index.md
@@ -8,7 +8,7 @@ struct adl_serializer;
Serializer that uses ADL ([Argument-Dependent Lookup](https://en.cppreference.com/w/cpp/language/adl)) to choose
`to_json`/`from_json` functions from the types' namespaces.
-It is implemented similarly to
+It is implemented similar to
```cpp
template
diff --git a/nlohmann_json/docs/mkdocs/docs/api/basic_json/accept.md b/nlohmann_json/docs/mkdocs/docs/api/basic_json/accept.md
index 5f9bac05..15206984 100644
--- a/nlohmann_json/docs/mkdocs/docs/api/basic_json/accept.md
+++ b/nlohmann_json/docs/mkdocs/docs/api/basic_json/accept.md
@@ -4,14 +4,12 @@
// (1)
template
static bool accept(InputType&& i,
- const bool ignore_comments = false,
- const bool ignore_trailing_commas = false);
+ const bool ignore_comments = false);
// (2)
template
static bool accept(IteratorType first, IteratorType last,
- const bool ignore_comments = false,
- const bool ignore_trailing_commas = false);
+ const bool ignore_comments = false);
```
Checks whether the input is valid JSON.
@@ -52,10 +50,6 @@ Unlike the [`parse()`](parse.md) function, this function neither throws an excep
: whether comments should be ignored and treated like whitespace (`#!cpp true`) or yield a parse error
(`#!cpp false`); (optional, `#!cpp false` by default)
-`ignore_trailing_commas` (in)
-: whether trailing commas in arrays or objects should be ignored and treated like whitespace (`#!cpp true`) or yield a parse error
- (`#!cpp false`); (optional, `#!cpp false` by default)
-
`first` (in)
: iterator to the start of the character range
@@ -108,7 +102,6 @@ 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.1.
!!! warning "Deprecation"
diff --git a/nlohmann_json/docs/mkdocs/docs/api/basic_json/basic_json.md b/nlohmann_json/docs/mkdocs/docs/api/basic_json/basic_json.md
index 83c50007..71def92a 100644
--- a/nlohmann_json/docs/mkdocs/docs/api/basic_json/basic_json.md
+++ b/nlohmann_json/docs/mkdocs/docs/api/basic_json/basic_json.md
@@ -74,7 +74,7 @@ basic_json(basic_json&& other) noexcept;
- **boolean**: `boolean_t` / `bool` can be used.
- **binary**: `binary_t` / `std::vector` may be used; unfortunately because string literals cannot be
distinguished from binary character arrays by the C++ type system, all types compatible with `const char*` will be
- directed to the string constructor instead. This is both for backwards compatibility and due to the fact that a
+ directed to the string constructor instead. This is both for backwards compatibility, and due to the fact that a
binary type is not a standard JSON type.
See the examples below.
diff --git a/nlohmann_json/docs/mkdocs/docs/api/basic_json/empty.md b/nlohmann_json/docs/mkdocs/docs/api/basic_json/empty.md
index 8d566738..26bf6e9a 100644
--- a/nlohmann_json/docs/mkdocs/docs/api/basic_json/empty.md
+++ b/nlohmann_json/docs/mkdocs/docs/api/basic_json/empty.md
@@ -4,7 +4,7 @@
bool empty() const noexcept;
```
-Checks if a JSON value has no elements (i.e., whether its [`size()`](size.md) is `0`).
+Checks if a JSON value has no elements (i.e. whether its [`size()`](size.md) is `0`).
## Return value
diff --git a/nlohmann_json/docs/mkdocs/docs/api/basic_json/insert.md b/nlohmann_json/docs/mkdocs/docs/api/basic_json/insert.md
index 160b0d43..2f809f01 100644
--- a/nlohmann_json/docs/mkdocs/docs/api/basic_json/insert.md
+++ b/nlohmann_json/docs/mkdocs/docs/api/basic_json/insert.md
@@ -29,11 +29,11 @@ void insert(const_iterator first, const_iterator last);
For all cases where an element is added to an **array**, a reallocation can happen, in which case all iterators
(including the [`end()`](end.md) iterator) and all references to the elements are invalidated. Otherwise, only the
[`end()`](end.md) iterator is invalidated. Also, any iterator or reference after the insertion point will point to the
-same index, which is now a different value.
+same index which is now a different value.
For [`ordered_json`](../ordered_json.md), also adding an element to an **object** can yield a reallocation which again
invalidates all iterators and all references. Also, any iterator or reference after the insertion point will point to
-the same index, which is now a different value.
+the same index which is now a different value.
## Parameters
diff --git a/nlohmann_json/docs/mkdocs/docs/api/basic_json/json_base_class_t.md b/nlohmann_json/docs/mkdocs/docs/api/basic_json/json_base_class_t.md
index dfe5f1cb..75752049 100644
--- a/nlohmann_json/docs/mkdocs/docs/api/basic_json/json_base_class_t.md
+++ b/nlohmann_json/docs/mkdocs/docs/api/basic_json/json_base_class_t.md
@@ -16,7 +16,7 @@ Examples of such functionality might be metadata, additional member functions (e
#### Default type
-The default value for `CustomBaseClass` is `void`. In this case, an
+The default value for `CustomBaseClass` is `void`. In this case an
[empty base class](https://en.cppreference.com/w/cpp/language/ebo) is used and no additional functionality is injected.
#### Limitations
diff --git a/nlohmann_json/docs/mkdocs/docs/api/basic_json/parse.md b/nlohmann_json/docs/mkdocs/docs/api/basic_json/parse.md
index 7baa16b8..140a08f3 100644
--- a/nlohmann_json/docs/mkdocs/docs/api/basic_json/parse.md
+++ b/nlohmann_json/docs/mkdocs/docs/api/basic_json/parse.md
@@ -6,16 +6,14 @@ template
static basic_json parse(InputType&& i,
const parser_callback_t cb = nullptr,
const bool allow_exceptions = true,
- const bool ignore_comments = false,
- const bool ignore_trailing_commas = false);
+ const bool ignore_comments = false);
// (2)
template
static basic_json parse(IteratorType first, IteratorType last,
const parser_callback_t cb = nullptr,
const bool allow_exceptions = true,
- const bool ignore_comments = false,
- const bool ignore_trailing_commas = false);
+ const bool ignore_comments = false);
```
1. Deserialize from a compatible input.
@@ -58,10 +56,6 @@ static basic_json parse(IteratorType first, IteratorType last,
: whether comments should be ignored and treated like whitespace (`#!cpp true`) or yield a parse error
(`#!cpp false`); (optional, `#!cpp false` by default)
-`ignore_trailing_commas` (in)
-: whether trailing commas in arrays or objects should be ignored and treated like whitespace (`#!cpp true`) or yield a parse error
- (`#!cpp false`); (optional, `#!cpp false` by default)
-
`first` (in)
: iterator to the start of a character range
@@ -195,34 +189,6 @@ A UTF-8 byte order mark is silently ignored.
--8<-- "examples/parse__allow_exceptions.output"
```
-??? example "Effect of `ignore_comments` parameter"
-
- The example below demonstrates the effect of the `ignore_comments` parameter in the `parse()` function.
-
- ```cpp
- --8<-- "examples/comments.cpp"
- ```
-
- Output:
-
- ```
- --8<-- "examples/comments.output"
- ```
-
-??? example "Effect of `ignore_trailing_commas` parameter"
-
- The example below demonstrates the effect of the `ignore_trailing_commas` parameter in the `parse()` function.
-
- ```cpp
- --8<-- "examples/trailing_commas.cpp"
- ```
-
- Output:
-
- ```
- --8<-- "examples/trailing_commas.output"
- ```
-
## See also
- [accept](accept.md) - check if the input is valid JSON
@@ -234,7 +200,6 @@ A UTF-8 byte order mark is silently ignored.
- 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.1.
!!! warning "Deprecation"
diff --git a/nlohmann_json/docs/mkdocs/docs/api/basic_json/sax_parse.md b/nlohmann_json/docs/mkdocs/docs/api/basic_json/sax_parse.md
index 26b2f236..43793d09 100644
--- a/nlohmann_json/docs/mkdocs/docs/api/basic_json/sax_parse.md
+++ b/nlohmann_json/docs/mkdocs/docs/api/basic_json/sax_parse.md
@@ -7,8 +7,7 @@ static bool sax_parse(InputType&& i,
SAX* sax,
input_format_t format = input_format_t::json,
const bool strict = true,
- const bool ignore_comments = false,
- const bool ignore_trailing_commas = false);
+ const bool ignore_comments = false);
// (2)
template
@@ -16,8 +15,7 @@ static bool sax_parse(IteratorType first, IteratorType last,
SAX* sax,
input_format_t format = input_format_t::json,
const bool strict = true,
- const bool ignore_comments = false,
- const bool ignore_trailing_commas = false);
+ const bool ignore_comments = false);
```
Read from input and generate SAX events
@@ -67,10 +65,6 @@ The SAX event lister must follow the interface of [`json_sax`](../json_sax/index
: whether comments should be ignored and treated like whitespace (`#!cpp true`) or yield a parse error
(`#!cpp false`); (optional, `#!cpp false` by default)
-`ignore_trailing_commas` (in)
-: whether trailing commas in arrays or objects should be ignored and treated like whitespace (`#!cpp true`) or yield a parse error
- (`#!cpp false`); (optional, `#!cpp false` by default)
-
`first` (in)
: iterator to the start of a character range
@@ -113,7 +107,6 @@ A UTF-8 byte order mark is silently ignored.
- 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.1.
!!! warning "Deprecation"
diff --git a/nlohmann_json/docs/mkdocs/docs/api/macros/nlohmann_define_derived_type.md b/nlohmann_json/docs/mkdocs/docs/api/macros/nlohmann_define_derived_type.md
index d33bc1ee..d9c9e042 100644
--- a/nlohmann_json/docs/mkdocs/docs/api/macros/nlohmann_define_derived_type.md
+++ b/nlohmann_json/docs/mkdocs/docs/api/macros/nlohmann_define_derived_type.md
@@ -79,7 +79,7 @@ template
void from_json(const BasicJsonType&, type&);
```
-Macros 3 and 6 add one function to the namespace, which takes care of the serialization only:
+Macros 3 and 6 add one function to the namespace which takes care of the serialization only:
```cpp
template
diff --git a/nlohmann_json/docs/mkdocs/docs/api/macros/nlohmann_define_type_intrusive.md b/nlohmann_json/docs/mkdocs/docs/api/macros/nlohmann_define_type_intrusive.md
index b95d2679..32fb68ee 100644
--- a/nlohmann_json/docs/mkdocs/docs/api/macros/nlohmann_define_type_intrusive.md
+++ b/nlohmann_json/docs/mkdocs/docs/api/macros/nlohmann_define_type_intrusive.md
@@ -46,7 +46,7 @@ template
friend void from_json(const BasicJsonType&, type&); // except (3)
```
-See the examples below for the concrete generated code.
+See examples below for the concrete generated code.
## Notes
diff --git a/nlohmann_json/docs/mkdocs/docs/api/macros/nlohmann_define_type_non_intrusive.md b/nlohmann_json/docs/mkdocs/docs/api/macros/nlohmann_define_type_non_intrusive.md
index c3e2721c..2bbf0a69 100644
--- a/nlohmann_json/docs/mkdocs/docs/api/macros/nlohmann_define_type_non_intrusive.md
+++ b/nlohmann_json/docs/mkdocs/docs/api/macros/nlohmann_define_type_non_intrusive.md
@@ -46,7 +46,7 @@ template
void from_json(const BasicJsonType&, type&); // except (3)
```
-See the examples below for the concrete generated code.
+See examples below for the concrete generated code.
## Notes
diff --git a/nlohmann_json/docs/mkdocs/docs/api/macros/nlohmann_json_serialize_enum.md b/nlohmann_json/docs/mkdocs/docs/api/macros/nlohmann_json_serialize_enum.md
index adaceae8..c54f9195 100644
--- a/nlohmann_json/docs/mkdocs/docs/api/macros/nlohmann_json_serialize_enum.md
+++ b/nlohmann_json/docs/mkdocs/docs/api/macros/nlohmann_json_serialize_enum.md
@@ -4,8 +4,8 @@
#define NLOHMANN_JSON_SERIALIZE_ENUM(type, conversion...)
```
-By default, enum values are serialized to JSON as integers. In some cases, this could result in undesired behavior. If
-an enum is modified or re-ordered after data has been serialized to JSON, the later deserialized JSON data may be
+By default, enum values are serialized to JSON as integers. In some cases this could result in undesired behavior. If an
+enum is modified or re-ordered after data has been serialized to JSON, the later deserialized JSON data may be
undefined or a different enum value than was originally intended.
The `NLOHMANN_JSON_SERIALIZE_ENUM` allows to define a user-defined serialization for every enumerator.
diff --git a/nlohmann_json/docs/mkdocs/docs/api/ordered_json.md b/nlohmann_json/docs/mkdocs/docs/api/ordered_json.md
index b28fe36f..f4062d13 100644
--- a/nlohmann_json/docs/mkdocs/docs/api/ordered_json.md
+++ b/nlohmann_json/docs/mkdocs/docs/api/ordered_json.md
@@ -11,7 +11,7 @@ This type preserves the insertion order of object keys.
The type is based on [`ordered_map`](ordered_map.md) which in turn uses a `std::vector` to store object elements.
Therefore, adding object elements can yield a reallocation in which case all iterators (including the
[`end()`](basic_json/end.md) iterator) and all references to the elements are invalidated. Also, any iterator or
-reference after the insertion point will point to the same index, which is now a different value.
+reference after the insertion point will point to the same index which is now a different value.
## Examples
diff --git a/nlohmann_json/docs/mkdocs/docs/community/quality_assurance.md b/nlohmann_json/docs/mkdocs/docs/community/quality_assurance.md
index 5b09b12f..134926ca 100644
--- a/nlohmann_json/docs/mkdocs/docs/community/quality_assurance.md
+++ b/nlohmann_json/docs/mkdocs/docs/community/quality_assurance.md
@@ -28,7 +28,6 @@ violations will result in a failed build.
| AppleClang 16.0.0.16000026; Xcode 16 | arm64 | macOS 15.2 (Sequoia) | GitHub |
| AppleClang 16.0.0.16000026; Xcode 16.1 | arm64 | macOS 15.2 (Sequoia) | GitHub |
| AppleClang 16.0.0.16000026; Xcode 16.2 | arm64 | macOS 15.2 (Sequoia) | GitHub |
- | AppleClang 17.0.0.17000013; Xcode 16.3 | arm64 | macOS 15.5 (Sequoia) | GitHub |
| Clang 3.5.2 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
| Clang 3.6.2 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
| Clang 3.7.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
@@ -58,7 +57,6 @@ violations will result in a failed build.
| Clang 19.1.7 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
| Clang 20.1.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
| Clang 21.0.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
- | Emscripten 4.0.6 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
| GNU 4.8.5 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
| GNU 4.9.3 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
| GNU 5.5.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
@@ -77,8 +75,6 @@ violations will result in a failed build.
| GNU 13.3.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
| GNU 14.2.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
| GNU 14.2.0 | arm64 | Linux 6.1.100 | Cirrus CI |
- | GNU 15.1.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub |
- | icpc (ICC) 2021.5.0 20211109 | x86_64 | Ubuntu 20.04.3 LTS | GitHub |
| MSVC 19.0.24241.7 | x86 | Windows 8.1 | AppVeyor |
| MSVC 19.16.27035.0 | x86 | Windows-10 (Build 14393) | AppVeyor |
| MSVC 19.29.30157.0 | x86 | Windows 10 (Build 17763) | GitHub |
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/README.cpp b/nlohmann_json/docs/mkdocs/docs/examples/README.cpp
index 2d641e58..c8594598 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/README.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/README.cpp
@@ -1,39 +1,26 @@
-#include
#include
+#include
#include
using json = nlohmann::json;
-int main()
-{
- // create a JSON object
- json j =
- {
- {"pi", 3.141},
- {"happy", true},
- {"name", "Niels"},
- {"nothing", nullptr},
- {
- "answer", {
- {"everything", 42}
- }
- },
- {"list", {1, 0, 2}},
- {
- "object", {
- {"currency", "USD"},
- {"value", 42.99}
- }
- }
- };
+int main() {
+ // create a JSON object
+ json j = {{"pi", 3.141},
+ {"happy", true},
+ {"name", "Niels"},
+ {"nothing", nullptr},
+ {"answer", {{"everything", 42}}},
+ {"list", {1, 0, 2}},
+ {"object", {{"currency", "USD"}, {"value", 42.99}}}};
- // add new values
- j["new"]["key"]["value"] = {"another", "list"};
+ // add new values
+ j["new"]["key"]["value"] = {"another", "list"};
- // count elements
- auto s = j.size();
- j["size"] = s;
+ // count elements
+ auto s = j.size();
+ j["size"] = s;
- // pretty print with indent of 4 spaces
- std::cout << std::setw(4) << j << '\n';
+ // pretty print with indent of 4 spaces
+ std::cout << std::setw(4) << j << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/accept__string.cpp b/nlohmann_json/docs/mkdocs/docs/examples/accept__string.cpp
index 8eb3d9b7..0deb1fb7 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/accept__string.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/accept__string.cpp
@@ -1,26 +1,24 @@
-#include
#include
+#include
#include
using json = nlohmann::json;
-int main()
-{
- // a valid JSON text
- auto valid_text = R"(
+int main() {
+ // a valid JSON text
+ auto valid_text = R"(
{
"numbers": [1, 2, 3]
}
)";
- // an invalid JSON text
- auto invalid_text = R"(
+ // an invalid JSON text
+ auto invalid_text = R"(
{
"strings": ["extra", "comma", ]
}
)";
- std::cout << std::boolalpha
- << json::accept(valid_text) << ' '
- << json::accept(invalid_text) << '\n';
+ std::cout << std::boolalpha << json::accept(valid_text) << ' '
+ << json::accept(invalid_text) << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/array.cpp b/nlohmann_json/docs/mkdocs/docs/examples/array.cpp
index 139b5ef1..df445026 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/array.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/array.cpp
@@ -3,17 +3,16 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON arrays
- json j_no_init_list = json::array();
- json j_empty_init_list = json::array({});
- json j_nonempty_init_list = json::array({1, 2, 3, 4});
- json j_list_of_pairs = json::array({ {"one", 1}, {"two", 2} });
+int main() {
+ // create JSON arrays
+ json j_no_init_list = json::array();
+ json j_empty_init_list = json::array({});
+ json j_nonempty_init_list = json::array({1, 2, 3, 4});
+ json j_list_of_pairs = json::array({{"one", 1}, {"two", 2}});
- // serialize the JSON arrays
- std::cout << j_no_init_list << '\n';
- std::cout << j_empty_init_list << '\n';
- std::cout << j_nonempty_init_list << '\n';
- std::cout << j_list_of_pairs << '\n';
+ // serialize the JSON arrays
+ std::cout << j_no_init_list << '\n';
+ std::cout << j_empty_init_list << '\n';
+ std::cout << j_nonempty_init_list << '\n';
+ std::cout << j_list_of_pairs << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/array_t.cpp b/nlohmann_json/docs/mkdocs/docs/examples/array_t.cpp
index 0964857b..2e04c6e3 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/array_t.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/array_t.cpp
@@ -1,10 +1,11 @@
-#include
#include
+#include
#include
using json = nlohmann::json;
-int main()
-{
- std::cout << std::boolalpha << std::is_same, json::array_t>::value << std::endl;
+int main() {
+ std::cout << std::boolalpha
+ << std::is_same, json::array_t>::value
+ << std::endl;
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/at__json_pointer.cpp b/nlohmann_json/docs/mkdocs/docs/examples/at__json_pointer.cpp
index 15e91433..f821441e 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/at__json_pointer.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/at__json_pointer.cpp
@@ -4,100 +4,78 @@
using json = nlohmann::json;
using namespace nlohmann::literals;
-int main()
-{
- // create a JSON value
- json j =
- {
- {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
- };
+int main() {
+ // create a JSON value
+ json j = {{"number", 1}, {"string", "foo"}, {"array", {1, 2}}};
- // read-only access
+ // read-only access
- // output element with JSON pointer "/number"
- std::cout << j.at("/number"_json_pointer) << '\n';
- // output element with JSON pointer "/string"
- std::cout << j.at("/string"_json_pointer) << '\n';
- // output element with JSON pointer "/array"
- std::cout << j.at("/array"_json_pointer) << '\n';
- // output element with JSON pointer "/array/1"
- std::cout << j.at("/array/1"_json_pointer) << '\n';
+ // output element with JSON pointer "/number"
+ std::cout << j.at("/number"_json_pointer) << '\n';
+ // output element with JSON pointer "/string"
+ std::cout << j.at("/string"_json_pointer) << '\n';
+ // output element with JSON pointer "/array"
+ std::cout << j.at("/array"_json_pointer) << '\n';
+ // output element with JSON pointer "/array/1"
+ std::cout << j.at("/array/1"_json_pointer) << '\n';
- // writing access
+ // writing access
- // change the string
- j.at("/string"_json_pointer) = "bar";
- // output the changed string
- std::cout << j["string"] << '\n';
+ // change the string
+ j.at("/string"_json_pointer) = "bar";
+ // output the changed string
+ std::cout << j["string"] << '\n';
- // change an array element
- j.at("/array/1"_json_pointer) = 21;
- // output the changed array
- std::cout << j["array"] << '\n';
+ // change an array element
+ j.at("/array/1"_json_pointer) = 21;
+ // output the changed array
+ std::cout << j["array"] << '\n';
- // out_of_range.106
- try
- {
- // try to use an array index with leading '0'
- json::reference ref = j.at("/array/01"_json_pointer);
- }
- catch (const json::parse_error& e)
- {
- std::cout << e.what() << '\n';
- }
+ // out_of_range.106
+ try {
+ // try to use an array index with leading '0'
+ json::reference ref = j.at("/array/01"_json_pointer);
+ } catch (const json::parse_error &e) {
+ std::cout << e.what() << '\n';
+ }
- // out_of_range.109
- try
- {
- // try to use an array index that is not a number
- json::reference ref = j.at("/array/one"_json_pointer);
- }
- catch (const json::parse_error& e)
- {
- std::cout << e.what() << '\n';
- }
+ // out_of_range.109
+ try {
+ // try to use an array index that is not a number
+ json::reference ref = j.at("/array/one"_json_pointer);
+ } catch (const json::parse_error &e) {
+ std::cout << e.what() << '\n';
+ }
- // out_of_range.401
- try
- {
- // try to use an invalid array index
- json::reference ref = j.at("/array/4"_json_pointer);
- }
- catch (const json::out_of_range& e)
- {
- std::cout << e.what() << '\n';
- }
+ // out_of_range.401
+ try {
+ // try to use an invalid array index
+ json::reference ref = j.at("/array/4"_json_pointer);
+ } catch (const json::out_of_range &e) {
+ std::cout << e.what() << '\n';
+ }
- // out_of_range.402
- try
- {
- // try to use the array index '-'
- json::reference ref = j.at("/array/-"_json_pointer);
- }
- catch (const json::out_of_range& e)
- {
- std::cout << e.what() << '\n';
- }
+ // out_of_range.402
+ try {
+ // try to use the array index '-'
+ json::reference ref = j.at("/array/-"_json_pointer);
+ } catch (const json::out_of_range &e) {
+ std::cout << e.what() << '\n';
+ }
- // out_of_range.403
- try
- {
- // try to use a JSON pointer to a nonexistent object key
- json::const_reference ref = j.at("/foo"_json_pointer);
- }
- catch (const json::out_of_range& e)
- {
- std::cout << e.what() << '\n';
- }
+ // out_of_range.403
+ try {
+ // try to use a JSON pointer to a nonexistent object key
+ json::const_reference ref = j.at("/foo"_json_pointer);
+ } catch (const json::out_of_range &e) {
+ std::cout << e.what() << '\n';
+ }
- // out_of_range.404
- try
- {
- // try to use a JSON pointer that cannot be resolved
- json::reference ref = j.at("/number/foo"_json_pointer);
- }
- catch (const json::out_of_range& e)
- {
- std::cout << e.what() << '\n';
- }
+ // out_of_range.404
+ try {
+ // try to use a JSON pointer that cannot be resolved
+ json::reference ref = j.at("/number/foo"_json_pointer);
+ } catch (const json::out_of_range &e) {
+ std::cout << e.what() << '\n';
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/at__json_pointer_const.cpp b/nlohmann_json/docs/mkdocs/docs/examples/at__json_pointer_const.cpp
index ab026e07..4d0edcbf 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/at__json_pointer_const.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/at__json_pointer_const.cpp
@@ -4,77 +4,58 @@
using json = nlohmann::json;
using namespace nlohmann::literals;
-int main()
-{
- // create a JSON value
- const json j =
- {
- {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
- };
-
- // read-only access
-
- // output element with JSON pointer "/number"
- std::cout << j.at("/number"_json_pointer) << '\n';
- // output element with JSON pointer "/string"
- std::cout << j.at("/string"_json_pointer) << '\n';
- // output element with JSON pointer "/array"
- std::cout << j.at("/array"_json_pointer) << '\n';
- // output element with JSON pointer "/array/1"
- std::cout << j.at("/array/1"_json_pointer) << '\n';
-
- // out_of_range.109
- try
- {
- // try to use an array index that is not a number
- json::const_reference ref = j.at("/array/one"_json_pointer);
- }
- catch (const json::parse_error& e)
- {
- std::cout << e.what() << '\n';
- }
-
- // out_of_range.401
- try
- {
- // try to use an invalid array index
- json::const_reference ref = j.at("/array/4"_json_pointer);
- }
- catch (const json::out_of_range& e)
- {
- std::cout << e.what() << '\n';
- }
-
- // out_of_range.402
- try
- {
- // try to use the array index '-'
- json::const_reference ref = j.at("/array/-"_json_pointer);
- }
- catch (const json::out_of_range& e)
- {
- std::cout << e.what() << '\n';
- }
-
- // out_of_range.403
- try
- {
- // try to use a JSON pointer to a nonexistent object key
- json::const_reference ref = j.at("/foo"_json_pointer);
- }
- catch (const json::out_of_range& e)
- {
- std::cout << e.what() << '\n';
- }
-
- // out_of_range.404
- try
- {
- // try to use a JSON pointer that cannot be resolved
- json::const_reference ref = j.at("/number/foo"_json_pointer);
- }
- catch (const json::out_of_range& e)
- {
- std::cout << e.what() << '\n';
- }
+int main() {
+ // create a JSON value
+ const json j = {{"number", 1}, {"string", "foo"}, {"array", {1, 2}}};
+
+ // read-only access
+
+ // output element with JSON pointer "/number"
+ std::cout << j.at("/number"_json_pointer) << '\n';
+ // output element with JSON pointer "/string"
+ std::cout << j.at("/string"_json_pointer) << '\n';
+ // output element with JSON pointer "/array"
+ std::cout << j.at("/array"_json_pointer) << '\n';
+ // output element with JSON pointer "/array/1"
+ std::cout << j.at("/array/1"_json_pointer) << '\n';
+
+ // out_of_range.109
+ try {
+ // try to use an array index that is not a number
+ json::const_reference ref = j.at("/array/one"_json_pointer);
+ } catch (const json::parse_error &e) {
+ std::cout << e.what() << '\n';
+ }
+
+ // out_of_range.401
+ try {
+ // try to use an invalid array index
+ json::const_reference ref = j.at("/array/4"_json_pointer);
+ } catch (const json::out_of_range &e) {
+ std::cout << e.what() << '\n';
+ }
+
+ // out_of_range.402
+ try {
+ // try to use the array index '-'
+ json::const_reference ref = j.at("/array/-"_json_pointer);
+ } catch (const json::out_of_range &e) {
+ std::cout << e.what() << '\n';
+ }
+
+ // out_of_range.403
+ try {
+ // try to use a JSON pointer to a nonexistent object key
+ json::const_reference ref = j.at("/foo"_json_pointer);
+ } catch (const json::out_of_range &e) {
+ std::cout << e.what() << '\n';
+ }
+
+ // out_of_range.404
+ try {
+ // try to use a JSON pointer that cannot be resolved
+ json::const_reference ref = j.at("/number/foo"_json_pointer);
+ } catch (const json::out_of_range &e) {
+ std::cout << e.what() << '\n';
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/at__keytype.c++17.cpp b/nlohmann_json/docs/mkdocs/docs/examples/at__keytype.c++17.cpp
index 032506ac..1818e8c8 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/at__keytype.c++17.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/at__keytype.c++17.cpp
@@ -1,49 +1,39 @@
#include
-#include
#include
+#include
using namespace std::string_view_literals;
using json = nlohmann::json;
-int main()
-{
- // create JSON object
- json object =
- {
- {"the good", "il buono"},
- {"the bad", "il cattivo"},
- {"the ugly", "il brutto"}
- };
+int main() {
+ // create JSON object
+ json object = {{"the good", "il buono"},
+ {"the bad", "il cattivo"},
+ {"the ugly", "il brutto"}};
- // output element with key "the ugly" using string_view
- std::cout << object.at("the ugly"sv) << '\n';
+ // output element with key "the ugly" using string_view
+ std::cout << object.at("the ugly"sv) << '\n';
- // change element with key "the bad" using string_view
- object.at("the bad"sv) = "il cattivo";
+ // change element with key "the bad" using string_view
+ object.at("the bad"sv) = "il cattivo";
- // output changed array
- std::cout << object << '\n';
+ // output changed array
+ std::cout << object << '\n';
- // exception type_error.304
- try
- {
- // use at() with string_view on a non-object type
- json str = "I am a string";
- str.at("the good"sv) = "Another string";
- }
- catch (const json::type_error& e)
- {
- std::cout << e.what() << '\n';
- }
+ // exception type_error.304
+ try {
+ // use at() with string_view on a non-object type
+ json str = "I am a string";
+ str.at("the good"sv) = "Another string";
+ } catch (const json::type_error &e) {
+ std::cout << e.what() << '\n';
+ }
- // exception out_of_range.401
- try
- {
- // try to write at a nonexisting key using string_view
- object.at("the fast"sv) = "il rapido";
- }
- catch (const json::out_of_range& e)
- {
- std::cout << e.what() << '\n';
- }
+ // exception out_of_range.401
+ try {
+ // try to write at a nonexisting key using string_view
+ object.at("the fast"sv) = "il rapido";
+ } catch (const json::out_of_range &e) {
+ std::cout << e.what() << '\n';
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/at__keytype_const.c++17.cpp b/nlohmann_json/docs/mkdocs/docs/examples/at__keytype_const.c++17.cpp
index 712d456e..1834fca3 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/at__keytype_const.c++17.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/at__keytype_const.c++17.cpp
@@ -1,43 +1,33 @@
#include
-#include
#include
+#include
using namespace std::string_view_literals;
using json = nlohmann::json;
-int main()
-{
- // create JSON object
- const json object =
- {
- {"the good", "il buono"},
- {"the bad", "il cattivo"},
- {"the ugly", "il brutto"}
- };
+int main() {
+ // create JSON object
+ const json object = {{"the good", "il buono"},
+ {"the bad", "il cattivo"},
+ {"the ugly", "il brutto"}};
- // output element with key "the ugly" using string_view
- std::cout << object.at("the ugly"sv) << '\n';
+ // output element with key "the ugly" using string_view
+ std::cout << object.at("the ugly"sv) << '\n';
- // exception type_error.304
- try
- {
- // use at() with string_view on a non-object type
- const json str = "I am a string";
- std::cout << str.at("the good"sv) << '\n';
- }
- catch (const json::type_error& e)
- {
- std::cout << e.what() << '\n';
- }
+ // exception type_error.304
+ try {
+ // use at() with string_view on a non-object type
+ const json str = "I am a string";
+ std::cout << str.at("the good"sv) << '\n';
+ } catch (const json::type_error &e) {
+ std::cout << e.what() << '\n';
+ }
- // exception out_of_range.401
- try
- {
- // try to read from a nonexisting key using string_view
- std::cout << object.at("the fast"sv) << '\n';
- }
- catch (const json::out_of_range& e)
- {
- std::cout << "out of range" << '\n';
- }
+ // exception out_of_range.401
+ try {
+ // try to read from a nonexisting key using string_view
+ std::cout << object.at("the fast"sv) << '\n';
+ } catch (const json::out_of_range &e) {
+ std::cout << "out of range" << '\n';
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/at__object_t_key_type.cpp b/nlohmann_json/docs/mkdocs/docs/examples/at__object_t_key_type.cpp
index e1f33cec..21a0ee2a 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/at__object_t_key_type.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/at__object_t_key_type.cpp
@@ -3,45 +3,35 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON object
- json object =
- {
- {"the good", "il buono"},
- {"the bad", "il cattivo"},
- {"the ugly", "il brutto"}
- };
+int main() {
+ // create JSON object
+ json object = {{"the good", "il buono"},
+ {"the bad", "il cattivo"},
+ {"the ugly", "il brutto"}};
- // output element with key "the ugly"
- std::cout << object.at("the ugly") << '\n';
+ // output element with key "the ugly"
+ std::cout << object.at("the ugly") << '\n';
- // change element with key "the bad"
- object.at("the bad") = "il cattivo";
+ // change element with key "the bad"
+ object.at("the bad") = "il cattivo";
- // output changed array
- std::cout << object << '\n';
+ // output changed array
+ std::cout << object << '\n';
- // exception type_error.304
- try
- {
- // use at() on a non-object type
- json str = "I am a string";
- str.at("the good") = "Another string";
- }
- catch (const json::type_error& e)
- {
- std::cout << e.what() << '\n';
- }
+ // exception type_error.304
+ try {
+ // use at() on a non-object type
+ json str = "I am a string";
+ str.at("the good") = "Another string";
+ } catch (const json::type_error &e) {
+ std::cout << e.what() << '\n';
+ }
- // exception out_of_range.401
- try
- {
- // try to write at a nonexisting key
- object.at("the fast") = "il rapido";
- }
- catch (const json::out_of_range& e)
- {
- std::cout << e.what() << '\n';
- }
+ // exception out_of_range.401
+ try {
+ // try to write at a nonexisting key
+ object.at("the fast") = "il rapido";
+ } catch (const json::out_of_range &e) {
+ std::cout << e.what() << '\n';
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/at__object_t_key_type_const.cpp b/nlohmann_json/docs/mkdocs/docs/examples/at__object_t_key_type_const.cpp
index b37bbd48..164ef8ee 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/at__object_t_key_type_const.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/at__object_t_key_type_const.cpp
@@ -3,39 +3,29 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON object
- const json object =
- {
- {"the good", "il buono"},
- {"the bad", "il cattivo"},
- {"the ugly", "il brutto"}
- };
+int main() {
+ // create JSON object
+ const json object = {{"the good", "il buono"},
+ {"the bad", "il cattivo"},
+ {"the ugly", "il brutto"}};
- // output element with key "the ugly"
- std::cout << object.at("the ugly") << '\n';
+ // output element with key "the ugly"
+ std::cout << object.at("the ugly") << '\n';
- // exception type_error.304
- try
- {
- // use at() on a non-object type
- const json str = "I am a string";
- std::cout << str.at("the good") << '\n';
- }
- catch (const json::type_error& e)
- {
- std::cout << e.what() << '\n';
- }
+ // exception type_error.304
+ try {
+ // use at() on a non-object type
+ const json str = "I am a string";
+ std::cout << str.at("the good") << '\n';
+ } catch (const json::type_error &e) {
+ std::cout << e.what() << '\n';
+ }
- // exception out_of_range.401
- try
- {
- // try to read from a nonexisting key
- std::cout << object.at("the fast") << '\n';
- }
- catch (const json::out_of_range)
- {
- std::cout << "out of range" << '\n';
- }
+ // exception out_of_range.401
+ try {
+ // try to read from a nonexisting key
+ std::cout << object.at("the fast") << '\n';
+ } catch (const json::out_of_range) {
+ std::cout << "out of range" << '\n';
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/at__size_type.cpp b/nlohmann_json/docs/mkdocs/docs/examples/at__size_type.cpp
index 6527c6b1..2c28b62f 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/at__size_type.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/at__size_type.cpp
@@ -3,40 +3,33 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON array
- json array = {"first", "2nd", "third", "fourth"};
+int main() {
+ // create JSON array
+ json array = {"first", "2nd", "third", "fourth"};
- // output element at index 2 (third element)
- std::cout << array.at(2) << '\n';
+ // output element at index 2 (third element)
+ std::cout << array.at(2) << '\n';
- // change element at index 1 (second element) to "second"
- array.at(1) = "second";
+ // change element at index 1 (second element) to "second"
+ array.at(1) = "second";
- // output changed array
- std::cout << array << '\n';
+ // output changed array
+ std::cout << array << '\n';
- // exception type_error.304
- try
- {
- // use at() on a non-array type
- json str = "I am a string";
- str.at(0) = "Another string";
- }
- catch (const json::type_error& e)
- {
- std::cout << e.what() << '\n';
- }
+ // exception type_error.304
+ try {
+ // use at() on a non-array type
+ json str = "I am a string";
+ str.at(0) = "Another string";
+ } catch (const json::type_error &e) {
+ std::cout << e.what() << '\n';
+ }
- // exception out_of_range.401
- try
- {
- // try to write beyond the array limit
- array.at(5) = "sixth";
- }
- catch (const json::out_of_range& e)
- {
- std::cout << e.what() << '\n';
- }
+ // exception out_of_range.401
+ try {
+ // try to write beyond the array limit
+ array.at(5) = "sixth";
+ } catch (const json::out_of_range &e) {
+ std::cout << e.what() << '\n';
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/at__size_type_const.cpp b/nlohmann_json/docs/mkdocs/docs/examples/at__size_type_const.cpp
index 2080387a..62dc7aa1 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/at__size_type_const.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/at__size_type_const.cpp
@@ -3,34 +3,27 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON array
- const json array = {"first", "2nd", "third", "fourth"};
+int main() {
+ // create JSON array
+ const json array = {"first", "2nd", "third", "fourth"};
- // output element at index 2 (third element)
- std::cout << array.at(2) << '\n';
+ // output element at index 2 (third element)
+ std::cout << array.at(2) << '\n';
- // exception type_error.304
- try
- {
- // use at() on a non-array type
- const json str = "I am a string";
- std::cout << str.at(0) << '\n';
- }
- catch (const json::type_error& e)
- {
- std::cout << e.what() << '\n';
- }
+ // exception type_error.304
+ try {
+ // use at() on a non-array type
+ const json str = "I am a string";
+ std::cout << str.at(0) << '\n';
+ } catch (const json::type_error &e) {
+ std::cout << e.what() << '\n';
+ }
- // exception out_of_range.401
- try
- {
- // try to read beyond the array limit
- std::cout << array.at(5) << '\n';
- }
- catch (const json::out_of_range& e)
- {
- std::cout << e.what() << '\n';
- }
+ // exception out_of_range.401
+ try {
+ // try to read beyond the array limit
+ std::cout << array.at(5) << '\n';
+ } catch (const json::out_of_range &e) {
+ std::cout << e.what() << '\n';
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/back.cpp b/nlohmann_json/docs/mkdocs/docs/examples/back.cpp
index 45342db1..02286ae0 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/back.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/back.cpp
@@ -3,36 +3,32 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_boolean = true;
- json j_number_integer = 17;
- json j_number_float = 23.42;
- json j_object = {{"one", 1}, {"two", 2}};
- json j_object_empty(json::value_t::object);
- json j_array = {1, 2, 4, 8, 16};
- json j_array_empty(json::value_t::array);
- json j_string = "Hello, world";
+int main() {
+ // create JSON values
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_float = 23.42;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_object_empty(json::value_t::object);
+ json j_array = {1, 2, 4, 8, 16};
+ json j_array_empty(json::value_t::array);
+ json j_string = "Hello, world";
- // call back()
- std::cout << j_boolean.back() << '\n';
- std::cout << j_number_integer.back() << '\n';
- std::cout << j_number_float.back() << '\n';
- std::cout << j_object.back() << '\n';
- //std::cout << j_object_empty.back() << '\n'; // undefined behavior
- std::cout << j_array.back() << '\n';
- //std::cout << j_array_empty.back() << '\n'; // undefined behavior
- std::cout << j_string.back() << '\n';
+ // call back()
+ std::cout << j_boolean.back() << '\n';
+ std::cout << j_number_integer.back() << '\n';
+ std::cout << j_number_float.back() << '\n';
+ std::cout << j_object.back() << '\n';
+ // std::cout << j_object_empty.back() << '\n'; // undefined behavior
+ std::cout << j_array.back() << '\n';
+ // std::cout << j_array_empty.back() << '\n'; // undefined behavior
+ std::cout << j_string.back() << '\n';
- // back() called on a null value
- try
- {
- json j_null;
- j_null.back();
- }
- catch (const json::invalid_iterator& e)
- {
- std::cout << e.what() << '\n';
- }
+ // back() called on a null value
+ try {
+ json j_null;
+ j_null.back();
+ } catch (const json::invalid_iterator &e) {
+ std::cout << e.what() << '\n';
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/basic_json__CompatibleType.cpp b/nlohmann_json/docs/mkdocs/docs/examples/basic_json__CompatibleType.cpp
index f0d0cc1e..13b4b75d 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/basic_json__CompatibleType.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/basic_json__CompatibleType.cpp
@@ -1,214 +1,205 @@
-#include
#include
-#include
#include
+#include
+#include
+#include
#include
#include
#include
#include
-#include
using json = nlohmann::json;
-int main()
-{
- // ============
- // object types
- // ============
-
- // create an object from an object_t value
- json::object_t object_value = { {"one", 1}, {"two", 2} };
- json j_object_t(object_value);
-
- // create an object from std::map
- std::map c_map
- {
- {"one", 1}, {"two", 2}, {"three", 3}
- };
- json j_map(c_map);
-
- // create an object from std::unordered_map
- std::unordered_map c_umap
- {
- {"one", 1.2}, {"two", 2.3}, {"three", 3.4}
- };
- json j_umap(c_umap);
-
- // create an object from std::multimap
- std::multimap c_mmap
- {
- {"one", true}, {"two", true}, {"three", false}, {"three", true}
- };
- json j_mmap(c_mmap); // only one entry for key "three" is used
-
- // create an object from std::unordered_multimap
- std::unordered_multimap c_ummap
- {
- {"one", true}, {"two", true}, {"three", false}, {"three", true}
- };
- json j_ummap(c_ummap); // only one entry for key "three" is used
-
- // serialize the JSON objects
- std::cout << j_object_t << '\n';
- std::cout << j_map << '\n';
- std::cout << j_umap << '\n';
- std::cout << j_mmap << '\n';
- std::cout << j_ummap << "\n\n";
-
- // ===========
- // array types
- // ===========
-
- // create an array from an array_t value
- json::array_t array_value = {"one", "two", 3, 4.5, false};
- json j_array_t(array_value);
-
- // create an array from std::vector
- std::vector c_vector {1, 2, 3, 4};
- json j_vec(c_vector);
-
- // create an array from std::valarray
- std::valarray c_valarray {10, 9, 8, 7};
- json j_valarray(c_valarray);
-
- // create an array from std::deque
- std::deque c_deque {1.2, 2.3, 3.4, 5.6};
- json j_deque(c_deque);
-
- // create an array from std::list
- std::list c_list {true, true, false, true};
- json j_list(c_list);
-
- // create an array from std::forward_list
- std::forward_list c_flist {12345678909876, 23456789098765, 34567890987654, 45678909876543};
- json j_flist(c_flist);
-
- // create an array from std::array
- std::array c_array {{1, 2, 3, 4}};
- json j_array(c_array);
-
- // create an array from std::set
- std::set c_set {"one", "two", "three", "four", "one"};
- json j_set(c_set); // only one entry for "one" is used
-
- // create an array from std::unordered_set
- std::unordered_set c_uset {"one", "two", "three", "four", "one"};
- json j_uset(c_uset); // only one entry for "one" is used
-
- // create an array from std::multiset
- std::multiset c_mset {"one", "two", "one", "four"};
- json j_mset(c_mset); // both entries for "one" are used
-
- // create an array from std::unordered_multiset
- std::unordered_multiset c_umset {"one", "two", "one", "four"};
- json j_umset(c_umset); // both entries for "one" are used
-
- // serialize the JSON arrays
- std::cout << j_array_t << '\n';
- std::cout << j_vec << '\n';
- std::cout << j_valarray << '\n';
- std::cout << j_deque << '\n';
- std::cout << j_list << '\n';
- std::cout << j_flist << '\n';
- std::cout << j_array << '\n';
- std::cout << j_set << '\n';
- std::cout << j_uset << '\n';
- std::cout << j_mset << '\n';
- std::cout << j_umset << "\n\n";
-
- // ============
- // string types
- // ============
-
- // create string from a string_t value
- json::string_t string_value = "The quick brown fox jumps over the lazy dog.";
- json j_string_t(string_value);
-
- // create a JSON string directly from a string literal
- json j_string_literal("The quick brown fox jumps over the lazy dog.");
-
- // create string from std::string
- std::string s_stdstring = "The quick brown fox jumps over the lazy dog.";
- json j_stdstring(s_stdstring);
-
- // serialize the JSON strings
- std::cout << j_string_t << '\n';
- std::cout << j_string_literal << '\n';
- std::cout << j_stdstring << "\n\n";
-
- // ============
- // number types
- // ============
-
- // create a JSON number from number_integer_t
- json::number_integer_t value_integer_t = -42;
- json j_integer_t(value_integer_t);
-
- // create a JSON number from number_unsigned_t
- json::number_integer_t value_unsigned_t = 17;
- json j_unsigned_t(value_unsigned_t);
-
- // create a JSON number from an anonymous enum
- enum { enum_value = 17 };
- json j_enum(enum_value);
-
- // create values of different integer types
- short n_short = 42;
- int n_int = -23;
- long n_long = 1024;
- int_least32_t n_int_least32_t = -17;
- uint8_t n_uint8_t = 8;
-
- // create (integer) JSON numbers
- json j_short(n_short);
- json j_int(n_int);
- json j_long(n_long);
- json j_int_least32_t(n_int_least32_t);
- json j_uint8_t(n_uint8_t);
-
- // create values of different floating-point types
- json::number_float_t v_ok = 3.141592653589793;
- json::number_float_t v_nan = NAN;
- json::number_float_t v_infinity = INFINITY;
-
- // create values of different floating-point types
- float n_float = 42.23;
- float n_float_nan = 1.0f / 0.0f;
- double n_double = 23.42;
-
- // create (floating point) JSON numbers
- json j_ok(v_ok);
- json j_nan(v_nan);
- json j_infinity(v_infinity);
- json j_float(n_float);
- json j_float_nan(n_float_nan);
- json j_double(n_double);
-
- // serialize the JSON numbers
- std::cout << j_integer_t << '\n';
- std::cout << j_unsigned_t << '\n';
- std::cout << j_enum << '\n';
- std::cout << j_short << '\n';
- std::cout << j_int << '\n';
- std::cout << j_long << '\n';
- std::cout << j_int_least32_t << '\n';
- std::cout << j_uint8_t << '\n';
- std::cout << j_ok << '\n';
- std::cout << j_nan << '\n';
- std::cout << j_infinity << '\n';
- std::cout << j_float << '\n';
- std::cout << j_float_nan << '\n';
- std::cout << j_double << "\n\n";
-
- // =============
- // boolean types
- // =============
-
- // create boolean values
- json j_truth = true;
- json j_falsity = false;
-
- // serialize the JSON booleans
- std::cout << j_truth << '\n';
- std::cout << j_falsity << '\n';
+int main() {
+ // ============
+ // object types
+ // ============
+
+ // create an object from an object_t value
+ json::object_t object_value = {{"one", 1}, {"two", 2}};
+ json j_object_t(object_value);
+
+ // create an object from std::map
+ std::map c_map{{"one", 1}, {"two", 2}, {"three", 3}};
+ json j_map(c_map);
+
+ // create an object from std::unordered_map
+ std::unordered_map c_umap{
+ {"one", 1.2}, {"two", 2.3}, {"three", 3.4}};
+ json j_umap(c_umap);
+
+ // create an object from std::multimap
+ std::multimap c_mmap{
+ {"one", true}, {"two", true}, {"three", false}, {"three", true}};
+ json j_mmap(c_mmap); // only one entry for key "three" is used
+
+ // create an object from std::unordered_multimap
+ std::unordered_multimap c_ummap{
+ {"one", true}, {"two", true}, {"three", false}, {"three", true}};
+ json j_ummap(c_ummap); // only one entry for key "three" is used
+
+ // serialize the JSON objects
+ std::cout << j_object_t << '\n';
+ std::cout << j_map << '\n';
+ std::cout << j_umap << '\n';
+ std::cout << j_mmap << '\n';
+ std::cout << j_ummap << "\n\n";
+
+ // ===========
+ // array types
+ // ===========
+
+ // create an array from an array_t value
+ json::array_t array_value = {"one", "two", 3, 4.5, false};
+ json j_array_t(array_value);
+
+ // create an array from std::vector
+ std::vector c_vector{1, 2, 3, 4};
+ json j_vec(c_vector);
+
+ // create an array from std::valarray
+ std::valarray c_valarray{10, 9, 8, 7};
+ json j_valarray(c_valarray);
+
+ // create an array from std::deque
+ std::deque c_deque{1.2, 2.3, 3.4, 5.6};
+ json j_deque(c_deque);
+
+ // create an array from std::list
+ std::list c_list{true, true, false, true};
+ json j_list(c_list);
+
+ // create an array from std::forward_list
+ std::forward_list c_flist{12345678909876, 23456789098765,
+ 34567890987654, 45678909876543};
+ json j_flist(c_flist);
+
+ // create an array from std::array
+ std::array c_array{{1, 2, 3, 4}};
+ json j_array(c_array);
+
+ // create an array from std::set
+ std::set c_set{"one", "two", "three", "four", "one"};
+ json j_set(c_set); // only one entry for "one" is used
+
+ // create an array from std::unordered_set
+ std::unordered_set c_uset{"one", "two", "three", "four", "one"};
+ json j_uset(c_uset); // only one entry for "one" is used
+
+ // create an array from std::multiset
+ std::multiset c_mset{"one", "two", "one", "four"};
+ json j_mset(c_mset); // both entries for "one" are used
+
+ // create an array from std::unordered_multiset
+ std::unordered_multiset c_umset{"one", "two", "one", "four"};
+ json j_umset(c_umset); // both entries for "one" are used
+
+ // serialize the JSON arrays
+ std::cout << j_array_t << '\n';
+ std::cout << j_vec << '\n';
+ std::cout << j_valarray << '\n';
+ std::cout << j_deque << '\n';
+ std::cout << j_list << '\n';
+ std::cout << j_flist << '\n';
+ std::cout << j_array << '\n';
+ std::cout << j_set << '\n';
+ std::cout << j_uset << '\n';
+ std::cout << j_mset << '\n';
+ std::cout << j_umset << "\n\n";
+
+ // ============
+ // string types
+ // ============
+
+ // create string from a string_t value
+ json::string_t string_value = "The quick brown fox jumps over the lazy dog.";
+ json j_string_t(string_value);
+
+ // create a JSON string directly from a string literal
+ json j_string_literal("The quick brown fox jumps over the lazy dog.");
+
+ // create string from std::string
+ std::string s_stdstring = "The quick brown fox jumps over the lazy dog.";
+ json j_stdstring(s_stdstring);
+
+ // serialize the JSON strings
+ std::cout << j_string_t << '\n';
+ std::cout << j_string_literal << '\n';
+ std::cout << j_stdstring << "\n\n";
+
+ // ============
+ // number types
+ // ============
+
+ // create a JSON number from number_integer_t
+ json::number_integer_t value_integer_t = -42;
+ json j_integer_t(value_integer_t);
+
+ // create a JSON number from number_unsigned_t
+ json::number_integer_t value_unsigned_t = 17;
+ json j_unsigned_t(value_unsigned_t);
+
+ // create a JSON number from an anonymous enum
+ enum { enum_value = 17 };
+ json j_enum(enum_value);
+
+ // create values of different integer types
+ short n_short = 42;
+ int n_int = -23;
+ long n_long = 1024;
+ int_least32_t n_int_least32_t = -17;
+ uint8_t n_uint8_t = 8;
+
+ // create (integer) JSON numbers
+ json j_short(n_short);
+ json j_int(n_int);
+ json j_long(n_long);
+ json j_int_least32_t(n_int_least32_t);
+ json j_uint8_t(n_uint8_t);
+
+ // create values of different floating-point types
+ json::number_float_t v_ok = 3.141592653589793;
+ json::number_float_t v_nan = NAN;
+ json::number_float_t v_infinity = INFINITY;
+
+ // create values of different floating-point types
+ float n_float = 42.23;
+ float n_float_nan = 1.0f / 0.0f;
+ double n_double = 23.42;
+
+ // create (floating point) JSON numbers
+ json j_ok(v_ok);
+ json j_nan(v_nan);
+ json j_infinity(v_infinity);
+ json j_float(n_float);
+ json j_float_nan(n_float_nan);
+ json j_double(n_double);
+
+ // serialize the JSON numbers
+ std::cout << j_integer_t << '\n';
+ std::cout << j_unsigned_t << '\n';
+ std::cout << j_enum << '\n';
+ std::cout << j_short << '\n';
+ std::cout << j_int << '\n';
+ std::cout << j_long << '\n';
+ std::cout << j_int_least32_t << '\n';
+ std::cout << j_uint8_t << '\n';
+ std::cout << j_ok << '\n';
+ std::cout << j_nan << '\n';
+ std::cout << j_infinity << '\n';
+ std::cout << j_float << '\n';
+ std::cout << j_float_nan << '\n';
+ std::cout << j_double << "\n\n";
+
+ // =============
+ // boolean types
+ // =============
+
+ // create boolean values
+ json j_truth = true;
+ json j_falsity = false;
+
+ // serialize the JSON booleans
+ std::cout << j_truth << '\n';
+ std::cout << j_falsity << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/basic_json__InputIt_InputIt.cpp b/nlohmann_json/docs/mkdocs/docs/examples/basic_json__InputIt_InputIt.cpp
index dec693c8..d2f4e3df 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/basic_json__InputIt_InputIt.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/basic_json__InputIt_InputIt.cpp
@@ -3,30 +3,26 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_array = {"alpha", "bravo", "charly", "delta", "easy"};
- json j_number = 42;
- json j_object = {{"one", "eins"}, {"two", "zwei"}};
+int main() {
+ // create JSON values
+ json j_array = {"alpha", "bravo", "charly", "delta", "easy"};
+ json j_number = 42;
+ json j_object = {{"one", "eins"}, {"two", "zwei"}};
- // create copies using iterators
- json j_array_range(j_array.begin() + 1, j_array.end() - 2);
- json j_number_range(j_number.begin(), j_number.end());
- json j_object_range(j_object.begin(), j_object.find("two"));
+ // create copies using iterators
+ json j_array_range(j_array.begin() + 1, j_array.end() - 2);
+ json j_number_range(j_number.begin(), j_number.end());
+ json j_object_range(j_object.begin(), j_object.find("two"));
- // serialize the values
- std::cout << j_array_range << '\n';
- std::cout << j_number_range << '\n';
- std::cout << j_object_range << '\n';
+ // serialize the values
+ std::cout << j_array_range << '\n';
+ std::cout << j_number_range << '\n';
+ std::cout << j_object_range << '\n';
- // example for an exception
- try
- {
- json j_invalid(j_number.begin() + 1, j_number.end());
- }
- catch (const json::invalid_iterator& e)
- {
- std::cout << e.what() << '\n';
- }
+ // example for an exception
+ try {
+ json j_invalid(j_number.begin() + 1, j_number.end());
+ } catch (const json::invalid_iterator &e) {
+ std::cout << e.what() << '\n';
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/basic_json__basic_json.cpp b/nlohmann_json/docs/mkdocs/docs/examples/basic_json__basic_json.cpp
index 17136f43..7f41f0b2 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/basic_json__basic_json.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/basic_json__basic_json.cpp
@@ -3,15 +3,14 @@
using json = nlohmann::json;
-int main()
-{
- // create a JSON array
- json j1 = {"one", "two", 3, 4.5, false};
+int main() {
+ // create a JSON array
+ json j1 = {"one", "two", 3, 4.5, false};
- // create a copy
- json j2(j1);
+ // create a copy
+ json j2(j1);
- // serialize the JSON array
- std::cout << j1 << " = " << j2 << '\n';
- std::cout << std::boolalpha << (j1 == j2) << '\n';
+ // serialize the JSON array
+ std::cout << j1 << " = " << j2 << '\n';
+ std::cout << std::boolalpha << (j1 == j2) << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/basic_json__copyassignment.cpp b/nlohmann_json/docs/mkdocs/docs/examples/basic_json__copyassignment.cpp
index 2d865740..58cfd6fe 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/basic_json__copyassignment.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/basic_json__copyassignment.cpp
@@ -3,16 +3,15 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json a = 23;
- json b = 42;
+int main() {
+ // create JSON values
+ json a = 23;
+ json b = 42;
- // copy-assign a to b
- b = a;
+ // copy-assign a to b
+ b = a;
- // serialize the JSON arrays
- std::cout << a << '\n';
- std::cout << b << '\n';
+ // serialize the JSON arrays
+ std::cout << a << '\n';
+ std::cout << b << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/basic_json__list_init_t.cpp b/nlohmann_json/docs/mkdocs/docs/examples/basic_json__list_init_t.cpp
index 78611e1a..162d70ca 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/basic_json__list_init_t.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/basic_json__list_init_t.cpp
@@ -3,19 +3,18 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_empty_init_list = json({});
- json j_object = { {"one", 1}, {"two", 2} };
- json j_array = {1, 2, 3, 4};
- json j_nested_object = { {"one", {1}}, {"two", {1, 2}} };
- json j_nested_array = { {{1}, "one"}, {{1, 2}, "two"} };
+int main() {
+ // create JSON values
+ json j_empty_init_list = json({});
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = {1, 2, 3, 4};
+ json j_nested_object = {{"one", {1}}, {"two", {1, 2}}};
+ json j_nested_array = {{{1}, "one"}, {{1, 2}, "two"}};
- // serialize the JSON value
- std::cout << j_empty_init_list << '\n';
- std::cout << j_object << '\n';
- std::cout << j_array << '\n';
- std::cout << j_nested_object << '\n';
- std::cout << j_nested_array << '\n';
+ // serialize the JSON value
+ std::cout << j_empty_init_list << '\n';
+ std::cout << j_object << '\n';
+ std::cout << j_array << '\n';
+ std::cout << j_nested_object << '\n';
+ std::cout << j_nested_array << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/basic_json__moveconstructor.cpp b/nlohmann_json/docs/mkdocs/docs/examples/basic_json__moveconstructor.cpp
index 48b68f61..e42f2753 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/basic_json__moveconstructor.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/basic_json__moveconstructor.cpp
@@ -3,15 +3,14 @@
using json = nlohmann::json;
-int main()
-{
- // create a JSON value
- json a = 23;
+int main() {
+ // create a JSON value
+ json a = 23;
- // move contents of a to b
- json b(std::move(a));
+ // move contents of a to b
+ json b(std::move(a));
- // serialize the JSON arrays
- std::cout << a << '\n';
- std::cout << b << '\n';
+ // serialize the JSON arrays
+ std::cout << a << '\n';
+ std::cout << b << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/basic_json__nullptr_t.cpp b/nlohmann_json/docs/mkdocs/docs/examples/basic_json__nullptr_t.cpp
index 7a436665..d9bceb70 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/basic_json__nullptr_t.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/basic_json__nullptr_t.cpp
@@ -3,14 +3,13 @@
using json = nlohmann::json;
-int main()
-{
- // implicitly create a JSON null value
- json j1;
+int main() {
+ // implicitly create a JSON null value
+ json j1;
- // explicitly create a JSON null value
- json j2(nullptr);
+ // explicitly create a JSON null value
+ json j2(nullptr);
- // serialize the JSON null value
- std::cout << j1 << '\n' << j2 << '\n';
+ // serialize the JSON null value
+ std::cout << j1 << '\n' << j2 << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/basic_json__size_type_basic_json.cpp b/nlohmann_json/docs/mkdocs/docs/examples/basic_json__size_type_basic_json.cpp
index 9ec76772..d408b45c 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/basic_json__size_type_basic_json.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/basic_json__size_type_basic_json.cpp
@@ -3,16 +3,15 @@
using json = nlohmann::json;
-int main()
-{
- // create an array by creating copies of a JSON value
- json value = "Hello";
- json array_0 = json(0, value);
- json array_1 = json(1, value);
- json array_5 = json(5, value);
+int main() {
+ // create an array by creating copies of a JSON value
+ json value = "Hello";
+ json array_0 = json(0, value);
+ json array_1 = json(1, value);
+ json array_5 = json(5, value);
- // serialize the JSON arrays
- std::cout << array_0 << '\n';
- std::cout << array_1 << '\n';
- std::cout << array_5 << '\n';
+ // serialize the JSON arrays
+ std::cout << array_0 << '\n';
+ std::cout << array_1 << '\n';
+ std::cout << array_5 << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/basic_json__value_t.cpp b/nlohmann_json/docs/mkdocs/docs/examples/basic_json__value_t.cpp
index c306731a..7927eee9 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/basic_json__value_t.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/basic_json__value_t.cpp
@@ -3,23 +3,22 @@
using json = nlohmann::json;
-int main()
-{
- // create the different JSON values with default values
- json j_null(json::value_t::null);
- json j_boolean(json::value_t::boolean);
- json j_number_integer(json::value_t::number_integer);
- json j_number_float(json::value_t::number_float);
- json j_object(json::value_t::object);
- json j_array(json::value_t::array);
- json j_string(json::value_t::string);
+int main() {
+ // create the different JSON values with default values
+ json j_null(json::value_t::null);
+ json j_boolean(json::value_t::boolean);
+ json j_number_integer(json::value_t::number_integer);
+ json j_number_float(json::value_t::number_float);
+ json j_object(json::value_t::object);
+ json j_array(json::value_t::array);
+ json j_string(json::value_t::string);
- // serialize the JSON values
- std::cout << j_null << '\n';
- std::cout << j_boolean << '\n';
- std::cout << j_number_integer << '\n';
- std::cout << j_number_float << '\n';
- std::cout << j_object << '\n';
- std::cout << j_array << '\n';
- std::cout << j_string << '\n';
+ // serialize the JSON values
+ std::cout << j_null << '\n';
+ std::cout << j_boolean << '\n';
+ std::cout << j_number_integer << '\n';
+ std::cout << j_number_float << '\n';
+ std::cout << j_object << '\n';
+ std::cout << j_array << '\n';
+ std::cout << j_string << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/begin.cpp b/nlohmann_json/docs/mkdocs/docs/examples/begin.cpp
index 654835b0..034b230a 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/begin.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/begin.cpp
@@ -3,14 +3,13 @@
using json = nlohmann::json;
-int main()
-{
- // create an array value
- json array = {1, 2, 3, 4, 5};
+int main() {
+ // create an array value
+ json array = {1, 2, 3, 4, 5};
- // get an iterator to the first element
- json::iterator it = array.begin();
+ // get an iterator to the first element
+ json::iterator it = array.begin();
- // serialize the element that the iterator points to
- std::cout << *it << '\n';
+ // serialize the element that the iterator points to
+ std::cout << *it << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/binary.cpp b/nlohmann_json/docs/mkdocs/docs/examples/binary.cpp
index 617ce609..acfc2019 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/binary.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/binary.cpp
@@ -3,14 +3,14 @@
using json = nlohmann::json;
-int main()
-{
- // create a binary vector
- std::vector vec = {0xCA, 0xFE, 0xBA, 0xBE};
+int main() {
+ // create a binary vector
+ std::vector vec = {0xCA, 0xFE, 0xBA, 0xBE};
- // create a binary JSON value with subtype 42
- json j = json::binary(vec, 42);
+ // create a binary JSON value with subtype 42
+ json j = json::binary(vec, 42);
- // output type and subtype
- std::cout << "type: " << j.type_name() << ", subtype: " << j.get_binary().subtype() << std::endl;
+ // output type and subtype
+ std::cout << "type: " << j.type_name()
+ << ", subtype: " << j.get_binary().subtype() << std::endl;
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/binary_t.cpp b/nlohmann_json/docs/mkdocs/docs/examples/binary_t.cpp
index bfaee5ca..08f09801 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/binary_t.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/binary_t.cpp
@@ -1,10 +1,14 @@
-#include
#include
+#include
#include
using json = nlohmann::json;
-int main()
-{
- std::cout << std::boolalpha << std::is_same>, json::binary_t>::value << std::endl;
+int main() {
+ std::cout
+ << std::boolalpha
+ << std::is_same<
+ nlohmann::byte_container_with_subtype>,
+ json::binary_t>::value
+ << std::endl;
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/boolean_t.cpp b/nlohmann_json/docs/mkdocs/docs/examples/boolean_t.cpp
index 75b8c99f..582f8911 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/boolean_t.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/boolean_t.cpp
@@ -1,10 +1,10 @@
-#include
#include
+#include
#include
using json = nlohmann::json;
-int main()
-{
- std::cout << std::boolalpha << std::is_same::value << std::endl;
+int main() {
+ std::cout << std::boolalpha << std::is_same::value
+ << std::endl;
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__byte_container_with_subtype.cpp b/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__byte_container_with_subtype.cpp
index 1c10be5c..10050798 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__byte_container_with_subtype.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__byte_container_with_subtype.cpp
@@ -2,22 +2,22 @@
#include
// define a byte container based on std::vector
-using byte_container_with_subtype = nlohmann::byte_container_with_subtype>;
+using byte_container_with_subtype =
+ nlohmann::byte_container_with_subtype>;
using json = nlohmann::json;
-int main()
-{
- // (1) create empty container
- auto c1 = byte_container_with_subtype();
+int main() {
+ // (1) create empty container
+ auto c1 = byte_container_with_subtype();
- std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}};
+ std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}};
- // (2) create container
- auto c2 = byte_container_with_subtype(bytes);
+ // (2) create container
+ auto c2 = byte_container_with_subtype(bytes);
- // (3) create container with subtype
- auto c3 = byte_container_with_subtype(bytes, 42);
+ // (3) create container with subtype
+ auto c3 = byte_container_with_subtype(bytes, 42);
- std::cout << json(c1) << "\n" << json(c2) << "\n" << json(c3) << std::endl;
+ std::cout << json(c1) << "\n" << json(c2) << "\n" << json(c3) << std::endl;
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__clear_subtype.cpp b/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__clear_subtype.cpp
index f9ce6842..eb993d52 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__clear_subtype.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__clear_subtype.cpp
@@ -2,20 +2,20 @@
#include
// define a byte container based on std::vector
-using byte_container_with_subtype = nlohmann::byte_container_with_subtype>;
+using byte_container_with_subtype =
+ nlohmann::byte_container_with_subtype>;
using json = nlohmann::json;
-int main()
-{
- std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}};
+int main() {
+ std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}};
- // create container with subtype
- auto c1 = byte_container_with_subtype(bytes, 42);
+ // create container with subtype
+ auto c1 = byte_container_with_subtype(bytes, 42);
- std::cout << "before calling clear_subtype(): " << json(c1) << '\n';
+ std::cout << "before calling clear_subtype(): " << json(c1) << '\n';
- c1.clear_subtype();
+ c1.clear_subtype();
- std::cout << "after calling clear_subtype(): " << json(c1) << '\n';
+ std::cout << "after calling clear_subtype(): " << json(c1) << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__has_subtype.cpp b/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__has_subtype.cpp
index 61c21eaa..a6da3024 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__has_subtype.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__has_subtype.cpp
@@ -2,18 +2,18 @@
#include
// define a byte container based on std::vector
-using byte_container_with_subtype = nlohmann::byte_container_with_subtype>;
+using byte_container_with_subtype =
+ nlohmann::byte_container_with_subtype>;
-int main()
-{
- std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}};
+int main() {
+ std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}};
- // create container
- auto c1 = byte_container_with_subtype(bytes);
+ // create container
+ auto c1 = byte_container_with_subtype(bytes);
- // create container with subtype
- auto c2 = byte_container_with_subtype(bytes, 42);
+ // create container with subtype
+ auto c2 = byte_container_with_subtype(bytes, 42);
- std::cout << std::boolalpha << "c1.has_subtype() = " << c1.has_subtype()
- << "\nc2.has_subtype() = " << c2.has_subtype() << std::endl;
+ std::cout << std::boolalpha << "c1.has_subtype() = " << c1.has_subtype()
+ << "\nc2.has_subtype() = " << c2.has_subtype() << std::endl;
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__set_subtype.cpp b/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__set_subtype.cpp
index b2694c54..36e4d8b6 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__set_subtype.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__set_subtype.cpp
@@ -2,21 +2,21 @@
#include
// define a byte container based on std::vector
-using byte_container_with_subtype = nlohmann::byte_container_with_subtype>;
+using byte_container_with_subtype =
+ nlohmann::byte_container_with_subtype>;
using json = nlohmann::json;
-int main()
-{
- std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}};
+int main() {
+ std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}};
- // create container without subtype
- auto c = byte_container_with_subtype(bytes);
+ // create container without subtype
+ auto c = byte_container_with_subtype(bytes);
- std::cout << "before calling set_subtype(42): " << json(c) << '\n';
+ std::cout << "before calling set_subtype(42): " << json(c) << '\n';
- // set the subtype
- c.set_subtype(42);
+ // set the subtype
+ c.set_subtype(42);
- std::cout << "after calling set_subtype(42): " << json(c) << '\n';
+ std::cout << "after calling set_subtype(42): " << json(c) << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__subtype.cpp b/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__subtype.cpp
index cd230ade..96ab684a 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__subtype.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/byte_container_with_subtype__subtype.cpp
@@ -2,21 +2,22 @@
#include
// define a byte container based on std::vector
-using byte_container_with_subtype = nlohmann::byte_container_with_subtype>;
+using byte_container_with_subtype =
+ nlohmann::byte_container_with_subtype>;
-int main()
-{
- std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}};
+int main() {
+ std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}};
- // create container
- auto c1 = byte_container_with_subtype(bytes);
+ // create container
+ auto c1 = byte_container_with_subtype(bytes);
- // create container with subtype
- auto c2 = byte_container_with_subtype(bytes, 42);
+ // create container with subtype
+ auto c2 = byte_container_with_subtype(bytes, 42);
- std::cout << "c1.subtype() = " << c1.subtype()
- << "\nc2.subtype() = " << c2.subtype() << std::endl;
+ std::cout << "c1.subtype() = " << c1.subtype()
+ << "\nc2.subtype() = " << c2.subtype() << std::endl;
- // in case no subtype is set, return special value
- assert(c1.subtype() == static_cast(-1));
+ // in case no subtype is set, return special value
+ assert(c1.subtype() ==
+ static_cast(-1));
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/cbegin.cpp b/nlohmann_json/docs/mkdocs/docs/examples/cbegin.cpp
index bed2b372..eaefd191 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/cbegin.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/cbegin.cpp
@@ -3,14 +3,13 @@
using json = nlohmann::json;
-int main()
-{
- // create an array value
- const json array = {1, 2, 3, 4, 5};
+int main() {
+ // create an array value
+ const json array = {1, 2, 3, 4, 5};
- // get an iterator to the first element
- json::const_iterator it = array.cbegin();
+ // get an iterator to the first element
+ json::const_iterator it = array.cbegin();
- // serialize the element that the iterator points to
- std::cout << *it << '\n';
+ // serialize the element that the iterator points to
+ std::cout << *it << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/cbor_tag_handler_t.cpp b/nlohmann_json/docs/mkdocs/docs/examples/cbor_tag_handler_t.cpp
index 38d168ca..7e6d1bd0 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/cbor_tag_handler_t.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/cbor_tag_handler_t.cpp
@@ -3,26 +3,25 @@
using json = nlohmann::json;
-int main()
-{
- // tagged byte string
- std::vector vec = {{0xd8, 0x42, 0x44, 0xcA, 0xfe, 0xba, 0xbe}};
+int main() {
+ // tagged byte string
+ std::vector vec = {{0xd8, 0x42, 0x44, 0xcA, 0xfe, 0xba, 0xbe}};
- // cbor_tag_handler_t::error throws
- try
- {
- auto b_throw_on_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::error);
- }
- catch (const json::parse_error& e)
- {
- std::cout << e.what() << std::endl;
- }
+ // cbor_tag_handler_t::error throws
+ try {
+ auto b_throw_on_tag =
+ json::from_cbor(vec, true, true, json::cbor_tag_handler_t::error);
+ } catch (const json::parse_error &e) {
+ std::cout << e.what() << std::endl;
+ }
- // cbor_tag_handler_t::ignore ignores the tag
- auto b_ignore_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::ignore);
- std::cout << b_ignore_tag << std::endl;
+ // cbor_tag_handler_t::ignore ignores the tag
+ auto b_ignore_tag =
+ json::from_cbor(vec, true, true, json::cbor_tag_handler_t::ignore);
+ std::cout << b_ignore_tag << std::endl;
- // cbor_tag_handler_t::store stores the tag as binary subtype
- auto b_store_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::store);
- std::cout << b_store_tag << std::endl;
+ // cbor_tag_handler_t::store stores the tag as binary subtype
+ auto b_store_tag =
+ json::from_cbor(vec, true, true, json::cbor_tag_handler_t::store);
+ std::cout << b_store_tag << std::endl;
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/cend.cpp b/nlohmann_json/docs/mkdocs/docs/examples/cend.cpp
index 3050f500..3449bc7e 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/cend.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/cend.cpp
@@ -3,17 +3,16 @@
using json = nlohmann::json;
-int main()
-{
- // create an array value
- json array = {1, 2, 3, 4, 5};
+int main() {
+ // create an array value
+ json array = {1, 2, 3, 4, 5};
- // get an iterator to one past the last element
- json::const_iterator it = array.cend();
+ // get an iterator to one past the last element
+ json::const_iterator it = array.cend();
- // decrement the iterator to point to the last element
- --it;
+ // decrement the iterator to point to the last element
+ --it;
- // serialize the element that the iterator points to
- std::cout << *it << '\n';
+ // serialize the element that the iterator points to
+ std::cout << *it << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/clear.cpp b/nlohmann_json/docs/mkdocs/docs/examples/clear.cpp
index f081e7ed..5cd7f188 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/clear.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/clear.cpp
@@ -3,32 +3,31 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_null;
- json j_boolean = true;
- json j_number_integer = 17;
- json j_number_float = 23.42;
- json j_object = {{"one", 1}, {"two", 2}};
- json j_array = {1, 2, 4, 8, 16};
- json j_string = "Hello, world";
+int main() {
+ // create JSON values
+ json j_null;
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_float = 23.42;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = {1, 2, 4, 8, 16};
+ json j_string = "Hello, world";
- // call clear()
- j_null.clear();
- j_boolean.clear();
- j_number_integer.clear();
- j_number_float.clear();
- j_object.clear();
- j_array.clear();
- j_string.clear();
+ // call clear()
+ j_null.clear();
+ j_boolean.clear();
+ j_number_integer.clear();
+ j_number_float.clear();
+ j_object.clear();
+ j_array.clear();
+ j_string.clear();
- // serialize the cleared values()
- std::cout << j_null << '\n';
- std::cout << j_boolean << '\n';
- std::cout << j_number_integer << '\n';
- std::cout << j_number_float << '\n';
- std::cout << j_object << '\n';
- std::cout << j_array << '\n';
- std::cout << j_string << '\n';
+ // serialize the cleared values()
+ std::cout << j_null << '\n';
+ std::cout << j_boolean << '\n';
+ std::cout << j_number_integer << '\n';
+ std::cout << j_number_float << '\n';
+ std::cout << j_object << '\n';
+ std::cout << j_array << '\n';
+ std::cout << j_string << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/comments.cpp b/nlohmann_json/docs/mkdocs/docs/examples/comments.cpp
deleted file mode 100644
index fc8a0ac3..00000000
--- a/nlohmann_json/docs/mkdocs/docs/examples/comments.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-
-#include
-#include
-
-using json = nlohmann::json;
-
-int main()
-{
- std::string s = R"(
- {
- // update in 2006: removed Pluto
- "planets": ["Mercury", "Venus", "Earth", "Mars",
- "Jupiter", "Uranus", "Neptune" /*, "Pluto" */]
- }
- )";
-
- try
- {
- json j = json::parse(s);
- }
- catch (json::exception& e)
- {
- std::cout << e.what() << std::endl;
- }
-
- json j = json::parse(s,
- /* callback */ nullptr,
- /* allow exceptions */ true,
- /* ignore_comments */ true);
- std::cout << j.dump(2) << '\n';
-}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/comments.output b/nlohmann_json/docs/mkdocs/docs/examples/comments.output
deleted file mode 100644
index 6e0d1c46..00000000
--- a/nlohmann_json/docs/mkdocs/docs/examples/comments.output
+++ /dev/null
@@ -1,12 +0,0 @@
-[json.exception.parse_error.101] parse error at line 3, column 9: syntax error while parsing object key - invalid literal; last read: ' { /'; expected string literal
-{
- "planets": [
- "Mercury",
- "Venus",
- "Earth",
- "Mars",
- "Jupiter",
- "Uranus",
- "Neptune"
- ]
-}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/contains__json_pointer.cpp b/nlohmann_json/docs/mkdocs/docs/examples/contains__json_pointer.cpp
index 14d8514b..2f1874e9 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/contains__json_pointer.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/contains__json_pointer.cpp
@@ -4,40 +4,29 @@
using json = nlohmann::json;
using namespace nlohmann::literals;
-int main()
-{
- // create a JSON value
- json j =
- {
- {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
- };
+int main() {
+ // create a JSON value
+ json j = {{"number", 1}, {"string", "foo"}, {"array", {1, 2}}};
- std::cout << std::boolalpha
- << j.contains("/number"_json_pointer) << '\n'
- << j.contains("/string"_json_pointer) << '\n'
- << j.contains("/array"_json_pointer) << '\n'
- << j.contains("/array/1"_json_pointer) << '\n'
- << j.contains("/array/-"_json_pointer) << '\n'
- << j.contains("/array/4"_json_pointer) << '\n'
- << j.contains("/baz"_json_pointer) << std::endl;
+ std::cout << std::boolalpha << j.contains("/number"_json_pointer) << '\n'
+ << j.contains("/string"_json_pointer) << '\n'
+ << j.contains("/array"_json_pointer) << '\n'
+ << j.contains("/array/1"_json_pointer) << '\n'
+ << j.contains("/array/-"_json_pointer) << '\n'
+ << j.contains("/array/4"_json_pointer) << '\n'
+ << j.contains("/baz"_json_pointer) << std::endl;
- try
- {
- // try to use an array index with leading '0'
- j.contains("/array/01"_json_pointer);
- }
- catch (const json::parse_error& e)
- {
- std::cout << e.what() << '\n';
- }
+ try {
+ // try to use an array index with leading '0'
+ j.contains("/array/01"_json_pointer);
+ } catch (const json::parse_error &e) {
+ std::cout << e.what() << '\n';
+ }
- try
- {
- // try to use an array index that is not a number
- j.contains("/array/one"_json_pointer);
- }
- catch (const json::parse_error& e)
- {
- std::cout << e.what() << '\n';
- }
+ try {
+ // try to use an array index that is not a number
+ j.contains("/array/one"_json_pointer);
+ } catch (const json::parse_error &e) {
+ std::cout << e.what() << '\n';
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/contains__keytype.c++17.cpp b/nlohmann_json/docs/mkdocs/docs/examples/contains__keytype.c++17.cpp
index 43b62fab..894e6bbd 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/contains__keytype.c++17.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/contains__keytype.c++17.cpp
@@ -1,20 +1,21 @@
#include
-#include
#include
+#include
using namespace std::string_view_literals;
using json = nlohmann::json;
using namespace nlohmann::literals;
-int main()
-{
- // create some JSON values
- json j_object = R"( {"key": "value"} )"_json;
- json j_array = R"( [1, 2, 3] )"_json;
+int main() {
+ // create some JSON values
+ json j_object = R"( {"key": "value"} )"_json;
+ json j_array = R"( [1, 2, 3] )"_json;
- // call contains
- std::cout << std::boolalpha <<
- "j_object contains 'key': " << j_object.contains("key"sv) << '\n' <<
- "j_object contains 'another': " << j_object.contains("another"sv) << '\n' <<
- "j_array contains 'key': " << j_array.contains("key"sv) << std::endl;
+ // call contains
+ std::cout << std::boolalpha
+ << "j_object contains 'key': " << j_object.contains("key"sv) << '\n'
+ << "j_object contains 'another': " << j_object.contains("another"sv)
+ << '\n'
+ << "j_array contains 'key': " << j_array.contains("key"sv)
+ << std::endl;
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/contains__object_t_key_type.cpp b/nlohmann_json/docs/mkdocs/docs/examples/contains__object_t_key_type.cpp
index a8bc8143..27fb33ce 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/contains__object_t_key_type.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/contains__object_t_key_type.cpp
@@ -4,15 +4,16 @@
using json = nlohmann::json;
using namespace nlohmann::literals;
-int main()
-{
- // create some JSON values
- json j_object = R"( {"key": "value"} )"_json;
- json j_array = R"( [1, 2, 3] )"_json;
+int main() {
+ // create some JSON values
+ json j_object = R"( {"key": "value"} )"_json;
+ json j_array = R"( [1, 2, 3] )"_json;
- // call contains
- std::cout << std::boolalpha <<
- "j_object contains 'key': " << j_object.contains("key") << '\n' <<
- "j_object contains 'another': " << j_object.contains("another") << '\n' <<
- "j_array contains 'key': " << j_array.contains("key") << std::endl;
+ // call contains
+ std::cout << std::boolalpha
+ << "j_object contains 'key': " << j_object.contains("key") << '\n'
+ << "j_object contains 'another': " << j_object.contains("another")
+ << '\n'
+ << "j_array contains 'key': " << j_array.contains("key")
+ << std::endl;
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/count__keytype.c++17.cpp b/nlohmann_json/docs/mkdocs/docs/examples/count__keytype.c++17.cpp
index ec6de060..2b671aef 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/count__keytype.c++17.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/count__keytype.c++17.cpp
@@ -1,20 +1,19 @@
#include
-#include
#include
+#include
using namespace std::string_view_literals;
using json = nlohmann::json;
-int main()
-{
- // create a JSON object
- json j_object = {{"one", 1}, {"two", 2}};
+int main() {
+ // create a JSON object
+ json j_object = {{"one", 1}, {"two", 2}};
- // call count()
- auto count_two = j_object.count("two"sv);
- auto count_three = j_object.count("three"sv);
+ // call count()
+ auto count_two = j_object.count("two"sv);
+ auto count_three = j_object.count("three"sv);
- // print values
- std::cout << "number of elements with key \"two\": " << count_two << '\n';
- std::cout << "number of elements with key \"three\": " << count_three << '\n';
+ // print values
+ std::cout << "number of elements with key \"two\": " << count_two << '\n';
+ std::cout << "number of elements with key \"three\": " << count_three << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/count__object_t_key_type.cpp b/nlohmann_json/docs/mkdocs/docs/examples/count__object_t_key_type.cpp
index a8d54b9d..fa848dda 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/count__object_t_key_type.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/count__object_t_key_type.cpp
@@ -3,16 +3,15 @@
using json = nlohmann::json;
-int main()
-{
- // create a JSON object
- json j_object = {{"one", 1}, {"two", 2}};
+int main() {
+ // create a JSON object
+ json j_object = {{"one", 1}, {"two", 2}};
- // call count()
- auto count_two = j_object.count("two");
- auto count_three = j_object.count("three");
+ // call count()
+ auto count_two = j_object.count("two");
+ auto count_three = j_object.count("three");
- // print values
- std::cout << "number of elements with key \"two\": " << count_two << '\n';
- std::cout << "number of elements with key \"three\": " << count_three << '\n';
+ // print values
+ std::cout << "number of elements with key \"two\": " << count_two << '\n';
+ std::cout << "number of elements with key \"three\": " << count_three << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/crbegin.cpp b/nlohmann_json/docs/mkdocs/docs/examples/crbegin.cpp
index dc3209cf..df93777f 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/crbegin.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/crbegin.cpp
@@ -3,14 +3,13 @@
using json = nlohmann::json;
-int main()
-{
- // create an array value
- json array = {1, 2, 3, 4, 5};
+int main() {
+ // create an array value
+ json array = {1, 2, 3, 4, 5};
- // get an iterator to the reverse-beginning
- json::const_reverse_iterator it = array.crbegin();
+ // get an iterator to the reverse-beginning
+ json::const_reverse_iterator it = array.crbegin();
- // serialize the element that the iterator points to
- std::cout << *it << '\n';
+ // serialize the element that the iterator points to
+ std::cout << *it << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/crend.cpp b/nlohmann_json/docs/mkdocs/docs/examples/crend.cpp
index dff26093..06c99614 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/crend.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/crend.cpp
@@ -3,17 +3,16 @@
using json = nlohmann::json;
-int main()
-{
- // create an array value
- json array = {1, 2, 3, 4, 5};
+int main() {
+ // create an array value
+ json array = {1, 2, 3, 4, 5};
- // get an iterator to the reverse-end
- json::const_reverse_iterator it = array.crend();
+ // get an iterator to the reverse-end
+ json::const_reverse_iterator it = array.crend();
- // increment the iterator to point to the first element
- --it;
+ // increment the iterator to point to the first element
+ --it;
- // serialize the element that the iterator points to
- std::cout << *it << '\n';
+ // serialize the element that the iterator points to
+ std::cout << *it << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/default_object_comparator_t.cpp b/nlohmann_json/docs/mkdocs/docs/examples/default_object_comparator_t.cpp
index 9f200fe6..273b7355 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/default_object_comparator_t.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/default_object_comparator_t.cpp
@@ -3,9 +3,10 @@
using json = nlohmann::json;
-int main()
-{
- std::cout << std::boolalpha
- << "one < two : " << json::default_object_comparator_t{}("one", "two") << "\n"
- << "three < four : " << json::default_object_comparator_t{}("three", "four") << std::endl;
+int main() {
+ std::cout << std::boolalpha << "one < two : "
+ << json::default_object_comparator_t{}("one", "two") << "\n"
+ << "three < four : "
+ << json::default_object_comparator_t{}("three", "four")
+ << std::endl;
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/diagnostic_positions.cpp b/nlohmann_json/docs/mkdocs/docs/examples/diagnostic_positions.cpp
index 259344cd..b5b3c980 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/diagnostic_positions.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/diagnostic_positions.cpp
@@ -5,9 +5,8 @@
using json = nlohmann::json;
-int main()
-{
- std::string json_string = R"(
+int main() {
+ std::string json_string = R"(
{
"address": {
"street": "Fake Street",
@@ -15,37 +14,54 @@ int main()
}
}
)";
- json j = json::parse(json_string);
+ json j = json::parse(json_string);
- std::cout << "Root diagnostic positions: \n";
- std::cout << "\tstart_pos: " << j.start_pos() << '\n';
- std::cout << "\tend_pos:" << j.end_pos() << "\n";
- std::cout << "Original string: \n";
- std::cout << "{\n \"address\": {\n \"street\": \"Fake Street\",\n \"housenumber\": 1\n }\n }" << "\n";
- std::cout << "Parsed string: \n";
- std::cout << json_string.substr(j.start_pos(), j.end_pos() - j.start_pos()) << "\n\n";
+ std::cout << "Root diagnostic positions: \n";
+ std::cout << "\tstart_pos: " << j.start_pos() << '\n';
+ std::cout << "\tend_pos:" << j.end_pos() << "\n";
+ std::cout << "Original string: \n";
+ std::cout << "{\n \"address\": {\n \"street\": \"Fake "
+ "Street\",\n \"housenumber\": 1\n }\n }"
+ << "\n";
+ std::cout << "Parsed string: \n";
+ std::cout << json_string.substr(j.start_pos(), j.end_pos() - j.start_pos())
+ << "\n\n";
- std::cout << "address diagnostic positions: \n";
- std::cout << "\tstart_pos:" << j["address"].start_pos() << '\n';
- std::cout << "\tend_pos:" << j["address"].end_pos() << "\n\n";
- std::cout << "Original string: \n";
- std::cout << "{ \"street\": \"Fake Street\",\n \"housenumber\": 1\n }" << "\n";
- std::cout << "Parsed string: \n";
- std::cout << json_string.substr(j["address"].start_pos(), j["address"].end_pos() - j["address"].start_pos()) << "\n\n";
+ std::cout << "address diagnostic positions: \n";
+ std::cout << "\tstart_pos:" << j["address"].start_pos() << '\n';
+ std::cout << "\tend_pos:" << j["address"].end_pos() << "\n\n";
+ std::cout << "Original string: \n";
+ std::cout << "{ \"street\": \"Fake Street\",\n "
+ "\"housenumber\": 1\n }"
+ << "\n";
+ std::cout << "Parsed string: \n";
+ std::cout << json_string.substr(j["address"].start_pos(),
+ j["address"].end_pos() -
+ j["address"].start_pos())
+ << "\n\n";
- std::cout << "street diagnostic positions: \n";
- std::cout << "\tstart_pos:" << j["address"]["street"].start_pos() << '\n';
- std::cout << "\tend_pos:" << j["address"]["street"].end_pos() << "\n\n";
- std::cout << "Original string: \n";
- std::cout << "\"Fake Street\"" << "\n";
- std::cout << "Parsed string: \n";
- std::cout << json_string.substr(j["address"]["street"].start_pos(), j["address"]["street"].end_pos() - j["address"]["street"].start_pos()) << "\n\n";
+ std::cout << "street diagnostic positions: \n";
+ std::cout << "\tstart_pos:" << j["address"]["street"].start_pos() << '\n';
+ std::cout << "\tend_pos:" << j["address"]["street"].end_pos() << "\n\n";
+ std::cout << "Original string: \n";
+ std::cout << "\"Fake Street\""
+ << "\n";
+ std::cout << "Parsed string: \n";
+ std::cout << json_string.substr(j["address"]["street"].start_pos(),
+ j["address"]["street"].end_pos() -
+ j["address"]["street"].start_pos())
+ << "\n\n";
- std::cout << "housenumber diagnostic positions: \n";
- std::cout << "\tstart_pos:" << j["address"]["housenumber"].start_pos() << '\n';
- std::cout << "\tend_pos:" << j["address"]["housenumber"].end_pos() << "\n\n";
- std::cout << "Original string: \n";
- std::cout << "1" << "\n";
- std::cout << "Parsed string: \n";
- std::cout << json_string.substr(j["address"]["housenumber"].start_pos(), j["address"]["housenumber"].end_pos() - j["address"]["housenumber"].start_pos()) << "\n\n";
+ std::cout << "housenumber diagnostic positions: \n";
+ std::cout << "\tstart_pos:" << j["address"]["housenumber"].start_pos()
+ << '\n';
+ std::cout << "\tend_pos:" << j["address"]["housenumber"].end_pos() << "\n\n";
+ std::cout << "Original string: \n";
+ std::cout << "1"
+ << "\n";
+ std::cout << "Parsed string: \n";
+ std::cout << json_string.substr(j["address"]["housenumber"].start_pos(),
+ j["address"]["housenumber"].end_pos() -
+ j["address"]["housenumber"].start_pos())
+ << "\n\n";
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/diagnostic_positions_exception.cpp b/nlohmann_json/docs/mkdocs/docs/examples/diagnostic_positions_exception.cpp
index ea4c4139..bd4663b4 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/diagnostic_positions_exception.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/diagnostic_positions_exception.cpp
@@ -5,11 +5,11 @@
using json = nlohmann::json;
-/* Demonstration of type error exception with diagnostic postions support enabled */
-int main()
-{
- //Invalid json string - housenumber type must be int instead of string
- const std::string json_invalid_string = R"(
+/* Demonstration of type error exception with diagnostic postions support
+ * enabled */
+int main() {
+ // Invalid json string - housenumber type must be int instead of string
+ const std::string json_invalid_string = R"(
{
"address": {
"street": "Fake Street",
@@ -17,14 +17,11 @@ int main()
}
}
)";
- json j = json::parse(json_invalid_string);
- try
- {
- int housenumber = j["address"]["housenumber"];
- std::cout << housenumber;
- }
- catch (const json::exception& e)
- {
- std::cout << e.what() << '\n';
- }
+ json j = json::parse(json_invalid_string);
+ try {
+ int housenumber = j["address"]["housenumber"];
+ std::cout << housenumber;
+ } catch (const json::exception &e) {
+ std::cout << e.what() << '\n';
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/diagnostics_extended.cpp b/nlohmann_json/docs/mkdocs/docs/examples/diagnostics_extended.cpp
index 3b9f484b..638b7f3f 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/diagnostics_extended.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/diagnostics_extended.cpp
@@ -1,22 +1,18 @@
#include
-# define JSON_DIAGNOSTICS 1
+#define JSON_DIAGNOSTICS 1
#include
using json = nlohmann::json;
-int main()
-{
- json j;
- j["address"]["street"] = "Fake Street";
- j["address"]["housenumber"] = "12";
+int main() {
+ json j;
+ j["address"]["street"] = "Fake Street";
+ j["address"]["housenumber"] = "12";
- try
- {
- int housenumber = j["address"]["housenumber"];
- }
- catch (const json::exception& e)
- {
- std::cout << e.what() << '\n';
- }
+ try {
+ int housenumber = j["address"]["housenumber"];
+ } catch (const json::exception &e) {
+ std::cout << e.what() << '\n';
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/diagnostics_extended_positions.cpp b/nlohmann_json/docs/mkdocs/docs/examples/diagnostics_extended_positions.cpp
index 0e0c0294..aa6aa0e9 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/diagnostics_extended_positions.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/diagnostics_extended_positions.cpp
@@ -6,11 +6,11 @@
using json = nlohmann::json;
-/* Demonstration of type error exception with diagnostic postions support enabled */
-int main()
-{
- //Invalid json string - housenumber type must be int instead of string
- const std::string json_invalid_string = R"(
+/* Demonstration of type error exception with diagnostic postions support
+ * enabled */
+int main() {
+ // Invalid json string - housenumber type must be int instead of string
+ const std::string json_invalid_string = R"(
{
"address": {
"street": "Fake Street",
@@ -18,14 +18,11 @@ int main()
}
}
)";
- json j = json::parse(json_invalid_string);
- try
- {
- int housenumber = j["address"]["housenumber"];
- std::cout << housenumber;
- }
- catch (const json::exception& e)
- {
- std::cout << e.what() << '\n';
- }
+ json j = json::parse(json_invalid_string);
+ try {
+ int housenumber = j["address"]["housenumber"];
+ std::cout << housenumber;
+ } catch (const json::exception &e) {
+ std::cout << e.what() << '\n';
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/diagnostics_standard.cpp b/nlohmann_json/docs/mkdocs/docs/examples/diagnostics_standard.cpp
index eae61a4a..a025f403 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/diagnostics_standard.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/diagnostics_standard.cpp
@@ -3,18 +3,14 @@
using json = nlohmann::json;
-int main()
-{
- json j;
- j["address"]["street"] = "Fake Street";
- j["address"]["housenumber"] = "12";
+int main() {
+ json j;
+ j["address"]["street"] = "Fake Street";
+ j["address"]["housenumber"] = "12";
- try
- {
- int housenumber = j["address"]["housenumber"];
- }
- catch (const json::exception& e)
- {
- std::cout << e.what() << '\n';
- }
+ try {
+ int housenumber = j["address"]["housenumber"];
+ } catch (const json::exception &e) {
+ std::cout << e.what() << '\n';
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/diff.cpp b/nlohmann_json/docs/mkdocs/docs/examples/diff.cpp
index ef01332a..e91e2be1 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/diff.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/diff.cpp
@@ -1,22 +1,21 @@
-#include
#include
+#include
#include
using json = nlohmann::json;
using namespace nlohmann::literals;
-int main()
-{
- // the source document
- json source = R"(
+int main() {
+ // the source document
+ json source = R"(
{
"baz": "qux",
"foo": "bar"
}
)"_json;
- // the target document
- json target = R"(
+ // the target document
+ json target = R"(
{
"baz": "boo",
"hello": [
@@ -25,13 +24,13 @@ int main()
}
)"_json;
- // create the patch
- json patch = json::diff(source, target);
+ // create the patch
+ json patch = json::diff(source, target);
- // roundtrip
- json patched_source = source.patch(patch);
+ // roundtrip
+ json patched_source = source.patch(patch);
- // output patch and roundtrip result
- std::cout << std::setw(4) << patch << "\n\n"
- << std::setw(4) << patched_source << std::endl;
+ // output patch and roundtrip result
+ std::cout << std::setw(4) << patch << "\n\n"
+ << std::setw(4) << patched_source << std::endl;
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/dump.cpp b/nlohmann_json/docs/mkdocs/docs/examples/dump.cpp
index 009c95fd..7c8ea11c 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/dump.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/dump.cpp
@@ -3,46 +3,42 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_object = {{"one", 1}, {"two", 2}};
- json j_array = {1, 2, 4, 8, 16};
- json j_string = "Hellö 😀!";
+int main() {
+ // create JSON values
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = {1, 2, 4, 8, 16};
+ json j_string = "Hellö 😀!";
- // call dump()
- std::cout << "objects:" << '\n'
- << j_object.dump() << "\n\n"
- << j_object.dump(-1) << "\n\n"
- << j_object.dump(0) << "\n\n"
- << j_object.dump(4) << "\n\n"
- << j_object.dump(1, '\t') << "\n\n";
+ // call dump()
+ std::cout << "objects:" << '\n'
+ << j_object.dump() << "\n\n"
+ << j_object.dump(-1) << "\n\n"
+ << j_object.dump(0) << "\n\n"
+ << j_object.dump(4) << "\n\n"
+ << j_object.dump(1, '\t') << "\n\n";
- std::cout << "arrays:" << '\n'
- << j_array.dump() << "\n\n"
- << j_array.dump(-1) << "\n\n"
- << j_array.dump(0) << "\n\n"
- << j_array.dump(4) << "\n\n"
- << j_array.dump(1, '\t') << "\n\n";
+ std::cout << "arrays:" << '\n'
+ << j_array.dump() << "\n\n"
+ << j_array.dump(-1) << "\n\n"
+ << j_array.dump(0) << "\n\n"
+ << j_array.dump(4) << "\n\n"
+ << j_array.dump(1, '\t') << "\n\n";
- std::cout << "strings:" << '\n'
- << j_string.dump() << '\n'
- << j_string.dump(-1, ' ', true) << '\n';
+ std::cout << "strings:" << '\n'
+ << j_string.dump() << '\n'
+ << j_string.dump(-1, ' ', true) << '\n';
- // create JSON value with invalid UTF-8 byte sequence
- json j_invalid = "ä\xA9ü";
- try
- {
- std::cout << j_invalid.dump() << std::endl;
- }
- catch (const json::type_error& e)
- {
- std::cout << e.what() << std::endl;
- }
+ // create JSON value with invalid UTF-8 byte sequence
+ json j_invalid = "ä\xA9ü";
+ try {
+ std::cout << j_invalid.dump() << std::endl;
+ } catch (const json::type_error &e) {
+ std::cout << e.what() << std::endl;
+ }
- std::cout << "string with replaced invalid characters: "
- << j_invalid.dump(-1, ' ', false, json::error_handler_t::replace)
- << "\nstring with ignored invalid characters: "
- << j_invalid.dump(-1, ' ', false, json::error_handler_t::ignore)
- << '\n';
+ std::cout << "string with replaced invalid characters: "
+ << j_invalid.dump(-1, ' ', false, json::error_handler_t::replace)
+ << "\nstring with ignored invalid characters: "
+ << j_invalid.dump(-1, ' ', false, json::error_handler_t::ignore)
+ << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/emplace.cpp b/nlohmann_json/docs/mkdocs/docs/examples/emplace.cpp
index a5314910..39919525 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/emplace.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/emplace.cpp
@@ -3,29 +3,28 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json object = {{"one", 1}, {"two", 2}};
- json null;
+int main() {
+ // create JSON values
+ json object = {{"one", 1}, {"two", 2}};
+ json null;
- // print values
- std::cout << object << '\n';
- std::cout << null << '\n';
+ // print values
+ std::cout << object << '\n';
+ std::cout << null << '\n';
- // add values
- auto res1 = object.emplace("three", 3);
- null.emplace("A", "a");
- null.emplace("B", "b");
+ // add values
+ auto res1 = object.emplace("three", 3);
+ null.emplace("A", "a");
+ null.emplace("B", "b");
- // the following call will not add an object, because there is already
- // a value stored at key "B"
- auto res2 = null.emplace("B", "c");
+ // the following call will not add an object, because there is already
+ // a value stored at key "B"
+ auto res2 = null.emplace("B", "c");
- // print values
- std::cout << object << '\n';
- std::cout << *res1.first << " " << std::boolalpha << res1.second << '\n';
+ // print values
+ std::cout << object << '\n';
+ std::cout << *res1.first << " " << std::boolalpha << res1.second << '\n';
- std::cout << null << '\n';
- std::cout << *res2.first << " " << std::boolalpha << res2.second << '\n';
+ std::cout << null << '\n';
+ std::cout << *res2.first << " " << std::boolalpha << res2.second << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/emplace_back.cpp b/nlohmann_json/docs/mkdocs/docs/examples/emplace_back.cpp
index e979a945..9455b81d 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/emplace_back.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/emplace_back.cpp
@@ -3,22 +3,21 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json array = {1, 2, 3, 4, 5};
- json null;
+int main() {
+ // create JSON values
+ json array = {1, 2, 3, 4, 5};
+ json null;
- // print values
- std::cout << array << '\n';
- std::cout << null << '\n';
+ // print values
+ std::cout << array << '\n';
+ std::cout << null << '\n';
- // add values
- array.emplace_back(6);
- null.emplace_back("first");
- null.emplace_back(3, "second");
+ // add values
+ array.emplace_back(6);
+ null.emplace_back("first");
+ null.emplace_back(3, "second");
- // print values
- std::cout << array << '\n';
- std::cout << null << '\n';
+ // print values
+ std::cout << array << '\n';
+ std::cout << null << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/empty.cpp b/nlohmann_json/docs/mkdocs/docs/examples/empty.cpp
index 6ef6e40e..9cadf013 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/empty.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/empty.cpp
@@ -3,28 +3,27 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_null;
- json j_boolean = true;
- json j_number_integer = 17;
- json j_number_float = 23.42;
- json j_object = {{"one", 1}, {"two", 2}};
- json j_object_empty(json::value_t::object);
- json j_array = {1, 2, 4, 8, 16};
- json j_array_empty(json::value_t::array);
- json j_string = "Hello, world";
+int main() {
+ // create JSON values
+ json j_null;
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_float = 23.42;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_object_empty(json::value_t::object);
+ json j_array = {1, 2, 4, 8, 16};
+ json j_array_empty(json::value_t::array);
+ json j_string = "Hello, world";
- // call empty()
- std::cout << std::boolalpha;
- std::cout << j_null.empty() << '\n';
- std::cout << j_boolean.empty() << '\n';
- std::cout << j_number_integer.empty() << '\n';
- std::cout << j_number_float.empty() << '\n';
- std::cout << j_object.empty() << '\n';
- std::cout << j_object_empty.empty() << '\n';
- std::cout << j_array.empty() << '\n';
- std::cout << j_array_empty.empty() << '\n';
- std::cout << j_string.empty() << '\n';
+ // call empty()
+ std::cout << std::boolalpha;
+ std::cout << j_null.empty() << '\n';
+ std::cout << j_boolean.empty() << '\n';
+ std::cout << j_number_integer.empty() << '\n';
+ std::cout << j_number_float.empty() << '\n';
+ std::cout << j_object.empty() << '\n';
+ std::cout << j_object_empty.empty() << '\n';
+ std::cout << j_array.empty() << '\n';
+ std::cout << j_array_empty.empty() << '\n';
+ std::cout << j_string.empty() << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/end.cpp b/nlohmann_json/docs/mkdocs/docs/examples/end.cpp
index 47beedb7..efa55d45 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/end.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/end.cpp
@@ -3,17 +3,16 @@
using json = nlohmann::json;
-int main()
-{
- // create an array value
- json array = {1, 2, 3, 4, 5};
+int main() {
+ // create an array value
+ json array = {1, 2, 3, 4, 5};
- // get an iterator to one past the last element
- json::iterator it = array.end();
+ // get an iterator to one past the last element
+ json::iterator it = array.end();
- // decrement the iterator to point to the last element
- --it;
+ // decrement the iterator to point to the last element
+ --it;
- // serialize the element that the iterator points to
- std::cout << *it << '\n';
+ // serialize the element that the iterator points to
+ std::cout << *it << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/erase__IteratorType.cpp b/nlohmann_json/docs/mkdocs/docs/examples/erase__IteratorType.cpp
index f0d4ec6f..a31a6e9e 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/erase__IteratorType.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/erase__IteratorType.cpp
@@ -3,29 +3,28 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_boolean = true;
- json j_number_integer = 17;
- json j_number_float = 23.42;
- json j_object = {{"one", 1}, {"two", 2}};
- json j_array = {1, 2, 4, 8, 16};
- json j_string = "Hello, world";
+int main() {
+ // create JSON values
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_float = 23.42;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = {1, 2, 4, 8, 16};
+ json j_string = "Hello, world";
- // call erase()
- j_boolean.erase(j_boolean.begin());
- j_number_integer.erase(j_number_integer.begin());
- j_number_float.erase(j_number_float.begin());
- j_object.erase(j_object.find("two"));
- j_array.erase(j_array.begin() + 2);
- j_string.erase(j_string.begin());
+ // call erase()
+ j_boolean.erase(j_boolean.begin());
+ j_number_integer.erase(j_number_integer.begin());
+ j_number_float.erase(j_number_float.begin());
+ j_object.erase(j_object.find("two"));
+ j_array.erase(j_array.begin() + 2);
+ j_string.erase(j_string.begin());
- // print values
- std::cout << j_boolean << '\n';
- std::cout << j_number_integer << '\n';
- std::cout << j_number_float << '\n';
- std::cout << j_object << '\n';
- std::cout << j_array << '\n';
- std::cout << j_string << '\n';
+ // print values
+ std::cout << j_boolean << '\n';
+ std::cout << j_number_integer << '\n';
+ std::cout << j_number_float << '\n';
+ std::cout << j_object << '\n';
+ std::cout << j_array << '\n';
+ std::cout << j_string << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/erase__IteratorType_IteratorType.cpp b/nlohmann_json/docs/mkdocs/docs/examples/erase__IteratorType_IteratorType.cpp
index 392511ff..007ddd2f 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/erase__IteratorType_IteratorType.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/erase__IteratorType_IteratorType.cpp
@@ -3,29 +3,28 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_boolean = true;
- json j_number_integer = 17;
- json j_number_float = 23.42;
- json j_object = {{"one", 1}, {"two", 2}};
- json j_array = {1, 2, 4, 8, 16};
- json j_string = "Hello, world";
+int main() {
+ // create JSON values
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_float = 23.42;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = {1, 2, 4, 8, 16};
+ json j_string = "Hello, world";
- // call erase()
- j_boolean.erase(j_boolean.begin(), j_boolean.end());
- j_number_integer.erase(j_number_integer.begin(), j_number_integer.end());
- j_number_float.erase(j_number_float.begin(), j_number_float.end());
- j_object.erase(j_object.find("two"), j_object.end());
- j_array.erase(j_array.begin() + 1, j_array.begin() + 3);
- j_string.erase(j_string.begin(), j_string.end());
+ // call erase()
+ j_boolean.erase(j_boolean.begin(), j_boolean.end());
+ j_number_integer.erase(j_number_integer.begin(), j_number_integer.end());
+ j_number_float.erase(j_number_float.begin(), j_number_float.end());
+ j_object.erase(j_object.find("two"), j_object.end());
+ j_array.erase(j_array.begin() + 1, j_array.begin() + 3);
+ j_string.erase(j_string.begin(), j_string.end());
- // print values
- std::cout << j_boolean << '\n';
- std::cout << j_number_integer << '\n';
- std::cout << j_number_float << '\n';
- std::cout << j_object << '\n';
- std::cout << j_array << '\n';
- std::cout << j_string << '\n';
+ // print values
+ std::cout << j_boolean << '\n';
+ std::cout << j_number_integer << '\n';
+ std::cout << j_number_float << '\n';
+ std::cout << j_object << '\n';
+ std::cout << j_array << '\n';
+ std::cout << j_string << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/erase__keytype.c++17.cpp b/nlohmann_json/docs/mkdocs/docs/examples/erase__keytype.c++17.cpp
index c5e4bed5..2c1f7832 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/erase__keytype.c++17.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/erase__keytype.c++17.cpp
@@ -1,20 +1,19 @@
#include
-#include
#include
+#include
using namespace std::string_view_literals;
using json = nlohmann::json;
-int main()
-{
- // create a JSON object
- json j_object = {{"one", 1}, {"two", 2}};
+int main() {
+ // create a JSON object
+ json j_object = {{"one", 1}, {"two", 2}};
- // call erase()
- auto count_one = j_object.erase("one"sv);
- auto count_three = j_object.erase("three"sv);
+ // call erase()
+ auto count_one = j_object.erase("one"sv);
+ auto count_three = j_object.erase("three"sv);
- // print values
- std::cout << j_object << '\n';
- std::cout << count_one << " " << count_three << '\n';
+ // print values
+ std::cout << j_object << '\n';
+ std::cout << count_one << " " << count_three << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/erase__object_t_key_type.cpp b/nlohmann_json/docs/mkdocs/docs/examples/erase__object_t_key_type.cpp
index 2fd84c86..2a72510f 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/erase__object_t_key_type.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/erase__object_t_key_type.cpp
@@ -3,16 +3,15 @@
using json = nlohmann::json;
-int main()
-{
- // create a JSON object
- json j_object = {{"one", 1}, {"two", 2}};
+int main() {
+ // create a JSON object
+ json j_object = {{"one", 1}, {"two", 2}};
- // call erase()
- auto count_one = j_object.erase("one");
- auto count_three = j_object.erase("three");
+ // call erase()
+ auto count_one = j_object.erase("one");
+ auto count_three = j_object.erase("three");
- // print values
- std::cout << j_object << '\n';
- std::cout << count_one << " " << count_three << '\n';
+ // print values
+ std::cout << j_object << '\n';
+ std::cout << count_one << " " << count_three << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/erase__size_type.cpp b/nlohmann_json/docs/mkdocs/docs/examples/erase__size_type.cpp
index 81006238..c35ddba4 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/erase__size_type.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/erase__size_type.cpp
@@ -3,14 +3,13 @@
using json = nlohmann::json;
-int main()
-{
- // create a JSON array
- json j_array = {0, 1, 2, 3, 4, 5};
+int main() {
+ // create a JSON array
+ json j_array = {0, 1, 2, 3, 4, 5};
- // call erase()
- j_array.erase(2);
+ // call erase()
+ j_array.erase(2);
- // print values
- std::cout << j_array << '\n';
+ // print values
+ std::cout << j_array << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/error_handler_t.cpp b/nlohmann_json/docs/mkdocs/docs/examples/error_handler_t.cpp
index b4718d7e..2e192055 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/error_handler_t.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/error_handler_t.cpp
@@ -3,22 +3,18 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON value with invalid UTF-8 byte sequence
- json j_invalid = "ä\xA9ü";
- try
- {
- std::cout << j_invalid.dump() << std::endl;
- }
- catch (const json::type_error& e)
- {
- std::cout << e.what() << std::endl;
- }
+int main() {
+ // create JSON value with invalid UTF-8 byte sequence
+ json j_invalid = "ä\xA9ü";
+ try {
+ std::cout << j_invalid.dump() << std::endl;
+ } catch (const json::type_error &e) {
+ std::cout << e.what() << std::endl;
+ }
- std::cout << "string with replaced invalid characters: "
- << j_invalid.dump(-1, ' ', false, json::error_handler_t::replace)
- << "\nstring with ignored invalid characters: "
- << j_invalid.dump(-1, ' ', false, json::error_handler_t::ignore)
- << '\n';
+ std::cout << "string with replaced invalid characters: "
+ << j_invalid.dump(-1, ' ', false, json::error_handler_t::replace)
+ << "\nstring with ignored invalid characters: "
+ << j_invalid.dump(-1, ' ', false, json::error_handler_t::ignore)
+ << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/exception.cpp b/nlohmann_json/docs/mkdocs/docs/examples/exception.cpp
index 3e5a23b3..7fc89a2a 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/exception.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/exception.cpp
@@ -3,18 +3,14 @@
using json = nlohmann::json;
-int main()
-{
- try
- {
- // calling at() for a non-existing key
- json j = {{"foo", "bar"}};
- json k = j.at("non-existing");
- }
- catch (const json::exception& e)
- {
- // output exception information
- std::cout << "message: " << e.what() << '\n'
- << "exception id: " << e.id << std::endl;
- }
+int main() {
+ try {
+ // calling at() for a non-existing key
+ json j = {{"foo", "bar"}};
+ json k = j.at("non-existing");
+ } catch (const json::exception &e) {
+ // output exception information
+ std::cout << "message: " << e.what() << '\n'
+ << "exception id: " << e.id << std::endl;
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/find__keytype.c++17.cpp b/nlohmann_json/docs/mkdocs/docs/examples/find__keytype.c++17.cpp
index da94cf0a..c4003825 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/find__keytype.c++17.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/find__keytype.c++17.cpp
@@ -1,22 +1,21 @@
#include
-#include
#include
+#include
using namespace std::string_view_literals;
using json = nlohmann::json;
-int main()
-{
- // create a JSON object
- json j_object = {{"one", 1}, {"two", 2}};
+int main() {
+ // create a JSON object
+ json j_object = {{"one", 1}, {"two", 2}};
- // call find
- auto it_two = j_object.find("two"sv);
- auto it_three = j_object.find("three"sv);
+ // call find
+ auto it_two = j_object.find("two"sv);
+ auto it_three = j_object.find("three"sv);
- // print values
- std::cout << std::boolalpha;
- std::cout << "\"two\" was found: " << (it_two != j_object.end()) << '\n';
- std::cout << "value at key \"two\": " << *it_two << '\n';
- std::cout << "\"three\" was found: " << (it_three != j_object.end()) << '\n';
+ // print values
+ std::cout << std::boolalpha;
+ std::cout << "\"two\" was found: " << (it_two != j_object.end()) << '\n';
+ std::cout << "value at key \"two\": " << *it_two << '\n';
+ std::cout << "\"three\" was found: " << (it_three != j_object.end()) << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/find__object_t_key_type.cpp b/nlohmann_json/docs/mkdocs/docs/examples/find__object_t_key_type.cpp
index 685ba776..c5555769 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/find__object_t_key_type.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/find__object_t_key_type.cpp
@@ -3,18 +3,17 @@
using json = nlohmann::json;
-int main()
-{
- // create a JSON object
- json j_object = {{"one", 1}, {"two", 2}};
+int main() {
+ // create a JSON object
+ json j_object = {{"one", 1}, {"two", 2}};
- // call find
- auto it_two = j_object.find("two");
- auto it_three = j_object.find("three");
+ // call find
+ auto it_two = j_object.find("two");
+ auto it_three = j_object.find("three");
- // print values
- std::cout << std::boolalpha;
- std::cout << "\"two\" was found: " << (it_two != j_object.end()) << '\n';
- std::cout << "value at key \"two\": " << *it_two << '\n';
- std::cout << "\"three\" was found: " << (it_three != j_object.end()) << '\n';
+ // print values
+ std::cout << std::boolalpha;
+ std::cout << "\"two\" was found: " << (it_two != j_object.end()) << '\n';
+ std::cout << "value at key \"two\": " << *it_two << '\n';
+ std::cout << "\"three\" was found: " << (it_three != j_object.end()) << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/flatten.cpp b/nlohmann_json/docs/mkdocs/docs/examples/flatten.cpp
index 83f3ff6c..3746a71b 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/flatten.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/flatten.cpp
@@ -1,32 +1,19 @@
-#include
#include
+#include
#include
using json = nlohmann::json;
-int main()
-{
- // create JSON value
- json j =
- {
- {"pi", 3.141},
- {"happy", true},
- {"name", "Niels"},
- {"nothing", nullptr},
- {
- "answer", {
- {"everything", 42}
- }
- },
- {"list", {1, 0, 2}},
- {
- "object", {
- {"currency", "USD"},
- {"value", 42.99}
- }
- }
- };
+int main() {
+ // create JSON value
+ json j = {{"pi", 3.141},
+ {"happy", true},
+ {"name", "Niels"},
+ {"nothing", nullptr},
+ {"answer", {{"everything", 42}}},
+ {"list", {1, 0, 2}},
+ {"object", {{"currency", "USD"}, {"value", 42.99}}}};
- // call flatten()
- std::cout << std::setw(4) << j.flatten() << '\n';
+ // call flatten()
+ std::cout << std::setw(4) << j.flatten() << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/from_bjdata.cpp b/nlohmann_json/docs/mkdocs/docs/examples/from_bjdata.cpp
index 961164c2..f723295e 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/from_bjdata.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/from_bjdata.cpp
@@ -1,20 +1,18 @@
-#include
#include
+#include
#include
using json = nlohmann::json;
-int main()
-{
- // create byte vector
- std::vector v = {0x7B, 0x69, 0x07, 0x63, 0x6F, 0x6D, 0x70, 0x61,
- 0x63, 0x74, 0x54, 0x69, 0x06, 0x73, 0x63, 0x68,
- 0x65, 0x6D, 0x61, 0x69, 0x00, 0x7D
- };
+int main() {
+ // create byte vector
+ std::vector v = {0x7B, 0x69, 0x07, 0x63, 0x6F, 0x6D, 0x70, 0x61,
+ 0x63, 0x74, 0x54, 0x69, 0x06, 0x73, 0x63, 0x68,
+ 0x65, 0x6D, 0x61, 0x69, 0x00, 0x7D};
- // deserialize it with BJData
- json j = json::from_bjdata(v);
+ // deserialize it with BJData
+ json j = json::from_bjdata(v);
- // print the deserialized JSON value
- std::cout << std::setw(2) << j << std::endl;
+ // print the deserialized JSON value
+ std::cout << std::setw(2) << j << std::endl;
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/from_bson.cpp b/nlohmann_json/docs/mkdocs/docs/examples/from_bson.cpp
index c9d9fdfa..7d2c6148 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/from_bson.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/from_bson.cpp
@@ -1,21 +1,19 @@
-#include
#include
+#include
#include
using json = nlohmann::json;
-int main()
-{
- // create byte vector
- std::vector v = {0x1b, 0x00, 0x00, 0x00, 0x08, 0x63, 0x6f, 0x6d,
- 0x70, 0x61, 0x63, 0x74, 0x00, 0x01, 0x10, 0x73,
- 0x63, 0x68, 0x65, 0x6d, 0x61, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00
- };
+int main() {
+ // create byte vector
+ std::vector v = {0x1b, 0x00, 0x00, 0x00, 0x08, 0x63, 0x6f,
+ 0x6d, 0x70, 0x61, 0x63, 0x74, 0x00, 0x01,
+ 0x10, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- // deserialize it with BSON
- json j = json::from_bson(v);
+ // deserialize it with BSON
+ json j = json::from_bson(v);
- // print the deserialized JSON value
- std::cout << std::setw(2) << j << std::endl;
+ // print the deserialized JSON value
+ std::cout << std::setw(2) << j << std::endl;
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/from_cbor.cpp b/nlohmann_json/docs/mkdocs/docs/examples/from_cbor.cpp
index e685329e..2e993b72 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/from_cbor.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/from_cbor.cpp
@@ -1,20 +1,18 @@
-#include
#include
+#include
#include
using json = nlohmann::json;
-int main()
-{
- // create byte vector
- std::vector v = {0xa2, 0x67, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63,
- 0x74, 0xf5, 0x66, 0x73, 0x63, 0x68, 0x65, 0x6d,
- 0x61, 0x00
- };
+int main() {
+ // create byte vector
+ std::vector v = {0xa2, 0x67, 0x63, 0x6f, 0x6d, 0x70,
+ 0x61, 0x63, 0x74, 0xf5, 0x66, 0x73,
+ 0x63, 0x68, 0x65, 0x6d, 0x61, 0x00};
- // deserialize it with CBOR
- json j = json::from_cbor(v);
+ // deserialize it with CBOR
+ json j = json::from_cbor(v);
- // print the deserialized JSON value
- std::cout << std::setw(2) << j << std::endl;
+ // print the deserialized JSON value
+ std::cout << std::setw(2) << j << std::endl;
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/from_json__default_constructible.cpp b/nlohmann_json/docs/mkdocs/docs/examples/from_json__default_constructible.cpp
index 07d71ac9..73d6bc00 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/from_json__default_constructible.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/from_json__default_constructible.cpp
@@ -3,35 +3,31 @@
using json = nlohmann::json;
-namespace ns
-{
+namespace ns {
// a simple struct to model a person
-struct person
-{
- std::string name;
- std::string address;
- int age;
+struct person {
+ std::string name;
+ std::string address;
+ int age;
};
} // namespace ns
-namespace ns
-{
-void from_json(const json& j, person& p)
-{
- j.at("name").get_to(p.name);
- j.at("address").get_to(p.address);
- j.at("age").get_to(p.age);
+namespace ns {
+void from_json(const json &j, person &p) {
+ j.at("name").get_to(p.name);
+ j.at("address").get_to(p.address);
+ j.at("age").get_to(p.age);
}
} // namespace ns
-int main()
-{
- json j;
- j["name"] = "Ned Flanders";
- j["address"] = "744 Evergreen Terrace";
- j["age"] = 60;
+int main() {
+ json j;
+ j["name"] = "Ned Flanders";
+ j["address"] = "744 Evergreen Terrace";
+ j["age"] = 60;
- auto p = j.template get();
+ auto p = j.template get();
- std::cout << p.name << " (" << p.age << ") lives in " << p.address << std::endl;
+ std::cout << p.name << " (" << p.age << ") lives in " << p.address
+ << std::endl;
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/from_json__non_default_constructible.cpp b/nlohmann_json/docs/mkdocs/docs/examples/from_json__non_default_constructible.cpp
index ec8206ea..7503be09 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/from_json__non_default_constructible.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/from_json__non_default_constructible.cpp
@@ -3,51 +3,43 @@
using json = nlohmann::json;
-namespace ns
-{
+namespace ns {
// a simple struct to model a person (not default constructible)
-struct person
-{
- person(std::string n, std::string a, int aa)
- : name(std::move(n)), address(std::move(a)), age(aa)
- {}
-
- std::string name;
- std::string address;
- int age;
+struct person {
+ person(std::string n, std::string a, int aa)
+ : name(std::move(n)), address(std::move(a)), age(aa) {}
+
+ std::string name;
+ std::string address;
+ int age;
};
} // namespace ns
-namespace nlohmann
-{
-template <>
-struct adl_serializer
-{
- static ns::person from_json(const json& j)
- {
- return {j.at("name"), j.at("address"), j.at("age")};
- }
-
- // Here's the catch! You must provide a to_json method! Otherwise, you
- // will not be able to convert person to json, since you fully
- // specialized adl_serializer on that type
- static void to_json(json& j, ns::person p)
- {
- j["name"] = p.name;
- j["address"] = p.address;
- j["age"] = p.age;
- }
+namespace nlohmann {
+template <> struct adl_serializer {
+ static ns::person from_json(const json &j) {
+ return {j.at("name"), j.at("address"), j.at("age")};
+ }
+
+ // Here's the catch! You must provide a to_json method! Otherwise, you
+ // will not be able to convert person to json, since you fully
+ // specialized adl_serializer on that type
+ static void to_json(json &j, ns::person p) {
+ j["name"] = p.name;
+ j["address"] = p.address;
+ j["age"] = p.age;
+ }
};
} // namespace nlohmann
-int main()
-{
- json j;
- j["name"] = "Ned Flanders";
- j["address"] = "744 Evergreen Terrace";
- j["age"] = 60;
+int main() {
+ json j;
+ j["name"] = "Ned Flanders";
+ j["address"] = "744 Evergreen Terrace";
+ j["age"] = 60;
- auto p = j.template get();
+ auto p = j.template get();
- std::cout << p.name << " (" << p.age << ") lives in " << p.address << std::endl;
+ std::cout << p.name << " (" << p.age << ") lives in " << p.address
+ << std::endl;
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/from_msgpack.cpp b/nlohmann_json/docs/mkdocs/docs/examples/from_msgpack.cpp
index 5c2183f1..2a075cc4 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/from_msgpack.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/from_msgpack.cpp
@@ -1,20 +1,18 @@
-#include
#include
+#include
#include
using json = nlohmann::json;
-int main()
-{
- // create byte vector
- std::vector v = {0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63,
- 0x74, 0xc3, 0xa6, 0x73, 0x63, 0x68, 0x65, 0x6d,
- 0x61, 0x00
- };
+int main() {
+ // create byte vector
+ std::vector v = {0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70,
+ 0x61, 0x63, 0x74, 0xc3, 0xa6, 0x73,
+ 0x63, 0x68, 0x65, 0x6d, 0x61, 0x00};
- // deserialize it with MessagePack
- json j = json::from_msgpack(v);
+ // deserialize it with MessagePack
+ json j = json::from_msgpack(v);
- // print the deserialized JSON value
- std::cout << std::setw(2) << j << std::endl;
+ // print the deserialized JSON value
+ std::cout << std::setw(2) << j << std::endl;
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/from_ubjson.cpp b/nlohmann_json/docs/mkdocs/docs/examples/from_ubjson.cpp
index 1e85e4e3..0686e1eb 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/from_ubjson.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/from_ubjson.cpp
@@ -1,20 +1,18 @@
-#include
#include
+#include
#include
using json = nlohmann::json;
-int main()
-{
- // create byte vector
- std::vector v = {0x7B, 0x69, 0x07, 0x63, 0x6F, 0x6D, 0x70, 0x61,
- 0x63, 0x74, 0x54, 0x69, 0x06, 0x73, 0x63, 0x68,
- 0x65, 0x6D, 0x61, 0x69, 0x00, 0x7D
- };
+int main() {
+ // create byte vector
+ std::vector v = {0x7B, 0x69, 0x07, 0x63, 0x6F, 0x6D, 0x70, 0x61,
+ 0x63, 0x74, 0x54, 0x69, 0x06, 0x73, 0x63, 0x68,
+ 0x65, 0x6D, 0x61, 0x69, 0x00, 0x7D};
- // deserialize it with UBJSON
- json j = json::from_ubjson(v);
+ // deserialize it with UBJSON
+ json j = json::from_ubjson(v);
- // print the deserialized JSON value
- std::cout << std::setw(2) << j << std::endl;
+ // print the deserialized JSON value
+ std::cout << std::setw(2) << j << std::endl;
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/front.cpp b/nlohmann_json/docs/mkdocs/docs/examples/front.cpp
index a0f63068..8e0db222 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/front.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/front.cpp
@@ -3,27 +3,26 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_null;
- json j_boolean = true;
- json j_number_integer = 17;
- json j_number_float = 23.42;
- json j_object = {{"one", 1}, {"two", 2}};
- json j_object_empty(json::value_t::object);
- json j_array = {1, 2, 4, 8, 16};
- json j_array_empty(json::value_t::array);
- json j_string = "Hello, world";
+int main() {
+ // create JSON values
+ json j_null;
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_float = 23.42;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_object_empty(json::value_t::object);
+ json j_array = {1, 2, 4, 8, 16};
+ json j_array_empty(json::value_t::array);
+ json j_string = "Hello, world";
- // call front()
- //std::cout << j_null.front() << '\n'; // would throw
- std::cout << j_boolean.front() << '\n';
- std::cout << j_number_integer.front() << '\n';
- std::cout << j_number_float.front() << '\n';
- std::cout << j_object.front() << '\n';
- //std::cout << j_object_empty.front() << '\n'; // undefined behavior
- std::cout << j_array.front() << '\n';
- //std::cout << j_array_empty.front() << '\n'; // undefined behavior
- std::cout << j_string.front() << '\n';
+ // call front()
+ // std::cout << j_null.front() << '\n'; // would throw
+ std::cout << j_boolean.front() << '\n';
+ std::cout << j_number_integer.front() << '\n';
+ std::cout << j_number_float.front() << '\n';
+ std::cout << j_object.front() << '\n';
+ // std::cout << j_object_empty.front() << '\n'; // undefined behavior
+ std::cout << j_array.front() << '\n';
+ // std::cout << j_array_empty.front() << '\n'; // undefined behavior
+ std::cout << j_string.front() << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/get__PointerType.cpp b/nlohmann_json/docs/mkdocs/docs/examples/get__PointerType.cpp
index 309c8dee..7a50da81 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/get__PointerType.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/get__PointerType.cpp
@@ -3,19 +3,18 @@
using json = nlohmann::json;
-int main()
-{
- // create a JSON number
- json value = 17;
+int main() {
+ // create a JSON number
+ json value = 17;
- // explicitly getting pointers
- auto p1 = value.template get();
- auto p2 = value.template get();
- auto p3 = value.template get();
- auto p4 = value.template get();
- auto p5 = value.template get();
+ // explicitly getting pointers
+ auto p1 = value.template get();
+ auto p2 = value.template get();
+ auto p3 = value.template get();
+ auto p4 = value.template get();
+ auto p5 = value.template get();
- // print the pointees
- std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n';
- std::cout << std::boolalpha << (p5 == nullptr) << '\n';
+ // print the pointees
+ std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n';
+ std::cout << std::boolalpha << (p5 == nullptr) << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/get__ValueType_const.cpp b/nlohmann_json/docs/mkdocs/docs/examples/get__ValueType_const.cpp
index db63791f..c5be3392 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/get__ValueType_const.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/get__ValueType_const.cpp
@@ -1,50 +1,39 @@
#include
-#include
#include
+#include
using json = nlohmann::json;
-int main()
-{
- // create a JSON value with different types
- json json_types =
- {
- {"boolean", true},
- {
- "number", {
- {"integer", 42},
- {"floating-point", 17.23}
- }
- },
- {"string", "Hello, world!"},
- {"array", {1, 2, 3, 4, 5}},
- {"null", nullptr}
- };
+int main() {
+ // create a JSON value with different types
+ json json_types = {{"boolean", true},
+ {"number", {{"integer", 42}, {"floating-point", 17.23}}},
+ {"string", "Hello, world!"},
+ {"array", {1, 2, 3, 4, 5}},
+ {"null", nullptr}};
- // use explicit conversions
- auto v1 = json_types["boolean"].template get();
- auto v2 = json_types["number"]["integer"].template get();
- auto v3 = json_types["number"]["integer"].template get();
- auto v4 = json_types["number"]["floating-point"].template get();
- auto v5 = json_types["number"]["floating-point"].template get();
- auto v6 = json_types["string"].template get();
- auto v7 = json_types["array"].template get>();
- auto v8 = json_types.template get>();
+ // use explicit conversions
+ auto v1 = json_types["boolean"].template get();
+ auto v2 = json_types["number"]["integer"].template get();
+ auto v3 = json_types["number"]["integer"].template get();
+ auto v4 = json_types["number"]["floating-point"].template get();
+ auto v5 = json_types["number"]["floating-point"].template get();
+ auto v6 = json_types["string"].template get();
+ auto v7 = json_types["array"].template get>();
+ auto v8 = json_types.template get>();
- // print the conversion results
- std::cout << v1 << '\n';
- std::cout << v2 << ' ' << v3 << '\n';
- std::cout << v4 << ' ' << v5 << '\n';
- std::cout << v6 << '\n';
+ // print the conversion results
+ std::cout << v1 << '\n';
+ std::cout << v2 << ' ' << v3 << '\n';
+ std::cout << v4 << ' ' << v5 << '\n';
+ std::cout << v6 << '\n';
- for (auto i : v7)
- {
- std::cout << i << ' ';
- }
- std::cout << "\n\n";
+ for (auto i : v7) {
+ std::cout << i << ' ';
+ }
+ std::cout << "\n\n";
- for (auto i : v8)
- {
- std::cout << i.first << ": " << i.second << '\n';
- }
+ for (auto i : v8) {
+ std::cout << i.first << ": " << i.second << '\n';
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/get_allocator.cpp b/nlohmann_json/docs/mkdocs/docs/examples/get_allocator.cpp
index 35079a10..f9657618 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/get_allocator.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/get_allocator.cpp
@@ -3,16 +3,15 @@
using json = nlohmann::json;
-int main()
-{
- auto alloc = json::get_allocator();
- using traits_t = std::allocator_traits;
+int main() {
+ auto alloc = json::get_allocator();
+ using traits_t = std::allocator_traits;
- json* j = traits_t::allocate(alloc, 1);
- traits_t::construct(alloc, j, "Hello, world!");
+ json *j = traits_t::allocate(alloc, 1);
+ traits_t::construct(alloc, j, "Hello, world!");
- std::cout << *j << std::endl;
+ std::cout << *j << std::endl;
- traits_t::destroy(alloc, j);
- traits_t::deallocate(alloc, j, 1);
+ traits_t::destroy(alloc, j);
+ traits_t::deallocate(alloc, j, 1);
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/get_binary.cpp b/nlohmann_json/docs/mkdocs/docs/examples/get_binary.cpp
index 617ce609..acfc2019 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/get_binary.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/get_binary.cpp
@@ -3,14 +3,14 @@
using json = nlohmann::json;
-int main()
-{
- // create a binary vector
- std::vector vec = {0xCA, 0xFE, 0xBA, 0xBE};
+int main() {
+ // create a binary vector
+ std::vector vec = {0xCA, 0xFE, 0xBA, 0xBE};
- // create a binary JSON value with subtype 42
- json j = json::binary(vec, 42);
+ // create a binary JSON value with subtype 42
+ json j = json::binary(vec, 42);
- // output type and subtype
- std::cout << "type: " << j.type_name() << ", subtype: " << j.get_binary().subtype() << std::endl;
+ // output type and subtype
+ std::cout << "type: " << j.type_name()
+ << ", subtype: " << j.get_binary().subtype() << std::endl;
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/get_ptr.cpp b/nlohmann_json/docs/mkdocs/docs/examples/get_ptr.cpp
index 564ce0f4..e6006f74 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/get_ptr.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/get_ptr.cpp
@@ -3,19 +3,18 @@
using json = nlohmann::json;
-int main()
-{
- // create a JSON number
- json value = 17;
+int main() {
+ // create a JSON number
+ json value = 17;
- // explicitly getting pointers
- auto p1 = value.get_ptr();
- auto p2 = value.get_ptr();
- auto p3 = value.get_ptr();
- auto p4 = value.get_ptr();
- auto p5 = value.get_ptr();
+ // explicitly getting pointers
+ auto p1 = value.get_ptr();
+ auto p2 = value.get_ptr();
+ auto p3 = value.get_ptr();
+ auto p4 = value.get_ptr();
+ auto p5 = value.get_ptr();
- // print the pointees
- std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n';
- std::cout << std::boolalpha << (p5 == nullptr) << '\n';
+ // print the pointees
+ std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n';
+ std::cout << std::boolalpha << (p5 == nullptr) << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/get_ref.cpp b/nlohmann_json/docs/mkdocs/docs/examples/get_ref.cpp
index 0183a653..8e906a7f 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/get_ref.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/get_ref.cpp
@@ -3,25 +3,21 @@
using json = nlohmann::json;
-int main()
-{
- // create a JSON number
- json value = 17;
+int main() {
+ // create a JSON number
+ json value = 17;
- // explicitly getting references
- auto r1 = value.get_ref();
- auto r2 = value.get_ref();
+ // explicitly getting references
+ auto r1 = value.get_ref();
+ auto r2 = value.get_ref();
- // print the values
- std::cout << r1 << ' ' << r2 << '\n';
+ // print the values
+ std::cout << r1 << ' ' << r2 << '\n';
- // incompatible type throws exception
- try
- {
- auto r3 = value.get_ref();
- }
- catch (const json::type_error& ex)
- {
- std::cout << ex.what() << '\n';
- }
+ // incompatible type throws exception
+ try {
+ auto r3 = value.get_ref();
+ } catch (const json::type_error &ex) {
+ std::cout << ex.what() << '\n';
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/get_to.cpp b/nlohmann_json/docs/mkdocs/docs/examples/get_to.cpp
index 358c8d43..6fcfbc53 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/get_to.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/get_to.cpp
@@ -1,59 +1,48 @@
#include
-#include
#include
+#include
using json = nlohmann::json;
-int main()
-{
- // create a JSON value with different types
- json json_types =
- {
- {"boolean", true},
- {
- "number", {
- {"integer", 42},
- {"floating-point", 17.23}
- }
- },
- {"string", "Hello, world!"},
- {"array", {1, 2, 3, 4, 5}},
- {"null", nullptr}
- };
+int main() {
+ // create a JSON value with different types
+ json json_types = {{"boolean", true},
+ {"number", {{"integer", 42}, {"floating-point", 17.23}}},
+ {"string", "Hello, world!"},
+ {"array", {1, 2, 3, 4, 5}},
+ {"null", nullptr}};
- bool v1;
- int v2;
- short v3;
- float v4;
- int v5;
- std::string v6;
- std::vector v7;
- std::unordered_map v8;
+ bool v1;
+ int v2;
+ short v3;
+ float v4;
+ int v5;
+ std::string v6;
+ std::vector v7;
+ std::unordered_map v8;
- // use explicit conversions
- json_types["boolean"].get_to(v1);
- json_types["number"]["integer"].get_to(v2);
- json_types["number"]["integer"].get_to(v3);
- json_types["number"]["floating-point"].get_to(v4);
- json_types["number"]["floating-point"].get_to(v5);
- json_types["string"].get_to(v6);
- json_types["array"].get_to(v7);
- json_types.get_to(v8);
+ // use explicit conversions
+ json_types["boolean"].get_to(v1);
+ json_types["number"]["integer"].get_to(v2);
+ json_types["number"]["integer"].get_to(v3);
+ json_types["number"]["floating-point"].get_to(v4);
+ json_types["number"]["floating-point"].get_to(v5);
+ json_types["string"].get_to(v6);
+ json_types["array"].get_to(v7);
+ json_types.get_to(v8);
- // print the conversion results
- std::cout << v1 << '\n';
- std::cout << v2 << ' ' << v3 << '\n';
- std::cout << v4 << ' ' << v5 << '\n';
- std::cout << v6 << '\n';
+ // print the conversion results
+ std::cout << v1 << '\n';
+ std::cout << v2 << ' ' << v3 << '\n';
+ std::cout << v4 << ' ' << v5 << '\n';
+ std::cout << v6 << '\n';
- for (auto i : v7)
- {
- std::cout << i << ' ';
- }
- std::cout << "\n\n";
+ for (auto i : v7) {
+ std::cout << i << ' ';
+ }
+ std::cout << "\n\n";
- for (auto i : v8)
- {
- std::cout << i.first << ": " << i.second << '\n';
- }
+ for (auto i : v8) {
+ std::cout << i.first << ": " << i.second << '\n';
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/insert.cpp b/nlohmann_json/docs/mkdocs/docs/examples/insert.cpp
index 4ee60987..8c3c3d7b 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/insert.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/insert.cpp
@@ -3,15 +3,14 @@
using json = nlohmann::json;
-int main()
-{
- // create a JSON array
- json v = {1, 2, 3, 4};
+int main() {
+ // create a JSON array
+ json v = {1, 2, 3, 4};
- // insert number 10 before number 3
- auto new_pos = v.insert(v.begin() + 2, 10);
+ // insert number 10 before number 3
+ auto new_pos = v.insert(v.begin() + 2, 10);
- // output new array and result of insert call
- std::cout << *new_pos << '\n';
- std::cout << v << '\n';
+ // output new array and result of insert call
+ std::cout << *new_pos << '\n';
+ std::cout << v << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/insert__count.cpp b/nlohmann_json/docs/mkdocs/docs/examples/insert__count.cpp
index ce33b93e..d5986150 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/insert__count.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/insert__count.cpp
@@ -3,15 +3,14 @@
using json = nlohmann::json;
-int main()
-{
- // create a JSON array
- json v = {1, 2, 3, 4};
+int main() {
+ // create a JSON array
+ json v = {1, 2, 3, 4};
- // insert number 7 copies of number 7 before number 3
- auto new_pos = v.insert(v.begin() + 2, 7, 7);
+ // insert number 7 copies of number 7 before number 3
+ auto new_pos = v.insert(v.begin() + 2, 7, 7);
- // output new array and result of insert call
- std::cout << *new_pos << '\n';
- std::cout << v << '\n';
+ // output new array and result of insert call
+ std::cout << *new_pos << '\n';
+ std::cout << v << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/insert__ilist.cpp b/nlohmann_json/docs/mkdocs/docs/examples/insert__ilist.cpp
index a20766a1..820d44c4 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/insert__ilist.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/insert__ilist.cpp
@@ -3,15 +3,14 @@
using json = nlohmann::json;
-int main()
-{
- // create a JSON array
- json v = {1, 2, 3, 4};
+int main() {
+ // create a JSON array
+ json v = {1, 2, 3, 4};
- // insert range from v2 before the end of array v
- auto new_pos = v.insert(v.end(), {7, 8, 9});
+ // insert range from v2 before the end of array v
+ auto new_pos = v.insert(v.end(), {7, 8, 9});
- // output new array and result of insert call
- std::cout << *new_pos << '\n';
- std::cout << v << '\n';
+ // output new array and result of insert call
+ std::cout << *new_pos << '\n';
+ std::cout << v << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/insert__range.cpp b/nlohmann_json/docs/mkdocs/docs/examples/insert__range.cpp
index 92fe63b0..6aa8754d 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/insert__range.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/insert__range.cpp
@@ -3,18 +3,17 @@
using json = nlohmann::json;
-int main()
-{
- // create a JSON array
- json v = {1, 2, 3, 4};
+int main() {
+ // create a JSON array
+ json v = {1, 2, 3, 4};
- // create a JSON array to copy values from
- json v2 = {"one", "two", "three", "four"};
+ // create a JSON array to copy values from
+ json v2 = {"one", "two", "three", "four"};
- // insert range from v2 before the end of array v
- auto new_pos = v.insert(v.end(), v2.begin(), v2.end());
+ // insert range from v2 before the end of array v
+ auto new_pos = v.insert(v.end(), v2.begin(), v2.end());
- // output new array and result of insert call
- std::cout << *new_pos << '\n';
- std::cout << v << '\n';
+ // output new array and result of insert call
+ std::cout << *new_pos << '\n';
+ std::cout << v << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/insert__range_object.cpp b/nlohmann_json/docs/mkdocs/docs/examples/insert__range_object.cpp
index 97373d3b..cb65c111 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/insert__range_object.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/insert__range_object.cpp
@@ -3,19 +3,18 @@
using json = nlohmann::json;
-int main()
-{
- // create two JSON objects
- json j1 = {{"one", "eins"}, {"two", "zwei"}};
- json j2 = {{"eleven", "elf"}, {"seventeen", "siebzehn"}};
+int main() {
+ // create two JSON objects
+ json j1 = {{"one", "eins"}, {"two", "zwei"}};
+ json j2 = {{"eleven", "elf"}, {"seventeen", "siebzehn"}};
- // output objects
- std::cout << j1 << '\n';
- std::cout << j2 << '\n';
+ // output objects
+ std::cout << j1 << '\n';
+ std::cout << j2 << '\n';
- // insert range from j2 to j1
- j1.insert(j2.begin(), j2.end());
+ // insert range from j2 to j1
+ j1.insert(j2.begin(), j2.end());
- // output result of insert call
- std::cout << j1 << '\n';
+ // output result of insert call
+ std::cout << j1 << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/invalid_iterator.cpp b/nlohmann_json/docs/mkdocs/docs/examples/invalid_iterator.cpp
index ecde12e6..8af49932 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/invalid_iterator.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/invalid_iterator.cpp
@@ -3,19 +3,15 @@
using json = nlohmann::json;
-int main()
-{
- try
- {
- // calling iterator::key() on non-object iterator
- json j = "string";
- json::iterator it = j.begin();
- auto k = it.key();
- }
- catch (const json::invalid_iterator& e)
- {
- // output exception information
- std::cout << "message: " << e.what() << '\n'
- << "exception id: " << e.id << std::endl;
- }
+int main() {
+ try {
+ // calling iterator::key() on non-object iterator
+ json j = "string";
+ json::iterator it = j.begin();
+ auto k = it.key();
+ } catch (const json::invalid_iterator &e) {
+ // output exception information
+ std::cout << "message: " << e.what() << '\n'
+ << "exception id: " << e.id << std::endl;
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/is_array.cpp b/nlohmann_json/docs/mkdocs/docs/examples/is_array.cpp
index 8ecc4503..702321b1 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/is_array.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/is_array.cpp
@@ -3,28 +3,27 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_null;
- json j_boolean = true;
- json j_number_integer = 17;
- json j_number_unsigned_integer = 12345678987654321u;
- json j_number_float = 23.42;
- json j_object = {{"one", 1}, {"two", 2}};
- json j_array = {1, 2, 4, 8, 16};
- json j_string = "Hello, world";
- json j_binary = json::binary({1, 2, 3});
+int main() {
+ // create JSON values
+ json j_null;
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_unsigned_integer = 12345678987654321u;
+ json j_number_float = 23.42;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = {1, 2, 4, 8, 16};
+ json j_string = "Hello, world";
+ json j_binary = json::binary({1, 2, 3});
- // call is_array()
- std::cout << std::boolalpha;
- std::cout << j_null.is_array() << '\n';
- std::cout << j_boolean.is_array() << '\n';
- std::cout << j_number_integer.is_array() << '\n';
- std::cout << j_number_unsigned_integer.is_array() << '\n';
- std::cout << j_number_float.is_array() << '\n';
- std::cout << j_object.is_array() << '\n';
- std::cout << j_array.is_array() << '\n';
- std::cout << j_string.is_array() << '\n';
- std::cout << j_binary.is_array() << '\n';
+ // call is_array()
+ std::cout << std::boolalpha;
+ std::cout << j_null.is_array() << '\n';
+ std::cout << j_boolean.is_array() << '\n';
+ std::cout << j_number_integer.is_array() << '\n';
+ std::cout << j_number_unsigned_integer.is_array() << '\n';
+ std::cout << j_number_float.is_array() << '\n';
+ std::cout << j_object.is_array() << '\n';
+ std::cout << j_array.is_array() << '\n';
+ std::cout << j_string.is_array() << '\n';
+ std::cout << j_binary.is_array() << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/is_binary.cpp b/nlohmann_json/docs/mkdocs/docs/examples/is_binary.cpp
index d7f049ec..dc90c81d 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/is_binary.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/is_binary.cpp
@@ -3,28 +3,27 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_null;
- json j_boolean = true;
- json j_number_integer = 17;
- json j_number_unsigned_integer = 12345678987654321u;
- json j_number_float = 23.42;
- json j_object = {{"one", 1}, {"two", 2}};
- json j_array = {1, 2, 4, 8, 16};
- json j_string = "Hello, world";
- json j_binary = json::binary({1, 2, 3});
+int main() {
+ // create JSON values
+ json j_null;
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_unsigned_integer = 12345678987654321u;
+ json j_number_float = 23.42;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = {1, 2, 4, 8, 16};
+ json j_string = "Hello, world";
+ json j_binary = json::binary({1, 2, 3});
- // call is_binary()
- std::cout << std::boolalpha;
- std::cout << j_null.is_binary() << '\n';
- std::cout << j_boolean.is_binary() << '\n';
- std::cout << j_number_integer.is_binary() << '\n';
- std::cout << j_number_unsigned_integer.is_binary() << '\n';
- std::cout << j_number_float.is_binary() << '\n';
- std::cout << j_object.is_binary() << '\n';
- std::cout << j_array.is_binary() << '\n';
- std::cout << j_string.is_binary() << '\n';
- std::cout << j_binary.is_binary() << '\n';
+ // call is_binary()
+ std::cout << std::boolalpha;
+ std::cout << j_null.is_binary() << '\n';
+ std::cout << j_boolean.is_binary() << '\n';
+ std::cout << j_number_integer.is_binary() << '\n';
+ std::cout << j_number_unsigned_integer.is_binary() << '\n';
+ std::cout << j_number_float.is_binary() << '\n';
+ std::cout << j_object.is_binary() << '\n';
+ std::cout << j_array.is_binary() << '\n';
+ std::cout << j_string.is_binary() << '\n';
+ std::cout << j_binary.is_binary() << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/is_boolean.cpp b/nlohmann_json/docs/mkdocs/docs/examples/is_boolean.cpp
index 0b798195..129eacdc 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/is_boolean.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/is_boolean.cpp
@@ -3,28 +3,27 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_null;
- json j_boolean = true;
- json j_number_integer = 17;
- json j_number_unsigned_integer = 12345678987654321u;
- json j_number_float = 23.42;
- json j_object = {{"one", 1}, {"two", 2}};
- json j_array = {1, 2, 4, 8, 16};
- json j_string = "Hello, world";
- json j_binary = json::binary({1, 2, 3});
+int main() {
+ // create JSON values
+ json j_null;
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_unsigned_integer = 12345678987654321u;
+ json j_number_float = 23.42;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = {1, 2, 4, 8, 16};
+ json j_string = "Hello, world";
+ json j_binary = json::binary({1, 2, 3});
- // call is_boolean()
- std::cout << std::boolalpha;
- std::cout << j_null.is_boolean() << '\n';
- std::cout << j_boolean.is_boolean() << '\n';
- std::cout << j_number_integer.is_boolean() << '\n';
- std::cout << j_number_unsigned_integer.is_boolean() << '\n';
- std::cout << j_number_float.is_boolean() << '\n';
- std::cout << j_object.is_boolean() << '\n';
- std::cout << j_array.is_boolean() << '\n';
- std::cout << j_string.is_boolean() << '\n';
- std::cout << j_binary.is_boolean() << '\n';
+ // call is_boolean()
+ std::cout << std::boolalpha;
+ std::cout << j_null.is_boolean() << '\n';
+ std::cout << j_boolean.is_boolean() << '\n';
+ std::cout << j_number_integer.is_boolean() << '\n';
+ std::cout << j_number_unsigned_integer.is_boolean() << '\n';
+ std::cout << j_number_float.is_boolean() << '\n';
+ std::cout << j_object.is_boolean() << '\n';
+ std::cout << j_array.is_boolean() << '\n';
+ std::cout << j_string.is_boolean() << '\n';
+ std::cout << j_binary.is_boolean() << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/is_discarded.cpp b/nlohmann_json/docs/mkdocs/docs/examples/is_discarded.cpp
index 09016655..58356688 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/is_discarded.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/is_discarded.cpp
@@ -3,28 +3,27 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_null;
- json j_boolean = true;
- json j_number_integer = 17;
- json j_number_unsigned_integer = 12345678987654321u;
- json j_number_float = 23.42;
- json j_object = {{"one", 1}, {"two", 2}};
- json j_array = {1, 2, 4, 8, 16};
- json j_string = "Hello, world";
- json j_binary = json::binary({1, 2, 3});
+int main() {
+ // create JSON values
+ json j_null;
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_unsigned_integer = 12345678987654321u;
+ json j_number_float = 23.42;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = {1, 2, 4, 8, 16};
+ json j_string = "Hello, world";
+ json j_binary = json::binary({1, 2, 3});
- // call is_discarded()
- std::cout << std::boolalpha;
- std::cout << j_null.is_discarded() << '\n';
- std::cout << j_boolean.is_discarded() << '\n';
- std::cout << j_number_integer.is_discarded() << '\n';
- std::cout << j_number_unsigned_integer.is_discarded() << '\n';
- std::cout << j_number_float.is_discarded() << '\n';
- std::cout << j_object.is_discarded() << '\n';
- std::cout << j_array.is_discarded() << '\n';
- std::cout << j_string.is_discarded() << '\n';
- std::cout << j_binary.is_discarded() << '\n';
+ // call is_discarded()
+ std::cout << std::boolalpha;
+ std::cout << j_null.is_discarded() << '\n';
+ std::cout << j_boolean.is_discarded() << '\n';
+ std::cout << j_number_integer.is_discarded() << '\n';
+ std::cout << j_number_unsigned_integer.is_discarded() << '\n';
+ std::cout << j_number_float.is_discarded() << '\n';
+ std::cout << j_object.is_discarded() << '\n';
+ std::cout << j_array.is_discarded() << '\n';
+ std::cout << j_string.is_discarded() << '\n';
+ std::cout << j_binary.is_discarded() << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/is_null.cpp b/nlohmann_json/docs/mkdocs/docs/examples/is_null.cpp
index 8a843326..0b1f49aa 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/is_null.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/is_null.cpp
@@ -3,28 +3,27 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_null;
- json j_boolean = true;
- json j_number_integer = 17;
- json j_number_unsigned_integer = 12345678987654321u;
- json j_number_float = 23.42;
- json j_object = {{"one", 1}, {"two", 2}};
- json j_array = {1, 2, 4, 8, 16};
- json j_string = "Hello, world";
- json j_binary = json::binary({1, 2, 3});
+int main() {
+ // create JSON values
+ json j_null;
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_unsigned_integer = 12345678987654321u;
+ json j_number_float = 23.42;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = {1, 2, 4, 8, 16};
+ json j_string = "Hello, world";
+ json j_binary = json::binary({1, 2, 3});
- // call is_null()
- std::cout << std::boolalpha;
- std::cout << j_null.is_null() << '\n';
- std::cout << j_boolean.is_null() << '\n';
- std::cout << j_number_integer.is_null() << '\n';
- std::cout << j_number_unsigned_integer.is_null() << '\n';
- std::cout << j_number_float.is_null() << '\n';
- std::cout << j_object.is_null() << '\n';
- std::cout << j_array.is_null() << '\n';
- std::cout << j_string.is_null() << '\n';
- std::cout << j_binary.is_null() << '\n';
+ // call is_null()
+ std::cout << std::boolalpha;
+ std::cout << j_null.is_null() << '\n';
+ std::cout << j_boolean.is_null() << '\n';
+ std::cout << j_number_integer.is_null() << '\n';
+ std::cout << j_number_unsigned_integer.is_null() << '\n';
+ std::cout << j_number_float.is_null() << '\n';
+ std::cout << j_object.is_null() << '\n';
+ std::cout << j_array.is_null() << '\n';
+ std::cout << j_string.is_null() << '\n';
+ std::cout << j_binary.is_null() << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/is_number.cpp b/nlohmann_json/docs/mkdocs/docs/examples/is_number.cpp
index f107a048..d7c2a754 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/is_number.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/is_number.cpp
@@ -3,28 +3,27 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_null;
- json j_boolean = true;
- json j_number_integer = 17;
- json j_number_unsigned_integer = 12345678987654321u;
- json j_number_float = 23.42;
- json j_object = {{"one", 1}, {"two", 2}};
- json j_array = {1, 2, 4, 8, 16};
- json j_string = "Hello, world";
- json j_binary = json::binary({1, 2, 3});
+int main() {
+ // create JSON values
+ json j_null;
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_unsigned_integer = 12345678987654321u;
+ json j_number_float = 23.42;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = {1, 2, 4, 8, 16};
+ json j_string = "Hello, world";
+ json j_binary = json::binary({1, 2, 3});
- // call is_number()
- std::cout << std::boolalpha;
- std::cout << j_null.is_number() << '\n';
- std::cout << j_boolean.is_number() << '\n';
- std::cout << j_number_integer.is_number() << '\n';
- std::cout << j_number_unsigned_integer.is_number() << '\n';
- std::cout << j_number_float.is_number() << '\n';
- std::cout << j_object.is_number() << '\n';
- std::cout << j_array.is_number() << '\n';
- std::cout << j_string.is_number() << '\n';
- std::cout << j_binary.is_number() << '\n';
+ // call is_number()
+ std::cout << std::boolalpha;
+ std::cout << j_null.is_number() << '\n';
+ std::cout << j_boolean.is_number() << '\n';
+ std::cout << j_number_integer.is_number() << '\n';
+ std::cout << j_number_unsigned_integer.is_number() << '\n';
+ std::cout << j_number_float.is_number() << '\n';
+ std::cout << j_object.is_number() << '\n';
+ std::cout << j_array.is_number() << '\n';
+ std::cout << j_string.is_number() << '\n';
+ std::cout << j_binary.is_number() << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/is_number_float.cpp b/nlohmann_json/docs/mkdocs/docs/examples/is_number_float.cpp
index bba2b446..95eded6d 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/is_number_float.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/is_number_float.cpp
@@ -3,28 +3,27 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_null;
- json j_boolean = true;
- json j_number_integer = 17;
- json j_number_unsigned_integer = 12345678987654321u;
- json j_number_float = 23.42;
- json j_object = {{"one", 1}, {"two", 2}};
- json j_array = {1, 2, 4, 8, 16};
- json j_string = "Hello, world";
- json j_binary = json::binary({1, 2, 3});
+int main() {
+ // create JSON values
+ json j_null;
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_unsigned_integer = 12345678987654321u;
+ json j_number_float = 23.42;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = {1, 2, 4, 8, 16};
+ json j_string = "Hello, world";
+ json j_binary = json::binary({1, 2, 3});
- // call is_number_float()
- std::cout << std::boolalpha;
- std::cout << j_null.is_number_float() << '\n';
- std::cout << j_boolean.is_number_float() << '\n';
- std::cout << j_number_integer.is_number_float() << '\n';
- std::cout << j_number_unsigned_integer.is_number_float() << '\n';
- std::cout << j_number_float.is_number_float() << '\n';
- std::cout << j_object.is_number_float() << '\n';
- std::cout << j_array.is_number_float() << '\n';
- std::cout << j_string.is_number_float() << '\n';
- std::cout << j_binary.is_number_float() << '\n';
+ // call is_number_float()
+ std::cout << std::boolalpha;
+ std::cout << j_null.is_number_float() << '\n';
+ std::cout << j_boolean.is_number_float() << '\n';
+ std::cout << j_number_integer.is_number_float() << '\n';
+ std::cout << j_number_unsigned_integer.is_number_float() << '\n';
+ std::cout << j_number_float.is_number_float() << '\n';
+ std::cout << j_object.is_number_float() << '\n';
+ std::cout << j_array.is_number_float() << '\n';
+ std::cout << j_string.is_number_float() << '\n';
+ std::cout << j_binary.is_number_float() << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/is_number_integer.cpp b/nlohmann_json/docs/mkdocs/docs/examples/is_number_integer.cpp
index 8d6a5ae1..d9e72931 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/is_number_integer.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/is_number_integer.cpp
@@ -3,28 +3,27 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_null;
- json j_boolean = true;
- json j_number_integer = 17;
- json j_number_unsigned_integer = 12345678987654321u;
- json j_number_float = 23.42;
- json j_object = {{"one", 1}, {"two", 2}};
- json j_array = {1, 2, 4, 8, 16};
- json j_string = "Hello, world";
- json j_binary = json::binary({1, 2, 3});
+int main() {
+ // create JSON values
+ json j_null;
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_unsigned_integer = 12345678987654321u;
+ json j_number_float = 23.42;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = {1, 2, 4, 8, 16};
+ json j_string = "Hello, world";
+ json j_binary = json::binary({1, 2, 3});
- // call is_number_integer()
- std::cout << std::boolalpha;
- std::cout << j_null.is_number_integer() << '\n';
- std::cout << j_boolean.is_number_integer() << '\n';
- std::cout << j_number_integer.is_number_integer() << '\n';
- std::cout << j_number_unsigned_integer.is_number_integer() << '\n';
- std::cout << j_number_float.is_number_integer() << '\n';
- std::cout << j_object.is_number_integer() << '\n';
- std::cout << j_array.is_number_integer() << '\n';
- std::cout << j_string.is_number_integer() << '\n';
- std::cout << j_binary.is_number_integer() << '\n';
+ // call is_number_integer()
+ std::cout << std::boolalpha;
+ std::cout << j_null.is_number_integer() << '\n';
+ std::cout << j_boolean.is_number_integer() << '\n';
+ std::cout << j_number_integer.is_number_integer() << '\n';
+ std::cout << j_number_unsigned_integer.is_number_integer() << '\n';
+ std::cout << j_number_float.is_number_integer() << '\n';
+ std::cout << j_object.is_number_integer() << '\n';
+ std::cout << j_array.is_number_integer() << '\n';
+ std::cout << j_string.is_number_integer() << '\n';
+ std::cout << j_binary.is_number_integer() << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/is_number_unsigned.cpp b/nlohmann_json/docs/mkdocs/docs/examples/is_number_unsigned.cpp
index b52ac6b3..dda4bab5 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/is_number_unsigned.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/is_number_unsigned.cpp
@@ -3,28 +3,27 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_null;
- json j_boolean = true;
- json j_number_integer = 17;
- json j_number_unsigned_integer = 12345678987654321u;
- json j_number_float = 23.42;
- json j_object = {{"one", 1}, {"two", 2}};
- json j_array = {1, 2, 4, 8, 16};
- json j_string = "Hello, world";
- json j_binary = json::binary({1, 2, 3});
+int main() {
+ // create JSON values
+ json j_null;
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_unsigned_integer = 12345678987654321u;
+ json j_number_float = 23.42;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = {1, 2, 4, 8, 16};
+ json j_string = "Hello, world";
+ json j_binary = json::binary({1, 2, 3});
- // call is_number_unsigned()
- std::cout << std::boolalpha;
- std::cout << j_null.is_number_unsigned() << '\n';
- std::cout << j_boolean.is_number_unsigned() << '\n';
- std::cout << j_number_integer.is_number_unsigned() << '\n';
- std::cout << j_number_unsigned_integer.is_number_unsigned() << '\n';
- std::cout << j_number_float.is_number_unsigned() << '\n';
- std::cout << j_object.is_number_unsigned() << '\n';
- std::cout << j_array.is_number_unsigned() << '\n';
- std::cout << j_string.is_number_unsigned() << '\n';
- std::cout << j_binary.is_number_unsigned() << '\n';
+ // call is_number_unsigned()
+ std::cout << std::boolalpha;
+ std::cout << j_null.is_number_unsigned() << '\n';
+ std::cout << j_boolean.is_number_unsigned() << '\n';
+ std::cout << j_number_integer.is_number_unsigned() << '\n';
+ std::cout << j_number_unsigned_integer.is_number_unsigned() << '\n';
+ std::cout << j_number_float.is_number_unsigned() << '\n';
+ std::cout << j_object.is_number_unsigned() << '\n';
+ std::cout << j_array.is_number_unsigned() << '\n';
+ std::cout << j_string.is_number_unsigned() << '\n';
+ std::cout << j_binary.is_number_unsigned() << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/is_object.cpp b/nlohmann_json/docs/mkdocs/docs/examples/is_object.cpp
index a0216fd2..77b2d2b6 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/is_object.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/is_object.cpp
@@ -3,28 +3,27 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_null;
- json j_boolean = true;
- json j_number_integer = 17;
- json j_number_float = 23.42;
- json j_number_unsigned_integer = 12345678987654321u;
- json j_object = {{"one", 1}, {"two", 2}};
- json j_array = {1, 2, 4, 8, 16};
- json j_string = "Hello, world";
- json j_binary = json::binary({1, 2, 3});
+int main() {
+ // create JSON values
+ json j_null;
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_float = 23.42;
+ json j_number_unsigned_integer = 12345678987654321u;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = {1, 2, 4, 8, 16};
+ json j_string = "Hello, world";
+ json j_binary = json::binary({1, 2, 3});
- // call is_object()
- std::cout << std::boolalpha;
- std::cout << j_null.is_object() << '\n';
- std::cout << j_boolean.is_object() << '\n';
- std::cout << j_number_integer.is_object() << '\n';
- std::cout << j_number_unsigned_integer.is_object() << '\n';
- std::cout << j_number_float.is_object() << '\n';
- std::cout << j_object.is_object() << '\n';
- std::cout << j_array.is_object() << '\n';
- std::cout << j_string.is_object() << '\n';
- std::cout << j_binary.is_object() << '\n';
+ // call is_object()
+ std::cout << std::boolalpha;
+ std::cout << j_null.is_object() << '\n';
+ std::cout << j_boolean.is_object() << '\n';
+ std::cout << j_number_integer.is_object() << '\n';
+ std::cout << j_number_unsigned_integer.is_object() << '\n';
+ std::cout << j_number_float.is_object() << '\n';
+ std::cout << j_object.is_object() << '\n';
+ std::cout << j_array.is_object() << '\n';
+ std::cout << j_string.is_object() << '\n';
+ std::cout << j_binary.is_object() << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/is_primitive.cpp b/nlohmann_json/docs/mkdocs/docs/examples/is_primitive.cpp
index af3968e8..85fc797a 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/is_primitive.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/is_primitive.cpp
@@ -3,28 +3,27 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_null;
- json j_boolean = true;
- json j_number_integer = 17;
- json j_number_float = 23.42;
- json j_number_unsigned_integer = 12345678987654321u;
- json j_object = {{"one", 1}, {"two", 2}};
- json j_array = {1, 2, 4, 8, 16};
- json j_string = "Hello, world";
- json j_binary = json::binary({1, 2, 3});
+int main() {
+ // create JSON values
+ json j_null;
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_float = 23.42;
+ json j_number_unsigned_integer = 12345678987654321u;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = {1, 2, 4, 8, 16};
+ json j_string = "Hello, world";
+ json j_binary = json::binary({1, 2, 3});
- // call is_primitive()
- std::cout << std::boolalpha;
- std::cout << j_null.is_primitive() << '\n';
- std::cout << j_boolean.is_primitive() << '\n';
- std::cout << j_number_integer.is_primitive() << '\n';
- std::cout << j_number_unsigned_integer.is_primitive() << '\n';
- std::cout << j_number_float.is_primitive() << '\n';
- std::cout << j_object.is_primitive() << '\n';
- std::cout << j_array.is_primitive() << '\n';
- std::cout << j_string.is_primitive() << '\n';
- std::cout << j_binary.is_primitive() << '\n';
+ // call is_primitive()
+ std::cout << std::boolalpha;
+ std::cout << j_null.is_primitive() << '\n';
+ std::cout << j_boolean.is_primitive() << '\n';
+ std::cout << j_number_integer.is_primitive() << '\n';
+ std::cout << j_number_unsigned_integer.is_primitive() << '\n';
+ std::cout << j_number_float.is_primitive() << '\n';
+ std::cout << j_object.is_primitive() << '\n';
+ std::cout << j_array.is_primitive() << '\n';
+ std::cout << j_string.is_primitive() << '\n';
+ std::cout << j_binary.is_primitive() << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/is_string.cpp b/nlohmann_json/docs/mkdocs/docs/examples/is_string.cpp
index c89f550b..f3107527 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/is_string.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/is_string.cpp
@@ -3,28 +3,27 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_null;
- json j_boolean = true;
- json j_number_integer = 17;
- json j_number_float = 23.42;
- json j_number_unsigned_integer = 12345678987654321u;
- json j_object = {{"one", 1}, {"two", 2}};
- json j_array = {1, 2, 4, 8, 16};
- json j_string = "Hello, world";
- json j_binary = json::binary({1, 2, 3});
+int main() {
+ // create JSON values
+ json j_null;
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_float = 23.42;
+ json j_number_unsigned_integer = 12345678987654321u;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = {1, 2, 4, 8, 16};
+ json j_string = "Hello, world";
+ json j_binary = json::binary({1, 2, 3});
- // call is_string()
- std::cout << std::boolalpha;
- std::cout << j_null.is_string() << '\n';
- std::cout << j_boolean.is_string() << '\n';
- std::cout << j_number_integer.is_string() << '\n';
- std::cout << j_number_unsigned_integer.is_string() << '\n';
- std::cout << j_number_float.is_string() << '\n';
- std::cout << j_object.is_string() << '\n';
- std::cout << j_array.is_string() << '\n';
- std::cout << j_string.is_string() << '\n';
- std::cout << j_binary.is_string() << '\n';
+ // call is_string()
+ std::cout << std::boolalpha;
+ std::cout << j_null.is_string() << '\n';
+ std::cout << j_boolean.is_string() << '\n';
+ std::cout << j_number_integer.is_string() << '\n';
+ std::cout << j_number_unsigned_integer.is_string() << '\n';
+ std::cout << j_number_float.is_string() << '\n';
+ std::cout << j_object.is_string() << '\n';
+ std::cout << j_array.is_string() << '\n';
+ std::cout << j_string.is_string() << '\n';
+ std::cout << j_binary.is_string() << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/is_structured.cpp b/nlohmann_json/docs/mkdocs/docs/examples/is_structured.cpp
index 41947b1b..565d04e0 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/is_structured.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/is_structured.cpp
@@ -3,28 +3,27 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_null;
- json j_boolean = true;
- json j_number_integer = 17;
- json j_number_float = 23.42;
- json j_number_unsigned_integer = 12345678987654321u;
- json j_object = {{"one", 1}, {"two", 2}};
- json j_array = {1, 2, 4, 8, 16};
- json j_string = "Hello, world";
- json j_binary = json::binary({1, 2, 3});
+int main() {
+ // create JSON values
+ json j_null;
+ json j_boolean = true;
+ json j_number_integer = 17;
+ json j_number_float = 23.42;
+ json j_number_unsigned_integer = 12345678987654321u;
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = {1, 2, 4, 8, 16};
+ json j_string = "Hello, world";
+ json j_binary = json::binary({1, 2, 3});
- // call is_structured()
- std::cout << std::boolalpha;
- std::cout << j_null.is_structured() << '\n';
- std::cout << j_boolean.is_structured() << '\n';
- std::cout << j_number_integer.is_structured() << '\n';
- std::cout << j_number_unsigned_integer.is_structured() << '\n';
- std::cout << j_number_float.is_structured() << '\n';
- std::cout << j_object.is_structured() << '\n';
- std::cout << j_array.is_structured() << '\n';
- std::cout << j_string.is_structured() << '\n';
- std::cout << j_binary.is_structured() << '\n';
+ // call is_structured()
+ std::cout << std::boolalpha;
+ std::cout << j_null.is_structured() << '\n';
+ std::cout << j_boolean.is_structured() << '\n';
+ std::cout << j_number_integer.is_structured() << '\n';
+ std::cout << j_number_unsigned_integer.is_structured() << '\n';
+ std::cout << j_number_float.is_structured() << '\n';
+ std::cout << j_object.is_structured() << '\n';
+ std::cout << j_array.is_structured() << '\n';
+ std::cout << j_string.is_structured() << '\n';
+ std::cout << j_binary.is_structured() << '\n';
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/items.cpp b/nlohmann_json/docs/mkdocs/docs/examples/items.cpp
index 9cd2b51b..bcee4d1c 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/items.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/items.cpp
@@ -3,21 +3,18 @@
using json = nlohmann::json;
-int main()
-{
- // create JSON values
- json j_object = {{"one", 1}, {"two", 2}};
- json j_array = {1, 2, 4, 8, 16};
+int main() {
+ // create JSON values
+ json j_object = {{"one", 1}, {"two", 2}};
+ json j_array = {1, 2, 4, 8, 16};
- // example for an object
- for (auto& x : j_object.items())
- {
- std::cout << "key: " << x.key() << ", value: " << x.value() << '\n';
- }
+ // example for an object
+ for (auto &x : j_object.items()) {
+ std::cout << "key: " << x.key() << ", value: " << x.value() << '\n';
+ }
- // example for an array
- for (auto& x : j_array.items())
- {
- std::cout << "key: " << x.key() << ", value: " << x.value() << '\n';
- }
+ // example for an array
+ for (auto &x : j_array.items()) {
+ std::cout << "key: " << x.key() << ", value: " << x.value() << '\n';
+ }
}
diff --git a/nlohmann_json/docs/mkdocs/docs/examples/json_base_class_t.cpp b/nlohmann_json/docs/mkdocs/docs/examples/json_base_class_t.cpp
index 3fb2d46a..8e37290d 100644
--- a/nlohmann_json/docs/mkdocs/docs/examples/json_base_class_t.cpp
+++ b/nlohmann_json/docs/mkdocs/docs/examples/json_base_class_t.cpp
@@ -1,88 +1,71 @@
#include
#include
-class visitor_adaptor_with_metadata
-{
- public:
- template