mirror of
https://github.com/nlohmann/json.git
synced 2026-02-17 09:03:58 +00:00
Compare commits
48 Commits
issue3989
...
issue4552-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ab98c39c3 | ||
|
|
493d1e4467 | ||
|
|
b167096e82 | ||
|
|
e9876d9e46 | ||
|
|
15ff3701a1 | ||
|
|
3cd50255a8 | ||
|
|
a6a06b76e7 | ||
|
|
663058e7d1 | ||
|
|
7d2a83b735 | ||
|
|
a2d828c204 | ||
|
|
a27a5b5442 | ||
|
|
9f73bc1b37 | ||
|
|
3db5cc4ba8 | ||
|
|
af4ad7915c | ||
|
|
58f5f25968 | ||
|
|
733c59588d | ||
|
|
1a76a2c514 | ||
|
|
3665dabb00 | ||
|
|
851584e609 | ||
|
|
6cb099e30e | ||
|
|
4d67e127aa | ||
|
|
094bd2651b | ||
|
|
30cd44df95 | ||
|
|
5362012fdd | ||
|
|
861ec9c3c6 | ||
|
|
f4910b20ce | ||
|
|
f2a4ac0673 | ||
|
|
8e1b800017 | ||
|
|
677e19e39c | ||
|
|
9e23b5d61e | ||
|
|
eb142e33c0 | ||
|
|
1c8e26dcb4 | ||
|
|
b6b8378c8c | ||
|
|
58949c0ad5 | ||
|
|
7cfbe321be | ||
|
|
4003f8da02 | ||
|
|
6a2ae22a5a | ||
|
|
620034ecec | ||
|
|
e6cafa573a | ||
|
|
e0a17f8475 | ||
|
|
20ae363a71 | ||
|
|
589641b175 | ||
|
|
f385fe28f2 | ||
|
|
981a4c39f4 | ||
|
|
dd81f878f7 | ||
|
|
549c79ba7e | ||
|
|
9f60e85557 | ||
|
|
a006a7a48b |
@@ -53,6 +53,7 @@ Checks: '*,
|
||||
-modernize-type-traits,
|
||||
-modernize-use-constraints,
|
||||
-modernize-use-designated-initializers,
|
||||
-modernize-use-integer-sign-comparison,
|
||||
-modernize-use-nodiscard,
|
||||
-modernize-use-ranges,
|
||||
-modernize-use-std-numbers,
|
||||
|
||||
21
.github/dependabot.yml
vendored
Normal file
21
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: github-actions
|
||||
directory: /
|
||||
schedule:
|
||||
interval: daily
|
||||
|
||||
- package-ecosystem: pip
|
||||
directory: /docs/mkdocs
|
||||
schedule:
|
||||
interval: daily
|
||||
|
||||
- package-ecosystem: pip
|
||||
directory: /tools/serve_header
|
||||
schedule:
|
||||
interval: daily
|
||||
|
||||
- package-ecosystem: pip
|
||||
directory: /cmake/requirements
|
||||
schedule:
|
||||
interval: daily
|
||||
19
.github/workflows/check_amalgamation.yml
vendored
19
.github/workflows/check_amalgamation.yml
vendored
@@ -3,18 +3,24 @@ name: "Check amalgamation"
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
permissions: read-all
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
save:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: Save PR number
|
||||
run: |
|
||||
mkdir -p ./pr
|
||||
echo ${{ github.event.number }} > ./pr/number
|
||||
echo ${{ github.event.pull_request.user.login }} > ./pr/author
|
||||
- uses: actions/upload-artifact@v4
|
||||
- uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
|
||||
with:
|
||||
name: pr
|
||||
path: pr/
|
||||
@@ -32,14 +38,19 @@ jobs:
|
||||
--formatted
|
||||
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: Checkout pull request
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: main
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
|
||||
- name: Checkout tools
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: tools
|
||||
ref: develop
|
||||
|
||||
11
.github/workflows/cifuzz.yml
vendored
11
.github/workflows/cifuzz.yml
vendored
@@ -8,22 +8,27 @@ jobs:
|
||||
Fuzzing:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: Build Fuzzers
|
||||
id: build
|
||||
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
|
||||
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@master
|
||||
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@v4
|
||||
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
|
||||
if: failure() && steps.build.outcome == 'success'
|
||||
with:
|
||||
name: artifacts
|
||||
|
||||
19
.github/workflows/codeql-analysis.yml
vendored
19
.github/workflows/codeql-analysis.yml
vendored
@@ -11,13 +11,13 @@ on:
|
||||
- cron: '0 19 * * 1'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
CodeQL-Build:
|
||||
|
||||
@@ -26,19 +26,24 @@ jobs:
|
||||
security-events: write
|
||||
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
uses: github/codeql-action/init@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
|
||||
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@v2
|
||||
uses: github/codeql-action/autobuild@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
uses: github/codeql-action/analyze@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
|
||||
|
||||
12
.github/workflows/comment_check_amalgamation.yml
vendored
12
.github/workflows/comment_check_amalgamation.yml
vendored
@@ -5,7 +5,8 @@ on:
|
||||
types:
|
||||
- completed
|
||||
|
||||
permissions: {}
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
comment:
|
||||
@@ -17,8 +18,13 @@ jobs:
|
||||
issues: read
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: 'Download artifact'
|
||||
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0
|
||||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||
with:
|
||||
script: |
|
||||
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
|
||||
@@ -40,7 +46,7 @@ jobs:
|
||||
- run: unzip pr.zip
|
||||
|
||||
- name: 'Comment on PR'
|
||||
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0
|
||||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
|
||||
27
.github/workflows/dependency-review.yml
vendored
Normal file
27
.github/workflows/dependency-review.yml
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
# Dependency Review Action
|
||||
#
|
||||
# This Action will scan dependency manifest files that change as part of a Pull Request,
|
||||
# surfacing known-vulnerable versions of the packages declared or updated in the PR.
|
||||
# Once installed, if the workflow run is marked as required,
|
||||
# PRs introducing known-vulnerable packages will be blocked from merging.
|
||||
#
|
||||
# Source repository: https://github.com/actions/dependency-review-action
|
||||
name: 'Dependency Review'
|
||||
on: [pull_request]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
dependency-review:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: 'Checkout Repository'
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: 'Dependency Review'
|
||||
uses: actions/dependency-review-action@3b139cfc5fae8b618d3eae3675e383bb1769c019 # v4.5.0
|
||||
10
.github/workflows/labeler.yml
vendored
10
.github/workflows/labeler.yml
vendored
@@ -4,7 +4,8 @@ on:
|
||||
pull_request_target:
|
||||
types: [opened, synchronize]
|
||||
|
||||
permissions: {}
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
label:
|
||||
@@ -15,6 +16,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: srvaroa/labeler@master
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: srvaroa/labeler@1b3cdb1af3e59155a08b9b2436d0d54feaff49e2 # master
|
||||
env:
|
||||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||
|
||||
18
.github/workflows/macos.yml
vendored
18
.github/workflows/macos.yml
vendored
@@ -9,13 +9,13 @@ on:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
# macos-11 is deprecated
|
||||
# macos-11:
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
# DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||
#
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
# - 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
|
||||
@@ -45,7 +45,7 @@ jobs:
|
||||
# DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||
#
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
# - 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
|
||||
@@ -62,7 +62,7 @@ jobs:
|
||||
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- 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
|
||||
@@ -79,7 +79,7 @@ jobs:
|
||||
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- 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
|
||||
@@ -96,7 +96,7 @@ jobs:
|
||||
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- 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
|
||||
@@ -111,7 +111,7 @@ jobs:
|
||||
standard: [11, 14, 17, 20, 23]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_TestStandards=${{ matrix.standard }}
|
||||
- name: Build
|
||||
|
||||
19
.github/workflows/publish_documentation.yml
vendored
19
.github/workflows/publish_documentation.yml
vendored
@@ -10,23 +10,28 @@ on:
|
||||
- docs/examples/**
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
# we don't want to have concurrent jobs, and we don't want to cancel running jobs to avoid broken publications
|
||||
concurrency:
|
||||
group: documentation
|
||||
cancel-in-progress: false
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
publish_documentation:
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
if: github.repository == 'nlohmann/json'
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: Install and update PlantUML
|
||||
run: sudo apt-get update ; sudo apt-get install -y plantuml
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
|
||||
- name: Install virtual environment
|
||||
run: make install_venv -C docs/mkdocs
|
||||
@@ -35,7 +40,7 @@ jobs:
|
||||
run: make build -C docs/mkdocs
|
||||
|
||||
- name: Deploy documentation
|
||||
uses: peaceiris/actions-gh-pages@v4
|
||||
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./docs/mkdocs/site
|
||||
|
||||
81
.github/workflows/scorecards.yml
vendored
Normal file
81
.github/workflows/scorecards.yml
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
# This workflow uses actions that are not certified by GitHub. They are provided
|
||||
# by a third-party and are governed by separate terms of service, privacy
|
||||
# policy, and support documentation.
|
||||
|
||||
name: Scorecard supply-chain security
|
||||
on:
|
||||
# For Branch-Protection check. Only the default branch is supported. See
|
||||
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
|
||||
branch_protection_rule:
|
||||
# To guarantee Maintained check is occasionally updated. See
|
||||
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
|
||||
schedule:
|
||||
- cron: '20 7 * * 2'
|
||||
push:
|
||||
branches: ["develop"]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
name: Scorecard analysis
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
# Needed to upload the results to code-scanning dashboard.
|
||||
security-events: write
|
||||
# Needed to publish results and get a badge (see publish_results below).
|
||||
id-token: write
|
||||
contents: read
|
||||
actions: read
|
||||
# To allow GraphQL ListCommits to work
|
||||
issues: read
|
||||
pull-requests: read
|
||||
# To detect SAST tools
|
||||
checks: read
|
||||
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
|
||||
# - you want to enable the Branch-Protection check on a *public* repository, or
|
||||
# - you are installing Scorecards on a *private* repository
|
||||
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
|
||||
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
|
||||
|
||||
# Public repositories:
|
||||
# - Publish results to OpenSSF REST API for easy access by consumers
|
||||
# - Allows the repository to include the Scorecard badge.
|
||||
# - See https://github.com/ossf/scorecard-action#publishing-results.
|
||||
# For private repositories:
|
||||
# - `publish_results` will always be set to `false`, regardless
|
||||
# of the value entered here.
|
||||
publish_results: true
|
||||
|
||||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
||||
# format to the repository Actions tab.
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
retention-days: 5
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
124
.github/workflows/ubuntu.yml
vendored
124
.github/workflows/ubuntu.yml
vendored
@@ -8,7 +8,7 @@ on:
|
||||
- release/*
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
@@ -23,9 +23,9 @@ jobs:
|
||||
steps:
|
||||
- name: Install git and unzip
|
||||
run: apt-get update ; apt-get install -y git unzip
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@v3.31.0
|
||||
uses: lukka/get-cmake@5979409e62bdf841487c5fb3c053149de97a86d3 # v3.31.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -33,9 +33,11 @@ jobs:
|
||||
|
||||
ci_test_gcc:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v2.4.0
|
||||
container: gcc:latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@5979409e62bdf841487c5fb3c053149de97a86d3 # v3.31.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -46,23 +48,45 @@ jobs:
|
||||
container: ghcr.io/nlohmann/json-ci:v2.4.0
|
||||
strategy:
|
||||
matrix:
|
||||
target: [ci_cppcheck, ci_test_valgrind, ci_test_amalgamation, ci_test_single_header, ci_single_binaries, ci_infer]
|
||||
target: [
|
||||
ci_test_valgrind, # needs Valgrind
|
||||
ci_test_amalgamation, # needs AStyle
|
||||
ci_infer, # needs Infer
|
||||
ci_single_binaries # needs iwyu
|
||||
]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
run: cmake --build build --target ${{ matrix.target }}
|
||||
|
||||
ci_test_single_header:
|
||||
runs-on: ubuntu-latest
|
||||
container: gcc:latest
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@5979409e62bdf841487c5fb3c053149de97a86d3 # v3.31.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
run: cmake --build build --target ci_test_single_header
|
||||
|
||||
ci_static_analysis_ubuntu:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
target: [ci_cpplint, ci_reproducible_tests, ci_non_git_tests, ci_offline_testdata]
|
||||
target: [ci_cppcheck, ci_cpplint, ci_reproducible_tests, ci_non_git_tests, ci_offline_testdata, ci_reuse_compliance]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@v3.31.0
|
||||
uses: lukka/get-cmake@5979409e62bdf841487c5fb3c053149de97a86d3 # v3.31.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -77,9 +101,9 @@ jobs:
|
||||
steps:
|
||||
- name: Install git, clang-tools, and unzip
|
||||
run: apt-get update ; apt-get install -y git clang-tools unzip
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@v3.31.0
|
||||
uses: lukka/get-cmake@5979409e62bdf841487c5fb3c053149de97a86d3 # v3.31.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -94,9 +118,9 @@ jobs:
|
||||
steps:
|
||||
- name: Install build-essential
|
||||
run: apt-get update ; apt-get install -y build-essential unzip wget git
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@v3.31.0
|
||||
uses: lukka/get-cmake@5979409e62bdf841487c5fb3c053149de97a86d3 # v3.31.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -104,11 +128,13 @@ jobs:
|
||||
|
||||
ci_test_coverage:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
checks: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Install dependencies and de_DE locale
|
||||
run: |
|
||||
sudo apt-get clean
|
||||
@@ -121,12 +147,12 @@ jobs:
|
||||
- name: Build
|
||||
run: cmake --build build --target ci_test_coverage
|
||||
- name: Archive coverage report
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
|
||||
with:
|
||||
name: code-coverage-report
|
||||
path: ${{ github.workspace }}/build/html
|
||||
- name: Publish report to Coveralls
|
||||
uses: coverallsapp/github-action@v2.3.4
|
||||
uses: coverallsapp/github-action@cfd0633edbd2411b532b808ba7a8b5e04f76d2c8 # v2.3.4
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
path-to-lcov: ${{ github.workspace }}/build/json.info.filtered.noexcept
|
||||
@@ -138,7 +164,7 @@ jobs:
|
||||
compiler: ['4.8', '4.9', '5', '6']
|
||||
container: ghcr.io/nlohmann/json-ci:v2.4.0
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Run CMake
|
||||
run: CXX=g++-${{ matrix.compiler }} cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -152,9 +178,9 @@ jobs:
|
||||
compiler: ['7', '8', '9', '10', '11', '12', '13', '14', 'latest']
|
||||
container: gcc:${{ matrix.compiler }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@v3.31.0
|
||||
uses: lukka/get-cmake@5979409e62bdf841487c5fb3c053149de97a86d3 # v3.31.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -169,9 +195,9 @@ jobs:
|
||||
steps:
|
||||
- name: Install unzip and git
|
||||
run: apt-get update ; apt-get install -y unzip git
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@v3.31.0
|
||||
uses: lukka/get-cmake@5979409e62bdf841487c5fb3c053149de97a86d3 # v3.31.2
|
||||
- name: Set env FORCE_STDCPPFS_FLAG for clang 7 / 8 / 9 / 10
|
||||
run: echo "JSON_FORCED_GLOBAL_COMPILE_OPTIONS=-DJSON_HAS_FILESYSTEM=0;-DJSON_HAS_EXPERIMENTAL_FILESYSTEM=0" >> "$GITHUB_ENV"
|
||||
if: ${{ matrix.compiler == '7' || matrix.compiler == '8' || matrix.compiler == '9' || matrix.compiler == '10' }}
|
||||
@@ -180,27 +206,16 @@ jobs:
|
||||
- name: Build
|
||||
run: cmake --build build --target ci_test_compiler_default
|
||||
|
||||
ci_test_compilers:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v2.4.0
|
||||
strategy:
|
||||
matrix:
|
||||
compiler: [g++-4.8]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
run: cmake --build build --target ci_test_compiler_${{ matrix.compiler }}
|
||||
|
||||
ci_test_standards_gcc:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v2.4.0
|
||||
container: gcc:latest
|
||||
strategy:
|
||||
matrix:
|
||||
standard: [11, 14, 17, 20, 23]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@5979409e62bdf841487c5fb3c053149de97a86d3 # v3.31.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -216,9 +231,9 @@ jobs:
|
||||
steps:
|
||||
- name: Install git and unzip
|
||||
run: apt-get update ; apt-get install -y git unzip
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@v3.31.0
|
||||
uses: lukka/get-cmake@5979409e62bdf841487c5fb3c053149de97a86d3 # v3.31.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build with libc++
|
||||
@@ -232,7 +247,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v2.4.0
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -242,7 +257,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/nlohmann/json-ci:v2.2.0
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
@@ -250,25 +265,18 @@ jobs:
|
||||
. /opt/intel/oneapi/setvars.sh
|
||||
cmake --build build --target ci_icpc
|
||||
|
||||
ci_reuse_compliance:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
- name: Install REUSE tool
|
||||
run: python -m pip install reuse
|
||||
- name: Run REUSE lint
|
||||
run: reuse lint
|
||||
|
||||
ci_test_documentation:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
target: [ci_test_examples, ci_test_api_documentation]
|
||||
target: [ci_test_examples, ci_test_build_documentation]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DJSON_CI=On
|
||||
- name: Build
|
||||
|
||||
16
.github/workflows/windows.yml
vendored
16
.github/workflows/windows.yml
vendored
@@ -24,9 +24,9 @@ jobs:
|
||||
architecture: [x64, x86]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Set up MinGW
|
||||
uses: egor-tensin/setup-mingw@v2
|
||||
uses: egor-tensin/setup-mingw@84c781b557efd538dec66bde06988d81cd3138cf # v2.2.0
|
||||
with:
|
||||
platform: ${{ matrix.architecture }}
|
||||
version: 12.2.0 # https://github.com/egor-tensin/setup-mingw/issues/14
|
||||
@@ -45,7 +45,7 @@ jobs:
|
||||
architecture: [Win32, x64]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- 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'
|
||||
@@ -61,7 +61,7 @@ jobs:
|
||||
runs-on: windows-2019
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- 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
|
||||
@@ -77,7 +77,7 @@ jobs:
|
||||
architecture: [Win32, x64]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- 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'
|
||||
@@ -93,7 +93,7 @@ jobs:
|
||||
runs-on: windows-2022
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- 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
|
||||
@@ -108,7 +108,7 @@ jobs:
|
||||
version: [11, 12, 13, 14, 15]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Install Clang
|
||||
run: curl -fsSL -o LLVM${{ matrix.version }}.exe https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ matrix.version }}.0.0/LLVM-${{ matrix.version }}.0.0-win64.exe ; 7z x LLVM${{ matrix.version }}.exe -y -o"C:/Program Files/LLVM"
|
||||
- name: Run CMake
|
||||
@@ -125,7 +125,7 @@ jobs:
|
||||
architecture: [Win32, x64]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -T ClangCL -DJSON_BuildTests=On
|
||||
- name: Build
|
||||
|
||||
18
.pre-commit-config.yaml
Normal file
18
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
repos:
|
||||
- repo: https://github.com/gitleaks/gitleaks
|
||||
rev: v8.16.3
|
||||
hooks:
|
||||
- id: gitleaks
|
||||
- repo: https://github.com/pocc/pre-commit-hooks
|
||||
rev: v1.3.5
|
||||
hooks:
|
||||
- id: cpplint
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.4.0
|
||||
hooks:
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
- repo: https://github.com/pylint-dev/pylint
|
||||
rev: v2.17.2
|
||||
hooks:
|
||||
- id: pylint
|
||||
@@ -40,6 +40,7 @@ endif()
|
||||
option(JSON_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ${JSON_BuildTests_INIT})
|
||||
option(JSON_CI "Enable CI build targets." OFF)
|
||||
option(JSON_Diagnostics "Use extended diagnostic messages." OFF)
|
||||
option(JSON_Diagnostic_Positions "Enable diagnostic positions." OFF)
|
||||
option(JSON_GlobalUDLs "Place user-defined string literals in the global namespace." ON)
|
||||
option(JSON_ImplicitConversions "Enable implicit conversions." ON)
|
||||
option(JSON_DisableEnumSerialization "Disable default integer enum serialization." OFF)
|
||||
@@ -81,23 +82,27 @@ else()
|
||||
endif()
|
||||
|
||||
if (NOT JSON_ImplicitConversions)
|
||||
message(STATUS "Implicit conversions are disabled")
|
||||
message(STATUS "Implicit conversions are disabled (JSON_USE_IMPLICIT_CONVERSIONS=0)")
|
||||
endif()
|
||||
|
||||
if (JSON_DisableEnumSerialization)
|
||||
message(STATUS "Enum integer serialization is disabled")
|
||||
message(STATUS "Enum integer serialization is disabled (JSON_DISABLE_ENUM_SERIALIZATION=0)")
|
||||
endif()
|
||||
|
||||
if (JSON_LegacyDiscardedValueComparison)
|
||||
message(STATUS "Legacy discarded value comparison enabled")
|
||||
message(STATUS "Legacy discarded value comparison enabled (JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON=1)")
|
||||
endif()
|
||||
|
||||
if (JSON_Diagnostics)
|
||||
message(STATUS "Diagnostics enabled")
|
||||
message(STATUS "Diagnostics enabled (JSON_DIAGNOSTICS=1)")
|
||||
endif()
|
||||
|
||||
if (JSON_Diagnostic_Positions)
|
||||
message(STATUS "Diagnostic positions enabled")
|
||||
endif()
|
||||
|
||||
if (NOT JSON_GlobalUDLs)
|
||||
message(STATUS "User-defined string literals are not put in the global namespace")
|
||||
message(STATUS "User-defined string literals are not put in the global namespace (JSON_USE_GLOBAL_UDLS=0)")
|
||||
endif()
|
||||
|
||||
if (JSON_SystemInclude)
|
||||
@@ -123,6 +128,7 @@ target_compile_definitions(
|
||||
$<$<NOT:$<BOOL:${JSON_ImplicitConversions}>>:JSON_USE_IMPLICIT_CONVERSIONS=0>
|
||||
$<$<BOOL:${JSON_DisableEnumSerialization}>:JSON_DISABLE_ENUM_SERIALIZATION=1>
|
||||
$<$<BOOL:${JSON_Diagnostics}>:JSON_DIAGNOSTICS=1>
|
||||
$<$<BOOL:${JSON_Diagnostic_Positions}>:JSON_DIAGNOSTIC_POSITIONS=1>
|
||||
$<$<BOOL:${JSON_LegacyDiscardedValueComparison}>:JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON=1>
|
||||
)
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
[](https://github.com/nlohmann/json/issues)
|
||||
[](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://github.com/sponsors/nlohmann)
|
||||
[](https://api.reuse.software/info/github.com/nlohmann/json)
|
||||
[](https://discord.gg/6mrGXKvX7y)
|
||||
@@ -39,6 +40,7 @@
|
||||
- [Conversions to/from arbitrary types](#arbitrary-types-conversions)
|
||||
- [Specializing enum conversion](#specializing-enum-conversion)
|
||||
- [Binary formats (BSON, CBOR, MessagePack, UBJSON, and BJData)](#binary-formats-bson-cbor-messagepack-ubjson-and-bjdata)
|
||||
- [Customers](#customers)
|
||||
- [Supported compilers](#supported-compilers)
|
||||
- [Integration](#integration)
|
||||
- [CMake](#cmake)
|
||||
@@ -1112,6 +1114,11 @@ binary.set_subtype(0x10);
|
||||
auto cbor = json::to_msgpack(j); // 0xD5 (fixext2), 0x10, 0xCA, 0xFE
|
||||
```
|
||||
|
||||
## Customers
|
||||
|
||||
The library is used in multiple projects, applications, operating systems, etc. The list below is not exhaustive, but the result of an internet search. If you know further customers of the library, please let me know, see [contact](#contact).
|
||||
|
||||
[](https://json.nlohmann.me/home/customers/)
|
||||
|
||||
## Supported compilers
|
||||
|
||||
|
||||
@@ -18,24 +18,19 @@ execute_process(COMMAND ${CLANG_TOOL} --version OUTPUT_VARIABLE CLANG_TOOL_VERSI
|
||||
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CLANG_TOOL_VERSION "${CLANG_TOOL_VERSION}")
|
||||
message(STATUS "🔖 Clang ${CLANG_TOOL_VERSION} (${CLANG_TOOL})")
|
||||
|
||||
find_program(CLANG_TIDY_TOOL NAMES clang-tidy-17 clang-tidy-16 clang-tidy-15 clang-tidy-14 clang-tidy-13 clang-tidy-12 clang-tidy-11 clang-tidy)
|
||||
find_program(CLANG_TIDY_TOOL NAMES clang-tidy-20 clang-tidy-19 clang-tidy-18 clang-tidy-17 clang-tidy-16 clang-tidy-15 clang-tidy-14 clang-tidy-13 clang-tidy-12 clang-tidy-11 clang-tidy)
|
||||
execute_process(COMMAND ${CLANG_TIDY_TOOL} --version OUTPUT_VARIABLE CLANG_TIDY_TOOL_VERSION ERROR_VARIABLE CLANG_TIDY_TOOL_VERSION)
|
||||
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CLANG_TIDY_TOOL_VERSION "${CLANG_TIDY_TOOL_VERSION}")
|
||||
message(STATUS "🔖 Clang-Tidy ${CLANG_TIDY_TOOL_VERSION} (${CLANG_TIDY_TOOL})")
|
||||
|
||||
message(STATUS "🔖 CMake ${CMAKE_VERSION} (${CMAKE_COMMAND})")
|
||||
|
||||
find_program(CPPCHECK_TOOL NAMES cppcheck)
|
||||
execute_process(COMMAND ${CPPCHECK_TOOL} --version OUTPUT_VARIABLE CPPCHECK_TOOL_VERSION ERROR_VARIABLE CPPCHECK_TOOL_VERSION)
|
||||
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CPPCHECK_TOOL_VERSION "${CPPCHECK_TOOL_VERSION}")
|
||||
message(STATUS "🔖 Cppcheck ${CPPCHECK_TOOL_VERSION} (${CPPCHECK_TOOL})")
|
||||
|
||||
find_program(GCC_TOOL NAMES g++-latest g++-HEAD g++-13 g++-12 g++-11 g++-10)
|
||||
find_program(GCC_TOOL NAMES g++-latest g++-HEAD g++ g++-15 g++-14 g++-13 g++-12 g++-11 g++-10)
|
||||
execute_process(COMMAND ${GCC_TOOL} --version OUTPUT_VARIABLE GCC_TOOL_VERSION ERROR_VARIABLE GCC_TOOL_VERSION)
|
||||
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" GCC_TOOL_VERSION "${GCC_TOOL_VERSION}")
|
||||
message(STATUS "🔖 GCC ${GCC_TOOL_VERSION} (${GCC_TOOL})")
|
||||
|
||||
find_program(GCOV_TOOL NAMES gcov-HEAD gcov-11 gcov-10 gcov)
|
||||
find_program(GCOV_TOOL NAMES gcov-HEAD gcov-15 gcov-14 gcov-13 gcov-12 gcov-11 gcov-10 gcov)
|
||||
execute_process(COMMAND ${GCOV_TOOL} --version OUTPUT_VARIABLE GCOV_TOOL_VERSION ERROR_VARIABLE GCOV_TOOL_VERSION)
|
||||
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" GCOV_TOOL_VERSION "${GCOV_TOOL_VERSION}")
|
||||
message(STATUS "🔖 GCOV ${GCOV_TOOL_VERSION} (${GCOV_TOOL})")
|
||||
@@ -96,7 +91,6 @@ file(GLOB_RECURSE SRC_FILES ${PROJECT_SOURCE_DIR}/include/nlohmann/*.hpp)
|
||||
# -Wno-padded We do not care about padding warnings.
|
||||
# -Wno-covered-switch-default All switches list all cases and a default case.
|
||||
# -Wno-unsafe-buffer-usage Otherwise Doctest would not compile.
|
||||
# -Wreserved-identifier See https://github.com/onqtam/doctest/issues/536.
|
||||
|
||||
set(CLANG_CXXFLAGS
|
||||
-Werror
|
||||
@@ -108,15 +102,15 @@ set(CLANG_CXXFLAGS
|
||||
-Wno-padded
|
||||
-Wno-covered-switch-default
|
||||
-Wno-unsafe-buffer-usage
|
||||
-Wno-reserved-identifier
|
||||
)
|
||||
|
||||
# Warning flags determined for GCC 13.0 (experimental) 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.
|
||||
@@ -135,28 +129,49 @@ set(GCC_CXXFLAGS
|
||||
-Waggressive-loop-optimizations
|
||||
-Waligned-new=all
|
||||
-Wall
|
||||
-Walloc-size
|
||||
-Walloc-zero
|
||||
-Walloca
|
||||
-Wanalyzer-allocation-size
|
||||
-Wanalyzer-deref-before-check
|
||||
-Wanalyzer-double-fclose
|
||||
-Wanalyzer-double-free
|
||||
-Wanalyzer-exposure-through-output-file
|
||||
-Wanalyzer-exposure-through-uninit-copy
|
||||
-Wanalyzer-fd-access-mode-mismatch
|
||||
-Wanalyzer-fd-double-close
|
||||
-Wanalyzer-fd-leak
|
||||
-Wanalyzer-fd-phase-mismatch
|
||||
-Wanalyzer-fd-type-mismatch
|
||||
-Wanalyzer-fd-use-after-close
|
||||
-Wanalyzer-fd-use-without-check
|
||||
-Wanalyzer-file-leak
|
||||
-Wanalyzer-free-of-non-heap
|
||||
-Wanalyzer-imprecise-fp-arithmetic
|
||||
-Wanalyzer-infinite-loop
|
||||
-Wanalyzer-infinite-recursion
|
||||
-Wanalyzer-jump-through-null
|
||||
-Wanalyzer-malloc-leak
|
||||
-Wanalyzer-mismatching-deallocation
|
||||
-Wanalyzer-null-argument
|
||||
-Wanalyzer-null-dereference
|
||||
-Wanalyzer-out-of-bounds
|
||||
-Wanalyzer-overlapping-buffers
|
||||
-Wanalyzer-possible-null-argument
|
||||
-Wanalyzer-possible-null-dereference
|
||||
-Wanalyzer-putenv-of-auto-var
|
||||
-Wanalyzer-shift-count-negative
|
||||
-Wanalyzer-shift-count-overflow
|
||||
-Wanalyzer-stale-setjmp-buffer
|
||||
-Wanalyzer-symbol-too-complex
|
||||
-Wanalyzer-tainted-allocation-size
|
||||
-Wanalyzer-tainted-array-index
|
||||
-Wanalyzer-tainted-assertion
|
||||
-Wanalyzer-tainted-divisor
|
||||
-Wanalyzer-tainted-offset
|
||||
-Wanalyzer-tainted-size
|
||||
-Wanalyzer-too-complex
|
||||
-Wanalyzer-undefined-behavior-strtok
|
||||
-Wanalyzer-unsafe-call-within-signal-handler
|
||||
-Wanalyzer-use-after-free
|
||||
-Wanalyzer-use-of-pointer-in-stale-stack-frame
|
||||
@@ -189,13 +204,17 @@ set(GCC_CXXFLAGS
|
||||
-Wc++20-compat
|
||||
-Wc++20-extensions
|
||||
-Wc++23-extensions
|
||||
-Wc++26-extensions
|
||||
-Wc++2a-compat
|
||||
-Wcalloc-transposed-args
|
||||
-Wcannot-profile
|
||||
-Wcast-align
|
||||
-Wcast-align=strict
|
||||
-Wcast-function-type
|
||||
-Wcast-qual
|
||||
-Wcast-user-defined
|
||||
-Wcatch-value=3
|
||||
-Wchanges-meaning
|
||||
-Wchar-subscripts
|
||||
-Wclass-conversion
|
||||
-Wclass-memaccess
|
||||
@@ -203,16 +222,19 @@ set(GCC_CXXFLAGS
|
||||
-Wcomma-subscript
|
||||
-Wcomment
|
||||
-Wcomments
|
||||
-Wcomplain-wrong-lang
|
||||
-Wconditionally-supported
|
||||
-Wconversion
|
||||
-Wconversion-null
|
||||
-Wcoverage-invalid-line-number
|
||||
-Wcoverage-mismatch
|
||||
-Wcoverage-too-many-conditions
|
||||
-Wcpp
|
||||
-Wctad-maybe-unsupported
|
||||
-Wctor-dtor-privacy
|
||||
-Wdangling-else
|
||||
-Wdangling-pointer=2
|
||||
-Wdangling-reference
|
||||
-Wdate-time
|
||||
-Wdelete-incomplete
|
||||
-Wdelete-non-virtual-dtor
|
||||
@@ -228,6 +250,7 @@ set(GCC_CXXFLAGS
|
||||
-Wduplicated-branches
|
||||
-Wduplicated-cond
|
||||
-Weffc++
|
||||
-Welaborated-enum-base
|
||||
-Wempty-body
|
||||
-Wendif-labels
|
||||
-Wenum-compare
|
||||
@@ -236,8 +259,15 @@ set(GCC_CXXFLAGS
|
||||
-Wexpansion-to-defined
|
||||
-Wextra
|
||||
-Wextra-semi
|
||||
-Wflex-array-member-not-at-end
|
||||
-Wfloat-conversion
|
||||
-Wfloat-equal
|
||||
-Wformat -Wformat-contains-nul
|
||||
-Wformat -Wformat-extra-args
|
||||
-Wformat -Wformat-nonliteral
|
||||
-Wformat -Wformat-security
|
||||
-Wformat -Wformat-y2k
|
||||
-Wformat -Wformat-zero-length
|
||||
-Wformat-diag
|
||||
-Wformat-overflow=2
|
||||
-Wformat-signedness
|
||||
@@ -245,6 +275,8 @@ set(GCC_CXXFLAGS
|
||||
-Wformat=2
|
||||
-Wframe-address
|
||||
-Wfree-nonheap-object
|
||||
-Wglobal-module
|
||||
-Whardened
|
||||
-Whsa
|
||||
-Wif-not-aligned
|
||||
-Wignored-attributes
|
||||
@@ -259,10 +291,12 @@ set(GCC_CXXFLAGS
|
||||
-Wint-in-bool-context
|
||||
-Wint-to-pointer-cast
|
||||
-Winterference-size
|
||||
-Winvalid-constexpr
|
||||
-Winvalid-imported-macros
|
||||
-Winvalid-memory-model
|
||||
-Winvalid-offsetof
|
||||
-Winvalid-pch
|
||||
-Winvalid-utf8
|
||||
-Wliteral-suffix
|
||||
-Wlogical-not-parentheses
|
||||
-Wlogical-op
|
||||
@@ -296,14 +330,16 @@ set(GCC_CXXFLAGS
|
||||
-Wnonnull
|
||||
-Wnonnull-compare
|
||||
-Wnormalized=nfkc
|
||||
-Wno-nrvo
|
||||
-Wnull-dereference
|
||||
-Wodr
|
||||
-Wold-style-cast
|
||||
-Wopenacc-parallelism
|
||||
-Wopenmp
|
||||
-Wopenmp-simd
|
||||
-Woverflow
|
||||
-Woverlength-strings
|
||||
-Woverloaded-virtual
|
||||
-Woverloaded-virtual=2
|
||||
-Wpacked
|
||||
-Wpacked-bitfield-compat
|
||||
-Wpacked-not-aligned
|
||||
@@ -328,6 +364,7 @@ set(GCC_CXXFLAGS
|
||||
-Wreturn-local-addr
|
||||
-Wreturn-type
|
||||
-Wscalar-storage-order
|
||||
-Wself-move
|
||||
-Wsequence-point
|
||||
-Wshadow=compatible-local
|
||||
-Wshadow=global
|
||||
@@ -347,7 +384,7 @@ set(GCC_CXXFLAGS
|
||||
-Wstack-protector
|
||||
-Wstrict-aliasing=3
|
||||
-Wstrict-null-sentinel
|
||||
-Wno-strict-overflow
|
||||
-Wstrict-overflow
|
||||
-Wstring-compare
|
||||
-Wstringop-overflow=4
|
||||
-Wstringop-overread
|
||||
@@ -359,6 +396,7 @@ set(GCC_CXXFLAGS
|
||||
-Wsuggest-attribute=malloc
|
||||
-Wsuggest-attribute=noreturn
|
||||
-Wsuggest-attribute=pure
|
||||
-Wsuggest-attribute=returns_nonnull
|
||||
-Wsuggest-final-methods
|
||||
-Wsuggest-final-types
|
||||
-Wsuggest-override
|
||||
@@ -380,6 +418,7 @@ set(GCC_CXXFLAGS
|
||||
-Wtsan
|
||||
-Wtype-limits
|
||||
-Wundef
|
||||
-Wunicode
|
||||
-Wuninitialized
|
||||
-Wunknown-pragmas
|
||||
-Wunreachable-code
|
||||
@@ -409,6 +448,7 @@ set(GCC_CXXFLAGS
|
||||
-Wvolatile
|
||||
-Wvolatile-register-var
|
||||
-Wwrite-strings
|
||||
-Wxor-used-as-pow
|
||||
-Wzero-as-null-pointer-constant
|
||||
-Wzero-length-bounds
|
||||
)
|
||||
@@ -671,7 +711,14 @@ add_custom_target(ci_clang_analyze
|
||||
###############################################################################
|
||||
|
||||
add_custom_target(ci_cppcheck
|
||||
COMMAND ${CPPCHECK_TOOL} --enable=warning --suppress=missingReturn --inline-suppr --inconclusive --force --std=c++11 ${PROJECT_SOURCE_DIR}/single_include/nlohmann/json.hpp --error-exitcode=1
|
||||
COMMAND ${Python3_EXECUTABLE} -mvenv venv_cppcheck
|
||||
COMMAND clang -dM -E -x c++ -std=c++11 ${CMAKE_SOURCE_DIR}/include/nlohmann/thirdparty/hedley/hedley.hpp > default_defines.hpp 2> /dev/null
|
||||
COMMAND venv_cppcheck/bin/pip3 --quiet install -r ${CMAKE_SOURCE_DIR}/cmake/requirements/requirements-cppcheck.txt
|
||||
COMMAND venv_cppcheck/bin/cppcheck --enable=warning --check-level=exhaustive --inline-suppr --inconclusive --force
|
||||
--std=c++11 ${PROJECT_SOURCE_DIR}/include/nlohmann/json.hpp -I ${CMAKE_SOURCE_DIR}/include
|
||||
--error-exitcode=1 --relative-paths=${PROJECT_SOURCE_DIR} -j 10 --include=default_defines.hpp
|
||||
-UJSON_CATCH_USER -UJSON_TRY_USER -UJSON_ASSERT -UJSON_INTERNAL_CATCH -UJSON_THROW
|
||||
-DJSON_HAS_CPP_11 -UJSON_HAS_CPP_14 -UJSON_HAS_CPP_17 -UJSON_HAS_CPP_20 -UJSON_HAS_THREE_WAY_COMPARISON
|
||||
COMMENT "Check code with Cppcheck"
|
||||
)
|
||||
|
||||
@@ -681,7 +728,7 @@ add_custom_target(ci_cppcheck
|
||||
|
||||
add_custom_target(ci_cpplint
|
||||
COMMAND ${Python3_EXECUTABLE} -mvenv venv_cpplint
|
||||
COMMAND venv_cpplint/bin/pip3 --quiet install cpplint
|
||||
COMMAND venv_cpplint/bin/pip3 --quiet install -r ${CMAKE_SOURCE_DIR}/cmake/requirements/requirements-cpplint.txt
|
||||
COMMAND venv_cpplint/bin/cpplint --filter=-whitespace,-legal,-runtime/references,-runtime/explicit,-runtime/indentation_namespace,-readability/casting,-readability/nolint --quiet --recursive ${SRC_FILES}
|
||||
COMMENT "Check code with cpplint"
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
@@ -968,6 +1015,17 @@ add_custom_target(ci_icpc
|
||||
COMMENT "Compile and test with ICPC"
|
||||
)
|
||||
|
||||
###############################################################################
|
||||
# REUSE
|
||||
###############################################################################
|
||||
|
||||
add_custom_target(ci_reuse_compliance
|
||||
COMMAND ${Python3_EXECUTABLE} -mvenv venv_reuse
|
||||
COMMAND venv_reuse/bin/pip3 --quiet install -r ${PROJECT_SOURCE_DIR}/cmake/requirements/requirements-reuse.txt
|
||||
COMMAND venv_reuse/bin/reuse --root ${PROJECT_SOURCE_DIR} lint
|
||||
COMMENT "Check REUSE specification compliance"
|
||||
)
|
||||
|
||||
###############################################################################
|
||||
# test documentation
|
||||
###############################################################################
|
||||
@@ -978,10 +1036,12 @@ add_custom_target(ci_test_examples
|
||||
COMMENT "Check that all examples compile and create the desired output"
|
||||
)
|
||||
|
||||
add_custom_target(ci_test_api_documentation
|
||||
COMMAND ${Python3_EXECUTABLE} scripts/check_structure.py
|
||||
add_custom_target(ci_test_build_documentation
|
||||
COMMAND ${Python3_EXECUTABLE} -mvenv venv
|
||||
COMMAND venv/bin/pip3 --quiet install -r requirements.txt
|
||||
COMMAND make build
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/docs/mkdocs
|
||||
COMMENT "Lint the API documentation"
|
||||
COMMENT "Build the documentation"
|
||||
)
|
||||
|
||||
###############################################################################
|
||||
|
||||
1
cmake/requirements/requirements-cppcheck.txt
Normal file
1
cmake/requirements/requirements-cppcheck.txt
Normal file
@@ -0,0 +1 @@
|
||||
cppcheck==1.4.6
|
||||
1
cmake/requirements/requirements-cpplint.txt
Normal file
1
cmake/requirements/requirements-cpplint.txt
Normal file
@@ -0,0 +1 @@
|
||||
cpplint==2.0.0
|
||||
1
cmake/requirements/requirements-reuse.txt
Normal file
1
cmake/requirements/requirements-reuse.txt
Normal file
@@ -0,0 +1 @@
|
||||
reuse==5.0.2
|
||||
51
docs/examples/diagnostic_positions.cpp
Normal file
51
docs/examples/diagnostic_positions.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include <iostream>
|
||||
|
||||
#define JSON_DIAGNOSTIC_POSITIONS 1
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string json_string = R"(
|
||||
{
|
||||
"address": {
|
||||
"street": "Fake Street",
|
||||
"housenumber": 1
|
||||
}
|
||||
}
|
||||
)";
|
||||
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 << "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 << "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";
|
||||
}
|
||||
50
docs/examples/diagnostic_positions.output
Normal file
50
docs/examples/diagnostic_positions.output
Normal file
@@ -0,0 +1,50 @@
|
||||
Root diagnostic positions:
|
||||
start_pos: 5
|
||||
end_pos:109
|
||||
Original string:
|
||||
{
|
||||
"address": {
|
||||
"street": "Fake Street",
|
||||
"housenumber": 1
|
||||
}
|
||||
}
|
||||
Parsed string:
|
||||
{
|
||||
"address": {
|
||||
"street": "Fake Street",
|
||||
"housenumber": 1
|
||||
}
|
||||
}
|
||||
|
||||
address diagnostic positions:
|
||||
start_pos:26
|
||||
end_pos:103
|
||||
|
||||
Original string:
|
||||
{ "street": "Fake Street",
|
||||
"housenumber": 1
|
||||
}
|
||||
Parsed string:
|
||||
{
|
||||
"street": "Fake Street",
|
||||
"housenumber": 1
|
||||
}
|
||||
|
||||
street diagnostic positions:
|
||||
start_pos:50
|
||||
end_pos:63
|
||||
|
||||
Original string:
|
||||
"Fake Street"
|
||||
Parsed string:
|
||||
"Fake Street"
|
||||
|
||||
housenumber diagnostic positions:
|
||||
start_pos:92
|
||||
end_pos:93
|
||||
|
||||
Original string:
|
||||
1
|
||||
Parsed string:
|
||||
1
|
||||
|
||||
@@ -35,3 +35,11 @@ install_venv: requirements.txt
|
||||
# uninstall the virtual environment
|
||||
uninstall_venv: clean
|
||||
rm -fr venv
|
||||
|
||||
update_requirements:
|
||||
rm -fr venv_small
|
||||
python3 -mvenv venv_small
|
||||
venv_small/bin/pip3 install pur
|
||||
venv_small/bin/pur -r requirements.txt
|
||||
rm -fr venv_small venv
|
||||
make install_venv
|
||||
|
||||
@@ -29,9 +29,9 @@ Unlike the [`parse`](parse.md) function, this function neither throws an excepti
|
||||
: A compatible input, for instance:
|
||||
|
||||
- an `std::istream` object
|
||||
- a `FILE` pointer (must not be null)
|
||||
- a `FILE` pointer (throws if null)
|
||||
- a C-style array of characters
|
||||
- a pointer to a null-terminated string of single byte characters
|
||||
- a pointer to a null-terminated string of single byte characters (throws if null)
|
||||
- a `std::string`
|
||||
- an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators.
|
||||
|
||||
@@ -64,18 +64,17 @@ Whether the input is valid JSON.
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
|
||||
|
||||
## Exceptions
|
||||
|
||||
Throws [`parse_error.101`](../../home/exceptions.md#jsonexceptionparse_error101) in case of an empty input like a null `FILE*` or `char*` pointer.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the length of the input. The parser is a predictive LL(1) parser.
|
||||
|
||||
## Notes
|
||||
|
||||
(1) A UTF-8 byte order mark is silently ignored.
|
||||
|
||||
!!! danger "Runtime assertion"
|
||||
|
||||
The precondition that a passed `#!cpp FILE` pointer must not be null is enforced with a
|
||||
[runtime assertion](../../features/assertions.md).
|
||||
A UTF-8 byte order mark is silently ignored.
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -102,6 +101,7 @@ Linear in the length of the input. The parser is a predictive LL(1) parser.
|
||||
|
||||
- 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.11.4.
|
||||
|
||||
!!! warning "Deprecation"
|
||||
|
||||
|
||||
@@ -25,10 +25,11 @@ and `ensure_ascii` parameters.
|
||||
result consists of ASCII characters only.
|
||||
|
||||
`error_handler` (in)
|
||||
: how to react on decoding errors; there are three possible values (see [`error_handler_t`](error_handler_t.md):
|
||||
`strict` (throws and exception in case a decoding error occurs; default), `replace` (replace invalid UTF-8 sequences
|
||||
with U+FFFD), and `ignore` (ignore invalid UTF-8 sequences during serialization; all bytes are copied to the output
|
||||
unchanged)).
|
||||
: how to react on decoding errors; there are four possible values (see [`error_handler_t`](error_handler_t.md)):
|
||||
: - `strict`: throws a [`type_error`](../../home/exceptions.md#type-errors) exception in case a decoding error occurs (this is the default),
|
||||
- `replace`: replace invalid UTF-8 sequences with U+FFFD (<28> REPLACEMENT CHARACTER),
|
||||
- `ignore`: ignore invalid UTF-8 sequences during serialization (i.e., these bytes are skipped and not copied to the output), and
|
||||
- `keep`: keep invalid UTF-8 sequences during serialization (i.e., all bytes are copied to the output unchanged)
|
||||
|
||||
## Return value
|
||||
|
||||
@@ -77,3 +78,4 @@ Binary values are serialized as object containing two keys:
|
||||
- Indentation character `indent_char`, option `ensure_ascii` and exceptions added in version 3.0.0.
|
||||
- Error handlers added in version 3.4.0.
|
||||
- Serialization of binary values added in version 3.8.0.
|
||||
- Added support for error handler value `keep` in version ???.
|
||||
|
||||
@@ -14,6 +14,11 @@ created from `args`.
|
||||
`Args`
|
||||
: compatible types to create a `basic_json` object
|
||||
|
||||
## Iterator invalidation
|
||||
|
||||
For [`ordered_json`](../ordered_json.md), adding a value to an object can yield a reallocation, in which case all
|
||||
iterators (including the `end()` iterator) and all references to the elements are invalidated.
|
||||
|
||||
## Parameters
|
||||
|
||||
`args` (in)
|
||||
|
||||
@@ -13,6 +13,12 @@ Creates a JSON value from the passed parameters `args` to the end of the JSON va
|
||||
`Args`
|
||||
: compatible types to create a `basic_json` object
|
||||
|
||||
## Iterator invalidation
|
||||
|
||||
By adding an element to the end of the 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.
|
||||
|
||||
## Parameters
|
||||
|
||||
`args` (in)
|
||||
@@ -48,6 +54,11 @@ Amortized constant.
|
||||
--8<-- "examples/emplace_back.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [operator+=](operator+=.md) add a value to an array/object
|
||||
- [push_back](push_back.md) add a value to an array/object
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 2.0.8.
|
||||
|
||||
@@ -12,13 +12,16 @@ This enumeration is used in the [`dump`](dump.md) function to choose how to trea
|
||||
`basic_json` value. Three values are differentiated:
|
||||
|
||||
strict
|
||||
: throw a `type_error` exception in case of invalid UTF-8
|
||||
: throw a [`type_error`](../../home/exceptions.md#type-errors) exception in case of invalid UTF-8
|
||||
|
||||
replace
|
||||
: replace invalid UTF-8 sequences with U+FFFD (<28> REPLACEMENT CHARACTER)
|
||||
|
||||
ignore
|
||||
: ignore invalid UTF-8 sequences; all bytes are copied to the output unchanged
|
||||
: ignore invalid UTF-8 sequences; these bytes are skipped and not copied to the output
|
||||
|
||||
keep
|
||||
: keep invalid UTF-8 sequences; all bytes are copied to the output unchanged
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -40,3 +43,4 @@ ignore
|
||||
## Version history
|
||||
|
||||
- Added in version 3.4.0.
|
||||
- Added value `keep` in version ???.
|
||||
|
||||
@@ -8,24 +8,36 @@ This class is an extension of [`std::exception`](https://en.cppreference.com/w/c
|
||||
member `id` for exception ids. It is used as the base class for all exceptions thrown by the `basic_json` class. This
|
||||
class can hence be used as "wildcard" to catch exceptions, see example below.
|
||||
|
||||
```plantuml
|
||||
std::exception <|-- basic_json::exception
|
||||
basic_json::exception <|-- basic_json::parse_error
|
||||
basic_json::exception <|-- basic_json::invalid_iterator
|
||||
basic_json::exception <|-- basic_json::type_error
|
||||
basic_json::exception <|-- basic_json::out_of_range
|
||||
basic_json::exception <|-- basic_json::other_error
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
|
||||
class std_exception ["std::exception"] {
|
||||
<<interface>>
|
||||
}
|
||||
|
||||
interface std::exception {}
|
||||
class json_exception ["basic_json::exception"] {
|
||||
+const int id
|
||||
+const char* what() const
|
||||
}
|
||||
|
||||
class json_parse_error ["basic_json::parse_error"] {
|
||||
+const std::size_t byte
|
||||
}
|
||||
|
||||
class basic_json::exception #FFFF00 {
|
||||
+ const int id
|
||||
+ const char* what() const
|
||||
}
|
||||
class json_invalid_iterator ["basic_json::invalid_iterator"]
|
||||
class json_type_error ["basic_json::type_error"]
|
||||
class json_out_of_range ["basic_json::out_of_range"]
|
||||
class json_other_error ["basic_json::other_error"]
|
||||
|
||||
class basic_json::parse_error {
|
||||
+ const std::size_t byte
|
||||
}
|
||||
std_exception <|-- json_exception
|
||||
json_exception <|-- json_parse_error
|
||||
json_exception <|-- json_invalid_iterator
|
||||
json_exception <|-- json_type_error
|
||||
json_exception <|-- json_out_of_range
|
||||
json_exception <|-- json_other_error
|
||||
|
||||
style json_exception fill:#CCCCFF
|
||||
```
|
||||
|
||||
Subclasses:
|
||||
|
||||
@@ -35,7 +35,37 @@ Constant.
|
||||
|
||||
!!! danger "Undefined behavior"
|
||||
|
||||
Writing data to the pointee of the result yields an undefined state.
|
||||
The pointer becomes invalid if the underlying JSON object changes.
|
||||
|
||||
Consider the following example code where the pointer `ptr` changes after the array is resized. As a result,
|
||||
reading or writing to `ptr` after the array change would be undefined behavior. The address of the first array
|
||||
element changes, because the underlying `std::vector` is resized after adding a fifth element.
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
json j = {1, 2, 3, 4};
|
||||
auto* ptr = j[0].get_ptr<std::int64_t*>();
|
||||
std::cout << "value at " << ptr << " is " << *ptr << std::endl;
|
||||
|
||||
j.push_back(5);
|
||||
|
||||
ptr = j[0].get_ptr<std::int64_t*>();
|
||||
std::cout << "value at " << ptr << " is " << *ptr << std::endl;
|
||||
}
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```
|
||||
value at 0x6000012fc1c8 is 1
|
||||
value at 0x6000029fc088 is 1
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -54,6 +84,10 @@ Constant.
|
||||
--8<-- "examples/get_ptr.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [get_ref()](get_ref.md) get a reference value
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
|
||||
@@ -40,7 +40,7 @@ Constant.
|
||||
|
||||
!!! danger "Undefined behavior"
|
||||
|
||||
Writing data to the referee of the result yields an undefined state.
|
||||
The reference becomes invalid if the underlying JSON object changes.
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -58,6 +58,10 @@ Constant.
|
||||
--8<-- "examples/get_ref.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [get_ptr()](get_ptr.md) get a pointer value
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.1.0.
|
||||
|
||||
@@ -42,7 +42,15 @@ class basic_json;
|
||||
|
||||
## Iterator invalidation
|
||||
|
||||
Todo
|
||||
All operations that add values to an **array** ([`push_back`](push_back.md) , [`operator+=`](operator+=.md),
|
||||
[`emplace_back`](emplace_back.md), [`insert`](insert.md), and [`operator[]`](operator%5B%5D.md) for a non-existing
|
||||
index) can yield a reallocation, in which case all iterators (including the [`end()`](end.md) iterator) and all
|
||||
references to the elements are invalidated.
|
||||
|
||||
For [`ordered_json`](../ordered_json.md), also all operations that add a value to an **object**
|
||||
([`push_back`](push_back.md), [`operator+=`](operator+=.md), [`emplace`](emplace.md), [`insert`](insert.md),
|
||||
[`update`](update.md), and [`operator[]`](operator%5B%5D.md) for a non-existing key) can yield a reallocation, in
|
||||
which case all iterators (including the [`end()`](end.md) iterator) and all references to the elements are invalidated.
|
||||
|
||||
## Requirements
|
||||
|
||||
|
||||
@@ -24,6 +24,17 @@ void insert(const_iterator first, const_iterator last);
|
||||
4. Inserts elements from initializer list `ilist` into array before iterator `pos`.
|
||||
5. Inserts elements from range `[first, last)` into object.
|
||||
|
||||
## Iterator invalidation
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
## Parameters
|
||||
|
||||
`pos` (in)
|
||||
|
||||
@@ -8,26 +8,36 @@ This exception is thrown if iterators passed to a library function do not match
|
||||
|
||||
Exceptions have ids 2xx (see [list of iterator errors](../../home/exceptions.md#iterator-errors)).
|
||||
|
||||
```plantuml
|
||||
std::exception <|-- basic_json::exception
|
||||
basic_json::exception <|-- basic_json::parse_error
|
||||
basic_json::exception <|-- basic_json::invalid_iterator
|
||||
basic_json::exception <|-- basic_json::type_error
|
||||
basic_json::exception <|-- basic_json::out_of_range
|
||||
basic_json::exception <|-- basic_json::other_error
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
|
||||
class std_exception ["std::exception"] {
|
||||
<<interface>>
|
||||
}
|
||||
|
||||
interface std::exception {}
|
||||
class json_exception ["basic_json::exception"] {
|
||||
+const int id
|
||||
+const char* what() const
|
||||
}
|
||||
|
||||
class json_parse_error ["basic_json::parse_error"] {
|
||||
+const std::size_t byte
|
||||
}
|
||||
|
||||
class basic_json::exception {
|
||||
+ const int id
|
||||
+ const char* what() const
|
||||
}
|
||||
class json_invalid_iterator ["basic_json::invalid_iterator"]
|
||||
class json_type_error ["basic_json::type_error"]
|
||||
class json_out_of_range ["basic_json::out_of_range"]
|
||||
class json_other_error ["basic_json::other_error"]
|
||||
|
||||
class basic_json::parse_error {
|
||||
+ const std::size_t byte
|
||||
}
|
||||
std_exception <|-- json_exception
|
||||
json_exception <|-- json_parse_error
|
||||
json_exception <|-- json_invalid_iterator
|
||||
json_exception <|-- json_type_error
|
||||
json_exception <|-- json_out_of_range
|
||||
json_exception <|-- json_other_error
|
||||
|
||||
class basic_json::invalid_iterator #FFFF00 {}
|
||||
style json_invalid_iterator fill:#CCCCFF
|
||||
```
|
||||
|
||||
## Member functions
|
||||
|
||||
@@ -66,7 +66,7 @@ When iterating over an array, `key()` will return the index of the element as st
|
||||
!!! danger "Lifetime issues"
|
||||
|
||||
Using `items()` on temporary objects is dangerous. Make sure the object's lifetime exceeds the iteration. See
|
||||
<https://github.com/nlohmann/json/issues/2040> for more information.
|
||||
[#2040](https://github.com/nlohmann/json/issues/2040) for more information.
|
||||
|
||||
## Examples
|
||||
|
||||
|
||||
@@ -27,6 +27,15 @@ reference operator+=(initializer_list_t init);
|
||||
`init` is converted into an object element and added using `operator+=(const typename object_t::value_type&)`.
|
||||
Otherwise, `init` is converted to a JSON value and added using `operator+=(basic_json&&)`.
|
||||
|
||||
## Iterator invalidation
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
## Parameters
|
||||
|
||||
`val` (in)
|
||||
@@ -103,6 +112,11 @@ interpreted as `object_t::value_type` or `std::initializer_list<basic_json>`, se
|
||||
--8<-- "examples/push_back__initializer_list.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [emplace_back](emplace_back.md) add a value to an array
|
||||
- [push_back](push_back.md) add a value to an array/object
|
||||
|
||||
## Version history
|
||||
|
||||
1. Since version 1.0.0.
|
||||
|
||||
@@ -34,6 +34,15 @@ const_reference operator[](const json_pointer& ptr) const;
|
||||
[`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md).
|
||||
This can also be a string view (C++17).
|
||||
|
||||
## Iterator invalidation
|
||||
|
||||
For the non-const versions 1. and 4., when passing an **array** index that does not exist, it is created and filled with
|
||||
a `#!json null` value before a reference to it is returned. For this, a reallocation can happen, in which case all
|
||||
iterators (including the [`end()`](end.md) iterator) and all references to the elements are invalidated.
|
||||
|
||||
For [`ordered_json`](../ordered_json.md), also passing an **object key** to the non-const versions 2., 3., and 4., a
|
||||
reallocation can happen which again invalidates all iterators and all references.
|
||||
|
||||
## Parameters
|
||||
|
||||
`idx` (in)
|
||||
|
||||
@@ -8,26 +8,36 @@ This exception is thrown in case of errors that cannot be classified with the ot
|
||||
|
||||
Exceptions have ids 5xx (see [list of other errors](../../home/exceptions.md#further-exceptions)).
|
||||
|
||||
```plantuml
|
||||
std::exception <|-- basic_json::exception
|
||||
basic_json::exception <|-- basic_json::parse_error
|
||||
basic_json::exception <|-- basic_json::invalid_iterator
|
||||
basic_json::exception <|-- basic_json::type_error
|
||||
basic_json::exception <|-- basic_json::out_of_range
|
||||
basic_json::exception <|-- basic_json::other_error
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
|
||||
class std_exception ["std::exception"] {
|
||||
<<interface>>
|
||||
}
|
||||
|
||||
interface std::exception {}
|
||||
class json_exception ["basic_json::exception"] {
|
||||
+const int id
|
||||
+const char* what() const
|
||||
}
|
||||
|
||||
class json_parse_error ["basic_json::parse_error"] {
|
||||
+const std::size_t byte
|
||||
}
|
||||
|
||||
class basic_json::exception {
|
||||
+ const int id
|
||||
+ const char* what() const
|
||||
}
|
||||
class json_invalid_iterator ["basic_json::invalid_iterator"]
|
||||
class json_type_error ["basic_json::type_error"]
|
||||
class json_out_of_range ["basic_json::out_of_range"]
|
||||
class json_other_error ["basic_json::other_error"]
|
||||
|
||||
class basic_json::parse_error {
|
||||
+ const std::size_t byte
|
||||
}
|
||||
std_exception <|-- json_exception
|
||||
json_exception <|-- json_parse_error
|
||||
json_exception <|-- json_invalid_iterator
|
||||
json_exception <|-- json_type_error
|
||||
json_exception <|-- json_out_of_range
|
||||
json_exception <|-- json_other_error
|
||||
|
||||
class basic_json::other_error #FFFF00 {}
|
||||
style json_other_error fill:#CCCCFF
|
||||
```
|
||||
|
||||
## Member functions
|
||||
|
||||
@@ -9,26 +9,36 @@ instance in case of array indices or nonexisting object keys.
|
||||
|
||||
Exceptions have ids 4xx (see [list of out-of-range errors](../../home/exceptions.md#out-of-range)).
|
||||
|
||||
```plantuml
|
||||
std::exception <|-- basic_json::exception
|
||||
basic_json::exception <|-- basic_json::parse_error
|
||||
basic_json::exception <|-- basic_json::invalid_iterator
|
||||
basic_json::exception <|-- basic_json::type_error
|
||||
basic_json::exception <|-- basic_json::out_of_range
|
||||
basic_json::exception <|-- basic_json::other_error
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
|
||||
class std_exception ["std::exception"] {
|
||||
<<interface>>
|
||||
}
|
||||
|
||||
interface std::exception {}
|
||||
class json_exception ["basic_json::exception"] {
|
||||
+const int id
|
||||
+const char* what() const
|
||||
}
|
||||
|
||||
class json_parse_error ["basic_json::parse_error"] {
|
||||
+const std::size_t byte
|
||||
}
|
||||
|
||||
class basic_json::exception {
|
||||
+ const int id
|
||||
+ const char* what() const
|
||||
}
|
||||
class json_invalid_iterator ["basic_json::invalid_iterator"]
|
||||
class json_type_error ["basic_json::type_error"]
|
||||
class json_out_of_range ["basic_json::out_of_range"]
|
||||
class json_other_error ["basic_json::other_error"]
|
||||
|
||||
class basic_json::parse_error {
|
||||
+ const std::size_t byte
|
||||
}
|
||||
std_exception <|-- json_exception
|
||||
json_exception <|-- json_parse_error
|
||||
json_exception <|-- json_invalid_iterator
|
||||
json_exception <|-- json_type_error
|
||||
json_exception <|-- json_out_of_range
|
||||
json_exception <|-- json_other_error
|
||||
|
||||
class basic_json::out_of_range #FFFF00 {}
|
||||
style json_out_of_range fill:#CCCCFF
|
||||
```
|
||||
|
||||
## Member functions
|
||||
|
||||
@@ -28,9 +28,9 @@ static basic_json parse(IteratorType first, IteratorType last,
|
||||
: A compatible input, for instance:
|
||||
|
||||
- an `std::istream` object
|
||||
- a `FILE` pointer (must not be null)
|
||||
- a `FILE` pointer (throws if null)
|
||||
- a C-style array of characters
|
||||
- a pointer to a null-terminated string of single byte characters
|
||||
- a pointer to a null-terminated string of single byte characters (throws if null)
|
||||
- a `std::string`
|
||||
- an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators.
|
||||
|
||||
@@ -73,10 +73,11 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va
|
||||
|
||||
## Exceptions
|
||||
|
||||
- Throws [`parse_error.101`](../../home/exceptions.md#jsonexceptionparse_error101) in case of an unexpected token.
|
||||
- Throws [`parse_error.102`](../../home/exceptions.md#jsonexceptionparse_error102) if to_unicode fails or surrogate
|
||||
- Throws [`parse_error.101`](../../home/exceptions.md#jsonexceptionparse_error101) in case of an unexpected token, or
|
||||
empty input like a null `FILE*` or `char*` pointer.
|
||||
- Throws [`parse_error.102`](../../home/exceptions.md#jsonexceptionparse_error102) if `to_unicode` fails or surrogate
|
||||
error.
|
||||
- Throws [`parse_error.103`](../../home/exceptions.md#jsonexceptionparse_error103) if to_unicode fails.
|
||||
- Throws [`parse_error.103`](../../home/exceptions.md#jsonexceptionparse_error103) if `to_unicode` fails.
|
||||
|
||||
## Complexity
|
||||
|
||||
@@ -86,12 +87,7 @@ super-linear complexity.
|
||||
|
||||
## Notes
|
||||
|
||||
(1) A UTF-8 byte order mark is silently ignored.
|
||||
|
||||
!!! danger "Runtime assertion"
|
||||
|
||||
The precondition that a passed `#!cpp FILE` pointer must not be null is enforced with a
|
||||
[runtime assertion](../../features/assertions.md).
|
||||
A UTF-8 byte order mark is silently ignored.
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -203,6 +199,7 @@ super-linear complexity.
|
||||
- Added in version 1.0.0.
|
||||
- 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.11.4.
|
||||
|
||||
!!! warning "Deprecation"
|
||||
|
||||
|
||||
@@ -11,24 +11,36 @@ Member `byte` holds the byte index of the last read character in the input file
|
||||
|
||||
Exceptions have ids 1xx (see [list of parse errors](../../home/exceptions.md#parse-errors)).
|
||||
|
||||
```plantuml
|
||||
std::exception <|-- basic_json::exception
|
||||
basic_json::exception <|-- basic_json::parse_error
|
||||
basic_json::exception <|-- basic_json::invalid_iterator
|
||||
basic_json::exception <|-- basic_json::type_error
|
||||
basic_json::exception <|-- basic_json::out_of_range
|
||||
basic_json::exception <|-- basic_json::other_error
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
|
||||
class std_exception ["std::exception"] {
|
||||
<<interface>>
|
||||
}
|
||||
|
||||
interface std::exception {}
|
||||
class json_exception ["basic_json::exception"] {
|
||||
+const int id
|
||||
+const char* what() const
|
||||
}
|
||||
|
||||
class json_parse_error ["basic_json::parse_error"] {
|
||||
+const std::size_t byte
|
||||
}
|
||||
|
||||
class basic_json::exception {
|
||||
+ const int id
|
||||
+ const char* what() const
|
||||
}
|
||||
class json_invalid_iterator ["basic_json::invalid_iterator"]
|
||||
class json_type_error ["basic_json::type_error"]
|
||||
class json_out_of_range ["basic_json::out_of_range"]
|
||||
class json_other_error ["basic_json::other_error"]
|
||||
|
||||
class basic_json::parse_error #FFFF00 {
|
||||
+ const std::size_t byte
|
||||
}
|
||||
std_exception <|-- json_exception
|
||||
json_exception <|-- json_parse_error
|
||||
json_exception <|-- json_invalid_iterator
|
||||
json_exception <|-- json_type_error
|
||||
json_exception <|-- json_out_of_range
|
||||
json_exception <|-- json_other_error
|
||||
|
||||
style json_parse_error fill:#CCCCFF
|
||||
```
|
||||
|
||||
## Member functions
|
||||
|
||||
@@ -27,6 +27,15 @@ void push_back(initializer_list_t init);
|
||||
`init` is converted into an object element and added using `push_back(const typename object_t::value_type&)`.
|
||||
Otherwise, `init` is converted to a JSON value and added using `push_back(basic_json&&)`.
|
||||
|
||||
## Iterator invalidation
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
## Parameters
|
||||
|
||||
`val` (in)
|
||||
@@ -99,6 +108,11 @@ All functions can throw the following exception:
|
||||
--8<-- "examples/push_back__initializer_list.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [emplace_back](emplace_back.md) add a value to an array
|
||||
- [operator+=](operator+=.md) add a value to an array/object
|
||||
|
||||
## Version history
|
||||
|
||||
1. Since version 1.0.0.
|
||||
|
||||
@@ -9,26 +9,36 @@ does not match the expected semantics.
|
||||
|
||||
Exceptions have ids 3xx (see [list of type errors](../../home/exceptions.md#type-errors)).
|
||||
|
||||
```plantuml
|
||||
std::exception <|-- basic_json::exception
|
||||
basic_json::exception <|-- basic_json::parse_error
|
||||
basic_json::exception <|-- basic_json::invalid_iterator
|
||||
basic_json::exception <|-- basic_json::type_error
|
||||
basic_json::exception <|-- basic_json::out_of_range
|
||||
basic_json::exception <|-- basic_json::other_error
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
|
||||
class std_exception ["std::exception"] {
|
||||
<<interface>>
|
||||
}
|
||||
|
||||
interface std::exception {}
|
||||
class json_exception ["basic_json::exception"] {
|
||||
+const int id
|
||||
+const char* what() const
|
||||
}
|
||||
|
||||
class json_parse_error ["basic_json::parse_error"] {
|
||||
+const std::size_t byte
|
||||
}
|
||||
|
||||
class basic_json::exception {
|
||||
+ const int id
|
||||
+ const char* what() const
|
||||
}
|
||||
class json_invalid_iterator ["basic_json::invalid_iterator"]
|
||||
class json_type_error ["basic_json::type_error"]
|
||||
class json_out_of_range ["basic_json::out_of_range"]
|
||||
class json_other_error ["basic_json::other_error"]
|
||||
|
||||
class basic_json::parse_error {
|
||||
+ const std::size_t byte
|
||||
}
|
||||
std_exception <|-- json_exception
|
||||
json_exception <|-- json_parse_error
|
||||
json_exception <|-- json_invalid_iterator
|
||||
json_exception <|-- json_type_error
|
||||
json_exception <|-- json_out_of_range
|
||||
json_exception <|-- json_other_error
|
||||
|
||||
class basic_json::type_error #FFFF00 {}
|
||||
style json_type_error fill:#CCCCFF
|
||||
```
|
||||
|
||||
## Member functions
|
||||
|
||||
@@ -17,6 +17,11 @@ recursively merges objects with common keys.
|
||||
The function is motivated by Python's [dict.update](https://docs.python.org/3.6/library/stdtypes.html#dict.update)
|
||||
function.
|
||||
|
||||
## Iterator invalidation
|
||||
|
||||
For [`ordered_json`](../ordered_json.md), adding a value to an object can yield a reallocation, in which case all
|
||||
iterators (including the `end()` iterator) and all references to the elements are invalidated.
|
||||
|
||||
## Parameters
|
||||
|
||||
`j` (in)
|
||||
|
||||
@@ -42,7 +42,6 @@ header. See also the [macro overview page](../../features/macros.md).
|
||||
- [**JSON_DISABLE_ENUM_SERIALIZATION**](json_disable_enum_serialization.md) - switch off default serialization/deserialization functions for enums
|
||||
- [**JSON_USE_IMPLICIT_CONVERSIONS**](json_use_implicit_conversions.md) - control implicit conversions
|
||||
|
||||
<!-- comment-->
|
||||
## Comparison behavior
|
||||
|
||||
- [**JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON**](json_use_legacy_discarded_value_comparison.md) -
|
||||
@@ -50,6 +49,20 @@ header. See also the [macro overview page](../../features/macros.md).
|
||||
|
||||
## Serialization/deserialization macros
|
||||
|
||||
- Enum: [**NLOHMANN_JSON_SERIALIZE_ENUM**](nlohmann_json_serialize_enum.md)
|
||||
- Class/struct:
|
||||
- Do you need to serialize private variables?
|
||||
- Yes? Do you only need serialization?
|
||||
- Yes? `NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE`
|
||||
- No? Allow deserialization of JSON values with missing values?
|
||||
- Yes? `NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT`
|
||||
- No? `NLOHMANN_DEFINE_TYPE_INTRUSIVE`
|
||||
- No? Do you only need serialization?
|
||||
- Yes? `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE`
|
||||
- No? Allow deserialization of JSON values with missing values?
|
||||
- Yes? `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT`
|
||||
- No? `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`
|
||||
|
||||
- [**NLOHMANN_DEFINE_TYPE_INTRUSIVE(type, member...)**<br>**NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(type, member...)**
|
||||
<br>**NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(type, member...)**][DefInt]
|
||||
\- serialization/deserialization of types _with_ access to private variables
|
||||
|
||||
61
docs/mkdocs/docs/api/macros/json_diagnostic_positions.md
Normal file
61
docs/mkdocs/docs/api/macros/json_diagnostic_positions.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# JSON_DIAGNOSTIC_POSITIONS
|
||||
|
||||
```cpp
|
||||
#define JSON_DIAGNOSTIC_POSITIONS /* value */
|
||||
```
|
||||
|
||||
This macro enables position diagnostics for generated JSON objects.
|
||||
|
||||
When enabled, two new properties: `start_pos()` and `end_pos()` are added to `nlohmann::basic_json` objects and fields. `start_pos()` returns the start
|
||||
position of that JSON object/field in the original string the object was parsed from. Likewise, `end_pos()` returns the end position of that JSON
|
||||
object/field in the original string the object was parsed from.
|
||||
|
||||
`start_pos()` returns the first character of a given element in the original JSON string, while `end_pos()` returns the character following the last
|
||||
character. For objects and arrays, the first and last characters correspond to the opening or closing braces/brackets, respectively. For fields, the first
|
||||
and last character represent the opening and closing quotes or the first and last character of the field's numerical or predefined value
|
||||
(true/false/null), respectively.
|
||||
|
||||
Given the above, `end_pos() - start_pos()` for an object or field provides the length of the string representation for that object or field, including the
|
||||
opening or closing braces, brackets, or quotes.
|
||||
|
||||
`start_pos()` and `end_pos()` are only set if the JSON object was parsed using `parse()`. For all other cases, `std::string::npos` will be returned.
|
||||
|
||||
Note that enabling this macro increases the size of every JSON value by two `std::size_t` fields and adds
|
||||
slight runtime overhead.
|
||||
|
||||
## Default definition
|
||||
|
||||
The default value is `0` (position diagnostics are switched off).
|
||||
|
||||
```cpp
|
||||
#define JSON_DIAGNOSTIC_POSITIONS 0
|
||||
```
|
||||
|
||||
When the macro is not defined, the library will define it to its default value.
|
||||
|
||||
## Notes
|
||||
|
||||
!!! hint "CMake option"
|
||||
|
||||
Diagnostic messages can also be controlled with the CMake option
|
||||
[`JSON_Diagnostic_Positions`](../../integration/cmake.md#json_diagnostic_positions) (`OFF` by default)
|
||||
which defines `JSON_DIAGNOSTIC_POSITIONS` accordingly.
|
||||
|
||||
## Examples
|
||||
|
||||
??? example "Example 1: retrieving positions"
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/diagnostic_positions.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```
|
||||
--8<-- "examples/diagnostic_positions.output"
|
||||
```
|
||||
|
||||
The output shows the start/end positions of all the objects and fields in the JSON string.
|
||||
|
||||
## Version history
|
||||
|
||||
@@ -27,7 +27,7 @@ By default, implicit conversions are enabled.
|
||||
!!! hint "CMake option"
|
||||
|
||||
Implicit conversions can also be controlled with the CMake option
|
||||
[`JSON_ImplicitConversions`](../../integration/cmake.md#json_legacydiscardedvaluecomparison)
|
||||
[`JSON_ImplicitConversions`](../../integration/cmake.md#json_implicitconversions)
|
||||
(`ON` by default) which defines `JSON_USE_IMPLICIT_CONVERSIONS` accordingly.
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -56,7 +56,7 @@ When the macro is not defined, the library will define it to its default value.
|
||||
!!! hint "CMake option"
|
||||
|
||||
Legacy comparison can also be controlled with the CMake option
|
||||
[`JSON_LegacyDiscardedValueComparison`](../../integration/cmake.md#json_legacydiscardedvaluecomparison)
|
||||
[`JSON_LegacyDiscardedValueComparison`](../../integration/cmake.md#json_implicitconversions)
|
||||
(`OFF` by default) which defines `JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON` accordingly.
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
# NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE, NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT
|
||||
|
||||
# NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE, NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT
|
||||
<h1>NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE, NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT,
|
||||
NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE, NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE,
|
||||
NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT, NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE</h1>
|
||||
|
||||
```cpp
|
||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(type, base_type, member...) // (1)
|
||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(type, base_type, member...) // (2)
|
||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(type, base_type, member...) // (1)
|
||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(type, base_type, member...) // (2)
|
||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE(type, base_type, member...) // (3)
|
||||
|
||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(type, base_type, member...) // (3)
|
||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(type, base_type, member...) // (4)
|
||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(type, base_type, member...) // (4)
|
||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(type, base_type, member...) // (5)
|
||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(type, base_type, member...) // (6)
|
||||
```
|
||||
|
||||
These macros can be used to simplify the serialization/deserialization of derived types if you want to use a JSON
|
||||
object as serialization and want to use the member variable names as object keys in that object.
|
||||
|
||||
- Macros 1 and 2 are to be defined **inside** the class/struct to create code for.
|
||||
- Macros 1, 2 and 3 are to be defined **inside** the class/struct to create code for.
|
||||
Like [`NLOHMANN_DEFINE_TYPE_INTRUSIVE`](nlohmann_define_type_intrusive.md), they can access private members.
|
||||
- Macros 3 and 4 are to be defined **outside** the class/struct to create code for, but **inside** its namespace.
|
||||
- Macros 4, 5 and 6 are to be defined **outside** the class/struct to create code for, but **inside** its namespace.
|
||||
Like [`NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`](nlohmann_define_type_non_intrusive.md),
|
||||
they **cannot** access private members.
|
||||
|
||||
|
||||
The first parameter is the name of the derived class/struct,
|
||||
the second parameter is the name of the base class/struct and all remaining parameters name the members.
|
||||
The base type **must** be already serializable/deserializable.
|
||||
@@ -50,14 +51,20 @@ friend void to_json(nlohmann::json&, const type&);
|
||||
friend void from_json(const nlohmann::json&, type&);
|
||||
```
|
||||
|
||||
Macros 3 and 4 add two functions to the namespace which take care of the serialization and deserialization:
|
||||
Macros 4 and 5 add two functions to the namespace which take care of the serialization and deserialization:
|
||||
|
||||
```cpp
|
||||
void to_json(nlohmann::json&, const type&);
|
||||
void from_json(const nlohmann::json&, type&);
|
||||
```
|
||||
|
||||
In both cases they call the `to_json`/`from_json` functions of the base type
|
||||
Macros 3 and 6 add one function to the namespace which take care of the serialization only:
|
||||
|
||||
```cpp
|
||||
void to_json(nlohmann::json&, const type&);
|
||||
```
|
||||
|
||||
In first two cases cases they call the `to_json`/`from_json` functions of the base type
|
||||
before serializing/deserializing the members of the derived type:
|
||||
|
||||
```cpp
|
||||
@@ -75,12 +82,24 @@ void from_json(const nlohmann::json& j, B& b) {
|
||||
}
|
||||
```
|
||||
|
||||
In the third case only `to_json` will be called:
|
||||
|
||||
```cpp
|
||||
class A { /* ... */ };
|
||||
class B : public A { /* ... */ };
|
||||
|
||||
void to_json(nlohmann::json& j, const B& b) {
|
||||
nlohmann::to_json(j, static_cast<const A&>(b));
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
!!! info "Prerequisites"
|
||||
|
||||
- Macros 1 and 2 have the same prerequisites of NLOHMANN_DEFINE_TYPE_INTRUSIVE.
|
||||
- Macros 3 and 3 have the same prerequisites of NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE.
|
||||
- Macros 1, 2 and 3 have the same prerequisites of NLOHMANN_DEFINE_TYPE_INTRUSIVE.
|
||||
- Macros 4, 5 and 6 have the same prerequisites of NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE.
|
||||
- Serialization/deserialization of base types must be defined.
|
||||
|
||||
!!! warning "Implementation limits"
|
||||
@@ -110,7 +129,7 @@ class B : public A {
|
||||
- [NLOHMANN_DEFINE_TYPE_INTRUSIVE / NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT](nlohmann_define_type_intrusive.md)
|
||||
for similar macros that can be defined _inside_ a non-derived type.
|
||||
- [NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE / NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT](nlohmann_define_type_non_intrusive.md)
|
||||
for a similar macros that can be defined _outside_ a non-derived type.
|
||||
for similar macros that can be defined _outside_ a non-derived type.
|
||||
- [Arbitrary Type Conversions](../../features/arbitrary_types.md) for an overview.
|
||||
|
||||
## Version history
|
||||
|
||||
@@ -17,7 +17,7 @@ using namespace nlohmann;
|
||||
```
|
||||
|
||||
This is suggested to ease migration to the next major version release of the library. See
|
||||
['JSON_USE_GLOBAL_UDLS`](macros/json_use_global_udls.md#notes) for details.
|
||||
[`JSON_USE_GLOBAL_UDLS`](macros/json_use_global_udls.md#notes) for details.
|
||||
|
||||
## Parameters
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ using namespace nlohmann::literals::json_literals;
|
||||
using namespace nlohmann;
|
||||
```
|
||||
This is suggested to ease migration to the next major version release of the library. See
|
||||
['JSON_USE_GLOBAL_UDLS`](macros/json_use_global_udls.md#notes) for details.
|
||||
[`JSON_USE_GLOBAL_UDLS`](macros/json_use_global_udls.md#notes) for details.
|
||||
|
||||
## Parameters
|
||||
|
||||
|
||||
@@ -6,6 +6,13 @@ using ordered_json = basic_json<ordered_map>;
|
||||
|
||||
This type preserves the insertion order of object keys.
|
||||
|
||||
## Iterator invalidation
|
||||
|
||||
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.
|
||||
|
||||
## Examples
|
||||
|
||||
??? example
|
||||
|
||||
@@ -23,6 +23,11 @@ A minimal map-like container that preserves insertion order for use within [`nlo
|
||||
`Allocator`
|
||||
: allocator type
|
||||
|
||||
## Iterator invalidation
|
||||
|
||||
The type uses a `std::vector` to store object elements. Therefore, adding elements can yield a reallocation in which
|
||||
case all iterators (including the `end()` iterator) and all references to the elements are invalidated.
|
||||
|
||||
## Member types
|
||||
|
||||
- **key_type** - key type (`Key`)
|
||||
|
||||
@@ -75,7 +75,7 @@ Likewise, when calling `template get<your_type>()` or `get_to(your_type&)`, the
|
||||
Some important things:
|
||||
|
||||
* Those methods **MUST** be in your type's namespace (which can be the global namespace), or the library will not be able to locate them (in this example, they are in namespace `ns`, where `person` is defined).
|
||||
* Those methods **MUST** be available (e.g., proper headers must be included) everywhere you use these conversions. Look at [issue 1108](https://github.com/nlohmann/json/issues/1108) for errors that may occur otherwise.
|
||||
* Those methods **MUST** be available (e.g., proper headers must be included) everywhere you use these conversions. Look at [#1108](https://github.com/nlohmann/json/issues/1108) for errors that may occur otherwise.
|
||||
* When using `template get<your_type>()`, `your_type` **MUST** be [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). (There is a way to bypass this requirement described later.)
|
||||
* In function `from_json`, use function [`at()`](../api/basic_json/at.md) to access the object values rather than `operator[]`. In case a key does not exist, `at` throws an exception that you can handle, whereas `operator[]` exhibits undefined behavior.
|
||||
* You do not need to add serializers or deserializers for STL types like `std::vector`: the library already implements these.
|
||||
|
||||
@@ -103,29 +103,38 @@ behavior and yields a runtime assertion.
|
||||
Assertion failed: (m_object != nullptr), function operator++, file iter_impl.hpp, line 368.
|
||||
```
|
||||
|
||||
### Reading from a null `FILE` pointer
|
||||
## Changes
|
||||
|
||||
Reading from a null `#!cpp FILE` pointer is undefined behavior and yields a runtime assertion. This can happen when
|
||||
calling `#!cpp std::fopen` on a nonexistent file.
|
||||
### Reading from a null `FILE` or `char` pointer
|
||||
|
||||
??? example "Example 4: Uninitialized iterator"
|
||||
Reading from a null `#!cpp FILE` or `#!cpp char` pointer in C++ is undefined behavior. Until version 3.11.4, this
|
||||
library asserted that the pointer was not `nullptr` using a runtime assertion. If assertions were disabled, this would
|
||||
result in undefined behavior. Since version 3.11.4, this library checks for `nullptr` and throws a
|
||||
[`parse_error.101`](../home/exceptions.md#jsonexceptionparse_error101) to prevent the undefined behavior.
|
||||
|
||||
??? example "Example 4: Reading from null pointer"
|
||||
|
||||
The following code will trigger an assertion at runtime:
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::FILE* f = std::fopen("nonexistent_file.json", "r");
|
||||
json j = json::parse(f);
|
||||
std::FILE* f = std::fopen("nonexistent_file.json", "r");
|
||||
try {
|
||||
json j = json::parse(f);
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```
|
||||
Assertion failed: (m_file != nullptr), function file_input_adapter, file input_adapters.hpp, line 55.
|
||||
[json.exception.parse_error.101] parse error: attempting to parse an empty input; check that your input string or stream contains the expected JSON
|
||||
```
|
||||
|
||||
@@ -10,17 +10,19 @@ serialized JSON text if they have been created manually or via a binary format.
|
||||
|
||||
## API for binary values
|
||||
|
||||
```plantuml
|
||||
class json::binary_t {
|
||||
-- setters --
|
||||
```mermaid
|
||||
classDiagram
|
||||
|
||||
class binary_t ["json::binary_t"] {
|
||||
+void set_subtype(std::uint64_t subtype)
|
||||
+void clear_subtype()
|
||||
-- getters --
|
||||
+std::uint64_t subtype() const
|
||||
+bool has_subtype() const
|
||||
}
|
||||
|
||||
"std::vector<uint8_t>" <|-- json::binary_t
|
||||
class vector ["std::vector<uint8_t>"]
|
||||
|
||||
vector <|-- binary_t
|
||||
```
|
||||
|
||||
By default, binary values are stored as `std::vector<std::uint8_t>`. This type can be changed by providing a template
|
||||
|
||||
@@ -5,9 +5,9 @@ This library does not support comments *by default*. It does so for three reason
|
||||
1. Comments are not part of the [JSON specification](https://tools.ietf.org/html/rfc8259). You may argue that `//` or `/* */` are allowed in JavaScript, but JSON is not JavaScript.
|
||||
2. This was not an oversight: Douglas Crockford [wrote on this](https://plus.google.com/118095276221607585885/posts/RK8qyGVaGSr) in May 2012:
|
||||
|
||||
> I removed comments from JSON because I saw people were using them to hold parsing directives, a practice which would have destroyed interoperability. I know that the lack of comments makes some people sad, but it shouldn't.
|
||||
> I removed comments from JSON because I saw people were using them to hold parsing directives, a practice which would have destroyed interoperability. I know that the lack of comments makes some people sad, but it shouldn't.
|
||||
|
||||
> Suppose you are using JSON to keep configuration files, which you would like to annotate. Go ahead and insert all the comments you like. Then pipe it through JSMin before handing it to your JSON parser.
|
||||
> Suppose you are using JSON to keep configuration files, which you would like to annotate. Go ahead and insert all the comments you like. Then pipe it through JSMin before handing it to your JSON parser.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ for (auto& [key, val] : j_object.items())
|
||||
|
||||
!!! warning
|
||||
|
||||
Using `items()` on temporary objects is dangerous. Make sure the object's lifetime exceeds the iteration. See <https://github.com/nlohmann/json/issues/2040> for more information.
|
||||
Using `items()` on temporary objects is dangerous. Make sure the object's lifetime exceeds the iteration. See [#2040](https://github.com/nlohmann/json/issues/2040) for more information.
|
||||
|
||||
### Reverse iteration order
|
||||
|
||||
|
||||
@@ -100,6 +100,13 @@ When defined to `0`, implicit conversions are switched off. By default, implicit
|
||||
|
||||
See [full documentation of `JSON_USE_IMPLICIT_CONVERSIONS`](../api/macros/json_use_implicit_conversions.md).
|
||||
|
||||
## `NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(type, base_type, member...)`
|
||||
## `NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(type, base_type, member...)`
|
||||
## `NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE(type, base_type, member...)`
|
||||
## `NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(type, base_type, member...)`
|
||||
## `NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(type, base_type, member...)`
|
||||
## `NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(type, base_type, member...)`
|
||||
|
||||
## `NLOHMANN_DEFINE_TYPE_INTRUSIVE(type, member...)`
|
||||
|
||||
This macro can be used to simplify the serialization/deserialization of types if (1) want to use a JSON object as
|
||||
|
||||
@@ -30,15 +30,16 @@ nlohmann::json_abi_diag_v3_11_2
|
||||
Several incompatibilities have been observed. Amongst the most common ones is linking code compiled with different
|
||||
definitions of [`JSON_DIAGNOSTICS`](../api/macros/json_diagnostics.md). This is illustrated in the diagram below.
|
||||
|
||||
```plantuml
|
||||
[**nlohmann_json (v3.10.5)**\nJSON_DIAGNOSTICS=0] as [json]
|
||||
[**nlohmann_json (v3.10.5)**\nJSON_DIAGNOSTICS=1] as [json_diag]
|
||||
[**some_library**] as [library]
|
||||
[**application**] as [app]
|
||||
|
||||
[library] ..|> [json]
|
||||
[app] ..|> [json_diag]
|
||||
[app] ..|>[library]
|
||||
```mermaid
|
||||
graph
|
||||
json["<strong>nlohmann_json (v3.10.5)</strong><br>JSON_DIAGNOSTICS=0"]
|
||||
json_diag["<strong>nlohmann_json (v3.10.5)</strong><br>JSON_DIAGNOSTICS=1"]
|
||||
library["<strong>some library</strong>"]
|
||||
app["<strong>application</strong>"]
|
||||
|
||||
library --> json
|
||||
app --> json_diag
|
||||
app --> library
|
||||
```
|
||||
|
||||
In releases prior to 3.11.0, mixing any version of the JSON library with different `JSON_DIAGNOSTICS` settings would
|
||||
|
||||
@@ -2,27 +2,30 @@
|
||||
|
||||
The library uses a SAX-like interface with the following functions:
|
||||
|
||||
```plantuml
|
||||
interface json::sax_t {
|
||||
+ {abstract} bool null()
|
||||
```mermaid
|
||||
classDiagram
|
||||
|
||||
+ {abstract} bool boolean(bool val)
|
||||
|
||||
+ {abstract} bool number_integer(number_integer_t val)
|
||||
+ {abstract} bool number_unsigned(number_unsigned_t val)
|
||||
|
||||
+ {abstract} bool number_float(number_float_t val, const string_t& s)
|
||||
|
||||
+ {abstract} bool string(string_t& val)
|
||||
+ {abstract} bool binary(binary_t& val)
|
||||
|
||||
+ {abstract} bool start_object(std::size_t elements)
|
||||
+ {abstract} bool end_object()
|
||||
+ {abstract} bool start_array(std::size_t elements)
|
||||
+ {abstract} bool end_array()
|
||||
+ {abstract} bool key(string_t& val)
|
||||
|
||||
+ {abstract} bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex)
|
||||
class sax_t ["json::sax_t"] {
|
||||
<<interface>>
|
||||
+bool null()*
|
||||
|
||||
+bool boolean(bool val)*
|
||||
|
||||
+bool number_integer(number_integer_t val)*
|
||||
+bool number_unsigned(number_unsigned_t val)*
|
||||
|
||||
+bool number_float(number_float_t val, const string_t& s)*
|
||||
|
||||
+bool string(string_t& val)*
|
||||
+bool binary(binary_t& val)*
|
||||
|
||||
+bool start_object(std::size_t elements)*
|
||||
+bool end_object()*
|
||||
+bool start_array(std::size_t elements)*
|
||||
+bool end_array()*
|
||||
+bool key(string_t& val)*
|
||||
|
||||
+bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex)*
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -19,8 +19,11 @@ Note there are three different types for numbers - when parsing JSON text, the b
|
||||
|
||||
## Storage
|
||||
|
||||
```plantuml
|
||||
enum value_t {
|
||||
```mermaid
|
||||
classDiagram
|
||||
|
||||
class value_t {
|
||||
<<enumeration>>
|
||||
null
|
||||
object
|
||||
array
|
||||
@@ -33,7 +36,8 @@ enum value_t {
|
||||
discarded
|
||||
}
|
||||
|
||||
class json_value << (U,orchid) >> {
|
||||
class json_value {
|
||||
<<union>>
|
||||
object_t* object
|
||||
array_t* array
|
||||
string_t* string
|
||||
@@ -45,17 +49,15 @@ class json_value << (U,orchid) >> {
|
||||
}
|
||||
|
||||
class basic_json {
|
||||
-- type and value --
|
||||
value_t m_type
|
||||
json_value m_value
|
||||
-- derived types --
|
||||
+ <u>typedef</u> object_t
|
||||
+ <u>typedef</u> array_t
|
||||
+ <u>typedef</u> binary_t
|
||||
+ <u>typedef</u> boolean_t
|
||||
+ <u>typedef</u> number_integer_t
|
||||
+ <u>typedef</u> number_unsigned_t
|
||||
+ <u>typedef</u> number_float_t
|
||||
-value_t m_type
|
||||
-json_value m_value
|
||||
+typedef object_t
|
||||
+typedef array_t
|
||||
+typedef binary_t
|
||||
+typedef boolean_t
|
||||
+typedef number_integer_t
|
||||
+typedef number_unsigned_t
|
||||
+typedef number_float_t
|
||||
}
|
||||
|
||||
basic_json .. json_value
|
||||
|
||||
159
docs/mkdocs/docs/home/customers.md
Normal file
159
docs/mkdocs/docs/home/customers.md
Normal file
@@ -0,0 +1,159 @@
|
||||
# Customers
|
||||
|
||||
The library is used in multiple projects, applications, operating systems, etc. The list below is not exhaustive, but
|
||||
the result of an internet search. If you know further customers of the library, [please let me know](mailto:mail@nlohmann.me).
|
||||
|
||||
[](../images/customers.png)
|
||||
|
||||
## Space Exploration
|
||||
|
||||
- [**Peregrine Lunar Lander Flight 01**](https://en.wikipedia.org/wiki/Peregrine_Mission_One) - The library was utilized for payload management in the **Peregrine Moon Lander**, developed by **Astrobotic Technology** and launched as part of NASA's **Commercial Lunar Payload Services (CLPS)** program. After six days in orbit, the spacecraft was intentionally redirected into Earth's atmosphere, where it burned up over the Pacific Ocean on **January 18, 2024**.
|
||||
|
||||
## Automotive
|
||||
|
||||
- [**Alexa Auto SDK**](https://github.com/alexa/alexa-auto-sdk), a software development kit enabling the integration of Alexa into automotive systems
|
||||
- [**Apollo**](https://github.com/ApolloAuto/apollo), a framework for building autonomous driving systems
|
||||
- [**Automotive Grade Linux (AGL)**](https://download.automotivelinux.org/AGL/release/jellyfish/latest/qemux86-64/deploy/licenses/nlohmann-json/): a collaborative open-source platform for automotive software development
|
||||
- [**Genesis Motor** (infotainment)](http://webmanual.genesis.com/ccIC/AVNT/JW/KOR/English/reference010.html), a luxury automotive brand
|
||||
- [**Hyundai** (infotainment)](https://www.hyundai.com/wsvc/ww/download.file.do?id=/content/hyundai/ww/data/opensource/data/GN7-2022/licenseCode/info), a global automotive brand
|
||||
- [**Kia** (infotainment)](http://webmanual.kia.com/PREM_GEN6/AVNT/RJPE/KOR/Korean/reference010.html), a global automotive brand
|
||||
- [**Mercedes-Benz Operating System (MB.OS)**](https://group.mercedes-benz.com/careers/about-us/mercedes-benz-operating-system/), a core component of the vehicle software ecosystem from Mercedes-Benz
|
||||
- [**Rivian** (infotainment)](https://assets.ctfassets.net/2md5qhoeajym/3cwyo4eoufk4yingUwusFt/ded2c47da620fdfc99c88c7156d2c1d8/In-Vehicle_OSS_Attribution_2024__11-24_.pdf), an electric vehicle manufacturer
|
||||
- [**Suzuki** (infotainment)](https://www.globalsuzuki.com/motorcycle/ipc/oss/oss_48KA_00.pdf), a global automotive and motorcycle manufacturer
|
||||
|
||||
## Gaming and Entertainment
|
||||
|
||||
- [**Assassin's Creed: Mirage**](https://www.mobygames.com/person/1195889/niels-lohmann/credits/): a stealth-action game set in the Middle East, focusing on the journey of a young assassin with classic parkour and stealth mechanics
|
||||
- [**Chasm: The Rift**](https://www.mobygames.com/person/1195889/niels-lohmann/credits/): a first-person shooter blending horror and adventure, where players navigate dark realms and battle monsters
|
||||
- [**College Football 25**](https://www.mobygames.com/person/1195889/niels-lohmann/credits/): a college football simulation game featuring gameplay that mimics real-life college teams and competitions
|
||||
- [**Concepts**](https://concepts.app/en/licenses): a digital sketching app designed for creative professionals, offering flexible drawing tools for illustration, design, and brainstorming
|
||||
- [**Depthkit**](https://www.depthkit.tv/third-party-licenses): a tool for creating and capturing volumetric video, enabling immersive 3D experiences and interactive content
|
||||
- [**immersivetech**](https://immersitech.io/open-source-third-party-software/): a technology company focused on immersive experiences, providing tools and solutions for virtual and augmented reality applications
|
||||
- [**LOOT**](https://loot.readthedocs.io/_/downloads/en/0.13.0/pdf/), a tool for optimizing the load order of game plugins, commonly used in The Elder Scrolls and Fallout series
|
||||
- [**Madden NFL 25**](https://www.mobygames.com/person/1195889/niels-lohmann/credits/): a sports simulation game capturing the excitement of American football with realistic gameplay and team management features
|
||||
- [**Marne**](https://marne.io/licenses), an unofficial private server platform for hosting custom Battlefield 1 game experiences
|
||||
- [**Minecraft**](https://www.minecraft.net/zh-hant/attribution), a popular sandbox video game
|
||||
- [**NHL 22**](https://www.mobygames.com/person/1195889/niels-lohmann/credits/): a hockey simulation game offering realistic gameplay, team management, and various modes to enhance the hockey experience
|
||||
- [**Pixelpart**](https://pixelpart.net/documentation/book/third-party.html): a 2D animation and video compositing software that allows users to create animated graphics and visual effects with a focus on simplicity and ease of use
|
||||
- [**Red Dead Redemption II**](https://www.mobygames.com/person/1195889/niels-lohmann/credits/): an open-world action-adventure game following an outlaw's story in the late 1800s, emphasizing deep storytelling and immersive gameplay
|
||||
- [**Tactics Ogre: Reborn**](https://www.square-enix-games.com/en_US/documents/tactics-ogre-reborn-pc-installer-software-and-associated-plug-ins-disclosure), a tactical role-playing game featuring strategic battles and deep storytelling elements
|
||||
- [**Throne and Liberty**](https://www.amazon.com/gp/help/customer/display.html?nodeId=T7fLNw5oAevCMtJFPj&pop-up=1), an MMORPG that offers an expansive fantasy world with dynamic gameplay and immersive storytelling
|
||||
- [**Unity Vivox**](https://docs.unity3d.com/Packages/com.unity.services.vivox@15.1/license/Third%20Party%20Notices.html), a communication service that enables voice and text chat functionality in multiplayer games developed with Unity
|
||||
- [**Zool: Redimensioned**](https://www.mobygames.com/person/1195889/niels-lohmann/credits/): a modern reimagining of the classic platformer featuring fast-paced gameplay and vibrant environments
|
||||
|
||||
## Consumer Electronics
|
||||
|
||||
- [**Audinate**](https://www.audinate.com/legal/software-licensing/dante-av-h-open-source-licenses/): a provider of networked audio solutions specializing in Dante technology, which facilitates high-quality digital audio transport over IP networks
|
||||
- [**Cisco Webex Desk Camera**](https://www.cisco.com/c/dam/en_us/about/doing_business/open_source/docs/CiscoWebexDeskCamera-23-1622100417.pdf), a video camera designed for professional-quality video conferencing and remote collaboration
|
||||
- [**Philips Hue Personal Wireless Lighting**](http://2ak5ape.257.cz/): a smart lighting system for customizable and wireless home illumination
|
||||
- [**Ray-Ban Meta Smart glasses**](https://www.meta.com/de/en/legal/smart-glasses/third-party-notices-android/03/), a pair of smart glasses designed for capturing photos and videos with integrated connectivity and social features
|
||||
- [**Siemens SINEMA Remote Connect**](https://cache.industry.siemens.com/dl/files/790/109793790/att_1054961/v2/OSS_SINEMA-RC_86.pdf), a remote connectivity solution for monitoring and managing industrial networks and devices securely
|
||||
- [**Sony PlayStation 4**](https://doc.dl.playstation.net/doc/ps4-oss/index.html), a gaming console developed by Sony that offers a wide range of games and multimedia entertainment features
|
||||
- [**Sony Virtual Webcam Driver for Remote Camera**](https://helpguide.sony.net/rc/vwd/v1/zh-cn/print.pdf), a software driver that enables the use of Sony cameras as virtual webcams for video conferencing and streaming
|
||||
|
||||
## Operating Systems
|
||||
|
||||
- [**Apple iOS and macOS**](https://www.apple.com/macos), a family of operating systems developed by Apple, including iOS for mobile devices and macOS for desktop computers
|
||||
- [**Google Fuchsia**](https://fuchsia.googlesource.com/third_party/json/), an open-source operating system developed by Google, designed to be secure, updatable, and adaptable across various devices
|
||||
- [**SerenityOS**](https://github.com/SerenityOS/serenity), an open-source operating system that aims to provide a simple and beautiful user experience with a focus on simplicity and elegance
|
||||
- [**Yocto**](http://ftp.emacinc.com/openembedded-sw/kirkstone-icop-5.15-kirkstone-6.0/archive-2024-10/pn8m-090t-ppc/licenses/nlohmann-json/): a Linux-based build system for creating custom operating systems and software distributions, tailored for embedded devices and IoT applications
|
||||
|
||||
## Development Tools and IDEs
|
||||
|
||||
- [**Accentize SpectralBalance**](https://www.accentize.com/products/SpectralBalanceManual.pdf), an adaptive speech analysis tool designed to enhance audio quality by optimizing frequency balance in recordings
|
||||
- [**Arm Compiler for Linux**](https://documentation-service.arm.com/static/66558e9d876c8d213b7843e4), a software development toolchain for compiling and optimizing applications on Arm-based Linux systems
|
||||
- [**BBEdit**](https://s3.amazonaws.com/BBSW-download/BBEdit_15.1.2_User_Manual.pdf), a professional text and code editor for macOS
|
||||
- [**CoderPad**](https://coderpad.io), a collaborative coding platform that enables real-time code interviews and assessments for developers; the library is included in every CoderPad instance and can be accessed with a simple `#include "json.hpp"`
|
||||
- [**Compiler Explorer**](https://godbolt.org), a web-based tool that allows users to write, compile, and visualize the assembly output of code in various programming languages; the library is readily available and accessible with the directive `#include <nlohmann/json.hpp>`.
|
||||
- [**GitHub CodeQL**](https://github.com/github/codeql), a code analysis tool used for identifying security vulnerabilities and bugs in software through semantic queries
|
||||
- [**Hex-Rays**](https://docs.hex-rays.com/user-guide/user-interface/licenses): a reverse engineering toolset for analyzing and decompiling binaries, primarily used for security research and vulnerability analysis
|
||||
- [**ImHex**](https://github.com/WerWolv/ImHex), a hex editor designed for reverse engineering, providing advanced features for data analysis and manipulation
|
||||
- [**Intel GPA Framework**](https://intel.github.io/gpasdk-doc/src/licenses.html), a suite of cross-platform tools for capturing, analyzing, and optimizing graphics applications across different APIs
|
||||
- [**Meta Yoga**](https://github.com/facebook/yoga), a layout engine that facilitates flexible and efficient user interface design across multiple platforms
|
||||
- [**MKVToolNix**](https://mkvtoolnix.download/doc/README.md), a set of tools for creating, editing, and inspecting MKV (Matroska) multimedia container files
|
||||
- [**NVIDIA Nsight Compute**](https://docs.nvidia.com/nsight-compute/2022.2/pdf/CopyrightAndLicenses.pdf), a performance analysis tool for CUDA applications that provides detailed insights into GPU performance metrics
|
||||
- [**Notepad++**](https://github.com/notepad-plus-plus/notepad-plus-plus), a free source code editor that supports various programming languages
|
||||
- [**OpenRGB**](https://gitlab.com/CalcProgrammer1/OpenRGB), an open source RGB lighting control that doesn't depend on manufacturer software
|
||||
- [**OpenTelemetry C++**](https://github.com/open-telemetry/opentelemetry-cpp): a library for collecting and exporting observability data in C++, enabling developers to implement distributed tracing and metrics in their application
|
||||
- [**Qt Creator**](https://doc.qt.io/qtcreator/qtcreator-attribution-json-nlohmann.html), an IDE for developing applications using the Qt application framework
|
||||
- [**Scanbot SDK**](https://docs.scanbot.io/barcode-scanner-sdk/web/third-party-libraries/): a software development kit (SDK) that provides tools for integrating advanced document scanning and barcode scanning capabilities into applications
|
||||
|
||||
## Machine Learning and AI
|
||||
|
||||
- [**Apple Core ML Tools**](https://github.com/apple/coremltools), a set of tools for converting and configuring machine learning models for deployment in Apple's Core ML framework
|
||||
- [**Avular Mobile Robotics**](https://www.avular.com/licenses/nlohmann-json-3.9.1.txt): a platform for developing and deploying mobile robotics solutions
|
||||
- [**Google gemma.cpp**](https://github.com/google/gemma.cpp), a lightweight C++ inference engine designed for running AI models from the Gemma family
|
||||
- [**llama.cpp**](https://github.com/ggerganov/llama.cpp), a C++ library designed for efficient inference of large language models (LLMs), enabling streamlined integration into applications
|
||||
- [**Mozilla llamafile**](https://github.com/Mozilla-Ocho/llamafile), a tool designed for distributing and executing large language models (LLMs) efficiently using a single file format
|
||||
- [**NVIDIA ACE**](https://docs.nvidia.com/ace/latest/index.html), a suite of real-time AI solutions designed for the development of interactive avatars and digital human applications, enabling scalable and sophisticated user interactions
|
||||
- [**Peer**](https://support.peer.inc/hc/en-us/articles/17261335054235-Licenses): a platform offering personalized AI assistants for interactive learning and creative collaboration
|
||||
- [**stable-diffusion.cpp**](https://github.com/leejet/stable-diffusion.cpp): a C++ implementation of the Stable Diffusion image generation model
|
||||
- [**TanvasTouch**](https://tanvas.co/tanvastouch-sdk-third-party-acknowledgments): a software development kit (SDK) that enables developers to create tactile experiences on touchscreens, allowing users to feel textures and physical sensations in a digital environment
|
||||
- [**TensorFlow**](https://github.com/tensorflow/tensorflow), a machine learning framework that facilitates the development and training of models, supporting data serialization and efficient data exchange between components
|
||||
|
||||
## Scientific Research and Analysis
|
||||
|
||||
- [**BLACK**](https://www.black-sat.org/en/stable/installation/linux.html), a bounded linear temporal logic (LTL) satisfiability checker
|
||||
- [**CERN Atlas Athena**](https://gitlab.cern.ch/atlas/athena/-/blob/main/Control/PerformanceMonitoring/PerfMonComps/src/PerfMonMTSvc.h), a software framework used in the ATLAS experiment at the Large Hadron Collider (LHC) for performance monitoring
|
||||
- [**KAMERA**](https://github.com/Kitware/kamera): a platform for synchronized data collection and real-time deep learning to map marine species like polar bears and seals, aiding Arctic ecosystem research
|
||||
- [**KiCad**](https://gitlab.com/kicad/code/kicad/-/tree/master/thirdparty/nlohmann_json): a free and open-source software suite for electronic design automation
|
||||
- [**MeVisLab**](https://mevislabdownloads.mevis.de/docs/current/MeVis/ThirdParty/Documentation/Publish/ThirdPartyReference/index.html): a software framework for medical image processing and visualization.
|
||||
- [**OpenPMD API**](https://openpmd-api.readthedocs.io/en/0.8.0-alpha/backends/json.html): a versatile programming interface for accessing and managing scientific data, designed to facilitate the efficient storage, retrieval, and sharing of simulation data across various applications and platforms
|
||||
- [**ParaView**](https://github.com/Kitware/ParaView): an open-source tool for large-scale data visualization and analysis across various scientific domains
|
||||
- [**QGIS**](https://gitlab.b-data.ch/qgis/qgis/-/blob/backport-57658-to-release-3_34/external/nlohmann/json.hpp): a free and open-source geographic information system (GIS) application that allows users to create, edit, visualize, and analyze geospatial data across a variety of formats
|
||||
- [**VTK**](https://github.com/Kitware/VTK): a software library for 3D computer graphics, image processing, and visualization
|
||||
- [**VolView**](https://github.com/Kitware/VolView): a lightweight application for interactive visualization and analysis of 3D medical imaging data.
|
||||
|
||||
## Business and Productivity Software
|
||||
|
||||
- [**ArcGIS PRO**](https://www.esri.com/content/dam/esrisites/en-us/media/legal/open-source-acknowledgements/arcgis-pro-2-8-attribution-report.html), a desktop geographic information system (GIS) application developed by Esri for mapping and spatial analysis
|
||||
- [**Autodesk Desktop**](https://damassets.autodesk.net/content/dam/autodesk/www/Company/legal-notices-trademarks/autodesk-desktop-platform-components/internal-autodesk-components-web-page-2023.pdf), a software platform developed by Autodesk for creating and managing desktop applications and services
|
||||
- [**Check Point**](https://www.checkpoint.com/about-us/copyright-and-trademarks/): a cybersecurity company specializing in threat prevention and network security solutions, offering a range of products designed to protect enterprises from cyber threats and ensure data integrity
|
||||
- [**Microsoft Office for Mac**](https://officecdnmac.microsoft.com/pr/legal/mac/OfficeforMacAttributions.html), a suite of productivity applications developed by Microsoft for macOS, including tools for word processing, spreadsheets, and presentations
|
||||
- [**Nexthink Infinity**](https://docs.nexthink.com/legal/services-terms/experience-open-source-software-licenses/infinity-2022.8-software-licenses): a digital employee experience management platform for monitoring and improving IT performance
|
||||
- [**Sophos Connect Client**](https://docs.sophos.com/nsg/licenses/SophosConnect/SophosConnectAttribution.html): a secure VPN client from Sophos that allows remote users to connect to their corporate network, ensuring secure access to resources and data
|
||||
- [**Stonebranch**](https://stonebranchdocs.atlassian.net/wiki/spaces/UA77/pages/799545647/Licenses+for+Third-Party+Libraries): a cloud-based cybersecurity solution that integrates backup, disaster recovery, and cybersecurity features to protect data and ensure business continuity for organizations
|
||||
- [**Tablecruncher**](https://tablecruncher.com/): a data analysis tool that allows users to import, analyze, and visualize spreadsheet data, offering interactive features for better insights and decision-making
|
||||
- [**magicplan**](https://help.magicplan.app/acknowledgments), a mobile application for creating floor plans and interior designs using augmented reality
|
||||
|
||||
## Databases and Big Data
|
||||
|
||||
- [**ADIOS2**](https://code.ornl.gov/ecpcitest/adios2/-/tree/pr4285_FFSUpstream/thirdparty/nlohmann_json?ref_type=heads): a data management framework designed for high-performance input and output operations
|
||||
- [**Cribl Stream**](https://docs.cribl.io/stream/third-party-current-list/): a real-time data processing platform that enables organizations to collect, route, and transform observability data, enhancing visibility and insights into their systems
|
||||
- [**DB Browser for SQLite**](https://github.com/sqlitebrowser/sqlitebrowser), a visual open-source tool for creating, designing, and editing SQLite database files
|
||||
- [**MySQL Connector/C++**](https://docs.oracle.com/cd/E17952_01/connector-cpp-9.1-license-com-en/license-opentelemetry-cpp-com.html), a C++ library for connecting and interacting with MySQL databases
|
||||
- [**MySQL NDB Cluster**](https://downloads.mysql.com/docs/licenses/cluster-9.0-com-en.pdf), a distributed database system that provides high availability and scalability for MySQL databases
|
||||
- [**PrestoDB**](https://github.com/prestodb/presto), a distributed SQL query engine designed for large-scale data analytics, originally developed by Facebook
|
||||
- [**ROOT Data Analysis Framework**](https://root.cern/doc/v614/classnlohmann_1_1basic__json.html), an open-source data analysis framework widely used in high-energy physics and other fields for data processing and visualization
|
||||
|
||||
## Simulation and Modeling
|
||||
|
||||
- [**Arcturus HoloSuite**](https://www.datocms-assets.com/104353/1698904597-holosuite-third-party-software-credits-and-attributions-2.pdf), a software toolset for capturing, editing, and streaming volumetric video, featuring advanced compression technologies for high-quality 3D content creation
|
||||
- [**azul**](https://pure.tudelft.nl/ws/files/85338589/tgis.12673.pdf), a fast and efficient 3D city model viewer designed for visualizing urban environments and spatial data
|
||||
- [**Blender**](https://projects.blender.org/blender/blender/search?q=nlohmann), a free and open-source 3D creation suite for modeling, animation, rendering, and more
|
||||
- [**cpplot**](https://cpplot.readthedocs.io/en/latest/library_api/function_eigen_8h_1ac080eac0541014c5892a55e41bf785e6.html), a library for creating interactive graphs and charts in C++, which can be viewed in web browsers
|
||||
- [**NVIDIA Omniverse**](https://docs.omniverse.nvidia.com/composer/latest/common/product-licenses/usd-explorer/usd-explorer-2023.2.0-licenses-manifest.html), a platform for 3D content creation and collaboration that enables real-time simulations and interactive experiences across various industries
|
||||
- [**Pixar Renderman**](https://rmanwiki-26.pixar.com/space/REN26/19662083/Legal+Notice), a photorealistic 3D rendering software developed by Pixar, widely used in the film industry for creating high-quality visual effects and animations
|
||||
- [**ROS - Robot Operating System**](http://docs.ros.org/en/noetic/api/behaviortree_cpp/html/json_8hpp_source.html), a set of software libraries and tools that assist in developing robot applications
|
||||
- [**UBS**](https://www.ubs.com/), a multinational financial services and banking company
|
||||
- [**GAMS**](https://www.gams.com/47/docs/THIRDPARTY.html): a high-performance mathematical modeling system for optimization and decision support
|
||||
- [**M-Star**](https://docs.mstarcfd.com/3_Licensing/thirdparty-licenses.html): a computational fluid dynamics software for simulating and analyzing fluid flow
|
||||
- [**MapleSim CAD Toolbox**](https://www.maplesoft.com/support/help/MapleSim/view.aspx?path=CADToolbox/copyright): a software extension for MapleSim that integrates CAD models, allowing users to import, manipulate, and analyze 3D CAD data within the MapleSim environment for enhanced modeling and simulation
|
||||
- [**Kitware SMTK**](https://github.com/Kitware/SMTK): a software toolkit for managing simulation models and workflows in scientific and engineering applications
|
||||
|
||||
## Enterprise and Cloud Applications
|
||||
|
||||
- [**Acronis Cyber Protect Cloud**](https://care.acronis.com/s/article/59533-Third-party-software-used-in-Acronis-Cyber-Protect-Cloud?language=en_US): an all-in-one data protection solution that combines backup, disaster recovery, and cybersecurity to safeguard business data from threats like ransomware
|
||||
- [**Baereos**](https://gitlab.tiger-computing.co.uk/packages/bareos/-/blob/tiger/bullseye/third-party/CLI11/examples/json.cpp): a backup solution that provides data protection and recovery options for various environments, including physical and virtual systems
|
||||
- [**Bitdefender Home Scanner**](https://www.bitdefender.de/site/Main/view/home-scanner-open-source.html), a tool from Bitdefender that scans devices for malware and security threats, providing a safeguard against potential online dangers
|
||||
- [**Citrix Provisioning**](https://docs.citrix.com/en-us/provisioning/2203-ltsr/downloads/pvs-third-party-notices-2203.pdf): a solution that streamlines the delivery of virtual desktops and applications by allowing administrators to manage and provision resources efficiently across multiple environments
|
||||
- [**Citrix Virtual Apps and Desktops**](https://docs.citrix.com/en-us/citrix-virtual-apps-desktops/2305/downloads/third-party-notices-apps-and-desktops.pdf), a solution from Citrix that delivers virtual apps and desktops
|
||||
- [**Cyberarc**](https://docs.cyberark.com/Downloads/Legal/Privileged%20Session%20Manager%20for%20SSH%20Third-Party%20Notices.pdf): a security solution that specializes in privileged access management, enabling organizations to control and monitor access to critical systems and data, thereby enhancing overall cybersecurity posture
|
||||
- [**Egnyte Desktop**](https://helpdesk.egnyte.com/hc/en-us/articles/360007071732-Third-Party-Software-Acknowledgements): a secure cloud storage solution designed for businesses, enabling file sharing, collaboration, and data management across teams while ensuring compliance and data protection
|
||||
- [**Ethereum Solidity**](https://github.com/ethereum/solidity), a high-level, object-oriented programming language designed for implementing smart contracts on the Ethereum platform
|
||||
- [**Inciga**](https://fossies.org/linux/icinga2/third-party/nlohmann_json/json.hpp): a monitoring tool for IT infrastructure, designed to provide insights into system performance and availability through customizable dashboards and alerts
|
||||
- [**Intel Accelerator Management Daemon for VMware ESXi**](https://downloadmirror.intel.com/772507/THIRD-PARTY.txt): a management tool designed for monitoring and controlling Intel hardware accelerators within VMware ESXi environments, optimizing performance and resource allocation
|
||||
- [**Juniper Identity Management Service**](https://www.juniper.net/documentation/us/en/software/jims/jims-guide/jims-guide.pdf)
|
||||
- [**Microsoft Azure IoT SDK**](https://library.e.abb.com/public/2779c5f85f30484192eb3cb3f666a201/IP%20Gateway%20Open%20License%20Declaration_9AKK108467A4095_Rev_C.pdf), a collection of tools and libraries to help developers connect, build, and deploy Internet of Things (IoT) solutions on the Azure cloud platform
|
||||
- [**Microsoft WinGet**](https://github.com/microsoft/winget-cli), a command-line utility included in the Windows Package Manager
|
||||
- [**Pointr**](https://docs-dev.pointr.tech/docs/8.x/Developer%20Portal/Open%20Source%20Licenses/): a platform for indoor positioning and navigation solutions, offering tools and SDKs for developers to create location-based applications
|
||||
@@ -2,7 +2,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.
|
||||
|
||||
- **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.
|
||||
|
||||
|
||||
@@ -6,24 +6,33 @@
|
||||
|
||||
All exceptions inherit from class `json::exception` (which in turn inherits from `std::exception`). It is used as the base class for all exceptions thrown by the `basic_json` class. This class can hence be used as "wildcard" to catch exceptions.
|
||||
|
||||
```plantuml
|
||||
std::exception <|-- json::exception
|
||||
json::exception <|-- json::parse_error
|
||||
json::exception <|-- json::invalid_iterator
|
||||
json::exception <|-- json::type_error
|
||||
json::exception <|-- json::out_of_range
|
||||
json::exception <|-- json::other_error
|
||||
``` mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class `std::exception` {
|
||||
<<interface>>
|
||||
}
|
||||
|
||||
interface std::exception {}
|
||||
class `json::exception` {
|
||||
+const int id
|
||||
+const char* what() const
|
||||
}
|
||||
|
||||
class json::exception {
|
||||
+ const int id
|
||||
+ const char* what() const
|
||||
}
|
||||
class `json::parse_error` {
|
||||
+const std::size_t byte
|
||||
}
|
||||
|
||||
class json::parse_error {
|
||||
+ const std::size_t byte
|
||||
}
|
||||
class `json::invalid_iterator`
|
||||
class `json::type_error`
|
||||
class `json::out_of_range`
|
||||
class `json::other_error`
|
||||
|
||||
`std::exception` <|-- `json::exception`
|
||||
`json::exception` <|-- `json::parse_error`
|
||||
`json::exception` <|-- `json::invalid_iterator`
|
||||
`json::exception` <|-- `json::type_error`
|
||||
`json::exception` <|-- `json::out_of_range`
|
||||
`json::exception` <|-- `json::other_error`
|
||||
```
|
||||
|
||||
### Switch off exceptions
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
You can sponsor this library at [GitHub Sponsors](https://github.com/sponsors/nlohmann).
|
||||
|
||||
## Priority Sponsor
|
||||
|
||||
- [Martti Laine](https://github.com/codeclown)
|
||||
- [Paul Harrington](https://github.com/phrrngtn)
|
||||
|
||||
## Named Sponsors
|
||||
|
||||
- [Michael Hartmann](https://github.com/reFX-Mike)
|
||||
@@ -9,5 +14,6 @@ You can sponsor this library at [GitHub Sponsors](https://github.com/sponsors/nl
|
||||
- [Steve Sperandeo](https://github.com/homer6)
|
||||
- [Robert Jefe Lindstädt](https://github.com/eljefedelrodeodeljefe)
|
||||
- [Steve Wagner](https://github.com/ciroque)
|
||||
- [Lion Yang](https://github.com/LionNatsu)
|
||||
|
||||
Thanks everyone!
|
||||
|
||||
BIN
docs/mkdocs/docs/images/customers.png
Normal file
BIN
docs/mkdocs/docs/images/customers.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
5
docs/mkdocs/docs/integration/bazel/BUILD
Normal file
5
docs/mkdocs/docs/integration/bazel/BUILD
Normal file
@@ -0,0 +1,5 @@
|
||||
cc_binary(
|
||||
name = "main",
|
||||
srcs = ["example.cpp"],
|
||||
deps = ["@nlohmann_json//:json"],
|
||||
)
|
||||
7
docs/mkdocs/docs/integration/bazel/WORKSPACE
Normal file
7
docs/mkdocs/docs/integration/bazel/WORKSPACE
Normal file
@@ -0,0 +1,7 @@
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
http_archive(
|
||||
name = "nlohmann_json",
|
||||
urls = ["https://github.com/nlohmann/json/archive/refs/tags/v3.11.3.tar.gz"],
|
||||
strip_prefix = "json-3.11.3",
|
||||
)
|
||||
10
docs/mkdocs/docs/integration/bazel/example.cpp
Normal file
10
docs/mkdocs/docs/integration/bazel/example.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << std::setw(4) << json::meta() << std::endl;
|
||||
}
|
||||
7
docs/mkdocs/docs/integration/cget/CMakeLists.txt
Normal file
7
docs/mkdocs/docs/integration/cget/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(json_example)
|
||||
|
||||
find_package(nlohmann_json REQUIRED)
|
||||
|
||||
add_executable(json_example example.cpp)
|
||||
target_link_libraries(json_example PRIVATE nlohmann_json::nlohmann_json)
|
||||
10
docs/mkdocs/docs/integration/cget/example.cpp
Normal file
10
docs/mkdocs/docs/integration/cget/example.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << std::setw(4) << json::meta() << std::endl;
|
||||
}
|
||||
@@ -119,9 +119,7 @@ automatically download a release as a dependency at configure type.
|
||||
)
|
||||
```
|
||||
|
||||
However, the repository <https://github.com/nlohmann/json> download size is quite large. You might want to depend on
|
||||
a smaller repository. For instance, you might want to replace the URL in the example by
|
||||
<https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent>.
|
||||
However, the repository <https://github.com/nlohmann/json> download size is quite large.
|
||||
|
||||
## CMake Options
|
||||
|
||||
@@ -137,6 +135,9 @@ Enable CI build targets. The exact targets are used during the several CI steps
|
||||
|
||||
Enable [extended diagnostic messages](../home/exceptions.md#extended-diagnostic-messages) by defining macro [`JSON_DIAGNOSTICS`](../api/macros/json_diagnostics.md). This option is `OFF` by default.
|
||||
|
||||
### `JSON_Diagnostic_Positions`
|
||||
Enable position diagnostics by defining macro [`JSON_DIAGNOSTIC_POSITIONS`](../api/macros/json_diagnostic_positions.md). This option is off by default.
|
||||
|
||||
### `JSON_DisableEnumSerialization`
|
||||
|
||||
Disable default `enum` serialization by defining the macro
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(json_example)
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
add_definitions("-std=c++11")
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup()
|
||||
find_package(nlohmann_json REQUIRED)
|
||||
|
||||
add_executable(json_example example.cpp)
|
||||
target_link_libraries(json_example ${CONAN_LIBS})
|
||||
target_link_libraries(json_example PRIVATE nlohmann_json::nlohmann_json)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
[requires]
|
||||
nlohmann_json/3.7.3
|
||||
nlohmann_json/3.11.3
|
||||
|
||||
[generators]
|
||||
cmake
|
||||
CMakeToolchain
|
||||
CMakeDeps
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << json::meta() << std::endl;
|
||||
std::cout << std::setw(4) << json::meta() << std::endl;
|
||||
}
|
||||
|
||||
9
docs/mkdocs/docs/integration/cpm/CMakeLists.txt
Normal file
9
docs/mkdocs/docs/integration/cpm/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(json_example)
|
||||
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/CPM.cmake)
|
||||
|
||||
CPMAddPackage("gh:nlohmann/json@3.11.3")
|
||||
|
||||
add_executable(json_example example.cpp)
|
||||
target_link_libraries(json_example PRIVATE nlohmann_json::nlohmann_json)
|
||||
10
docs/mkdocs/docs/integration/cpm/example.cpp
Normal file
10
docs/mkdocs/docs/integration/cpm/example.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << std::setw(4) << json::meta() << std::endl;
|
||||
}
|
||||
7
docs/mkdocs/docs/integration/homebrew/CMakeLists.txt
Normal file
7
docs/mkdocs/docs/integration/homebrew/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(json_example)
|
||||
|
||||
find_package(nlohmann_json CONFIG REQUIRED)
|
||||
|
||||
add_executable(json_example example.cpp)
|
||||
target_link_libraries(json_example PRIVATE nlohmann_json::nlohmann_json)
|
||||
10
docs/mkdocs/docs/integration/homebrew/example.cpp
Normal file
10
docs/mkdocs/docs/integration/homebrew/example.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << std::setw(4) << json::meta() << std::endl;
|
||||
}
|
||||
15
docs/mkdocs/docs/integration/hunter/CMakeLists.txt
Normal file
15
docs/mkdocs/docs/integration/hunter/CMakeLists.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
include("cmake/HunterGate.cmake")
|
||||
HunterGate(
|
||||
URL "https://github.com/cpp-pm/hunter/archive/v0.23.297.tar.gz"
|
||||
SHA1 "3319fe6a3b08090df7df98dee75134d68e2ef5a3"
|
||||
)
|
||||
|
||||
project(json_example)
|
||||
|
||||
hunter_add_package(nlohmann_json)
|
||||
find_package(nlohmann_json CONFIG REQUIRED)
|
||||
|
||||
add_executable(json_example example.cpp)
|
||||
target_link_libraries(json_example PRIVATE nlohmann_json::nlohmann_json)
|
||||
10
docs/mkdocs/docs/integration/hunter/example.cpp
Normal file
10
docs/mkdocs/docs/integration/hunter/example.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << std::setw(4) << json::meta() << std::endl;
|
||||
}
|
||||
7
docs/mkdocs/docs/integration/macports/CMakeLists.txt
Normal file
7
docs/mkdocs/docs/integration/macports/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(json_example)
|
||||
|
||||
find_package(nlohmann_json CONFIG REQUIRED)
|
||||
|
||||
add_executable(json_example example.cpp)
|
||||
target_link_libraries(json_example PRIVATE nlohmann_json::nlohmann_json)
|
||||
10
docs/mkdocs/docs/integration/macports/example.cpp
Normal file
10
docs/mkdocs/docs/integration/macports/example.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << std::setw(4) << json::meta() << std::endl;
|
||||
}
|
||||
10
docs/mkdocs/docs/integration/meson/example.cpp
Normal file
10
docs/mkdocs/docs/integration/meson/example.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << std::setw(4) << json::meta() << std::endl;
|
||||
}
|
||||
12
docs/mkdocs/docs/integration/meson/meson.build
Normal file
12
docs/mkdocs/docs/integration/meson/meson.build
Normal file
@@ -0,0 +1,12 @@
|
||||
project('json_example', 'cpp',
|
||||
version: '1.0',
|
||||
default_options: ['cpp_std=c++11']
|
||||
)
|
||||
|
||||
dependency_json = dependency('nlohmann_json', required: true)
|
||||
|
||||
executable('json_example',
|
||||
sources: ['example.cpp'],
|
||||
dependencies: [dependency_json],
|
||||
install: true
|
||||
)
|
||||
BIN
docs/mkdocs/docs/integration/nuget/nuget-package-content.png
Normal file
BIN
docs/mkdocs/docs/integration/nuget/nuget-package-content.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
BIN
docs/mkdocs/docs/integration/nuget/nuget-project-changes.png
Normal file
BIN
docs/mkdocs/docs/integration/nuget/nuget-project-changes.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
BIN
docs/mkdocs/docs/integration/nuget/nuget-project-makefile.png
Normal file
BIN
docs/mkdocs/docs/integration/nuget/nuget-project-makefile.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 54 KiB |
BIN
docs/mkdocs/docs/integration/nuget/nuget-search-package.png
Normal file
BIN
docs/mkdocs/docs/integration/nuget/nuget-search-package.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 94 KiB |
BIN
docs/mkdocs/docs/integration/nuget/nuget-select-package.png
Normal file
BIN
docs/mkdocs/docs/integration/nuget/nuget-select-package.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 154 KiB |
@@ -14,61 +14,178 @@ When executed, this program should create output similar to
|
||||
|
||||
## Homebrew
|
||||
|
||||
If you are using OS X and [Homebrew](http://brew.sh), just type
|
||||
!!! abstract "Summary"
|
||||
|
||||
formula: [**`nlohmann-json`**](https://formulae.brew.sh/formula/nlohmann-json)
|
||||
|
||||
- :octicons-tag-24: Availalbe versions: current version and development version (with `--HEAD` parameter)
|
||||
- :octicons-rocket-24: The formula is updated with every release.
|
||||
- :octicons-person-24: Maintainer: Niels Lohmann
|
||||
- :octicons-file-24: File issues at the [Homebrew issue tracker](https://github.com/Homebrew/homebrew-core/issues)
|
||||
- :octicons-question-24: [Homebrew website](https://brew.sh)
|
||||
|
||||
If you are using [Homebrew](http://brew.sh), you can install the library with
|
||||
|
||||
```sh
|
||||
brew install nlohmann-json
|
||||
```
|
||||
|
||||
and you're set. If you want the bleeding edge rather than the latest release, use
|
||||
The header can be used directly in your code or via CMake.
|
||||
|
||||
```sh
|
||||
brew install nlohmann-json --HEAD
|
||||
```
|
||||
|
||||
instead. See [nlohmann-json](https://formulae.brew.sh/formula/nlohmann-json) for more information.
|
||||
|
||||
??? example
|
||||
??? example "Example: Raw compilation"
|
||||
|
||||
1. Create the following file:
|
||||
|
||||
```cpp title="example.cpp"
|
||||
--8<-- "integration/example.cpp"
|
||||
--8<-- "integration/homebrew/example.cpp"
|
||||
```
|
||||
|
||||
2. Install the package
|
||||
2. Install the package:
|
||||
|
||||
```sh
|
||||
brew install nlohmann-json
|
||||
```
|
||||
|
||||
3. Determine the include path, which defaults to `/usr/local/Cellar/nlohmann-json/$version/include`, where `$version` is the version of the library, e.g. `3.7.3`. The path of the library can be determined with
|
||||
3. Compile the code and pass the Homebrew prefix to the include path such that the library can be found:
|
||||
|
||||
```sh
|
||||
brew list nlohmann-json
|
||||
c++ example.cpp -I$(brew --prefix nlohmann-json)/include -std=c++11 -o example
|
||||
```
|
||||
|
||||
4. Compile the code. For instance, the code can be compiled using Clang with
|
||||
??? example "Example: CMake"
|
||||
|
||||
1. Create the following files:
|
||||
|
||||
```cpp title="example.cpp"
|
||||
--8<-- "integration/homebrew/example.cpp"
|
||||
```
|
||||
|
||||
```cmake title="CMakeLists.txt"
|
||||
--8<-- "integration/homebrew/CMakeLists.txt"
|
||||
```
|
||||
|
||||
2. Install the package:
|
||||
|
||||
```sh
|
||||
clang++ example.cpp -I/usr/local/Cellar/nlohmann-json/3.7.3/include -std=c++11 -o example
|
||||
brew install nlohmann-json
|
||||
```
|
||||
|
||||
:material-update: The [formula](https://formulae.brew.sh/formula/nlohmann-json) is updated automatically.
|
||||
3. Compile the code and pass the Homebrew prefix to CMake to find installed packages via `#!cmake find_package`:
|
||||
|
||||
```sh
|
||||
CMAKE_PREFIX_PATH=$(brew --prefix) cmake -S . -B build
|
||||
cmake --build build
|
||||
```
|
||||
|
||||
## Meson
|
||||
|
||||
If you are using the [Meson Build System](http://mesonbuild.com), add this source tree as a [meson subproject](https://mesonbuild.com/Subprojects.html#using-a-subproject). You may also use the `include.zip` published in this project's [Releases](https://github.com/nlohmann/json/releases) to reduce the size of the vendored source tree. Alternatively, you can get a wrap file by downloading it from [Meson WrapDB](https://wrapdb.mesonbuild.com/nlohmann_json), or simply use `meson wrap install nlohmann_json`. Please see the meson project for any issues regarding the packaging.
|
||||
!!! abstract "Summary"
|
||||
|
||||
The provided `meson.build` can also be used as an alternative to cmake for installing `nlohmann_json` system-wide in which case a pkg-config file is installed. To use it, simply have your build system require the `nlohmann_json` pkg-config dependency. In Meson, it is preferred to use the [`dependency()`](https://mesonbuild.com/Reference-manual.html#dependency) object with a subproject fallback, rather than using the subproject directly.
|
||||
wrap: **`nlohmann_json`**
|
||||
|
||||
- :octicons-tag-24: Availalbe versions: current version and select older versions (see
|
||||
[WrapDB](https://mesonbuild.com/Wrapdb-projects.html))
|
||||
- :octicons-rocket-24: The package is update automatically from file
|
||||
[`meson.build`](https://github.com/nlohmann/json/blob/develop/meson.build).
|
||||
- :octicons-file-24: File issues at the [library issue tracker](https://github.com/nlohmann/json/issues)
|
||||
- :octicons-question-24: [Meson website](https://mesonbuild.com/index.html)
|
||||
|
||||
If you are using the [Meson Build System](http://mesonbuild.com), add this source tree as a [meson subproject](https://mesonbuild.com/Subprojects.html#using-a-subproject). You may also use the
|
||||
`include.zip` published in this project's [Releases](https://github.com/nlohmann/json/releases) to reduce the size of the vendored source tree. Alternatively,
|
||||
you can get a wrap file by downloading it from [Meson WrapDB](https://mesonbuild.com/Wrapdb-projects.html), or simply
|
||||
use
|
||||
|
||||
```shell
|
||||
meson wrap install nlohmann_json
|
||||
```
|
||||
|
||||
Please see the Meson project for any issues regarding the packaging.
|
||||
|
||||
The provided `meson.build` can also be used as an alternative to CMake for installing `nlohmann_json` system-wide in
|
||||
which case a pkg-config file is installed. To use it, simply have your build system require the `nlohmann_json`
|
||||
pkg-config dependency. In Meson, it is preferred to use the
|
||||
[`dependency()`](https://mesonbuild.com/Reference-manual.html#dependency) object with a subproject fallback, rather than
|
||||
using the subproject directly.
|
||||
|
||||
??? example "Example: Wrap"
|
||||
|
||||
1. Create the following files:
|
||||
|
||||
```ini title="meson.build"
|
||||
--8<-- "integration/meson/meson.build"
|
||||
```
|
||||
|
||||
```cpp title="example.cpp"
|
||||
--8<-- "integration/meson/example.cpp"
|
||||
```
|
||||
|
||||
2. Use the Meson WrapDB to fetch the nlohmann/json wrap:
|
||||
|
||||
```shell
|
||||
mkdir subprojects
|
||||
meson wrap install nlohmann_json
|
||||
```
|
||||
|
||||
3. Build:
|
||||
|
||||
```shell
|
||||
meson setup build
|
||||
meson compile -C build
|
||||
```
|
||||
|
||||
## Bazel
|
||||
|
||||
This repository provides a [Bazel](https://bazel.build/) `WORKSPACE.bazel` and a corresponding `BUILD.bazel` file. Therefore, this repository can be referenced by workspace rules such as `http_archive`, `git_repository`, or `local_repository` from other Bazel workspaces. To use the library you only need to depend on the target `@nlohmann_json//:json` (e.g. via `deps` attribute).
|
||||
!!! abstract "Summary"
|
||||
|
||||
use `http_archive`, `git_repository`, or `local_repository`
|
||||
|
||||
- :octicons-tag-24: Any version, as version is specified in `WORKSPACE` file
|
||||
- :octicons-file-24: File issues at the [library issue tracker](https://github.com/nlohmann/json/issues)
|
||||
- :octicons-question-24: [Bazel website](https://bazel.build)
|
||||
|
||||
This repository provides a [Bazel](https://bazel.build/) `WORKSPACE.bazel` and a corresponding `BUILD.bazel` file. Therefore, this
|
||||
repository can be referenced by workspace rules such as `http_archive`, `git_repository`, or `local_repository` from
|
||||
other Bazel workspaces. To use the library you only need to depend on the target `@nlohmann_json//:json` (e.g., via
|
||||
`deps` attribute).
|
||||
|
||||
??? example
|
||||
|
||||
1. Create the following files:
|
||||
|
||||
```ini title="BUILD"
|
||||
--8<-- "integration/bazel/BUILD"
|
||||
```
|
||||
|
||||
```ini title="WORKSPACE"
|
||||
--8<-- "integration/bazel/WORKSPACE"
|
||||
```
|
||||
|
||||
```cpp title="example.cpp"
|
||||
--8<-- "integration/bazel/example.cpp"
|
||||
```
|
||||
|
||||
2. Build and run:
|
||||
|
||||
```shell
|
||||
bazel build //:main
|
||||
bazel run //:main
|
||||
```
|
||||
|
||||
## Conan
|
||||
|
||||
If you are using [Conan](https://www.conan.io/) to manage your dependencies, merely add `nlohmann_json/x.y.z` to your `conanfile`'s requires, where `x.y.z` is the release version you want to use. Please file issues [here](https://github.com/conan-io/conan-center-index/issues) if you experience problems with the packages.
|
||||
!!! abstract "Summary"
|
||||
|
||||
recipe: [**`nlohmann_json`**](https://conan.io/center/recipes/nlohmann_json)
|
||||
|
||||
- :octicons-tag-24: Availalbe versions: current version and older versions (see
|
||||
[Conan Center](https://conan.io/center/recipes/nlohmann_json))
|
||||
- :octicons-rocket-24: The package is update automatically via
|
||||
[this recipe](https://github.com/conan-io/conan-center-index/tree/master/recipes/nlohmann_json).
|
||||
- :octicons-file-24: File issues at the [Conan Center issue tracker](https://github.com/conan-io/conan-center-index/issues)
|
||||
- :octicons-question-24: [Conan website](https://conan.io)
|
||||
|
||||
If you are using [Conan](https://www.conan.io/) to manage your dependencies, merely add `nlohmann_json/x.y.z` to your `conanfile`'s
|
||||
requires, where `x.y.z` is the release version you want to use.
|
||||
|
||||
??? example
|
||||
|
||||
@@ -86,33 +203,147 @@ If you are using [Conan](https://www.conan.io/) to manage your dependencies, mer
|
||||
--8<-- "integration/conan/example.cpp"
|
||||
```
|
||||
|
||||
2. Build:
|
||||
2. Call Conan:
|
||||
|
||||
```sh
|
||||
mkdir build
|
||||
cd build
|
||||
conan install ..
|
||||
cmake ..
|
||||
cmake --build .
|
||||
conan install . --output-folder=build --build=missing
|
||||
```
|
||||
|
||||
:material-update: The [package](https://conan.io/center/nlohmann_json) is updated automatically.
|
||||
3. Build:
|
||||
|
||||
```sh
|
||||
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build build
|
||||
```
|
||||
|
||||
## Spack
|
||||
|
||||
If you are using [Spack](https://www.spack.io/) to manage your dependencies, you can use the [`nlohmann-json` package](https://spack.readthedocs.io/en/latest/package_list.html#nlohmann-json). Please see the [spack project](https://github.com/spack/spack) for any issues regarding the packaging.
|
||||
!!! abstract "Summary"
|
||||
|
||||
package: [**`nlohmann-json`**](https://packages.spack.io/package.html?name=nlohmann-json)
|
||||
|
||||
- :octicons-tag-24: Availalbe versions: current version and older versions (see
|
||||
[Spack package](https://packages.spack.io/package.html?name=nlohmann-json))
|
||||
- :octicons-rocket-24: The package is updated with every release.
|
||||
- :octicons-person-24: Maintainer: [Axel Huebl](https://github.com/ax3l)
|
||||
- :octicons-file-24: File issues at the [Spack issue tracker](https://github.com/spack/spack/issues)
|
||||
- :octicons-question-24: [Spack website](https://spack.io)
|
||||
|
||||
If you are using [Spack](https://www.spack.io/) to manage your dependencies, you can use the
|
||||
[`nlohmann-json` package](https://packages.spack.io/package.html?name=nlohmann-json) via
|
||||
|
||||
```shell
|
||||
spack install nlohmann-json
|
||||
```
|
||||
|
||||
Please see the [Spack project](https://github.com/spack/spack) for any issues regarding the packaging.
|
||||
|
||||
??? example
|
||||
|
||||
1. Create the following files:
|
||||
|
||||
```cmake title="CMakeLists.txt"
|
||||
--8<-- "integration/spack/CMakeLists.txt"
|
||||
```
|
||||
|
||||
```cpp title="example.cpp"
|
||||
--8<-- "integration/spack/example.cpp"
|
||||
```
|
||||
|
||||
2. Install the library:
|
||||
|
||||
```sh
|
||||
spack install nlohmann-json
|
||||
```
|
||||
|
||||
3. Load the environment for your Spack-installed packages:
|
||||
|
||||
```sh
|
||||
spack load nlohmann-json
|
||||
```
|
||||
|
||||
4. Build the project with CMake:
|
||||
|
||||
```sh
|
||||
cmake -S . -B build -DCMAKE_PREFIX_PATH=$(spack location -i nlohmann-json)
|
||||
cmake --build build
|
||||
```
|
||||
|
||||
## Hunter
|
||||
|
||||
If you are using [hunter](https://github.com/cpp-pm/hunter) on your project for external dependencies, then you can use the [nlohmann_json package](https://hunter.readthedocs.io/en/latest/packages/pkg/nlohmann_json.html). Please see the hunter project for any issues regarding the packaging.
|
||||
!!! abstract "Summary"
|
||||
|
||||
package: [**`nlohmann_json`**](https://hunter.readthedocs.io/en/latest/packages/pkg/nlohmann_json.html)
|
||||
|
||||
- :octicons-tag-24: Availalbe versions: current version and older versions (see
|
||||
[Hunter package](https://hunter.readthedocs.io/en/latest/packages/pkg/nlohmann_json.html))
|
||||
- :octicons-rocket-24: The package is updated with every release.
|
||||
- :octicons-file-24: File issues at the [Hunter issue tracker](https://github.com/cpp-pm/hunter/issues)
|
||||
- :octicons-question-24: [Hunter website](https://hunter.readthedocs.io/en/latest/)
|
||||
|
||||
If you are using [Hunter](https://github.com/cpp-pm/hunter) on your project for external dependencies, then you can use
|
||||
the [nlohmann_json package](https://hunter.readthedocs.io/en/latest/packages/pkg/nlohmann_json.html) via
|
||||
|
||||
```cmake
|
||||
hunter_add_package(nlohmann_json)
|
||||
```
|
||||
|
||||
Please see the Hunter project for any issues regarding the packaging.
|
||||
|
||||
??? example
|
||||
|
||||
1. Create the following files:
|
||||
|
||||
```cmake title="CMakeLists.txt"
|
||||
--8<-- "integration/hunter/CMakeLists.txt"
|
||||
```
|
||||
|
||||
```cpp title="example.cpp"
|
||||
--8<-- "integration/hunter/example.cpp"
|
||||
```
|
||||
|
||||
2. Download required files
|
||||
|
||||
```shell
|
||||
mkdir cmake
|
||||
wget https://raw.githubusercontent.com/cpp-pm/gate/master/cmake/HunterGate.cmake -O cmake/HunterGate.cmake
|
||||
```
|
||||
|
||||
3. Build the project with CMake:
|
||||
|
||||
```shell
|
||||
cmake -S . -B build
|
||||
cmake --build build
|
||||
```
|
||||
|
||||
## Buckaroo
|
||||
|
||||
If you are using [Buckaroo](https://buckaroo.pm), you can install this library's module with `buckaroo add github.com/buckaroo-pm/nlohmann-json`. Please file issues [here](https://github.com/buckaroo-pm/nlohmann-json). There is a demo repo [here](https://github.com/njlr/buckaroo-nholmann-json-example).
|
||||
If you are using [Buckaroo](https://buckaroo.pm), you can install this library's module with `buckaroo add github.com/buckaroo-pm/nlohmann-json`. There is a demo repo [here](https://github.com/njlr/buckaroo-nholmann-json-example).
|
||||
|
||||
!!! warning
|
||||
|
||||
The module is outdated as the respective [repository](https://github.com/buckaroo-pm/nlohmann-json) has not been
|
||||
updated in years.
|
||||
|
||||
## vcpkg
|
||||
|
||||
If you are using [vcpkg](https://github.com/Microsoft/vcpkg/) on your project for external dependencies, then you can install the [nlohmann-json package](https://github.com/Microsoft/vcpkg/tree/master/ports/nlohmann-json) with `vcpkg install nlohmann-json` and follow the then displayed descriptions. Please see the vcpkg project for any issues regarding the packaging.
|
||||
!!! abstract "Summary"
|
||||
|
||||
package: [**`nlohmann-json`**](https://github.com/Microsoft/vcpkg/tree/master/ports/nlohmann-json)
|
||||
|
||||
- :octicons-tag-24: Availalbe versions: current version
|
||||
- :octicons-rocket-24: The package is updated with every release.
|
||||
- :octicons-file-24: File issues at the [vcpkg issue tracker](https://github.com/microsoft/vcpkg/issues)
|
||||
- :octicons-question-24: [vcpkg website](https://vcpkg.io/)
|
||||
|
||||
If you are using [vcpkg](https://github.com/Microsoft/vcpkg/) on your project for external dependencies, then you can
|
||||
install the [nlohmann-json package](https://github.com/Microsoft/vcpkg/tree/master/ports/nlohmann-json) with
|
||||
|
||||
```shell
|
||||
vcpkg install nlohmann-json
|
||||
```
|
||||
|
||||
and follow the then displayed descriptions. Please see the vcpkg project for any issues regarding the packaging.
|
||||
|
||||
??? example
|
||||
|
||||
@@ -135,19 +366,60 @@ If you are using [vcpkg](https://github.com/Microsoft/vcpkg/) on your project fo
|
||||
3. Build:
|
||||
|
||||
```sh
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake
|
||||
cmake --build .
|
||||
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake
|
||||
cmake --build build
|
||||
```
|
||||
|
||||
Note you need to adjust `/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake` to your system.
|
||||
|
||||
## cget
|
||||
|
||||
If you are using [cget](http://cget.readthedocs.io/en/latest/), you can install the latest development version with `cget install nlohmann/json`. A specific version can be installed with `cget install nlohmann/json@v3.1.0`. Also, the multiple header version can be installed by adding the `-DJSON_MultipleHeaders=ON` flag (i.e., `cget install nlohmann/json -DJSON_MultipleHeaders=ON`).
|
||||
!!! abstract "Summary"
|
||||
|
||||
:material-update: cget reads directly from the [GitHub repository](https://github.com/nlohmann/json) and is always up-to-date.
|
||||
package: [**`nlohmann/json`**](https://github.com/pfultz2/cget-recipes/blob/master/recipes/nlohmann/json/package.txt)
|
||||
|
||||
- :octicons-tag-24: Availalbe versions: current version and older versions
|
||||
- :octicons-rocket-24: The package is updated with every release.
|
||||
- :octicons-file-24: File issues at the [cget issue tracker](https://github.com/pfultz2/cget-recipes/issues)
|
||||
- :octicons-question-24: [cget website](https://cget.readthedocs.io/)
|
||||
|
||||
If you are using [cget](http://cget.readthedocs.io/en/latest/), you can install the latest `master` version with
|
||||
|
||||
```shell
|
||||
cget install nlohmann/json
|
||||
```
|
||||
|
||||
A specific version can be installed with `cget install nlohmann/json@v3.11.3`. Also, the multiple header version can be
|
||||
installed by adding the `-DJSON_MultipleHeaders=ON` flag (i.e., `cget install nlohmann/json -DJSON_MultipleHeaders=ON`).
|
||||
|
||||
??? example
|
||||
|
||||
1. Create the following files:
|
||||
|
||||
```cmake title="CMakeLists.txt"
|
||||
--8<-- "integration/vcpkg/CMakeLists.txt"
|
||||
```
|
||||
|
||||
```cpp title="example.cpp"
|
||||
--8<-- "integration/vcpkg/example.cpp"
|
||||
```
|
||||
|
||||
2. Initialize cget
|
||||
|
||||
```shell
|
||||
cget init
|
||||
```
|
||||
|
||||
3. Install the library
|
||||
|
||||
```shell
|
||||
cget install nlohmann/json
|
||||
```
|
||||
|
||||
4. Build
|
||||
|
||||
```shell
|
||||
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=cget/cget/cget.cmake
|
||||
cmake --build build
|
||||
```
|
||||
|
||||
## CocoaPods
|
||||
|
||||
@@ -155,7 +427,136 @@ If you are using [CocoaPods](https://cocoapods.org), you can use the library by
|
||||
|
||||
## NuGet
|
||||
|
||||
If you are using [NuGet](https://www.nuget.org), you can use the package [nlohmann.json](https://www.nuget.org/packages/nlohmann.json/). Please check [this extensive description](https://github.com/nlohmann/json/issues/1132#issuecomment-452250255) on how to use the package. Please file issues [here](https://github.com/hnkb/nlohmann-json-nuget/issues).
|
||||
!!! abstract "Summary"
|
||||
|
||||
package: [**`nlohmann.json`**](https://www.nuget.org/packages/nlohmann.json/)
|
||||
|
||||
- :octicons-tag-24: Availalbe versions: current and previous versions
|
||||
- :octicons-rocket-24: The package is updated with every release.
|
||||
- :octicons-person-24: Maintainer: [Hani Kaabi](https://github.com/hnkb)
|
||||
- :octicons-file-24: File issues at the [maintainer's issue tracker](https://github.com/hnkb/nlohmann-json-nuget/issues)
|
||||
- :octicons-question-24: [NuGet website](https://www.nuget.org)
|
||||
|
||||
If you are using [NuGet](https://www.nuget.org), you can use the package [nlohmann.json](https://www.nuget.org/packages/nlohmann.json/)
|
||||
with
|
||||
|
||||
```shell
|
||||
dotnet add package nlohmann.json
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
Probably the easiest way to use NuGet packages is through Visual Studio graphical interface. Just right-click on a
|
||||
project (any C++ project would do) in “Solution Explorer” and select “Manage NuGet Packages…”
|
||||
|
||||

|
||||
|
||||
Now you can click on “Browse” tab and find the package you like to install.
|
||||
|
||||

|
||||
|
||||
Most of the packages in NuGet gallery are .NET packages and would not be useful in a C++ project. Microsoft
|
||||
recommends adding “native” and “nativepackage” tags to C++ NuGet packages to distinguish them, but even adding
|
||||
“native” to search query would still show many .NET-only packages in the list.
|
||||
|
||||
Nevertheless, after finding the package you want, just click on “Install” button and accept confirmation dialogs.
|
||||
After the package is successfully added to the projects, you should be able to just build and execute the project
|
||||
without the need for making any more changes to build settings.
|
||||
|
||||
!!! note
|
||||
|
||||
A few notes:
|
||||
|
||||
- NuGet packages are installed per project and not system-wide. The header and binaries for the package are only
|
||||
available to the project it is added to, and not other projects (obviously unless we add the package to those
|
||||
projects as well)
|
||||
- One of the many great things about your elegant work is that it is a header-only library, which makes
|
||||
deployment very straightforward. In case of libraries which need binary deployment (`.lib`, `.dll` and `.pdb`
|
||||
for debug info) the different binaries for each supported compiler version must be added to the NuGet package.
|
||||
Some library creators cram binary versions for all supported Visual C++ compiler versions in the same package,
|
||||
so a single package will support all compilers. Some others create a different package for each compiler
|
||||
version (and you usually see things like “v140” or “vc141” in package name to clarify which VC++ compiler this
|
||||
package supports).
|
||||
- Packages can have dependency to other packages, and in this case, NuGet will install all dependencies as well
|
||||
as the requested package recursively.
|
||||
|
||||
**What happens behind the scenes**
|
||||
|
||||
After you add a NuGet package, three changes occur in the project source directory. Of course, we could make these
|
||||
changes manually instead of using GUI:
|
||||
|
||||

|
||||
|
||||
1. A `packages.config` file will be created (or updated to include the package name if one such file already
|
||||
exists). This file contains a list of the packages required by this project (name and minimum version) and must
|
||||
be added to the project source code repository, so if you move the source code to a new machine, MSBuild/NuGet
|
||||
knows which packages it has to restore (which it does automatically before each build).
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="nlohmann.json" version="3.5.0" targetFramework="native" />
|
||||
</packages>
|
||||
```
|
||||
|
||||
2. A `packages` folder which contains actual files in the packages (these are header and binary files required for
|
||||
a successful build, plus a few metadata files). In case of this library for example, it contains `json.hpp`:
|
||||
|
||||

|
||||
|
||||
!!! note
|
||||
|
||||
This directory should not be added to the project source code repository, as it will be restored before each
|
||||
build by MSBuild/NuGet. If you go ahead and delete this folder, then build the project again, it will
|
||||
magically re-appear!
|
||||
|
||||
3. Project MSBuild makefile (which for Visual C++ projects has a .vcxproj extension) will be updated to include
|
||||
settings from the package.
|
||||
|
||||

|
||||
|
||||
The important bit for us here is line 170, which tells MSBuild to import settings from
|
||||
`packages\nlohmann.json.3.5.0\build\native\nlohmann.json.targets` file. This is a file the package creator
|
||||
created and added to the package (you can see it is one of the two files I created in this repository, the other
|
||||
just contains package attributes like name and version number). What does it contain?
|
||||
|
||||
For our header-only repository, the only setting we need is to add our include directory to the list of
|
||||
`AdditionalIncludeDirectories`:
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
</Project>
|
||||
```
|
||||
|
||||
For libraries with binary files, we will need to add `.lib` files to linker inputs and add settings to copy
|
||||
`.dll` and other redistributable files to output directory, if needed.
|
||||
|
||||
There are other changes to the makefile as well:
|
||||
|
||||
- Lines 165-167 add the `packages.config` as one of project files (so it is shown in Solution Explorer tree
|
||||
view). It is added as None (no build action) and removing it wouldn’t affect build.
|
||||
|
||||
- Lines 172-177 check to ensure the required packages are present. This will display a build error if package
|
||||
directory is empty (for example when NuGet cannot restore packages because Internet connection is down).
|
||||
Again, if you omit this section, the only change in build would be a more cryptic error message if build
|
||||
fails.
|
||||
|
||||
!!! note
|
||||
|
||||
Changes to .vcxproj makefile should also be added to project source code repository.
|
||||
|
||||
As you can see, the mechanism NuGet uses to modify project settings is through MSBuild makefiles, so using NuGet
|
||||
with other build systems and compilers (like CMake) as a dependency manager is either impossible or more problematic
|
||||
than useful.
|
||||
|
||||
Please refer to [this extensive description](https://github.com/nlohmann/json/issues/1132#issuecomment-452250255) for
|
||||
more information.
|
||||
|
||||
## Conda
|
||||
|
||||
@@ -169,9 +570,67 @@ If you are using [MSYS2](http://www.msys2.org/), you can use the [mingw-w64-nloh
|
||||
|
||||
## MacPorts
|
||||
|
||||
If you are using [MacPorts](https://ports.macports.org), execute `sudo port install nlohmann-json` to install the [nlohmann-json](https://ports.macports.org/port/nlohmann-json/) package.
|
||||
!!! abstract "Summary"
|
||||
|
||||
:material-update: The [package](https://ports.macports.org/port/nlohmann-json/) is updated automatically.
|
||||
port: [**`nlohmann-json`**](https://ports.macports.org/port/nlohmann-json/)
|
||||
|
||||
- :octicons-tag-24: Availalbe versions: current version
|
||||
- :octicons-rocket-24: The port is updated with every release.
|
||||
- :octicons-file-24: File issues at the [MacPorts issue tracker](https://trac.macports.org/newticket?port=nlohmann-json)
|
||||
- :octicons-question-24: [MacPorts website](https://www.macports.org)
|
||||
|
||||
If you are using [MacPorts](https://ports.macports.org), execute
|
||||
|
||||
```shell
|
||||
sudo port install nlohmann-json
|
||||
```
|
||||
|
||||
to install the [nlohmann-json](https://ports.macports.org/port/nlohmann-json/) package.
|
||||
|
||||
??? example "Example: Raw compilation"
|
||||
|
||||
1. Create the following file:
|
||||
|
||||
```cpp title="example.cpp"
|
||||
--8<-- "integration/macports/example.cpp"
|
||||
```
|
||||
|
||||
2. Install the package:
|
||||
|
||||
```sh
|
||||
sudo port install nlohmann-json
|
||||
```
|
||||
|
||||
3. Compile the code and pass the Homebrew prefix to the include path such that the library can be found:
|
||||
|
||||
```sh
|
||||
c++ example.cpp -I/opt/local/include -std=c++11 -o example
|
||||
```
|
||||
|
||||
??? example "Example: CMake"
|
||||
|
||||
1. Create the following files:
|
||||
|
||||
```cpp title="example.cpp"
|
||||
--8<-- "integration/homebrew/example.cpp"
|
||||
```
|
||||
|
||||
```cmake title="CMakeLists.txt"
|
||||
--8<-- "integration/homebrew/CMakeLists.txt"
|
||||
```
|
||||
|
||||
2. Install the package:
|
||||
|
||||
```sh
|
||||
sudo port install nlohmann-json
|
||||
```
|
||||
|
||||
3. Compile the code:
|
||||
|
||||
```sh
|
||||
cmake -S . -B build
|
||||
cmake --build build
|
||||
```
|
||||
|
||||
## build2
|
||||
|
||||
@@ -188,11 +647,44 @@ If you are using [`wsjcpp`](http://wsjcpp.org), you can use the command `wsjcpp
|
||||
|
||||
## CPM.cmake
|
||||
|
||||
If you are using [`CPM.cmake`](https://github.com/TheLartians/CPM.cmake), you can check this [`example`](https://github.com/TheLartians/CPM.cmake/tree/master/examples/json). After [adding CPM script](https://github.com/TheLartians/CPM.cmake#adding-cpm) to your project, implement the following snippet to your CMake:
|
||||
!!! abstract "Summary"
|
||||
|
||||
package: **`gh:nlohmann/json`**
|
||||
|
||||
- :octicons-tag-24: Availalbe versions: current and previous versions
|
||||
- :octicons-rocket-24: The package is updated with every release.
|
||||
- :octicons-file-24: File issues at the [CPM.cmake issue tracker](https://github.com/cpm-cmake/CPM.cmake/issues)
|
||||
- :octicons-question-24: [CPM.cmake website](https://github.com/cpm-cmake/CPM.cmake)
|
||||
|
||||
If you are using [`CPM.cmake`](https://github.com/TheLartians/CPM.cmake), add the
|
||||
[CPM.cmake script](https://github.com/TheLartians/CPM.cmake#adding-cpm) and the following snippet to your CMake project:
|
||||
|
||||
```cmake
|
||||
CPMAddPackage(
|
||||
NAME nlohmann_json
|
||||
GITHUB_REPOSITORY nlohmann/json
|
||||
VERSION 3.9.1)
|
||||
CPMAddPackage("gh:nlohmann/json@3.11.3")
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
1. Create the following files:
|
||||
|
||||
```cpp title="example.cpp"
|
||||
--8<-- "integration/cpm/example.cpp"
|
||||
```
|
||||
|
||||
```cmake title="CMakeLists.txt"
|
||||
--8<-- "integration/cpm/CMakeLists.txt"
|
||||
```
|
||||
|
||||
2. Download CPM.cmake
|
||||
|
||||
```shell
|
||||
mkdir -p cmake
|
||||
wget -O cmake/CPM.cmake https://github.com/cpm-cmake/CPM.cmake/releases/latest/download/get_cpm.cmake
|
||||
```
|
||||
|
||||
3. Build
|
||||
|
||||
```shell
|
||||
cmake -S . -B build
|
||||
cmake --build build
|
||||
```
|
||||
|
||||
7
docs/mkdocs/docs/integration/spack/CMakeLists.txt
Normal file
7
docs/mkdocs/docs/integration/spack/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(json_example)
|
||||
|
||||
find_package(nlohmann_json REQUIRED)
|
||||
|
||||
add_executable(json_example example.cpp)
|
||||
target_link_libraries(json_example PRIVATE nlohmann_json::nlohmann_json)
|
||||
10
docs/mkdocs/docs/integration/spack/example.cpp
Normal file
10
docs/mkdocs/docs/integration/spack/example.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << std::setw(4) << json::meta() << std::endl;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(json_example)
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
|
||||
find_package(nlohmann_json CONFIG REQUIRED)
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << json::meta() << std::endl;
|
||||
std::cout << std::setw(4) << json::meta() << std::endl;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ repo_url: https://github.com/nlohmann/json
|
||||
edit_uri: edit/develop/docs/mkdocs/docs
|
||||
|
||||
# Copyright
|
||||
copyright: Copyright © 2013 - 2023 Niels Lohmann
|
||||
copyright: Copyright © 2013 - 2024 Niels Lohmann
|
||||
|
||||
# Configuration
|
||||
theme:
|
||||
@@ -30,7 +30,8 @@ theme:
|
||||
toggle:
|
||||
icon: material/brightness-4
|
||||
name: Switch to light mode
|
||||
|
||||
icon:
|
||||
repo: fontawesome/brands/github
|
||||
font:
|
||||
text: Roboto
|
||||
code: JetBrains Mono
|
||||
@@ -41,6 +42,8 @@ theme:
|
||||
- navigation.indexes
|
||||
- navigation.top
|
||||
- content.tabs.link
|
||||
- content.action.edit
|
||||
- content.action.view
|
||||
|
||||
nav:
|
||||
- Home:
|
||||
@@ -51,6 +54,7 @@ nav:
|
||||
- home/exceptions.md
|
||||
- home/releases.md
|
||||
- home/design_goals.md
|
||||
- home/customers.md
|
||||
- home/sponsors.md
|
||||
- Features:
|
||||
- features/arbitrary_types.md
|
||||
@@ -281,6 +285,12 @@ nav:
|
||||
- 'JSON_USE_GLOBAL_UDLS': api/macros/json_use_global_udls.md
|
||||
- 'JSON_USE_IMPLICIT_CONVERSIONS': api/macros/json_use_implicit_conversions.md
|
||||
- 'JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON': api/macros/json_use_legacy_discarded_value_comparison.md
|
||||
- 'NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE': api/macros/nlohmann_define_derived_type.md
|
||||
- 'NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT': api/macros/nlohmann_define_derived_type.md
|
||||
- 'NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE': api/macros/nlohmann_define_derived_type.md
|
||||
- 'NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE': api/macros/nlohmann_define_derived_type.md
|
||||
- 'NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT': api/macros/nlohmann_define_derived_type.md
|
||||
- 'NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE': api/macros/nlohmann_define_derived_type.md
|
||||
- 'NLOHMANN_DEFINE_TYPE_INTRUSIVE': api/macros/nlohmann_define_type_intrusive.md
|
||||
- 'NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT': api/macros/nlohmann_define_type_intrusive.md
|
||||
- 'NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE': api/macros/nlohmann_define_type_non_intrusive.md
|
||||
@@ -299,8 +309,6 @@ extra:
|
||||
social:
|
||||
- icon: fontawesome/brands/github
|
||||
link: https://github.com/nlohmann
|
||||
- icon: fontawesome/brands/twitter
|
||||
link: https://twitter.com/nlohmann
|
||||
- icon: fontawesome/brands/linkedin
|
||||
link: https://www.linkedin.com/in/nielslohmann/
|
||||
- icon: fontawesome/brands/xing
|
||||
@@ -332,7 +340,11 @@ markdown_extensions:
|
||||
- pymdownx.magiclink
|
||||
- pymdownx.mark
|
||||
#- pymdownx.smartsymbols
|
||||
- pymdownx.superfences
|
||||
- pymdownx.superfences:
|
||||
custom_fences:
|
||||
- name: mermaid
|
||||
class: mermaid
|
||||
format: !!python/name:pymdownx.superfences.fence_code_format
|
||||
- pymdownx.tasklist:
|
||||
custom_checkbox: true
|
||||
- pymdownx.tabbed:
|
||||
@@ -341,23 +353,21 @@ markdown_extensions:
|
||||
- pymdownx.snippets:
|
||||
base_path: docs
|
||||
check_paths: true
|
||||
- plantuml_markdown:
|
||||
format: svg
|
||||
|
||||
plugins:
|
||||
- search:
|
||||
separator: '[\s\-\.]'
|
||||
lang: en
|
||||
- minify:
|
||||
minify_html: true
|
||||
- git-revision-date-localized
|
||||
- redirects:
|
||||
redirect_maps:
|
||||
'api/basic_json/operator_gtgt.md': api/operator_gtgt.md
|
||||
'api/basic_json/operator_ltlt.md': api/operator_ltlt.md
|
||||
'api/basic_json/operator_literal_json.md': api/operator_literal_json.md
|
||||
'api/basic_json/operator_literal_json_pointer.md': api/operator_literal_json_pointer.md
|
||||
'api/json_pointer/operator_string.md': api/json_pointer/operator_string_t.md
|
||||
- search:
|
||||
separator: '[\s\-\.]'
|
||||
lang: en
|
||||
- minify:
|
||||
minify_html: true
|
||||
- git-revision-date-localized
|
||||
- redirects:
|
||||
redirect_maps:
|
||||
'api/basic_json/operator_gtgt.md': api/operator_gtgt.md
|
||||
'api/basic_json/operator_ltlt.md': api/operator_ltlt.md
|
||||
'api/basic_json/operator_literal_json.md': api/operator_literal_json.md
|
||||
'api/basic_json/operator_literal_json_pointer.md': api/operator_literal_json_pointer.md
|
||||
'api/json_pointer/operator_string.md': api/json_pointer/operator_string_t.md
|
||||
|
||||
extra_css:
|
||||
- css/custom.css
|
||||
|
||||
@@ -1,49 +1,6 @@
|
||||
Babel==2.13.1
|
||||
certifi==2023.7.22
|
||||
charset-normalizer==3.3.1
|
||||
click==8.1.7
|
||||
csscompressor==0.9.5
|
||||
future==0.18.3
|
||||
ghp-import==2.1.0
|
||||
gitdb==4.0.11
|
||||
GitPython==3.1.40
|
||||
htmlmin==0.1.12
|
||||
httplib2==0.22.0
|
||||
idna==3.4
|
||||
importlib-metadata==6.8.0
|
||||
Jinja2==3.1.2
|
||||
joblib==1.3.2
|
||||
jsmin==3.0.1
|
||||
livereload==2.6.3
|
||||
lunr==0.7.0.post1
|
||||
Markdown==3.5
|
||||
markdown-include==0.8.1
|
||||
MarkupSafe==2.1.3
|
||||
mergedeep==1.3.4
|
||||
mkdocs==1.5.3
|
||||
mkdocs-git-revision-date-localized-plugin==1.2.1
|
||||
mkdocs-material==9.4.7
|
||||
mkdocs-material-extensions==1.3
|
||||
mkdocs-minify-plugin==0.7.1
|
||||
mkdocs-redirects==1.2.1
|
||||
mkdocs-simple-hooks==0.1.5
|
||||
nltk==3.8.1
|
||||
packaging==23.2
|
||||
plantuml==0.3.0
|
||||
plantuml-markdown==3.9.2
|
||||
Pygments==2.16.1
|
||||
pymdown-extensions==10.3.1
|
||||
pyparsing==3.1.1
|
||||
python-dateutil==2.8.2
|
||||
pytz==2023.3.post1
|
||||
PyYAML==6.0.1
|
||||
pyyaml_env_tag==0.1
|
||||
regex==2023.10.3
|
||||
requests==2.31.0
|
||||
six==1.16.0
|
||||
smmap==5.0.1
|
||||
tornado==6.3.3
|
||||
tqdm==4.66.1
|
||||
urllib3==2.0.7
|
||||
watchdog==3.0.0
|
||||
zipp==3.17.0
|
||||
mkdocs==1.6.1 # documentation framework
|
||||
mkdocs-git-revision-date-localized-plugin==1.3.0 # plugin "git-revision-date-localized"
|
||||
mkdocs-material==9.5.49 # theme for mkdocs
|
||||
mkdocs-material-extensions==1.3.1 # extensions
|
||||
mkdocs-minify-plugin==0.8.0 # plugin "minify"
|
||||
mkdocs-redirects==1.2.2 # plugin "redirects"
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
#define JSON_DIAGNOSTICS 0
|
||||
#endif
|
||||
|
||||
#ifndef JSON_DIAGNOSTIC_POSITIONS
|
||||
#define JSON_DIAGNOSTIC_POSITIONS 0
|
||||
#endif
|
||||
|
||||
#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
|
||||
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
|
||||
#endif
|
||||
@@ -36,6 +40,12 @@
|
||||
#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
|
||||
#endif
|
||||
|
||||
#if JSON_DIAGNOSTIC_POSITIONS
|
||||
#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS _dp
|
||||
#else
|
||||
#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS
|
||||
#endif
|
||||
|
||||
#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
|
||||
#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
|
||||
#else
|
||||
@@ -47,14 +57,15 @@
|
||||
#endif
|
||||
|
||||
// Construct the namespace ABI tags component
|
||||
#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b
|
||||
#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \
|
||||
NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b)
|
||||
#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c) json_abi ## a ## b ## c
|
||||
#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b, c) \
|
||||
NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c)
|
||||
|
||||
#define NLOHMANN_JSON_ABI_TAGS \
|
||||
NLOHMANN_JSON_ABI_TAGS_CONCAT( \
|
||||
NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
|
||||
NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
|
||||
NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON, \
|
||||
NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS)
|
||||
|
||||
// Construct the namespace version component
|
||||
#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
|
||||
|
||||
@@ -212,6 +212,54 @@ auto from_json(const BasicJsonType& j, T (&arr)[N]) // NOLINT(cppcoreguidelines
|
||||
}
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename T, std::size_t N1, std::size_t N2>
|
||||
auto from_json(const BasicJsonType& j, T (&arr)[N1][N2]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
-> decltype(j.template get<T>(), void())
|
||||
{
|
||||
for (std::size_t i1 = 0; i1 < N1; ++i1)
|
||||
{
|
||||
for (std::size_t i2 = 0; i2 < N2; ++i2)
|
||||
{
|
||||
arr[i1][i2] = j.at(i1).at(i2).template get<T>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename T, std::size_t N1, std::size_t N2, std::size_t N3>
|
||||
auto from_json(const BasicJsonType& j, T (&arr)[N1][N2][N3]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
-> decltype(j.template get<T>(), void())
|
||||
{
|
||||
for (std::size_t i1 = 0; i1 < N1; ++i1)
|
||||
{
|
||||
for (std::size_t i2 = 0; i2 < N2; ++i2)
|
||||
{
|
||||
for (std::size_t i3 = 0; i3 < N3; ++i3)
|
||||
{
|
||||
arr[i1][i2][i3] = j.at(i1).at(i2).at(i3).template get<T>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename T, std::size_t N1, std::size_t N2, std::size_t N3, std::size_t N4>
|
||||
auto from_json(const BasicJsonType& j, T (&arr)[N1][N2][N3][N4]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
-> decltype(j.template get<T>(), void())
|
||||
{
|
||||
for (std::size_t i1 = 0; i1 < N1; ++i1)
|
||||
{
|
||||
for (std::size_t i2 = 0; i2 < N2; ++i2)
|
||||
{
|
||||
for (std::size_t i3 = 0; i3 < N3; ++i3)
|
||||
{
|
||||
for (std::size_t i4 = 0; i4 < N4; ++i4)
|
||||
{
|
||||
arr[i1][i2][i3][i4] = j.at(i1).at(i2).at(i3).at(i4).template get<T>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename BasicJsonType>
|
||||
inline void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_t& arr, priority_tag<3> /*unused*/)
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user