mirror of
https://github.com/nlohmann/json.git
synced 2026-06-18 18:34:17 +00:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 02dfbea39d | |||
| a5f8e230ac | |||
| d8ebaf61d7 | |||
| a39f33b951 | |||
| e4bdf1be72 | |||
| d10879bca8 | |||
| 484483acad | |||
| 584e6b1cfb | |||
| a69a42a930 | |||
| 77388b95fc | |||
| e054d4df94 | |||
| d96329f8d6 | |||
| 1d7688aef2 | |||
| 58cfecf7f7 | |||
| 47202c804a | |||
| 4e5fa3bdd2 | |||
| cba5dc0ed8 | |||
| e08b3cab68 | |||
| 65c52ae1c8 | |||
| b1bb9fce0c | |||
| bb5404bb86 |
@@ -11,7 +11,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@9ca718d3bf646d6534007c269a635b3e54cadf99 # v2.19.2
|
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
@@ -34,18 +34,18 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@9ca718d3bf646d6534007c269a635b3e54cadf99 # v2.19.2
|
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Checkout pull request
|
- name: Checkout pull request
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
with:
|
with:
|
||||||
path: main
|
path: main
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
|
||||||
- name: Checkout tools
|
- name: Checkout tools
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
with:
|
with:
|
||||||
path: tools
|
path: tools
|
||||||
ref: develop
|
ref: develop
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ jobs:
|
|||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@9ca718d3bf646d6534007c269a635b3e54cadf99 # v2.19.2
|
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
|
|||||||
@@ -27,23 +27,23 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@9ca718d3bf646d6534007c269a635b3e54cadf99 # v2.19.2
|
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@68bde559dea0fdcac2102bfdf6230c5f70eb485e # v4.35.4
|
uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
|
||||||
with:
|
with:
|
||||||
languages: c-cpp
|
languages: c-cpp
|
||||||
|
|
||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
# If this step fails, then you should remove it and run the build manually (see below)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@68bde559dea0fdcac2102bfdf6230c5f70eb485e # v4.35.4
|
uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@68bde559dea0fdcac2102bfdf6230c5f70eb485e # v4.35.4
|
uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@9ca718d3bf646d6534007c269a635b3e54cadf99 # v2.19.2
|
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@9ca718d3bf646d6534007c269a635b3e54cadf99 # v2.19.2
|
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: 'Checkout Repository'
|
- name: 'Checkout Repository'
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: 'Dependency Review'
|
- name: 'Dependency Review'
|
||||||
uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0
|
uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0
|
||||||
|
|||||||
@@ -27,20 +27,20 @@ jobs:
|
|||||||
security-events: write
|
security-events: write
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@9ca718d3bf646d6534007c269a635b3e54cadf99 # v2.19.2
|
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
|
|
||||||
- name: flawfinder_scan
|
- name: flawfinder_scan
|
||||||
uses: david-a-wheeler/flawfinder@c57197cd6061453f10a496f30a732bc1905918d1 # v2.0.19
|
uses: david-a-wheeler/flawfinder@c4216b74cf2639ffa98503768bd6e4299b5440c9 # v2.0.20
|
||||||
with:
|
with:
|
||||||
arguments: '--sarif ./'
|
arguments: '--sarif ./'
|
||||||
output: 'flawfinder_results.sarif'
|
output: 'flawfinder_results.sarif'
|
||||||
|
|
||||||
- name: Upload analysis results to GitHub Security tab
|
- name: Upload analysis results to GitHub Security tab
|
||||||
uses: github/codeql-action/upload-sarif@68bde559dea0fdcac2102bfdf6230c5f70eb485e # v4
|
uses: github/codeql-action/upload-sarif@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4
|
||||||
with:
|
with:
|
||||||
sarif_file: ${{github.workspace}}/flawfinder_results.sarif
|
sarif_file: ${{github.workspace}}/flawfinder_results.sarif
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@9ca718d3bf646d6534007c269a635b3e54cadf99 # v2.19.2
|
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ jobs:
|
|||||||
# DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
# DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||||
#
|
#
|
||||||
# steps:
|
# steps:
|
||||||
# - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
# - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
# - name: Run CMake
|
# - name: Run CMake
|
||||||
# run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
|
# run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
|
||||||
# - name: Build
|
# - name: Build
|
||||||
@@ -45,7 +45,7 @@ jobs:
|
|||||||
# DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
# DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||||
#
|
#
|
||||||
# steps:
|
# steps:
|
||||||
# - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
# - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
# - name: Run CMake
|
# - name: Run CMake
|
||||||
# run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
|
# run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
|
||||||
# - name: Build
|
# - name: Build
|
||||||
@@ -63,7 +63,7 @@ jobs:
|
|||||||
# DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
# DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||||
#
|
#
|
||||||
# steps:
|
# steps:
|
||||||
# - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
# - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
# - name: Run CMake
|
# - name: Run CMake
|
||||||
# run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
|
# run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
|
||||||
# - name: Build
|
# - name: Build
|
||||||
@@ -80,7 +80,7 @@ jobs:
|
|||||||
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Run CMake
|
- name: Run CMake
|
||||||
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
|
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
|
||||||
- name: Build
|
- name: Build
|
||||||
@@ -97,7 +97,7 @@ jobs:
|
|||||||
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Run CMake
|
- name: Run CMake
|
||||||
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
|
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
|
||||||
- name: Build
|
- name: Build
|
||||||
@@ -112,7 +112,7 @@ jobs:
|
|||||||
standard: [11, 14, 17, 20, 23, 26]
|
standard: [11, 14, 17, 20, 23, 26]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Run CMake
|
- name: Run CMake
|
||||||
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_TestStandards=${{ matrix.standard }}
|
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_TestStandards=${{ matrix.standard }}
|
||||||
- name: Build
|
- name: Build
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ jobs:
|
|||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@9ca718d3bf646d6534007c269a635b3e54cadf99 # v2.19.2
|
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
|
|
||||||
- name: Install virtual environment
|
- name: Install virtual environment
|
||||||
run: make install_venv -C docs/mkdocs
|
run: make install_venv -C docs/mkdocs
|
||||||
|
|||||||
@@ -36,12 +36,12 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@9ca718d3bf646d6534007c269a635b3e54cadf99 # v2.19.2
|
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: "Checkout code"
|
- name: "Checkout code"
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
@@ -76,6 +76,6 @@ jobs:
|
|||||||
|
|
||||||
# Upload the results to GitHub's code scanning dashboard.
|
# Upload the results to GitHub's code scanning dashboard.
|
||||||
- name: "Upload to code-scanning"
|
- name: "Upload to code-scanning"
|
||||||
uses: github/codeql-action/upload-sarif@68bde559dea0fdcac2102bfdf6230c5f70eb485e # v4.35.4
|
uses: github/codeql-action/upload-sarif@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
|
||||||
with:
|
with:
|
||||||
sarif_file: results.sarif
|
sarif_file: results.sarif
|
||||||
|
|||||||
@@ -32,12 +32,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@9ca718d3bf646d6534007c269a635b3e54cadf99 # v2.19.2
|
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
# Checkout project source
|
# Checkout project source
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
|
|
||||||
# Scan code using project's configuration on https://semgrep.dev/manage
|
# Scan code using project's configuration on https://semgrep.dev/manage
|
||||||
- uses: returntocorp/semgrep-action@713efdd345f3035192eaa63f56867b88e63e4e5d
|
- uses: returntocorp/semgrep-action@713efdd345f3035192eaa63f56867b88e63e4e5d
|
||||||
@@ -48,7 +48,7 @@ jobs:
|
|||||||
|
|
||||||
# Upload SARIF file generated in previous step
|
# Upload SARIF file generated in previous step
|
||||||
- name: Upload SARIF file
|
- name: Upload SARIF file
|
||||||
uses: github/codeql-action/upload-sarif@68bde559dea0fdcac2102bfdf6230c5f70eb485e # v4
|
uses: github/codeql-action/upload-sarif@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4
|
||||||
with:
|
with:
|
||||||
sarif_file: semgrep.sarif
|
sarif_file: semgrep.sarif
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@9ca718d3bf646d6534007c269a635b3e54cadf99 # v2.19.2
|
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- uses: actions/stale@b5d41d4e1d5dceea10e7104786b73624c18a190f # v10.2.0
|
- uses: actions/stale@eb5cf3af3ac0a1aa4c9c45633dd1ae542a27a899 # v10.3.0
|
||||||
with:
|
with:
|
||||||
stale-issue-label: 'state: stale'
|
stale-issue-label: 'state: stale'
|
||||||
stale-pr-label: 'state: stale'
|
stale-pr-label: 'state: stale'
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: gcc:latest
|
container: gcc:latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Get latest CMake and ninja
|
- name: Get latest CMake and ninja
|
||||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
uses: lukka/get-cmake@591817e96fcad43505fb4eae36172462abb3a42e # v4.3.3
|
||||||
- name: Run CMake
|
- name: Run CMake
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
- name: Build
|
- name: Build
|
||||||
@@ -33,7 +33,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: ghcr.io/nlohmann/json-ci:v2.4.0
|
container: ghcr.io/nlohmann/json-ci:v2.4.0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Run CMake
|
- name: Run CMake
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
- name: Build
|
- name: Build
|
||||||
@@ -46,15 +46,15 @@ jobs:
|
|||||||
target: [ci_test_amalgamation, ci_test_single_header, ci_cppcheck, ci_cpplint, ci_reproducible_tests, ci_non_git_tests, ci_offline_testdata, ci_reuse_compliance, ci_test_valgrind]
|
target: [ci_test_amalgamation, ci_test_single_header, ci_cppcheck, ci_cpplint, ci_reproducible_tests, ci_non_git_tests, ci_offline_testdata, ci_reuse_compliance, ci_test_valgrind]
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@9ca718d3bf646d6534007c269a635b3e54cadf99 # v2.19.2
|
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Install Valgrind
|
- name: Install Valgrind
|
||||||
run: sudo apt-get update ; sudo apt-get install -y valgrind
|
run: sudo apt-get update ; sudo apt-get install -y valgrind
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Get latest CMake and ninja
|
- name: Get latest CMake and ninja
|
||||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
uses: lukka/get-cmake@591817e96fcad43505fb4eae36172462abb3a42e # v4.3.3
|
||||||
- name: Run CMake
|
- name: Run CMake
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
- name: Build
|
- name: Build
|
||||||
@@ -69,9 +69,9 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Install git, clang-tools, iwyu (ci_single_binaries), and unzip
|
- name: Install git, clang-tools, iwyu (ci_single_binaries), and unzip
|
||||||
run: apt-get update ; apt-get install -y git clang-tools iwyu unzip
|
run: apt-get update ; apt-get install -y git clang-tools iwyu unzip
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Get latest CMake and ninja
|
- name: Get latest CMake and ninja
|
||||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
uses: lukka/get-cmake@591817e96fcad43505fb4eae36172462abb3a42e # v4.3.3
|
||||||
- name: Run CMake
|
- name: Run CMake
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
- name: Build
|
- name: Build
|
||||||
@@ -86,9 +86,9 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Install build-essential
|
- name: Install build-essential
|
||||||
run: apt-get update ; apt-get install -y build-essential unzip wget git libssl-dev
|
run: apt-get update ; apt-get install -y build-essential unzip wget git libssl-dev
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Get latest CMake and ninja
|
- name: Get latest CMake and ninja
|
||||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
uses: lukka/get-cmake@591817e96fcad43505fb4eae36172462abb3a42e # v4.3.3
|
||||||
- name: Run CMake
|
- name: Run CMake
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
- name: Build
|
- name: Build
|
||||||
@@ -98,11 +98,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@9ca718d3bf646d6534007c269a635b3e54cadf99 # v2.19.2
|
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Install dependencies and de_DE locale
|
- name: Install dependencies and de_DE locale
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get clean
|
sudo apt-get clean
|
||||||
@@ -133,7 +133,7 @@ jobs:
|
|||||||
compiler: ['4.8', '4.9', '5', '6']
|
compiler: ['4.8', '4.9', '5', '6']
|
||||||
container: ghcr.io/nlohmann/json-ci:v2.4.0
|
container: ghcr.io/nlohmann/json-ci:v2.4.0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Run CMake
|
- name: Run CMake
|
||||||
run: CXX=g++-${{ matrix.compiler }} cmake -S . -B build -DJSON_CI=On
|
run: CXX=g++-${{ matrix.compiler }} cmake -S . -B build -DJSON_CI=On
|
||||||
- name: Build
|
- name: Build
|
||||||
@@ -147,9 +147,9 @@ jobs:
|
|||||||
compiler: ['7', '8', '9', '10', '11', '12', '13', '14', '15', 'latest']
|
compiler: ['7', '8', '9', '10', '11', '12', '13', '14', '15', 'latest']
|
||||||
container: gcc:${{ matrix.compiler }}
|
container: gcc:${{ matrix.compiler }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Get latest CMake and ninja
|
- name: Get latest CMake and ninja
|
||||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
uses: lukka/get-cmake@591817e96fcad43505fb4eae36172462abb3a42e # v4.3.3
|
||||||
- name: Run CMake
|
- name: Run CMake
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
- name: Build
|
- name: Build
|
||||||
@@ -162,9 +162,9 @@ jobs:
|
|||||||
compiler: ['3.4', '3.5', '3.6', '3.7', '3.8', '3.9', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15-bullseye', '16', '17', '18', '19', '20', 'latest']
|
compiler: ['3.4', '3.5', '3.6', '3.7', '3.8', '3.9', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15-bullseye', '16', '17', '18', '19', '20', 'latest']
|
||||||
container: silkeh/clang:${{ matrix.compiler }}
|
container: silkeh/clang:${{ matrix.compiler }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Get latest CMake and ninja
|
- name: Get latest CMake and ninja
|
||||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
uses: lukka/get-cmake@591817e96fcad43505fb4eae36172462abb3a42e # v4.3.3
|
||||||
- name: Set env FORCE_STDCPPFS_FLAG for clang 7 / 8 / 9 / 10
|
- 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"
|
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' }}
|
if: ${{ matrix.compiler == '7' || matrix.compiler == '8' || matrix.compiler == '9' || matrix.compiler == '10' }}
|
||||||
@@ -180,9 +180,9 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
standard: [11, 14, 17, 20, 23, 26]
|
standard: [11, 14, 17, 20, 23, 26]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Get latest CMake and ninja
|
- name: Get latest CMake and ninja
|
||||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
uses: lukka/get-cmake@591817e96fcad43505fb4eae36172462abb3a42e # v4.3.3
|
||||||
- name: Run CMake
|
- name: Run CMake
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
- name: Build
|
- name: Build
|
||||||
@@ -198,9 +198,9 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Install git and unzip
|
- name: Install git and unzip
|
||||||
run: apt-get update ; apt-get install -y git unzip
|
run: apt-get update ; apt-get install -y git unzip
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Get latest CMake and ninja
|
- name: Get latest CMake and ninja
|
||||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
uses: lukka/get-cmake@591817e96fcad43505fb4eae36172462abb3a42e # v4.3.3
|
||||||
- name: Run CMake
|
- name: Run CMake
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
- name: Build with libc++
|
- name: Build with libc++
|
||||||
@@ -214,7 +214,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: ghcr.io/nlohmann/json-ci:v2.4.0
|
container: ghcr.io/nlohmann/json-ci:v2.4.0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Run CMake
|
- name: Run CMake
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
- name: Build
|
- name: Build
|
||||||
@@ -227,9 +227,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: ${{ matrix.container }}
|
container: ${{ matrix.container }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Get latest CMake and ninja
|
- name: Get latest CMake and ninja
|
||||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
uses: lukka/get-cmake@591817e96fcad43505fb4eae36172462abb3a42e # v4.3.3
|
||||||
- name: Run CMake
|
- name: Run CMake
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
- name: Build
|
- name: Build
|
||||||
@@ -239,7 +239,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: ghcr.io/nlohmann/json-ci:v2.2.0
|
container: ghcr.io/nlohmann/json-ci:v2.2.0
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Run CMake
|
- name: Run CMake
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
- name: Build
|
- name: Build
|
||||||
@@ -251,15 +251,15 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@9ca718d3bf646d6534007c269a635b3e54cadf99 # v2.19.2
|
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Install emscripten
|
- name: Install emscripten
|
||||||
uses: mymindstorm/setup-emsdk@4528d102f7230f0e7b276855c01ea1159be0e984 # v16
|
uses: mymindstorm/setup-emsdk@4528d102f7230f0e7b276855c01ea1159be0e984 # v16
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Get latest CMake and ninja
|
- name: Get latest CMake and ninja
|
||||||
uses: lukka/get-cmake@7bfc9baacbbdcb5e37957ad05c3546b3e222be3c # v4.3.2
|
uses: lukka/get-cmake@591817e96fcad43505fb4eae36172462abb3a42e # v4.3.3
|
||||||
- name: Run CMake
|
- name: Run CMake
|
||||||
run: cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -GNinja
|
run: cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -GNinja
|
||||||
- name: Build
|
- name: Build
|
||||||
@@ -272,11 +272,11 @@ jobs:
|
|||||||
target: [ci_test_examples, ci_test_build_documentation]
|
target: [ci_test_examples, ci_test_build_documentation]
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@9ca718d3bf646d6534007c269a635b3e54cadf99 # v2.19.2
|
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Run CMake
|
- name: Run CMake
|
||||||
run: cmake -S . -B build -DJSON_CI=On
|
run: cmake -S . -B build -DJSON_CI=On
|
||||||
- name: Build
|
- name: Build
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ jobs:
|
|||||||
architecture: [x64, x86]
|
architecture: [x64, x86]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Set up MinGW
|
- name: Set up MinGW
|
||||||
uses: egor-tensin/setup-mingw@41b837e47d7f85214629d255b9c4bc3fcbe9fd63 # v3.0
|
uses: egor-tensin/setup-mingw@41b837e47d7f85214629d255b9c4bc3fcbe9fd63 # v3.0
|
||||||
with:
|
with:
|
||||||
@@ -47,7 +47,7 @@ jobs:
|
|||||||
runs-on: windows-2022
|
runs-on: windows-2022
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Set extra CXX_FLAGS for latest std_version
|
- name: Set extra CXX_FLAGS for latest std_version
|
||||||
id: cxxflags
|
id: cxxflags
|
||||||
run: |
|
run: |
|
||||||
@@ -77,7 +77,7 @@ jobs:
|
|||||||
version: [11.0.1, 12.0.1, 13.0.1, 14.0.6, 15.0.7, 16.0.6, 18.1.8, 19.1.7, 20.1.8]
|
version: [11.0.1, 12.0.1, 13.0.1, 14.0.6, 15.0.7, 16.0.6, 18.1.8, 19.1.7, 20.1.8]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Install Clang
|
- name: Install Clang
|
||||||
run: curl -fsSL -o LLVM${{ matrix.version }}.exe https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ matrix.version }}/LLVM-${{ matrix.version }}-win64.exe ; 7z x LLVM${{ matrix.version }}.exe -y -o"C:/Program Files/LLVM"
|
run: curl -fsSL -o LLVM${{ matrix.version }}.exe https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ matrix.version }}/LLVM-${{ matrix.version }}-win64.exe ; 7z x LLVM${{ matrix.version }}.exe -y -o"C:/Program Files/LLVM"
|
||||||
- name: Set up MinGW
|
- name: Set up MinGW
|
||||||
@@ -105,7 +105,7 @@ jobs:
|
|||||||
architecture: [Win32, x64]
|
architecture: [Win32, x64]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Run CMake
|
- name: Run CMake
|
||||||
run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -T ClangCL -DJSON_BuildTests=On
|
run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -T ClangCL -DJSON_BuildTests=On
|
||||||
- name: Build
|
- name: Build
|
||||||
@@ -114,9 +114,9 @@ jobs:
|
|||||||
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure
|
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure
|
||||||
|
|
||||||
ci_module_cpp20:
|
ci_module_cpp20:
|
||||||
runs-on: windows-latest
|
runs-on: windows-2022
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- name: Run CMake (Debug)
|
- name: Run CMake (Debug)
|
||||||
run: cmake -S . -B build -G "Visual Studio 17 2022" -DJSON_CI=ON -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4 /WX"
|
run: cmake -S . -B build -G "Visual Studio 17 2022" -DJSON_CI=ON -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4 /WX"
|
||||||
- name: Build
|
- name: Build
|
||||||
|
|||||||
@@ -855,9 +855,9 @@ Some important things:
|
|||||||
|
|
||||||
#### Simplify your life with macros
|
#### Simplify your life with macros
|
||||||
|
|
||||||
If you just want to serialize/deserialize some structs, the `to_json`/`from_json` functions can be a lot of boilerplate. There are [**several macros**](https://json.nlohmann.me/features/arbitrary_types/#simplify-your-life-with-macros) to make your life easier as long as you (1) want to use a JSON object as serialization and (2) want to use the member variable names as object keys in that object.
|
If you just want to serialize/deserialize some structs, the `to_json`/`from_json` functions can be a lot of boilerplate. There are [**several macros**](https://json.nlohmann.me/api/macros/#serializationdeserialization-macros) to make your life easier as long as you want to use a JSON object as serialization.
|
||||||
|
|
||||||
Which macro to choose depends on whether private member variables need to be accessed, a deserialization is needed, missing values should yield an error or should be replaced by default values, and if derived classes are used. See [this overview to choose the right one for your use case](https://json.nlohmann.me/api/macros/#serializationdeserialization-macros).
|
Which macro to choose depends on whether private member variables need to be accessed, a deserialization is needed, missing values should yield an error or should be replaced by default values, and if derived classes are used. See [this overview to choose the right one for your use case](https://json.nlohmann.me/features/arbitrary_types/#simplify-your-life-with-macros).
|
||||||
|
|
||||||
##### Example usage of macros
|
##### Example usage of macros
|
||||||
|
|
||||||
@@ -869,6 +869,18 @@ namespace ns {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you want to inherit the `person` struct and add a field to it, it can be done with:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
namespace ns {
|
||||||
|
struct person_derived : person {
|
||||||
|
std::string email;
|
||||||
|
};
|
||||||
|
|
||||||
|
NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(person_derived, person, email)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Here is another example with private members, where [`NLOHMANN_DEFINE_TYPE_INTRUSIVE`](https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/) is needed:
|
Here is another example with private members, where [`NLOHMANN_DEFINE_TYPE_INTRUSIVE`](https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/) is needed:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
@@ -885,6 +897,24 @@ namespace ns {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Or in case if you use some naming convention that you do not want to expose to JSON:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
namespace ns {
|
||||||
|
class address {
|
||||||
|
private:
|
||||||
|
std::string m_street;
|
||||||
|
int m_housenumber;
|
||||||
|
int m_postcode;
|
||||||
|
|
||||||
|
public:
|
||||||
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_NAMES(address, "street", m_street,
|
||||||
|
"housenumber", m_housenumber,
|
||||||
|
"postcode", m_postcode)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#### How do I convert third-party types?
|
#### How do I convert third-party types?
|
||||||
|
|
||||||
This requires a bit more advanced technique. But first, let's see how this conversion mechanism works:
|
This requires a bit more advanced technique. But first, let's see how this conversion mechanism works:
|
||||||
@@ -1075,7 +1105,7 @@ Just as in [Arbitrary Type Conversions](#arbitrary-types-conversions) above,
|
|||||||
|
|
||||||
Other Important points:
|
Other Important points:
|
||||||
|
|
||||||
- When using `get<ENUM_TYPE>()`, undefined JSON values will default to the first pair specified in your map. Select this default pair carefully.
|
- When using `get<ENUM_TYPE>()`, undefined JSON values will default to the first pair specified in your map. Select this default pair carefully. If you desire an exception in this circumstance use `NLOHMANN_JSON_SERIALIZE_ENUM_STRICT()` which behaves identically except for throwing an exception on unrecognized values.
|
||||||
- If an enum or JSON value is specified more than once in your map, the first matching occurrence from the top of the map will be returned when converting to or from JSON.
|
- If an enum or JSON value is specified more than once in your map, the first matching occurrence from the top of the map will be returned when converting to or from JSON.
|
||||||
|
|
||||||
### Binary formats (BSON, CBOR, MessagePack, UBJSON, and BJData)
|
### Binary formats (BSON, CBOR, MessagePack, UBJSON, and BJData)
|
||||||
|
|||||||
@@ -90,10 +90,25 @@ Depends on what `json_serializer<ValueType>` `from_json()` method throws
|
|||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
!!! danger "Undefined behavior"
|
!!! danger "Undefined behavior for pointers"
|
||||||
|
|
||||||
Writing data to the pointee (overload 3) of the result yields an undefined state.
|
Writing data to the pointee (overload 3) of the result yields an undefined state.
|
||||||
|
|
||||||
|
!!! danger "Undefined behavior for numeric conversions"
|
||||||
|
|
||||||
|
Conversions between numeric types are performed by the corresponding
|
||||||
|
`from_json()` implementation using the target C++ type. When converting
|
||||||
|
between numeric types, the library does not check whether the source
|
||||||
|
value is representable by the target type.
|
||||||
|
|
||||||
|
If the source value is outside the range of the target type, the behavior
|
||||||
|
is the same as the corresponding C++ conversion. In particular, converting
|
||||||
|
a floating-point value to an integer type that cannot represent the value
|
||||||
|
results in undefined behavior.
|
||||||
|
|
||||||
|
See [Number conversion](../../features/types/number_handling.md#number-conversion)
|
||||||
|
for more information.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
??? example
|
??? example
|
||||||
|
|||||||
@@ -92,7 +92,6 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va
|
|||||||
- Throws [`parse_error.102`](../../home/exceptions.md#jsonexceptionparse_error102) if `to_unicode` fails or surrogate
|
- Throws [`parse_error.102`](../../home/exceptions.md#jsonexceptionparse_error102) if `to_unicode` fails or surrogate
|
||||||
error.
|
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.
|
||||||
- Throws [`other_error.502`](../../home/exceptions.md#jsonexceptionother_error502) if `sax` is a null pointer.
|
|
||||||
|
|
||||||
## Complexity
|
## Complexity
|
||||||
|
|
||||||
@@ -125,7 +124,6 @@ A UTF-8 byte order mark is silently ignored.
|
|||||||
- Added in version 3.2.0.
|
- Added in version 3.2.0.
|
||||||
- Ignoring comments via `ignore_comments` added in version 3.9.0.
|
- Ignoring comments via `ignore_comments` added in version 3.9.0.
|
||||||
- Added `ignore_trailing_commas` in version 3.12.1.
|
- Added `ignore_trailing_commas` in version 3.12.1.
|
||||||
- Added `json.exception.other_error.502` exception in version 3.12.1.
|
|
||||||
|
|
||||||
!!! warning "Deprecation"
|
!!! warning "Deprecation"
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ header. See also the [macro overview page](../../features/macros.md).
|
|||||||
### Enums
|
### Enums
|
||||||
|
|
||||||
- [**NLOHMANN_JSON_SERIALIZE_ENUM**](nlohmann_json_serialize_enum.md) - serialize/deserialize an enum
|
- [**NLOHMANN_JSON_SERIALIZE_ENUM**](nlohmann_json_serialize_enum.md) - serialize/deserialize an enum
|
||||||
|
- [**NLOHMANN_JSON_SERIALIZE_ENUM_STRICT**](nlohmann_json_serialize_enum_strict.md) - serialize/deserialize an enum with exceptions
|
||||||
|
|
||||||
### Classes and structs
|
### Classes and structs
|
||||||
|
|
||||||
@@ -82,3 +83,28 @@ header. See also the [macro overview page](../../features/macros.md).
|
|||||||
a derived class; uses default values
|
a derived class; uses default values
|
||||||
- [**NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE**](nlohmann_define_derived_type.md) - serialize a derived
|
- [**NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE**](nlohmann_define_derived_type.md) - serialize a derived
|
||||||
class
|
class
|
||||||
|
- [**NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_NAMES**](nlohmann_define_type_with_names.md) - serialize/deserialize a non-derived class
|
||||||
|
with private members; uses custom names
|
||||||
|
- [**NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT_WITH_NAMES**](nlohmann_define_type_with_names.md) - serialize/deserialize a
|
||||||
|
non-derived class with private members; uses default values; uses custom names
|
||||||
|
- [**NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES**](nlohmann_define_type_with_names.md) - serialize a non-derived class
|
||||||
|
with private members; uses custom names
|
||||||
|
- [**NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_NAMES**](nlohmann_define_type_with_names.md) - serialize/deserialize a non-derived
|
||||||
|
class; uses custom names
|
||||||
|
- [**NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT_WITH_NAMES**](nlohmann_define_type_with_names.md) - serialize/deserialize a
|
||||||
|
non-derived class; uses default values; uses custom names
|
||||||
|
- [**NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES**](nlohmann_define_type_with_names.md) - serialize a
|
||||||
|
non-derived class; uses custom names
|
||||||
|
|
||||||
|
- [**NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_NAMES**](nlohmann_define_type_with_names.md) - serialize/deserialize a derived class
|
||||||
|
with private members; uses custom names
|
||||||
|
- [**NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT_WITH_NAMES**](nlohmann_define_type_with_names.md) - serialize/deserialize a
|
||||||
|
derived class with private members; uses default values; uses custom names
|
||||||
|
- [**NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES**](nlohmann_define_type_with_names.md) - serialize a derived
|
||||||
|
class with private members; uses custom names
|
||||||
|
- [**NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_NAMES**](nlohmann_define_type_with_names.md) - serialize/deserialize a derived
|
||||||
|
class; uses custom names
|
||||||
|
- [**NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT_WITH_NAMES**](nlohmann_define_type_with_names.md) - serialize/deserialize
|
||||||
|
a derived class; uses default values; uses custom names
|
||||||
|
- [**NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES**](nlohmann_define_type_with_names.md) - serialize a derived
|
||||||
|
class; uses custom names
|
||||||
@@ -57,7 +57,7 @@ Summary:
|
|||||||
: name of the base type (class, struct) `type` is derived from
|
: name of the base type (class, struct) `type` is derived from
|
||||||
|
|
||||||
`member` (in)
|
`member` (in)
|
||||||
: name of the member variable to serialize/deserialize; up to 64 members can be given as a comma-separated list
|
: name of the member variable to serialize/deserialize; up to 63 members can be given as a comma-separated list
|
||||||
|
|
||||||
## Default definition
|
## Default definition
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ Summary:
|
|||||||
: name of the type (class, struct) to serialize/deserialize
|
: name of the type (class, struct) to serialize/deserialize
|
||||||
|
|
||||||
`member` (in)
|
`member` (in)
|
||||||
: name of the member variable to serialize/deserialize; up to 64 members can be given as a comma-separated list
|
: name of the member variable to serialize/deserialize; up to 63 members can be given as a comma-separated list
|
||||||
|
|
||||||
## Default definition
|
## Default definition
|
||||||
|
|
||||||
@@ -60,8 +60,8 @@ See the examples below for the concrete generated code.
|
|||||||
|
|
||||||
!!! warning "Implementation limits"
|
!!! warning "Implementation limits"
|
||||||
|
|
||||||
- The current implementation is limited to at most 64 member variables. If you want to serialize/deserialize types
|
- The current implementation is limited to at most 63 member variables. If you want to serialize/deserialize types
|
||||||
with more than 64 member variables, you need to define the `to_json`/`from_json` functions manually.
|
with more than 63 member variables, you need to define the `to_json`/`from_json` functions manually.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ Summary:
|
|||||||
: name of the type (class, struct) to serialize/deserialize
|
: name of the type (class, struct) to serialize/deserialize
|
||||||
|
|
||||||
`member` (in)
|
`member` (in)
|
||||||
: name of the (public) member variable to serialize/deserialize; up to 64 members can be given as a comma-separated list
|
: name of the (public) member variable to serialize/deserialize; up to 63 members can be given as a comma-separated list
|
||||||
|
|
||||||
## Default definition
|
## Default definition
|
||||||
|
|
||||||
@@ -61,8 +61,8 @@ See the examples below for the concrete generated code.
|
|||||||
|
|
||||||
!!! warning "Implementation limits"
|
!!! warning "Implementation limits"
|
||||||
|
|
||||||
- The current implementation is limited to at most 64 member variables. If you want to serialize/deserialize types
|
- The current implementation is limited to at most 63 member variables. If you want to serialize/deserialize types
|
||||||
with more than 64 member variables, you need to define the `to_json`/`from_json` functions manually.
|
with more than 63 member variables, you need to define the `to_json`/`from_json` functions manually.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<h1>NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_NAMES, NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT_WITH_NAMES,
|
||||||
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES, NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_NAMES,
|
||||||
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT_WITH_NAMES, NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES,
|
||||||
|
NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_NAMES, NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT_WITH_NAMES,
|
||||||
|
NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES, NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_NAMES,
|
||||||
|
NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT_WITH_NAMES, NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES</h1>
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_NAMES(type, "json_member_name", member...)
|
||||||
|
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT_WITH_NAMES(type, "json_member_name", member...)
|
||||||
|
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES(type, "json_member_name", member...)
|
||||||
|
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_NAMES(type, "json_member_name", member...)
|
||||||
|
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT_WITH_NAMES(type, "json_member_name", member...)
|
||||||
|
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES(type, "json_member_name", member...)
|
||||||
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_NAMES(type, base_type, "json_member_name", member...)
|
||||||
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT_WITH_NAMES(type, base_type, "json_member_name", member...)
|
||||||
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES(type, base_type, "json_member_name", member...)
|
||||||
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_NAMES(type, base_type, "json_member_name", member...)
|
||||||
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT_WITH_NAMES(type, base_type, "json_member_name", member...)
|
||||||
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES(type, base_type, "json_member_name", member...)
|
||||||
|
```
|
||||||
|
|
||||||
|
These macros can be used in case you want to use the custom names for the member variables in the resulting JSON.
|
||||||
|
They behave exactly as their non-`WITH_NAMES` counterparts, but require an additional parameter for each member variable
|
||||||
|
which will be used in JSON. Both serialization and deserialization will only use the custom names for JSON, the names of
|
||||||
|
the member variables themselves will be ignored.
|
||||||
|
|
||||||
|
Using the named conversion macros will halve the maximum number of member variables from 63 to 31.
|
||||||
|
|
||||||
|
For further information please refer to the corresponding macros without `WITH_NAMES`.
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
`type` (in)
|
||||||
|
: name of the type (class, struct) to serialize/deserialize
|
||||||
|
|
||||||
|
`base_type` (in)
|
||||||
|
: name of the base type (class, struct) `type` is derived from (used only in `DEFINE_DERIVED_TYPE` macros)
|
||||||
|
|
||||||
|
`json_member_name` (in)
|
||||||
|
: the string that will be used as the name for the next value
|
||||||
|
|
||||||
|
`member` (in)
|
||||||
|
: name of the member variable to serialize/deserialize
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example "Example (1): NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_NAMES"
|
||||||
|
|
||||||
|
Consider the following complete example:
|
||||||
|
|
||||||
|
```cpp hl_lines="16"
|
||||||
|
--8<-- "examples/nlohmann_define_type_non_intrusive_with_names_macro.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```json
|
||||||
|
--8<-- "examples/nlohmann_define_type_non_intrusive_with_names_macro.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
- `ns::person` is default-constructible. This is a requirement for using the macro.
|
||||||
|
- `ns::person` has only public member variables. This makes `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_NAMES` applicable.
|
||||||
|
- The macro `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_NAMES` is used _outside_ the class, but _inside_ its namespace `ns`.
|
||||||
|
- A missing key "age" in the deserialization yields an exception. To fall back to the default value,
|
||||||
|
`NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT_WITH_NAMES` can be used.
|
||||||
|
|
||||||
|
The macro is equivalent to:
|
||||||
|
|
||||||
|
```cpp hl_lines="16 17 18 19 20 21 22 23 24 25 26 27 28"
|
||||||
|
--8<-- "examples/nlohmann_define_type_non_intrusive_with_names_explicit.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
1. Added in version 3.11.x.
|
||||||
@@ -78,6 +78,7 @@ inline void from_json(const BasicJsonType& j, type& e);
|
|||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [Specializing enum conversion](../../features/enum_conversion.md)
|
- [Specializing enum conversion](../../features/enum_conversion.md)
|
||||||
|
- [`NLOHMANN_JSON_SERIALIZE_ENUM_STRICT`](./nlohmann_json_serialize_enum_strict.md)
|
||||||
- [`JSON_DISABLE_ENUM_SERIALIZATION`](json_disable_enum_serialization.md)
|
- [`JSON_DISABLE_ENUM_SERIALIZATION`](json_disable_enum_serialization.md)
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
# NLOHMANN_JSON_SERIALIZE_ENUM_STRICT
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
#define NLOHMANN_JSON_SERIALIZE_ENUM_STRICT(type, conversion...)
|
||||||
|
```
|
||||||
|
|
||||||
|
By default, enum values are serialized to JSON as integers. In some cases, this could result in undesired behavior. If
|
||||||
|
an enum is modified or re-ordered after data has been serialized to JSON, the later deserialized JSON data may be
|
||||||
|
undefined or a different enum value than was originally intended.
|
||||||
|
|
||||||
|
`NLOHMANN_JSON_SERIALIZE_ENUM_STRICT` allows to define a user-defined serialization for every enumerator that
|
||||||
|
throws an exception on undefined input.
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
`type` (in)
|
||||||
|
: name of the enum to serialize/deserialize
|
||||||
|
|
||||||
|
`conversion` (in)
|
||||||
|
: a pair of an enumerator and a JSON serialization; arbitrary pairs can be given as a comma-separated list
|
||||||
|
|
||||||
|
## Default definition
|
||||||
|
|
||||||
|
The macro adds two functions to the namespace which take care of the serialization and deserialization:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
template<typename BasicJsonType>
|
||||||
|
inline void to_json(BasicJsonType& j, const type& e);
|
||||||
|
template<typename BasicJsonType>
|
||||||
|
inline void from_json(const BasicJsonType& j, type& e);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
!!! info "Prerequisites"
|
||||||
|
|
||||||
|
The macro must be used inside the namespace of the enum.
|
||||||
|
|
||||||
|
!!! important "Important notes"
|
||||||
|
|
||||||
|
- When using [`get<ENUM_TYPE>()`](../basic_json/get.md), undefined JSON values will throw an exception.
|
||||||
|
- If an enum or JSON value is specified in multiple conversions, the first matching conversion from the top of the
|
||||||
|
list will be returned when converting to or from JSON. See example 2 below.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
??? example "Example 1: Basic usage"
|
||||||
|
|
||||||
|
The example shows how `NLOHMANN_JSON_SERIALIZE_ENUM_STRICT` can be used to serialize/deserialize both classical enums and
|
||||||
|
C++11 enum classes:
|
||||||
|
|
||||||
|
```cpp hl_lines="16 17 18 19 20 21 22 29 30 31 32 33"
|
||||||
|
--8<-- "examples/nlohmann_json_serialize_enum_strict.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```json
|
||||||
|
--8<-- "examples/nlohmann_json_serialize_enum_strict.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
??? example "Example 2: Multiple conversions for one enumerator"
|
||||||
|
|
||||||
|
The example shows how to use multiple conversions for a single enumerator. In the example, `Color::red` will always
|
||||||
|
be *serialized* to `"red"`, because the first occurring conversion. The second conversion, however, offers an
|
||||||
|
alternative *deserialization* from `"rot"` to `Color::red`.
|
||||||
|
|
||||||
|
```cpp hl_lines="17"
|
||||||
|
--8<-- "examples/nlohmann_json_serialize_enum_strict_2.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
```json
|
||||||
|
--8<-- "examples/nlohmann_json_serialize_enum_strict_2.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
??? example "Example 3: exceptions on invalid serialization"
|
||||||
|
|
||||||
|
The example shows how an invalid serialization causes an exception to be thrown. In the example,
|
||||||
|
Color::unknown is not defined in the mapping used to call `NLOHMANN_JSON_SERIALIZE_ENUM_STRICT`
|
||||||
|
so causes an exception when used to serialize. Similarly, "what" does not refer to an enum
|
||||||
|
value so also causes an exception when deserialization is attempted.
|
||||||
|
|
||||||
|
```cpp hl_lines="14 32 33 43 44 45"
|
||||||
|
--8<-- "examples/nlohmann_json_serialize_enum_strict_err.cpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
```json
|
||||||
|
--8<-- "examples/nlohmann_json_serialize_enum_strict_err.output"
|
||||||
|
```
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
- [Specializing enum conversion](../../features/enum_conversion.md)
|
||||||
|
- [`NLOHMANN_JSON_SERIALIZE_ENUM`](./nlohmann_json_serialize_enum.md)
|
||||||
|
- [`JSON_DISABLE_ENUM_SERIALIZATION`](json_disable_enum_serialization.md)
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
Added in version 3.12.0.
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
using namespace nlohmann::literals;
|
||||||
|
|
||||||
|
namespace ns
|
||||||
|
{
|
||||||
|
struct person
|
||||||
|
{
|
||||||
|
std::string name;
|
||||||
|
std::string address;
|
||||||
|
int age;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
||||||
|
void to_json(BasicJsonType& nlohmann_json_j, const person& nlohmann_json_t)
|
||||||
|
{
|
||||||
|
nlohmann_json_j["json_name"] = nlohmann_json_t.name;
|
||||||
|
nlohmann_json_j["json_address"] = nlohmann_json_t.address;
|
||||||
|
nlohmann_json_j["json_age"] = nlohmann_json_t.age;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
||||||
|
void from_json(const BasicJsonType& nlohmann_json_j, person& nlohmann_json_t)
|
||||||
|
{
|
||||||
|
nlohmann_json_j.at("json_name").get_to(nlohmann_json_t.name);
|
||||||
|
nlohmann_json_j.at("json_address").get_to(nlohmann_json_t.address);
|
||||||
|
nlohmann_json_j.at("json_age").get_to(nlohmann_json_t.age);
|
||||||
|
}
|
||||||
|
} // namespace ns
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
|
||||||
|
|
||||||
|
// serialization: person -> json
|
||||||
|
json j = p;
|
||||||
|
std::cout << "serialization: " << j << std::endl;
|
||||||
|
|
||||||
|
// deserialization: json -> person
|
||||||
|
json j2 = R"({"json_address": "742 Evergreen Terrace", "json_age": 40, "json_name": "Homer Simpson"})"_json;
|
||||||
|
auto p2 = j2.template get<ns::person>();
|
||||||
|
|
||||||
|
// incomplete deserialization:
|
||||||
|
json j3 = R"({"json_address": "742 Evergreen Terrace", "json_name": "Maggie Simpson"})"_json;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
auto p3 = j3.template get<ns::person>();
|
||||||
|
}
|
||||||
|
catch (const json::exception& e)
|
||||||
|
{
|
||||||
|
std::cout << "deserialization failed: " << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
serialization: {"json_address":"744 Evergreen Terrace","json_age":60,"json_name":"Ned Flanders"}
|
||||||
|
deserialization failed: [json.exception.out_of_range.403] key 'json_age' not found
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
using namespace nlohmann::literals;
|
||||||
|
|
||||||
|
namespace ns
|
||||||
|
{
|
||||||
|
struct person
|
||||||
|
{
|
||||||
|
std::string name;
|
||||||
|
std::string address;
|
||||||
|
int age;
|
||||||
|
};
|
||||||
|
|
||||||
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_NAMES(person, "json_name", name, "json_address", address, "json_age", age)
|
||||||
|
} // namespace ns
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
|
||||||
|
|
||||||
|
// serialization: person -> json
|
||||||
|
json j = p;
|
||||||
|
std::cout << "serialization: " << j << std::endl;
|
||||||
|
|
||||||
|
// deserialization: json -> person
|
||||||
|
json j2 = R"({"json_address": "742 Evergreen Terrace", "json_age": 40, "json_name": "Homer Simpson"})"_json;
|
||||||
|
auto p2 = j2.template get<ns::person>();
|
||||||
|
|
||||||
|
// incomplete deserialization:
|
||||||
|
json j3 = R"({"json_address": "742 Evergreen Terrace", "json_name": "Maggie Simpson"})"_json;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
auto p3 = j3.template get<ns::person>();
|
||||||
|
}
|
||||||
|
catch (const json::exception& e)
|
||||||
|
{
|
||||||
|
std::cout << "deserialization failed: " << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
serialization: {"json_address":"744 Evergreen Terrace","json_age":60,"json_name":"Ned Flanders"}
|
||||||
|
deserialization failed: [json.exception.out_of_range.403] key 'json_age' not found
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
namespace ns
|
||||||
|
{
|
||||||
|
enum TaskState
|
||||||
|
{
|
||||||
|
TS_STOPPED,
|
||||||
|
TS_RUNNING,
|
||||||
|
TS_COMPLETED,
|
||||||
|
TS_INVALID = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
NLOHMANN_JSON_SERIALIZE_ENUM_STRICT(TaskState,
|
||||||
|
{
|
||||||
|
{ TS_INVALID, nullptr },
|
||||||
|
{ TS_STOPPED, "stopped" },
|
||||||
|
{ TS_RUNNING, "running" },
|
||||||
|
{ TS_COMPLETED, "completed" }
|
||||||
|
})
|
||||||
|
|
||||||
|
enum class Color
|
||||||
|
{
|
||||||
|
red, green, blue, unknown
|
||||||
|
};
|
||||||
|
|
||||||
|
NLOHMANN_JSON_SERIALIZE_ENUM_STRICT(Color,
|
||||||
|
{
|
||||||
|
{ Color::unknown, "unknown" }, { Color::red, "red" },
|
||||||
|
{ Color::green, "green" }, { Color::blue, "blue" }
|
||||||
|
})
|
||||||
|
} // namespace ns
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// serialization
|
||||||
|
json j_stopped = ns::TS_STOPPED;
|
||||||
|
json j_red = ns::Color::red;
|
||||||
|
std::cout << "ns::TS_STOPPED -> " << j_stopped
|
||||||
|
<< ", ns::Color::red -> " << j_red << std::endl;
|
||||||
|
|
||||||
|
// deserialization
|
||||||
|
json j_running = "running";
|
||||||
|
json j_blue = "blue";
|
||||||
|
auto running = j_running.get<ns::TaskState>();
|
||||||
|
auto blue = j_blue.get<ns::Color>();
|
||||||
|
std::cout << j_running << " -> " << running
|
||||||
|
<< ", " << j_blue << " -> " << static_cast<int>(blue) << std::endl;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
ns::TS_STOPPED -> "stopped", ns::Color::red -> "red"
|
||||||
|
"running" -> 1, "blue" -> 2
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
namespace ns
|
||||||
|
{
|
||||||
|
enum class Color
|
||||||
|
{
|
||||||
|
red, green, blue, unknown
|
||||||
|
};
|
||||||
|
|
||||||
|
NLOHMANN_JSON_SERIALIZE_ENUM_STRICT(Color,
|
||||||
|
{
|
||||||
|
{ Color::unknown, "unknown" }, { Color::red, "red" },
|
||||||
|
{ Color::green, "green" }, { Color::blue, "blue" },
|
||||||
|
{ Color::red, "rot" } // a second conversion for Color::red
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// serialization
|
||||||
|
json j_red = ns::Color::red;
|
||||||
|
std::cout << static_cast<int>(ns::Color::red) << " -> " << j_red << std::endl;
|
||||||
|
|
||||||
|
// deserialization
|
||||||
|
json j_rot = "rot";
|
||||||
|
auto rot = j_rot.get<ns::Color>();
|
||||||
|
auto red = j_red.get<ns::Color>();
|
||||||
|
std::cout << j_rot << " -> " << static_cast<int>(rot) << std::endl;
|
||||||
|
std::cout << j_red << " -> " << static_cast<int>(red) << std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
0 -> "red"
|
||||||
|
"rot" -> 0
|
||||||
|
"red" -> 0
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
namespace ns
|
||||||
|
{
|
||||||
|
|
||||||
|
enum class Color
|
||||||
|
{
|
||||||
|
red,
|
||||||
|
green,
|
||||||
|
blue,
|
||||||
|
unknown // not mapped in JSON_SERIALIZE_ENUM_STRICT
|
||||||
|
};
|
||||||
|
|
||||||
|
NLOHMANN_JSON_SERIALIZE_ENUM_STRICT(Color,
|
||||||
|
{
|
||||||
|
{Color::red, "red"},
|
||||||
|
{Color::green, "green"},
|
||||||
|
{Color::blue, "blue"}
|
||||||
|
})
|
||||||
|
|
||||||
|
} // namespace ns
|
||||||
|
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// invalid serialization
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// ns::color::unknown was not mapped in macro
|
||||||
|
json invalid_serialization = ns::Color::unknown;
|
||||||
|
}
|
||||||
|
catch (const json::exception e)
|
||||||
|
{
|
||||||
|
std::cout << "deserialization failed: " << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// invalid deserialization
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// what does not map to an enum
|
||||||
|
json invalid_deserialization("what");
|
||||||
|
ns::Color color = invalid_deserialization.get<ns::Color>();
|
||||||
|
}
|
||||||
|
catch (const json::exception e)
|
||||||
|
{
|
||||||
|
std::cout << "deserialization failed: " << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
deserialization failed: [json.exception.out_of_range.410] enum value out of range for Color
|
||||||
|
deserialization failed: [json.exception.out_of_range.410] enum value out of range for Color: "what"
|
||||||
@@ -85,16 +85,18 @@ Some important things:
|
|||||||
|
|
||||||
If you just want to serialize/deserialize some structs, the `to_json`/`from_json` functions can be a lot of boilerplate.
|
If you just want to serialize/deserialize some structs, the `to_json`/`from_json` functions can be a lot of boilerplate.
|
||||||
|
|
||||||
There are six macros to make your life easier as long as you (1) want to use a JSON object as serialization and (2) want to use the member variable names as object keys in that object:
|
There are several macros to make your life easier as long as you want to use a JSON object as serialization. The macros are following the naming pattern, and you can chose the macro based on the needed features:
|
||||||
|
|
||||||
- [`NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(name, member1, member2, ...)`](../api/macros/nlohmann_define_type_non_intrusive.md) is to be defined inside the namespace of the class/struct to create code for. It will throw an exception in `from_json()` due to a missing value in the JSON object.
|
- All the macros start with `NLOHMANN_DEFINE`.
|
||||||
- [`NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(name, member1, member2, ...)`](../api/macros/nlohmann_define_type_non_intrusive.md) is to be defined inside the namespace of the class/struct to create code for. It will not throw an exception in `from_json()` due to a missing value in the JSON object, but fills in values from an object which is default-constructed by the type.
|
- If you want a macro for the derived object, use the [`DERIVED_TYPE`](../api/macros/nlohmann_define_derived_type.md) variant, otherwise use `TYPE`.
|
||||||
- [`NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(name, member1, member2, ...)`](../api/macros/nlohmann_define_type_non_intrusive.md) is to be defined inside the namespace of the class/struct to create code for. It does not define a `from_json()` function which is needed in case the type does not have a default constructor.
|
- The `DERIVED_TYPE` variant requires an additional parameter of a base type, which should have the `to_json`/`from_json` functions defined. For instance, with a macro of its own.
|
||||||
- [`NLOHMANN_DEFINE_TYPE_INTRUSIVE(name, member1, member2, ...)`](../api/macros/nlohmann_define_type_intrusive.md) is to be defined inside the class/struct to create code for. This macro can also access private members. It will throw an exception in `from_json()` due to a missing value in the JSON object.
|
- If you need access to the private fields use [`INTRUSIVE`](../api/macros/nlohmann_define_type_intrusive.md) variant, otherwise use [`NON_INTRUSIVE`](../api/macros/nlohmann_define_type_non_intrusive.md).
|
||||||
- [`NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(name, member1, member2, ...)`](../api/macros/nlohmann_define_type_intrusive.md) is to be defined inside the class/struct to create code for. This macro can also access private members. It will not throw an exception in `from_json()` due to a missing value in the JSON object, but fills in values from an object which is default-constructed by the type.
|
- The `INTRUSIVE` macro should be defined **inside** the target class/struct, `NON_INTRUSIVE` should be defined within the same namespace.
|
||||||
- [`NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(name, member1, member2, ...)`](../api/macros/nlohmann_define_type_intrusive.md) is to be defined inside the class/struct to create code for. This macro can also access private members. It does not define a `from_json()` function which is needed in case the type does not have a default constructor.
|
- If you want to deserialize the incomplete JSONs, use the `WITH_DEFAULTS` variant, which will use the default values for the member variables absent in JSON, the variant without `WITH_DEFAULTS` will raise an exception.
|
||||||
|
- If you do not need deserialization at all and only interested in `to_json` function, you can use the `ONLY_SERIALIZE` variant.
|
||||||
|
- If you want to use the custom JSON names for member variables, use [`WITH_NAMES`](../api/macros/nlohmann_define_type_with_names.md) variant, otherwise the JSON name of the variable will be the same as its regular name.
|
||||||
|
|
||||||
Furthermore, there exist versions to use in the case of derived classes:
|
For all the macros, the first parameter is the name of the class/struct. The `DERIVED_TYPE` macros require a second parameter of a base class. All the remaining parameters name the member variables. The `WITH_NAMES` macros require a JSON name before each of the variables.
|
||||||
|
|
||||||
| Need access to private members | Need only de-serialization | Allow missing values when de-serializing | macro |
|
| Need access to private members | Need only de-serialization | Allow missing values when de-serializing | macro |
|
||||||
|------------------------------------------------------------------|------------------------------------------------------------------|------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|
|
|------------------------------------------------------------------|------------------------------------------------------------------|------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|
|
||||||
@@ -118,8 +120,9 @@ For _derived_ classes and structs, use the following macros
|
|||||||
|
|
||||||
!!! info "Implementation limits"
|
!!! info "Implementation limits"
|
||||||
|
|
||||||
- The current macro implementations are limited to at most 64 member variables. If you want to serialize/deserialize
|
- The current macro implementations are limited to at most 63 member variables. If you want to serialize/deserialize
|
||||||
types with more than 64 member variables, you need to define the `to_json`/`from_json` functions manually.
|
types with more than 63 member variables, you need to define the `to_json`/`from_json` functions manually.
|
||||||
|
- For the `WITH_NAMES` variants the limit is halved to 31 member variables.
|
||||||
|
|
||||||
??? example
|
??? example
|
||||||
|
|
||||||
@@ -131,7 +134,19 @@ For _derived_ classes and structs, use the following macros
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Here is an example with private members, where `NLOHMANN_DEFINE_TYPE_INTRUSIVE` is needed:
|
If you want to inherit the `person` struct and add a field to it, it can be done with:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
namespace ns {
|
||||||
|
struct person_derived : person {
|
||||||
|
std:string email;
|
||||||
|
};
|
||||||
|
|
||||||
|
NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(person_derived, person, email)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Here is another example with private members, where `NLOHMANN_DEFINE_TYPE_INTRUSIVE` is needed:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
namespace ns {
|
namespace ns {
|
||||||
@@ -147,6 +162,24 @@ For _derived_ classes and structs, use the following macros
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Or in case if you use some naming convention that you do not want to expose to JSON:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
namespace ns {
|
||||||
|
class address {
|
||||||
|
private:
|
||||||
|
std::string m_street;
|
||||||
|
int m_housenumber;
|
||||||
|
int m_postcode;
|
||||||
|
|
||||||
|
public:
|
||||||
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_NAMES(address, "street", m_street,
|
||||||
|
"housenumber", m_housenumber,
|
||||||
|
"postcode", m_postcode)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## How do I convert third-party types?
|
## How do I convert third-party types?
|
||||||
|
|
||||||
This requires a bit more advanced technique. But first, let us see how this conversion mechanism works:
|
This requires a bit more advanced technique. But first, let us see how this conversion mechanism works:
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ Just as in [Arbitrary Type Conversions](arbitrary_types.md) above,
|
|||||||
Other Important points:
|
Other Important points:
|
||||||
|
|
||||||
- When using `get<ENUM_TYPE>()`, undefined JSON values will default to the first pair specified in your map. Select this
|
- When using `get<ENUM_TYPE>()`, undefined JSON values will default to the first pair specified in your map. Select this
|
||||||
default pair carefully.
|
default pair carefully. If you desire an exception in this circumstance use [`NLOHMANN_JSON_SERIALIZE_ENUM_STRICT()`](../api/macros/nlohmann_json_serialize_enum_strict.md)
|
||||||
|
which behaves identically except for throwing an exception on unrecognized values.
|
||||||
- If an enum or JSON value is specified more than once in your map, the first matching occurrence from the top of the
|
- If an enum or JSON value is specified more than once in your map, the first matching occurrence from the top of the
|
||||||
map will be returned when converting to or from JSON.
|
map will be returned when converting to or from JSON.
|
||||||
- To disable the default serialization of enumerators as integers and force a compiler error instead, see [`JSON_DISABLE_ENUM_SERIALIZATION`](../api/macros/json_disable_enum_serialization.md).
|
- To disable the default serialization of enumerators as integers and force a compiler error instead, see [`JSON_DISABLE_ENUM_SERIALIZATION`](../api/macros/json_disable_enum_serialization.md).
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ It should be noted that as modules do not export macros, the `nlohmann.json` mod
|
|||||||
|
|
||||||
## Exported symbols
|
## Exported symbols
|
||||||
Only the following symbols are exported from `nlohmann.json`:
|
Only the following symbols are exported from `nlohmann.json`:
|
||||||
|
|
||||||
- `nlohmann::adl_serializer`
|
- `nlohmann::adl_serializer`
|
||||||
- `nlohmann::basic_json`
|
- `nlohmann::basic_json`
|
||||||
- `nlohmann::json`
|
- `nlohmann::json`
|
||||||
@@ -37,8 +38,3 @@ Only the following symbols are exported from `nlohmann.json`:
|
|||||||
- `nlohmann::to_string`
|
- `nlohmann::to_string`
|
||||||
- `nlohmann::literals::json_literals::operator""_json`
|
- `nlohmann::literals::json_literals::operator""_json`
|
||||||
- `nlohmann::literals::json_literals::operator""_json_pointer`
|
- `nlohmann::literals::json_literals::operator""_json_pointer`
|
||||||
|
|
||||||
The following specialisations of `std` symbols are also exported:
|
|
||||||
- `std::hash`
|
|
||||||
- `std::less`
|
|
||||||
- `std::swap`
|
|
||||||
|
|||||||
@@ -243,6 +243,19 @@ integers, and between integers and floating-point values to integers. This behav
|
|||||||
Note the last line with throw a [`json.exception.type_error.302`](../../home/exceptions.md#jsonexceptiontype_error302)
|
Note the last line with throw a [`json.exception.type_error.302`](../../home/exceptions.md#jsonexceptiontype_error302)
|
||||||
exception if `jd` is not a numerical type, for instance a string.
|
exception if `jd` is not a numerical type, for instance a string.
|
||||||
|
|
||||||
|
Numeric conversions are performed according to the corresponding C++ conversion rules. The library does not perform
|
||||||
|
range checks when converting between numeric types.
|
||||||
|
|
||||||
|
In particular, conversions from floating-point values to integer types, or conversions to integer types with a
|
||||||
|
smaller range than the stored value, may produce implementation-defined or undefined behavior if the source value
|
||||||
|
cannot be represented by the target type.
|
||||||
|
|
||||||
|
Applications requiring checked conversions should inspect the stored number type with
|
||||||
|
[`is_number_float()`](../../api/basic_json/is_number_float.md),
|
||||||
|
[`is_number_integer()`](../../api/basic_json/is_number_integer.md),
|
||||||
|
[`is_number_unsigned()`](../../api/basic_json/is_number_unsigned.md), or
|
||||||
|
[`type()`](../../api/basic_json/type.md), and perform explicit range checks before converting to a narrower type.
|
||||||
|
|
||||||
The rationale is twofold:
|
The rationale is twofold:
|
||||||
|
|
||||||
1. JSON does not define a number type or precision (see above).
|
1. JSON does not define a number type or precision (see above).
|
||||||
|
|||||||
@@ -868,6 +868,16 @@ Key identifiers to be serialized to BSON cannot contain code point U+0000, since
|
|||||||
BSON key cannot contain code point U+0000 (at byte 2)
|
BSON key cannot contain code point U+0000 (at byte 2)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### json.exception.out_of_range.410
|
||||||
|
|
||||||
|
Undefined json fields cannot be used with [`NLOHMANN_JSON_SERIALIZE_ENUM_STRICT`](../api/macros/nlohmann_json_serialize_enum_strict.md)
|
||||||
|
|
||||||
|
!!! failure "Example message"
|
||||||
|
|
||||||
|
```
|
||||||
|
enum value out of range
|
||||||
|
```
|
||||||
|
|
||||||
## Further exceptions
|
## Further exceptions
|
||||||
|
|
||||||
This exception is thrown in case of errors that cannot be classified with the
|
This exception is thrown in case of errors that cannot be classified with the
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ nav:
|
|||||||
- macros:
|
- macros:
|
||||||
- 'Overview': api/macros/index.md
|
- 'Overview': api/macros/index.md
|
||||||
- 'JSON_ASSERT': api/macros/json_assert.md
|
- 'JSON_ASSERT': api/macros/json_assert.md
|
||||||
|
- 'JSON_BRACE_INIT_COPY_SEMANTICS': api/macros/json_brace_init_copy_semantics.md
|
||||||
- 'JSON_CATCH_USER, JSON_THROW_USER, JSON_TRY_USER': api/macros/json_throw_user.md
|
- 'JSON_CATCH_USER, JSON_THROW_USER, JSON_TRY_USER': api/macros/json_throw_user.md
|
||||||
- 'JSON_DIAGNOSTICS': api/macros/json_diagnostics.md
|
- 'JSON_DIAGNOSTICS': api/macros/json_diagnostics.md
|
||||||
- 'JSON_DIAGNOSTIC_POSITIONS': api/macros/json_diagnostic_positions.md
|
- 'JSON_DIAGNOSTIC_POSITIONS': api/macros/json_diagnostic_positions.md
|
||||||
@@ -289,10 +290,12 @@ nav:
|
|||||||
- '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': api/macros/nlohmann_define_derived_type.md
|
- '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': api/macros/nlohmann_define_derived_type.md
|
||||||
- 'NLOHMANN_DEFINE_TYPE_INTRUSIVE, NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT, NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE': api/macros/nlohmann_define_type_intrusive.md
|
- 'NLOHMANN_DEFINE_TYPE_INTRUSIVE, NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT, NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE': api/macros/nlohmann_define_type_intrusive.md
|
||||||
- 'NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE, NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT, NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE': api/macros/nlohmann_define_type_non_intrusive.md
|
- 'NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE, NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT, NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE': api/macros/nlohmann_define_type_non_intrusive.md
|
||||||
|
- 'NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_NAMES, NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT_WITH_NAMES, NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES, NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_NAMES, NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT_WITH_NAMES, NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES, NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_NAMES, NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT_WITH_NAMES, NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES, NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_NAMES, NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT_WITH_NAMES, NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES': api/macros/nlohmann_define_type_with_names.md
|
||||||
- 'NLOHMANN_JSON_NAMESPACE': api/macros/nlohmann_json_namespace.md
|
- 'NLOHMANN_JSON_NAMESPACE': api/macros/nlohmann_json_namespace.md
|
||||||
- 'NLOHMANN_JSON_NAMESPACE_BEGIN, NLOHMANN_JSON_NAMESPACE_END': api/macros/nlohmann_json_namespace_begin.md
|
- 'NLOHMANN_JSON_NAMESPACE_BEGIN, NLOHMANN_JSON_NAMESPACE_END': api/macros/nlohmann_json_namespace_begin.md
|
||||||
- 'NLOHMANN_JSON_NAMESPACE_NO_VERSION': api/macros/nlohmann_json_namespace_no_version.md
|
- 'NLOHMANN_JSON_NAMESPACE_NO_VERSION': api/macros/nlohmann_json_namespace_no_version.md
|
||||||
- 'NLOHMANN_JSON_SERIALIZE_ENUM': api/macros/nlohmann_json_serialize_enum.md
|
- 'NLOHMANN_JSON_SERIALIZE_ENUM': api/macros/nlohmann_json_serialize_enum.md
|
||||||
|
- 'NLOHMANN_JSON_SERIALIZE_ENUM_STRICT': api/macros/nlohmann_json_serialize_enum_strict.md
|
||||||
- 'NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, NLOHMANN_JSON_VERSION_PATCH': api/macros/nlohmann_json_version_major.md
|
- 'NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, NLOHMANN_JSON_VERSION_PATCH': api/macros/nlohmann_json_version_major.md
|
||||||
- Community:
|
- Community:
|
||||||
- community/index.md
|
- community/index.md
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
wheel==0.47.0
|
wheel==0.47.0
|
||||||
|
|
||||||
mkdocs==1.6.1 # documentation framework
|
mkdocs==1.6.1 # documentation framework
|
||||||
mkdocs-git-revision-date-localized-plugin==1.5.2 # plugin "git-revision-date-localized"
|
mkdocs-git-revision-date-localized-plugin==1.5.3 # plugin "git-revision-date-localized"
|
||||||
mkdocs-material==9.7.6 # theme for mkdocs
|
mkdocs-material==9.7.6 # theme for mkdocs
|
||||||
mkdocs-material-extensions==1.3.1 # extensions
|
mkdocs-material-extensions==1.3.1 # extensions
|
||||||
mkdocs-minify-plugin==0.8.0 # plugin "minify"
|
mkdocs-minify-plugin==0.8.0 # plugin "minify"
|
||||||
|
|||||||
@@ -558,6 +558,11 @@ inline void from_json(const BasicJsonType& j, std::unordered_map<Key, Value, Has
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
||||||
|
|
||||||
|
// Workaround for MSVC 19.51 (and possibly later): in large in large cpp files, the compiler may fail to resolve with generic has_from_json (issue #4996)
|
||||||
|
template<typename BasicJsonType>
|
||||||
|
struct has_from_json<BasicJsonType, std_fs::path, void> : std::true_type {};
|
||||||
|
|
||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
inline void from_json(const BasicJsonType& j, std_fs::path& p)
|
inline void from_json(const BasicJsonType& j, std_fs::path& p)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -450,6 +450,10 @@ inline void to_json(BasicJsonType& j, const std::basic_string<char8_t, Tr, Alloc
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Workaround for MSVC 19.51 (and possibly later): in large cpp files, the compiler may fail to resolve with generic has_to_json (issue #4996)
|
||||||
|
template<typename BasicJsonType>
|
||||||
|
struct has_to_json<BasicJsonType, std_fs::path, void> : std::true_type {};
|
||||||
|
|
||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
inline void to_json(BasicJsonType& j, const std_fs::path& p)
|
inline void to_json(BasicJsonType& j, const std_fs::path& p)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -253,6 +253,61 @@
|
|||||||
e = ((it != std::end(m)) ? it : std::begin(m))->first; \
|
e = ((it != std::end(m)) ? it : std::begin(m))->first; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief function to wrap JSON_THROW_MACRO - there can be compilation errors about
|
||||||
|
there being no arguments to JSON_THROW that depend on template arguments
|
||||||
|
if this is not used to call JSON_THROW
|
||||||
|
*/
|
||||||
|
template<typename ExceptionType>
|
||||||
|
void templated_json_throw(ExceptionType exception)
|
||||||
|
{
|
||||||
|
JSON_THROW(exception);
|
||||||
|
|
||||||
|
/* JSON_THROW(exception) discards exception and aborts - void cast needed to supress
|
||||||
|
compilation error if compiled with -Werror and Wunused-parameter */
|
||||||
|
(void)exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief macro to briefly define a mapping between an enum and JSON with exception
|
||||||
|
on invalid input
|
||||||
|
@def NLOHMANN_JSON_SERIALIZE_ENUM_STRICT
|
||||||
|
@since version 3.12.0
|
||||||
|
*/
|
||||||
|
#define NLOHMANN_JSON_SERIALIZE_ENUM_STRICT(ENUM_TYPE, ...) \
|
||||||
|
template<typename BasicJsonType> \
|
||||||
|
inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
|
||||||
|
{ \
|
||||||
|
/* NOLINTNEXTLINE(modernize-type-traits) we use C++11 */ \
|
||||||
|
static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
|
||||||
|
/* NOLINTNEXTLINE(modernize-avoid-c-arrays) we don't want to depend on <array> */ \
|
||||||
|
static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
|
||||||
|
auto it = std::find_if(std::begin(m), std::end(m), \
|
||||||
|
[e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
|
||||||
|
{ \
|
||||||
|
return ej_pair.first == e; \
|
||||||
|
}); \
|
||||||
|
if (it != std::end(m)) j = it->second; \
|
||||||
|
else templated_json_throw<nlohmann::detail::out_of_range>(nlohmann::detail::out_of_range::create(410,"enum value out of range for " #ENUM_TYPE, nullptr)); \
|
||||||
|
} \
|
||||||
|
template<typename BasicJsonType> \
|
||||||
|
inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
|
||||||
|
{ \
|
||||||
|
/* NOLINTNEXTLINE(modernize-type-traits) we use C++11 */ \
|
||||||
|
static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
|
||||||
|
/* NOLINTNEXTLINE(modernize-avoid-c-arrays) we don't want to depend on <array> */ \
|
||||||
|
static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
|
||||||
|
auto it = std::find_if(std::begin(m), std::end(m), \
|
||||||
|
[&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
|
||||||
|
{ \
|
||||||
|
return ej_pair.second == j; \
|
||||||
|
}); \
|
||||||
|
if (it != std::end(m)) e = it->first; \
|
||||||
|
else templated_json_throw<nlohmann::detail::out_of_range>(nlohmann::detail::out_of_range::create(410,"enum value out of range for " #ENUM_TYPE ": " + j.dump(), &j)); \
|
||||||
|
}
|
||||||
|
|
||||||
// Ugly macros to avoid uglier copy-paste when specializing basic_json. They
|
// Ugly macros to avoid uglier copy-paste when specializing basic_json. They
|
||||||
// may be removed in the future once the class is split.
|
// may be removed in the future once the class is split.
|
||||||
|
|
||||||
@@ -403,11 +458,113 @@
|
|||||||
#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61)
|
#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61)
|
||||||
#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
|
#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
|
||||||
#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
|
#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE63, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE63, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE61, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE61, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE59, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE59, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE57, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE57, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE55, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE55, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE53, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE53, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE51, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE51, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE49, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE49, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE47, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE47, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE45, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE45, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE43, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE43, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE41, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE41, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE39, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE39, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE37, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE37, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE35, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE35, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE33, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE33, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE31, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE31, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE29, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE29, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE27, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE27, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE25, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE25, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE23, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE23, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE21, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE21, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE19, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE19, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE17, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE17, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE15, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE15, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE13, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE13, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE11, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE11, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE9, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE9, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE7, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE7, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE5, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE5, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE3, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE3, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE1, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE1)(__VA_ARGS__))
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) func(v1, v2)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE3(func, v3, v4)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE5(func, v3, v4, v5, v6)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE7(func, v3, v4, v5, v6, v7, v8)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE9(func, v3, v4, v5, v6, v7, v8, v9, v10)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE11(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE13(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE15(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE17(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE19(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE21(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE23(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE25(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE27(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE29(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE31(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE33(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE35(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE37(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE39(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE41(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE43(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE45(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE47(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE49(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE51(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE53(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE55(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE57(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE59(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE61(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
|
||||||
|
|
||||||
#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
|
#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
|
||||||
#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
|
#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
|
||||||
#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = !nlohmann_json_j.is_null() ? nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1) : nlohmann_json_default_obj.v1;
|
#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = !nlohmann_json_j.is_null() ? nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1) : nlohmann_json_default_obj.v1;
|
||||||
|
|
||||||
|
#define NLOHMANN_JSON_TO_WITH_NAME(v1, v2) nlohmann_json_j[v1] = nlohmann_json_t.v2;
|
||||||
|
#define NLOHMANN_JSON_FROM_WITH_NAME(v1, v2) nlohmann_json_j.at(v1).get_to(nlohmann_json_t.v2);
|
||||||
|
#define NLOHMANN_JSON_FROM_WITH_DEFAULT_WITH_NAME(v1, v2) nlohmann_json_t.v2 = !nlohmann_json_j.is_null() ? nlohmann_json_j.value(v1, nlohmann_json_default_obj.v2) : nlohmann_json_default_obj.v2;
|
||||||
|
|
||||||
|
#define NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(...) template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> __VA_ARGS__
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@def NLOHMANN_DEFINE_TYPE_INTRUSIVE
|
@def NLOHMANN_DEFINE_TYPE_INTRUSIVE
|
||||||
@@ -415,10 +572,12 @@
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
|
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }) \
|
||||||
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) })
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
|
||||||
friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_NAMES(Type, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) }) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_FROM_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -427,10 +586,12 @@
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
|
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }) \
|
||||||
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) })
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
|
||||||
friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
|
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT_WITH_NAMES(Type, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) }) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -439,8 +600,10 @@
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
|
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) })
|
||||||
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
|
|
||||||
|
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES(Type, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -449,10 +612,12 @@
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
|
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }) \
|
||||||
void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) })
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
|
||||||
void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_NAMES(Type, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) }) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_FROM_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -461,10 +626,12 @@
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
|
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }) \
|
||||||
void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) })
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
|
||||||
void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
|
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT_WITH_NAMES(Type, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) }) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -473,8 +640,10 @@
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
|
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) })
|
||||||
void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
|
|
||||||
|
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES(Type, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -483,10 +652,12 @@
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Type, BaseType, ...) \
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Type, BaseType, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }) \
|
||||||
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) })
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
|
||||||
friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_NAMES(Type, BaseType, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) }) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_FROM_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -495,10 +666,12 @@
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }) \
|
||||||
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) })
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
|
||||||
friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT_WITH_NAMES(Type, BaseType, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) }) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -507,8 +680,11 @@
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) })
|
||||||
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
|
|
||||||
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES(Type, BaseType, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -517,10 +693,12 @@
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(Type, BaseType, ...) \
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(Type, BaseType, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }) \
|
||||||
void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) })
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
|
||||||
void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_NAMES(Type, BaseType, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) }) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_FROM_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -529,10 +707,12 @@
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }) \
|
||||||
void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) })
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
|
||||||
void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT_WITH_NAMES(Type, BaseType, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) }) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -541,8 +721,10 @@
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) })
|
||||||
void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
|
|
||||||
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES(Type, BaseType, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
// inspired from https://stackoverflow.com/a/26745591
|
// inspired from https://stackoverflow.com/a/26745591
|
||||||
// allows calling any std function as if (e.g., with begin):
|
// allows calling any std function as if (e.g., with begin):
|
||||||
|
|||||||
@@ -836,7 +836,7 @@ class serializer
|
|||||||
static int snprintf_float(char* buf, std::size_t size, int d, long double x)
|
static int snprintf_float(char* buf, std::size_t size, int d, long double x)
|
||||||
{
|
{
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||||
return (std::snprintf)(buf, size, "%.*lg", d, x);
|
return (std::snprintf)(buf, size, "%.*Lg", d, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump_float(number_float_t x, std::false_type /*is_ieee_single_or_double*/)
|
void dump_float(number_float_t x, std::false_type /*is_ieee_single_or_double*/)
|
||||||
|
|||||||
@@ -18,6 +18,16 @@
|
|||||||
#ifndef INCLUDE_NLOHMANN_JSON_HPP_
|
#ifndef INCLUDE_NLOHMANN_JSON_HPP_
|
||||||
#define INCLUDE_NLOHMANN_JSON_HPP_
|
#define INCLUDE_NLOHMANN_JSON_HPP_
|
||||||
|
|
||||||
|
// Workaround for GCC template redefinition errors in C++ modules
|
||||||
|
// When nlohmann/json.hpp is included in a C++20 module preamble after
|
||||||
|
// other module imports, GCC may report spurious redefinition errors for
|
||||||
|
// STL templates. These pragmas suppress those false positives.
|
||||||
|
// See: https://github.com/nlohmann/json/issues/5103
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__) && __cplusplus >= 202002L
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wignored-attributes"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <algorithm> // all_of, find, for_each
|
#include <algorithm> // all_of, find, for_each
|
||||||
#include <cstddef> // nullptr_t, ptrdiff_t, size_t
|
#include <cstddef> // nullptr_t, ptrdiff_t, size_t
|
||||||
#include <functional> // hash, less
|
#include <functional> // hash, less
|
||||||
@@ -3487,6 +3497,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
if (it2 != m_data.m_value.object->end())
|
if (it2 != m_data.m_value.object->end())
|
||||||
{
|
{
|
||||||
it2->second.update(it.value(), true);
|
it2->second.update(it.value(), true);
|
||||||
|
#if JSON_DIAGNOSTICS
|
||||||
|
it2->second.set_parents();
|
||||||
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5344,4 +5357,9 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC
|
|||||||
|
|
||||||
#include <nlohmann/detail/macro_unscope.hpp>
|
#include <nlohmann/detail/macro_unscope.hpp>
|
||||||
|
|
||||||
|
// End of GCC diagnostic pragmas for C++ modules support
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__) && __cplusplus >= 202002L
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // INCLUDE_NLOHMANN_JSON_HPP_
|
#endif // INCLUDE_NLOHMANN_JSON_HPP_
|
||||||
|
|||||||
@@ -340,6 +340,20 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return Container::end();
|
return Container::end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class KeyType, detail::enable_if_t<
|
||||||
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
|
const_iterator find(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
|
||||||
|
{
|
||||||
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
|
{
|
||||||
|
if (m_compare(it->first, key))
|
||||||
|
{
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Container::end();
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<iterator, bool> insert( value_type&& value )
|
std::pair<iterator, bool> insert( value_type&& value )
|
||||||
{
|
{
|
||||||
return emplace(value.first, std::move(value.second));
|
return emplace(value.first, std::move(value.second));
|
||||||
|
|||||||
@@ -18,6 +18,16 @@
|
|||||||
#ifndef INCLUDE_NLOHMANN_JSON_HPP_
|
#ifndef INCLUDE_NLOHMANN_JSON_HPP_
|
||||||
#define INCLUDE_NLOHMANN_JSON_HPP_
|
#define INCLUDE_NLOHMANN_JSON_HPP_
|
||||||
|
|
||||||
|
// Workaround for GCC template redefinition errors in C++ modules
|
||||||
|
// When nlohmann/json.hpp is included in a C++20 module preamble after
|
||||||
|
// other module imports, GCC may report spurious redefinition errors for
|
||||||
|
// STL templates. These pragmas suppress those false positives.
|
||||||
|
// See: https://github.com/nlohmann/json/issues/5103
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__) && __cplusplus >= 202002L
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wignored-attributes"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <algorithm> // all_of, find, for_each
|
#include <algorithm> // all_of, find, for_each
|
||||||
#include <cstddef> // nullptr_t, ptrdiff_t, size_t
|
#include <cstddef> // nullptr_t, ptrdiff_t, size_t
|
||||||
#include <functional> // hash, less
|
#include <functional> // hash, less
|
||||||
@@ -2617,6 +2627,61 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
|||||||
e = ((it != std::end(m)) ? it : std::begin(m))->first; \
|
e = ((it != std::end(m)) ? it : std::begin(m))->first; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief function to wrap JSON_THROW_MACRO - there can be compilation errors about
|
||||||
|
there being no arguments to JSON_THROW that depend on template arguments
|
||||||
|
if this is not used to call JSON_THROW
|
||||||
|
*/
|
||||||
|
template<typename ExceptionType>
|
||||||
|
void templated_json_throw(ExceptionType exception)
|
||||||
|
{
|
||||||
|
JSON_THROW(exception);
|
||||||
|
|
||||||
|
/* JSON_THROW(exception) discards exception and aborts - void cast needed to supress
|
||||||
|
compilation error if compiled with -Werror and Wunused-parameter */
|
||||||
|
(void)exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief macro to briefly define a mapping between an enum and JSON with exception
|
||||||
|
on invalid input
|
||||||
|
@def NLOHMANN_JSON_SERIALIZE_ENUM_STRICT
|
||||||
|
@since version 3.12.0
|
||||||
|
*/
|
||||||
|
#define NLOHMANN_JSON_SERIALIZE_ENUM_STRICT(ENUM_TYPE, ...) \
|
||||||
|
template<typename BasicJsonType> \
|
||||||
|
inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
|
||||||
|
{ \
|
||||||
|
/* NOLINTNEXTLINE(modernize-type-traits) we use C++11 */ \
|
||||||
|
static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
|
||||||
|
/* NOLINTNEXTLINE(modernize-avoid-c-arrays) we don't want to depend on <array> */ \
|
||||||
|
static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
|
||||||
|
auto it = std::find_if(std::begin(m), std::end(m), \
|
||||||
|
[e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
|
||||||
|
{ \
|
||||||
|
return ej_pair.first == e; \
|
||||||
|
}); \
|
||||||
|
if (it != std::end(m)) j = it->second; \
|
||||||
|
else templated_json_throw<nlohmann::detail::out_of_range>(nlohmann::detail::out_of_range::create(410,"enum value out of range for " #ENUM_TYPE, nullptr)); \
|
||||||
|
} \
|
||||||
|
template<typename BasicJsonType> \
|
||||||
|
inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
|
||||||
|
{ \
|
||||||
|
/* NOLINTNEXTLINE(modernize-type-traits) we use C++11 */ \
|
||||||
|
static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
|
||||||
|
/* NOLINTNEXTLINE(modernize-avoid-c-arrays) we don't want to depend on <array> */ \
|
||||||
|
static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
|
||||||
|
auto it = std::find_if(std::begin(m), std::end(m), \
|
||||||
|
[&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
|
||||||
|
{ \
|
||||||
|
return ej_pair.second == j; \
|
||||||
|
}); \
|
||||||
|
if (it != std::end(m)) e = it->first; \
|
||||||
|
else templated_json_throw<nlohmann::detail::out_of_range>(nlohmann::detail::out_of_range::create(410,"enum value out of range for " #ENUM_TYPE ": " + j.dump(), &j)); \
|
||||||
|
}
|
||||||
|
|
||||||
// Ugly macros to avoid uglier copy-paste when specializing basic_json. They
|
// Ugly macros to avoid uglier copy-paste when specializing basic_json. They
|
||||||
// may be removed in the future once the class is split.
|
// may be removed in the future once the class is split.
|
||||||
|
|
||||||
@@ -2767,11 +2832,113 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
|||||||
#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61)
|
#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61)
|
||||||
#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
|
#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
|
||||||
#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
|
#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE63, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE63, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE61, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE61, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE59, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE59, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE57, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE57, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE55, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE55, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE53, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE53, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE51, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE51, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE49, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE49, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE47, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE47, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE45, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE45, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE43, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE43, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE41, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE41, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE39, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE39, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE37, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE37, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE35, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE35, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE33, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE33, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE31, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE31, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE29, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE29, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE27, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE27, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE25, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE25, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE23, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE23, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE21, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE21, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE19, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE19, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE17, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE17, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE15, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE15, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE13, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE13, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE11, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE11, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE9, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE9, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE7, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE7, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE5, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE5, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE3, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE3, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE1, \
|
||||||
|
NLOHMANN_JSON_DOUBLE_PASTE1)(__VA_ARGS__))
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) func(v1, v2)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE3(func, v3, v4)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE5(func, v3, v4, v5, v6)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE7(func, v3, v4, v5, v6, v7, v8)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE9(func, v3, v4, v5, v6, v7, v8, v9, v10)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE11(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE13(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE15(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE17(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE19(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE21(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE23(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE25(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE27(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE29(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE31(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE33(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE35(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE37(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE39(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE41(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE43(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE45(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE47(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE49(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE51(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE53(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE55(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE57(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE59(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60)
|
||||||
|
#define NLOHMANN_JSON_DOUBLE_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_DOUBLE_PASTE3(func, v1, v2) NLOHMANN_JSON_DOUBLE_PASTE61(func, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
|
||||||
|
|
||||||
#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
|
#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
|
||||||
#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
|
#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
|
||||||
#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = !nlohmann_json_j.is_null() ? nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1) : nlohmann_json_default_obj.v1;
|
#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = !nlohmann_json_j.is_null() ? nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1) : nlohmann_json_default_obj.v1;
|
||||||
|
|
||||||
|
#define NLOHMANN_JSON_TO_WITH_NAME(v1, v2) nlohmann_json_j[v1] = nlohmann_json_t.v2;
|
||||||
|
#define NLOHMANN_JSON_FROM_WITH_NAME(v1, v2) nlohmann_json_j.at(v1).get_to(nlohmann_json_t.v2);
|
||||||
|
#define NLOHMANN_JSON_FROM_WITH_DEFAULT_WITH_NAME(v1, v2) nlohmann_json_t.v2 = !nlohmann_json_j.is_null() ? nlohmann_json_j.value(v1, nlohmann_json_default_obj.v2) : nlohmann_json_default_obj.v2;
|
||||||
|
|
||||||
|
#define NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(...) template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> __VA_ARGS__
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@def NLOHMANN_DEFINE_TYPE_INTRUSIVE
|
@def NLOHMANN_DEFINE_TYPE_INTRUSIVE
|
||||||
@@ -2779,10 +2946,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
|
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }) \
|
||||||
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) })
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
|
||||||
friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_NAMES(Type, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) }) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_FROM_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -2791,10 +2960,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
|
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }) \
|
||||||
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) })
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
|
||||||
friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
|
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT_WITH_NAMES(Type, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) }) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -2803,8 +2974,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
|
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) })
|
||||||
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
|
|
||||||
|
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES(Type, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -2813,10 +2986,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
|
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }) \
|
||||||
void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) })
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
|
||||||
void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_NAMES(Type, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) }) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_FROM_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -2825,10 +3000,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
|
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }) \
|
||||||
void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) })
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
|
||||||
void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
|
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT_WITH_NAMES(Type, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) }) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -2837,8 +3014,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
|
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) })
|
||||||
void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
|
|
||||||
|
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES(Type, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -2847,10 +3026,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Type, BaseType, ...) \
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Type, BaseType, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }) \
|
||||||
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) })
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
|
||||||
friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_NAMES(Type, BaseType, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) }) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_FROM_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -2859,10 +3040,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }) \
|
||||||
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) })
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
|
||||||
friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT_WITH_NAMES(Type, BaseType, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) }) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -2871,8 +3054,11 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) })
|
||||||
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
|
|
||||||
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES(Type, BaseType, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -2881,10 +3067,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(Type, BaseType, ...) \
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(Type, BaseType, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }) \
|
||||||
void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) })
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
|
||||||
void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_NAMES(Type, BaseType, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) }) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_FROM_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -2893,10 +3081,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }) \
|
||||||
void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) })
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
|
||||||
void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT_WITH_NAMES(Type, BaseType, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) }) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief macro
|
@brief macro
|
||||||
@@ -2905,8 +3095,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
|||||||
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/
|
||||||
*/
|
*/
|
||||||
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
|
||||||
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) })
|
||||||
void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
|
|
||||||
|
#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES(Type, BaseType, ...) \
|
||||||
|
NLOHMANN_JSON_BASIC_TYPE_TEMPLATE(void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_DOUBLE_PASTE(NLOHMANN_JSON_TO_WITH_NAME, __VA_ARGS__)) })
|
||||||
|
|
||||||
// inspired from https://stackoverflow.com/a/26745591
|
// inspired from https://stackoverflow.com/a/26745591
|
||||||
// allows calling any std function as if (e.g., with begin):
|
// allows calling any std function as if (e.g., with begin):
|
||||||
@@ -5476,6 +5668,11 @@ inline void from_json(const BasicJsonType& j, std::unordered_map<Key, Value, Has
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
||||||
|
|
||||||
|
// Workaround for MSVC 19.51 (and possibly later): in large in large cpp files, the compiler may fail to resolve with generic has_from_json (issue #4996)
|
||||||
|
template<typename BasicJsonType>
|
||||||
|
struct has_from_json<BasicJsonType, std_fs::path, void> : std::true_type {};
|
||||||
|
|
||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
inline void from_json(const BasicJsonType& j, std_fs::path& p)
|
inline void from_json(const BasicJsonType& j, std_fs::path& p)
|
||||||
{
|
{
|
||||||
@@ -6259,6 +6456,10 @@ inline void to_json(BasicJsonType& j, const std::basic_string<char8_t, Tr, Alloc
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Workaround for MSVC 19.51 (and possibly later): in large cpp files, the compiler may fail to resolve with generic has_to_json (issue #4996)
|
||||||
|
template<typename BasicJsonType>
|
||||||
|
struct has_to_json<BasicJsonType, std_fs::path, void> : std::true_type {};
|
||||||
|
|
||||||
template<typename BasicJsonType>
|
template<typename BasicJsonType>
|
||||||
inline void to_json(BasicJsonType& j, const std_fs::path& p)
|
inline void to_json(BasicJsonType& j, const std_fs::path& p)
|
||||||
{
|
{
|
||||||
@@ -19818,7 +20019,7 @@ class serializer
|
|||||||
static int snprintf_float(char* buf, std::size_t size, int d, long double x)
|
static int snprintf_float(char* buf, std::size_t size, int d, long double x)
|
||||||
{
|
{
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||||
return (std::snprintf)(buf, size, "%.*lg", d, x);
|
return (std::snprintf)(buf, size, "%.*Lg", d, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump_float(number_float_t x, std::false_type /*is_ieee_single_or_double*/)
|
void dump_float(number_float_t x, std::false_type /*is_ieee_single_or_double*/)
|
||||||
@@ -20331,6 +20532,20 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
|||||||
return Container::end();
|
return Container::end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class KeyType, detail::enable_if_t<
|
||||||
|
detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
|
||||||
|
const_iterator find(KeyType && key) const // NOLINT(cppcoreguidelines-missing-std-forward)
|
||||||
|
{
|
||||||
|
for (auto it = this->begin(); it != this->end(); ++it)
|
||||||
|
{
|
||||||
|
if (m_compare(it->first, key))
|
||||||
|
{
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Container::end();
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<iterator, bool> insert( value_type&& value )
|
std::pair<iterator, bool> insert( value_type&& value )
|
||||||
{
|
{
|
||||||
return emplace(value.first, std::move(value.second));
|
return emplace(value.first, std::move(value.second));
|
||||||
@@ -23794,6 +24009,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
if (it2 != m_data.m_value.object->end())
|
if (it2 != m_data.m_value.object->end())
|
||||||
{
|
{
|
||||||
it2->second.update(it.value(), true);
|
it2->second.update(it.value(), true);
|
||||||
|
#if JSON_DIAGNOSTICS
|
||||||
|
it2->second.set_parents();
|
||||||
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25859,4 +26077,9 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// End of GCC diagnostic pragmas for C++ modules support
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__) && __cplusplus >= 202002L
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // INCLUDE_NLOHMANN_JSON_HPP_
|
#endif // INCLUDE_NLOHMANN_JSON_HPP_
|
||||||
|
|||||||
@@ -8,6 +8,15 @@
|
|||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
|
// GCC workaround for C++ modules support.
|
||||||
|
// When using C++20 modules, some compilers (particularly GCC) may have issues
|
||||||
|
// with template instantiations in the module preamble. If you encounter
|
||||||
|
// "redefinition" errors when including nlohmann/json.hpp, try one of:
|
||||||
|
// 1. Include nlohmann/json.hpp in your module preamble BEFORE other #includes
|
||||||
|
// 2. Or use: import nlohmann.json; instead of #include <nlohmann/json.hpp>
|
||||||
|
// 3. Or upgrade to a newer GCC version with better modules support.
|
||||||
|
// See: https://github.com/nlohmann/json/issues/5103
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
export module nlohmann.json;
|
export module nlohmann.json;
|
||||||
@@ -41,10 +50,3 @@ namespace detail
|
|||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
NLOHMANN_JSON_NAMESPACE_END
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
export namespace std
|
|
||||||
{
|
|
||||||
using std::hash;
|
|
||||||
using std::less;
|
|
||||||
using std::swap;
|
|
||||||
} // namespace std
|
|
||||||
|
|||||||
@@ -1657,6 +1657,84 @@ TEST_CASE("JSON to enum mapping")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class strict_cards {kreuz, pik, herz, karo, andere}; // andere not included in mapping
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(misc-use-internal-linkage,misc-const-correctness,cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - false positive
|
||||||
|
NLOHMANN_JSON_SERIALIZE_ENUM_STRICT(strict_cards,
|
||||||
|
{
|
||||||
|
{strict_cards::kreuz, "kreuz"},
|
||||||
|
{strict_cards::pik, "pik"},
|
||||||
|
{strict_cards::pik, "puk"}, // second entry for cards::pik; will not be used
|
||||||
|
{strict_cards::herz, "herz"},
|
||||||
|
{strict_cards::karo, "karo"}
|
||||||
|
})
|
||||||
|
|
||||||
|
enum StrictTaskState // NOLINT(cert-int09-c,readability-enum-initial-value,cppcoreguidelines-use-enum-class)
|
||||||
|
{
|
||||||
|
STRICT_TS_STOPPED,
|
||||||
|
STRICT_TS_RUNNING,
|
||||||
|
STRICT_TS_COMPLETED,
|
||||||
|
STRICT_TS_OTHER, // STRICT_TS_OTHER not in mapping
|
||||||
|
STRICT_TS_INVALID = -1,
|
||||||
|
};
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(misc-const-correctness,misc-use-internal-linkage,cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - false positive
|
||||||
|
NLOHMANN_JSON_SERIALIZE_ENUM_STRICT(StrictTaskState,
|
||||||
|
{
|
||||||
|
{STRICT_TS_INVALID, nullptr},
|
||||||
|
{STRICT_TS_STOPPED, "stopped"},
|
||||||
|
{STRICT_TS_RUNNING, "running"},
|
||||||
|
{STRICT_TS_COMPLETED, "completed"},
|
||||||
|
})
|
||||||
|
|
||||||
|
TEST_CASE("Strict JSON to enum mapping")
|
||||||
|
{
|
||||||
|
SECTION("enum class")
|
||||||
|
{
|
||||||
|
// enum -> json
|
||||||
|
CHECK(json(strict_cards::kreuz) == "kreuz");
|
||||||
|
CHECK(json(strict_cards::pik) == "pik");
|
||||||
|
CHECK(json(strict_cards::herz) == "herz");
|
||||||
|
CHECK(json(strict_cards::karo) == "karo");
|
||||||
|
|
||||||
|
// json -> enum
|
||||||
|
CHECK(strict_cards::kreuz == json("kreuz"));
|
||||||
|
CHECK(strict_cards::pik == json("pik"));
|
||||||
|
CHECK(strict_cards::herz == json("herz"));
|
||||||
|
CHECK(strict_cards::karo == json("karo"));
|
||||||
|
|
||||||
|
// invalid json -> exception thrown
|
||||||
|
json _;
|
||||||
|
CHECK_THROWS_WITH_AS(_ = json("what?").get<strict_cards>(), "[json.exception.out_of_range.410] enum value out of range for strict_cards: \"what?\"", json::out_of_range&);
|
||||||
|
|
||||||
|
// conversion of unmapped enum -> exception thrown
|
||||||
|
CHECK_THROWS_WITH_AS(json(strict_cards::andere), "[json.exception.out_of_range.410] enum value out of range for strict_cards", json::out_of_range&);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("traditional enum")
|
||||||
|
{
|
||||||
|
// enum -> json
|
||||||
|
CHECK(json(STRICT_TS_STOPPED) == "stopped");
|
||||||
|
CHECK(json(STRICT_TS_RUNNING) == "running");
|
||||||
|
CHECK(json(STRICT_TS_COMPLETED) == "completed");
|
||||||
|
CHECK(json(STRICT_TS_INVALID) == json());
|
||||||
|
|
||||||
|
// json -> enum
|
||||||
|
CHECK(STRICT_TS_STOPPED == json("stopped"));
|
||||||
|
CHECK(STRICT_TS_RUNNING == json("running"));
|
||||||
|
CHECK(STRICT_TS_COMPLETED == json("completed"));
|
||||||
|
CHECK(STRICT_TS_INVALID == json());
|
||||||
|
|
||||||
|
// invalid json -> exception thrown
|
||||||
|
json _;
|
||||||
|
CHECK_THROWS_WITH_AS(_ = json("what?").get<StrictTaskState>(), "[json.exception.out_of_range.410] enum value out of range for StrictTaskState: \"what?\"", json::out_of_range&);
|
||||||
|
|
||||||
|
// conversion of unmapped enum -> exception thrown
|
||||||
|
CHECK_THROWS_WITH_AS(json(STRICT_TS_OTHER), "[json.exception.out_of_range.410] enum value out of range for StrictTaskState", json::out_of_range&);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef JSON_HAS_CPP_17
|
#ifdef JSON_HAS_CPP_17
|
||||||
#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
||||||
TEST_CASE("std::filesystem::path")
|
TEST_CASE("std::filesystem::path")
|
||||||
@@ -1683,7 +1761,7 @@ TEST_CASE("std::filesystem::path")
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef JSON_USE_IMPLICIT_CONVERSIONS
|
#if !JSON_USE_IMPLICIT_CONVERSIONS
|
||||||
TEST_CASE("std::optional")
|
TEST_CASE("std::optional")
|
||||||
{
|
{
|
||||||
SECTION("null")
|
SECTION("null")
|
||||||
|
|||||||
@@ -262,4 +262,16 @@ TEST_CASE("Regression tests for extended diagnostics")
|
|||||||
|
|
||||||
CHECK(k.dump() == "{\"prop1\":\"prop1_value\",\"root\":\"root_str\"}");
|
CHECK(k.dump() == "{\"prop1\":\"prop1_value\",\"root\":\"root_str\"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("Regression test for issue #4813 - update() with merge_objects=true triggers JSON_ASSERT with JSON_DIAGNOSTICS")
|
||||||
|
{
|
||||||
|
// https://github.com/nlohmann/json/issues/4813
|
||||||
|
nlohmann::ordered_json j1 = {{"numbers", {{"one", 1}}}};
|
||||||
|
nlohmann::ordered_json const j2 = {{"numbers", {{"two", 2}}}, {"string", "t"}};
|
||||||
|
CHECK_NOTHROW(j1.update(j2, true));
|
||||||
|
CHECK(j1["numbers"]["one"] == 1);
|
||||||
|
CHECK(j1["numbers"]["two"] == 2);
|
||||||
|
CHECK(j1["string"] == "t");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -269,6 +269,11 @@ TEST_CASE("ordered_map")
|
|||||||
CHECK(com.find("vier") == com.end());
|
CHECK(com.find("vier") == com.end());
|
||||||
CHECK(com.find(std::string("vier")) == com.end());
|
CHECK(com.find(std::string("vier")) == com.end());
|
||||||
CHECK(com.find(vier) == com.end());
|
CHECK(com.find(vier) == com.end());
|
||||||
|
|
||||||
|
#ifdef JSON_HAS_CPP_17
|
||||||
|
CHECK(om.find(std::string_view("eins")) == om.begin());
|
||||||
|
CHECK(com.find(std::string_view("eins")) == com.begin());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("insert")
|
SECTION("insert")
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
using nlohmann::json;
|
using nlohmann::json;
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
@@ -295,3 +296,89 @@ TEST_CASE("dump with binary values")
|
|||||||
"]");
|
"]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("dump for basic_json with long double number_float_t")
|
||||||
|
{
|
||||||
|
// Custom basic_json instantiation with long double as NumberFloatType.
|
||||||
|
// On platforms where long double is wider than double (e.g. GCC/Clang on
|
||||||
|
// Linux/macOS x86_64), dump() goes through the snprintf path in
|
||||||
|
// serializer::dump_float(x, std::false_type). That branch must use the
|
||||||
|
// "%.*Lg" format specifier; using "%.*g" with a long double argument is
|
||||||
|
// undefined behavior and corrupts the output.
|
||||||
|
using long_double_json = nlohmann::basic_json<std::map, std::vector, std::string,
|
||||||
|
bool, std::int64_t, std::uint64_t, long double>;
|
||||||
|
|
||||||
|
SECTION("round-trip dump/parse")
|
||||||
|
{
|
||||||
|
constexpr std::array<long double, 13> values =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
0.0L, -0.0L, 1.0L, -1.0L,
|
||||||
|
0.5L, -0.5L, 1.5L, -2.25L,
|
||||||
|
1.23e45L, 1.23e-45L,
|
||||||
|
(std::numeric_limits<long double>::min)(),
|
||||||
|
std::numeric_limits<long double>::lowest(),
|
||||||
|
(std::numeric_limits<long double>::max)()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (long double v : values)
|
||||||
|
{
|
||||||
|
const long_double_json j = v;
|
||||||
|
const auto s = j.dump();
|
||||||
|
const auto j2 = long_double_json::parse(s);
|
||||||
|
CHECK(j2.template get<long double>() == v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("exact dump string for simple values")
|
||||||
|
{
|
||||||
|
CHECK(long_double_json(0.5L).dump() == "0.5");
|
||||||
|
CHECK(long_double_json(-0.5L).dump() == "-0.5");
|
||||||
|
CHECK(long_double_json(1.5L).dump() == "1.5");
|
||||||
|
CHECK(long_double_json(-2.25L).dump() == "-2.25");
|
||||||
|
CHECK(long_double_json(0.0L).dump() == "0.0");
|
||||||
|
CHECK(long_double_json(1.0L).dump() == "1.0");
|
||||||
|
CHECK(long_double_json(-1.0L).dump() == "-1.0");
|
||||||
|
CHECK(long_double_json(100.0L).dump() == "100.0");
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("NaN and infinity dump as null")
|
||||||
|
{
|
||||||
|
CHECK(long_double_json(std::numeric_limits<long double>::quiet_NaN()).dump() == "null");
|
||||||
|
|
||||||
|
// Probe the platform's runtime behavior — `volatile` forces a runtime
|
||||||
|
// call rather than constexpr-folding to a known answer at compile time.
|
||||||
|
// Skip the infinity assertions if std::isfinite() doesn't actually
|
||||||
|
// recognize long double infinity on this platform (notably, Valgrind
|
||||||
|
// 3.22's x87 80-bit emulation reports +/-inf as a large finite value).
|
||||||
|
// TODO(rusloker): remove this guard once Valgrind's 80-bit long double
|
||||||
|
// support ships (Valgrind bug https://bugs.kde.org/show_bug.cgi?id=197915,
|
||||||
|
// ASSIGNED since 2009 — the Valgrind project tracks its bugs on
|
||||||
|
// bugs.kde.org) and the minimum supported Valgrind version contains it.
|
||||||
|
const volatile long double inf_probe = std::numeric_limits<long double>::infinity();
|
||||||
|
if (!std::isfinite(inf_probe))
|
||||||
|
{
|
||||||
|
CHECK(long_double_json(std::numeric_limits<long double>::infinity()).dump() == "null");
|
||||||
|
CHECK(long_double_json(-std::numeric_limits<long double>::infinity()).dump() == "null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("dump output matches double for exactly-representable values")
|
||||||
|
{
|
||||||
|
auto check_same = [](long double v_ld, double v_d)
|
||||||
|
{
|
||||||
|
const long_double_json j_ld = v_ld;
|
||||||
|
const json j_d = v_d;
|
||||||
|
CHECK(j_ld.dump() == j_d.dump());
|
||||||
|
};
|
||||||
|
|
||||||
|
check_same(0.0L, 0.0);
|
||||||
|
check_same(0.5L, 0.5);
|
||||||
|
check_same(-0.5L, -0.5);
|
||||||
|
check_same(1.5L, 1.5);
|
||||||
|
check_same(-2.25L, -2.25);
|
||||||
|
check_same(1.0L, 1.0);
|
||||||
|
check_same(100.0L, 100.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+496
-12
@@ -94,6 +94,85 @@ class person_with_private_data_2
|
|||||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(person_with_private_data_2, age, name, metadata)
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(person_with_private_data_2, age, name, metadata)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class person_with_private_data_3
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::string name{}; // NOLINT(readability-redundant-member-init)
|
||||||
|
int age = 0;
|
||||||
|
json metadata = nullptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool operator==(const person_with_private_data_3& rhs) const
|
||||||
|
{
|
||||||
|
return name == rhs.name && age == rhs.age && metadata == rhs.metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
person_with_private_data_3() = default;
|
||||||
|
person_with_private_data_3(std::string name_, int age_, json metadata_)
|
||||||
|
: name(std::move(name_))
|
||||||
|
, age(age_)
|
||||||
|
, metadata(std::move(metadata_))
|
||||||
|
{}
|
||||||
|
|
||||||
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_NAMES(person_with_private_data_3, "json_age", age, "json_name", name, "json_metadata", metadata)
|
||||||
|
};
|
||||||
|
|
||||||
|
class derived_person_with_private_data_3 : public person_with_private_data_3
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::string hair_color{"blue"};
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool operator==(const derived_person_with_private_data_3& rhs) const
|
||||||
|
{
|
||||||
|
return person_with_private_data_3::operator==(rhs) && hair_color == rhs.hair_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
derived_person_with_private_data_3() = default;
|
||||||
|
derived_person_with_private_data_3(std::string name_, int age_, json metadata_, std::string hair_color_)
|
||||||
|
: person_with_private_data_3(std::move(name_), age_, std::move(metadata_))
|
||||||
|
, hair_color(std::move(hair_color_))
|
||||||
|
{}
|
||||||
|
|
||||||
|
NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_NAMES(derived_person_with_private_data_3, person_with_private_data_3, "json_hair_color", hair_color)
|
||||||
|
};
|
||||||
|
|
||||||
|
class person_with_private_data_4
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::string name{}; // NOLINT(readability-redundant-member-init)
|
||||||
|
int age = 0;
|
||||||
|
json metadata = nullptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool operator==(const person_with_private_data_4& rhs) const
|
||||||
|
{
|
||||||
|
return name == rhs.name && age == rhs.age && metadata == rhs.metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
person_with_private_data_4() = default;
|
||||||
|
person_with_private_data_4(std::string name_, int age_, json metadata_)
|
||||||
|
: name(std::move(name_))
|
||||||
|
, age(age_)
|
||||||
|
, metadata(std::move(metadata_))
|
||||||
|
{}
|
||||||
|
|
||||||
|
std::string getName() const
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
int getAge() const
|
||||||
|
{
|
||||||
|
return age;
|
||||||
|
}
|
||||||
|
json getMetadata() const
|
||||||
|
{
|
||||||
|
return metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT_WITH_NAMES(person_with_private_data_4, "json_age", age, "json_name", name, "json_metadata", metadata)
|
||||||
|
};
|
||||||
|
|
||||||
class derived_person_with_private_data_2 : public person_with_private_data_2
|
class derived_person_with_private_data_2 : public person_with_private_data_2
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -119,6 +198,31 @@ class derived_person_with_private_data_2 : public person_with_private_data_2
|
|||||||
NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(derived_person_with_private_data_2, person_with_private_data_2, hair_color)
|
NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(derived_person_with_private_data_2, person_with_private_data_2, hair_color)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class derived_person_with_private_data_4 : public person_with_private_data_4
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::string hair_color{"blue"};
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool operator==(const derived_person_with_private_data_4& rhs) const
|
||||||
|
{
|
||||||
|
return person_with_private_data_4::operator==(rhs) && hair_color == rhs.hair_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
derived_person_with_private_data_4() = default;
|
||||||
|
derived_person_with_private_data_4(std::string name_, int age_, json metadata_, std::string hair_color_)
|
||||||
|
: person_with_private_data_4(std::move(name_), age_, std::move(metadata_))
|
||||||
|
, hair_color(std::move(hair_color_))
|
||||||
|
{}
|
||||||
|
|
||||||
|
std::string getHairColor() const
|
||||||
|
{
|
||||||
|
return hair_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT_WITH_NAMES(derived_person_with_private_data_4, person_with_private_data_4, "json_hair_color", hair_color)
|
||||||
|
};
|
||||||
|
|
||||||
class person_without_private_data_1
|
class person_without_private_data_1
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -267,6 +371,154 @@ class derived_person_without_private_data_3 : public person_without_private_data
|
|||||||
// NOLINTNEXTLINE(misc-use-internal-linkage)
|
// NOLINTNEXTLINE(misc-use-internal-linkage)
|
||||||
NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(derived_person_without_private_data_3, person_without_private_data_3, hair_color)
|
NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(derived_person_without_private_data_3, person_without_private_data_3, hair_color)
|
||||||
|
|
||||||
|
class person_without_private_data_4
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string name{}; // NOLINT(readability-redundant-member-init)
|
||||||
|
int age = 0;
|
||||||
|
json metadata = nullptr;
|
||||||
|
|
||||||
|
bool operator==(const person_without_private_data_4& rhs) const
|
||||||
|
{
|
||||||
|
return name == rhs.name && age == rhs.age && metadata == rhs.metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
person_without_private_data_4() = default;
|
||||||
|
person_without_private_data_4(std::string name_, int age_, json metadata_)
|
||||||
|
: name(std::move(name_))
|
||||||
|
, age(age_)
|
||||||
|
, metadata(std::move(metadata_))
|
||||||
|
{}
|
||||||
|
|
||||||
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_NAMES(person_without_private_data_4, "json_age", age, "json_name", name, "json_metadata", metadata)
|
||||||
|
};
|
||||||
|
|
||||||
|
class derived_person_without_private_data_4 : public person_without_private_data_4
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string hair_color{"blue"};
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool operator==(const derived_person_without_private_data_4& rhs) const
|
||||||
|
{
|
||||||
|
return person_without_private_data_4::operator==(rhs) && hair_color == rhs.hair_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
derived_person_without_private_data_4() = default;
|
||||||
|
derived_person_without_private_data_4(std::string name_, int age_, json metadata_, std::string hair_color_)
|
||||||
|
: person_without_private_data_4(std::move(name_), age_, std::move(metadata_))
|
||||||
|
, hair_color(std::move(hair_color_))
|
||||||
|
{}
|
||||||
|
|
||||||
|
NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_NAMES(derived_person_without_private_data_4, person_without_private_data_4, "json_hair_color", hair_color)
|
||||||
|
};
|
||||||
|
|
||||||
|
class person_without_private_data_5
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string name{}; // NOLINT(readability-redundant-member-init)
|
||||||
|
int age = 0;
|
||||||
|
json metadata = nullptr;
|
||||||
|
|
||||||
|
bool operator==(const person_without_private_data_5& rhs) const
|
||||||
|
{
|
||||||
|
return name == rhs.name && age == rhs.age && metadata == rhs.metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
person_without_private_data_5() = default;
|
||||||
|
person_without_private_data_5(std::string name_, int age_, json metadata_)
|
||||||
|
: name(std::move(name_))
|
||||||
|
, age(age_)
|
||||||
|
, metadata(std::move(metadata_))
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(misc-use-internal-linkage)
|
||||||
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_NAMES(person_without_private_data_5, "json_age", age, "json_name", name, "json_metadata", metadata)
|
||||||
|
|
||||||
|
class derived_person_without_private_data_5 : public person_without_private_data_5
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string hair_color{"blue"};
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool operator==(const derived_person_without_private_data_5& rhs) const
|
||||||
|
{
|
||||||
|
return person_without_private_data_5::operator==(rhs) && hair_color == rhs.hair_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
derived_person_without_private_data_5() = default;
|
||||||
|
derived_person_without_private_data_5(std::string name_, int age_, json metadata_, std::string hair_color_)
|
||||||
|
: person_without_private_data_5(std::move(name_), age_, std::move(metadata_))
|
||||||
|
, hair_color(std::move(hair_color_))
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(misc-use-internal-linkage)
|
||||||
|
NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_NAMES(derived_person_without_private_data_5, person_without_private_data_5, "json_hair_color", hair_color)
|
||||||
|
|
||||||
|
class person_without_private_data_6
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string name{}; // NOLINT(readability-redundant-member-init)
|
||||||
|
int age = 0;
|
||||||
|
json metadata = nullptr;
|
||||||
|
|
||||||
|
bool operator==(const person_without_private_data_6& rhs) const
|
||||||
|
{
|
||||||
|
return name == rhs.name && age == rhs.age && metadata == rhs.metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
person_without_private_data_6() = default;
|
||||||
|
person_without_private_data_6(std::string name_, int age_, json metadata_)
|
||||||
|
: name(std::move(name_))
|
||||||
|
, age(age_)
|
||||||
|
, metadata(std::move(metadata_))
|
||||||
|
{}
|
||||||
|
|
||||||
|
std::string getName() const
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
int getAge() const
|
||||||
|
{
|
||||||
|
return age;
|
||||||
|
}
|
||||||
|
json getMetadata() const
|
||||||
|
{
|
||||||
|
return metadata;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(misc-use-internal-linkage)
|
||||||
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT_WITH_NAMES(person_without_private_data_6, "json_age", age, "json_name", name, "json_metadata", metadata)
|
||||||
|
|
||||||
|
class derived_person_without_private_data_6 : public person_without_private_data_6
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string hair_color{"blue"};
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool operator==(const derived_person_without_private_data_6& rhs) const
|
||||||
|
{
|
||||||
|
return person_without_private_data_6::operator==(rhs) && hair_color == rhs.hair_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
derived_person_without_private_data_6() = default;
|
||||||
|
derived_person_without_private_data_6(std::string name_, int age_, json metadata_, std::string hair_color_)
|
||||||
|
: person_without_private_data_6(std::move(name_), age_, std::move(metadata_))
|
||||||
|
, hair_color(std::move(hair_color_))
|
||||||
|
{}
|
||||||
|
|
||||||
|
std::string getHairColor() const
|
||||||
|
{
|
||||||
|
return hair_color;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(misc-use-internal-linkage)
|
||||||
|
NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT_WITH_NAMES(derived_person_without_private_data_6, person_without_private_data_6, "json_hair_color", hair_color)
|
||||||
|
|
||||||
class person_with_private_alphabet
|
class person_with_private_alphabet
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -433,31 +685,97 @@ class person_without_default_constructor_2
|
|||||||
// NOLINTNEXTLINE(misc-use-internal-linkage)
|
// NOLINTNEXTLINE(misc-use-internal-linkage)
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(person_without_default_constructor_2, name, age)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(person_without_default_constructor_2, name, age)
|
||||||
|
|
||||||
class derived_person_only_serialize_public : public person_without_default_constructor_1
|
class person_without_default_constructor_3
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string name;
|
||||||
|
int age;
|
||||||
|
|
||||||
|
bool operator==(const person_without_default_constructor_3& other) const
|
||||||
|
{
|
||||||
|
return name == other.name && age == other.age;
|
||||||
|
}
|
||||||
|
|
||||||
|
person_without_default_constructor_3(std::string name_, int age_)
|
||||||
|
: name{std::move(name_)}
|
||||||
|
, age{age_}
|
||||||
|
{}
|
||||||
|
|
||||||
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES(person_without_default_constructor_3, "json_name", name, "json_age", age)
|
||||||
|
};
|
||||||
|
|
||||||
|
class person_without_default_constructor_4
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string name;
|
||||||
|
int age;
|
||||||
|
|
||||||
|
bool operator==(const person_without_default_constructor_4& other) const
|
||||||
|
{
|
||||||
|
return name == other.name && age == other.age;
|
||||||
|
}
|
||||||
|
|
||||||
|
person_without_default_constructor_4(std::string name_, int age_)
|
||||||
|
: name{std::move(name_)}
|
||||||
|
, age{age_}
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(misc-use-internal-linkage)
|
||||||
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES(person_without_default_constructor_4, "json_name", name, "json_age", age)
|
||||||
|
|
||||||
|
class derived_person_only_serialize_public_1 : public person_without_default_constructor_1
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string hair_color;
|
std::string hair_color;
|
||||||
|
|
||||||
derived_person_only_serialize_public(std::string name_, int age_, std::string hair_color_)
|
derived_person_only_serialize_public_1(std::string name_, int age_, std::string hair_color_)
|
||||||
: person_without_default_constructor_1(std::move(name_), age_)
|
: person_without_default_constructor_1(std::move(name_), age_)
|
||||||
, hair_color(std::move(hair_color_))
|
, hair_color(std::move(hair_color_))
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
// NOLINTNEXTLINE(misc-use-internal-linkage)
|
// NOLINTNEXTLINE(misc-use-internal-linkage)
|
||||||
NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(derived_person_only_serialize_public, person_without_default_constructor_1, hair_color)
|
NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(derived_person_only_serialize_public_1, person_without_default_constructor_1, hair_color)
|
||||||
|
|
||||||
class derived_person_only_serialize_private : person_without_default_constructor_1
|
class derived_person_only_serialize_public_3 : public person_without_default_constructor_3
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string hair_color;
|
||||||
|
|
||||||
|
derived_person_only_serialize_public_3(std::string name_, int age_, std::string hair_color_)
|
||||||
|
: person_without_default_constructor_3(std::move(name_), age_)
|
||||||
|
, hair_color(std::move(hair_color_))
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(misc-use-internal-linkage)
|
||||||
|
NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES(derived_person_only_serialize_public_3, person_without_default_constructor_3, "json_hair_color", hair_color)
|
||||||
|
|
||||||
|
class derived_person_only_serialize_private_1 : person_without_default_constructor_1
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::string hair_color;
|
std::string hair_color;
|
||||||
public:
|
public:
|
||||||
derived_person_only_serialize_private(std::string name_, int age_, std::string hair_color_)
|
derived_person_only_serialize_private_1(std::string name_, int age_, std::string hair_color_)
|
||||||
: person_without_default_constructor_1(std::move(name_), age_)
|
: person_without_default_constructor_1(std::move(name_), age_)
|
||||||
, hair_color(std::move(hair_color_))
|
, hair_color(std::move(hair_color_))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE(derived_person_only_serialize_private, person_without_default_constructor_1, hair_color)
|
NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE(derived_person_only_serialize_private_1, person_without_default_constructor_1, hair_color)
|
||||||
|
};
|
||||||
|
|
||||||
|
class derived_person_only_serialize_private_3 : person_without_default_constructor_3
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::string hair_color;
|
||||||
|
public:
|
||||||
|
derived_person_only_serialize_private_3(std::string name_, int age_, std::string hair_color_)
|
||||||
|
: person_without_default_constructor_3(std::move(name_), age_)
|
||||||
|
, hair_color(std::move(hair_color_))
|
||||||
|
{}
|
||||||
|
|
||||||
|
NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES(derived_person_only_serialize_private_3, person_without_default_constructor_3, "json_hair_color", hair_color)
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace persons
|
} // namespace persons
|
||||||
@@ -532,6 +850,58 @@ TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_DERIVED_TY
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_NAMES and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_NAMES", T, // NOLINT(readability-math-missing-parentheses, bugprone-throwing-static-initialization)
|
||||||
|
persons::person_with_private_data_3,
|
||||||
|
persons::person_without_private_data_4,
|
||||||
|
persons::person_without_private_data_5)
|
||||||
|
{
|
||||||
|
SECTION("person")
|
||||||
|
{
|
||||||
|
// serialization
|
||||||
|
T p1("Erik", 1, {{"haircuts", 2}});
|
||||||
|
CHECK(json(p1).dump() == "{\"json_age\":1,\"json_metadata\":{\"haircuts\":2},\"json_name\":\"Erik\"}");
|
||||||
|
|
||||||
|
// deserialization
|
||||||
|
auto p2 = json(p1).get<T>();
|
||||||
|
CHECK(p2 == p1);
|
||||||
|
|
||||||
|
// roundtrip
|
||||||
|
CHECK(T(json(p1)) == p1);
|
||||||
|
CHECK(json(T(json(p1))) == json(p1));
|
||||||
|
|
||||||
|
// check exception in case of missing field
|
||||||
|
json j = json(p1);
|
||||||
|
j.erase("json_age");
|
||||||
|
CHECK_THROWS_WITH_AS(j.get<T>(), "[json.exception.out_of_range.403] key 'json_age' not found", json::out_of_range);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_NAMES and NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_NAMES", T, // NOLINT(readability-math-missing-parentheses, bugprone-throwing-static-initialization)
|
||||||
|
persons::derived_person_with_private_data_3,
|
||||||
|
persons::derived_person_without_private_data_4,
|
||||||
|
persons::derived_person_without_private_data_5)
|
||||||
|
{
|
||||||
|
SECTION("person")
|
||||||
|
{
|
||||||
|
// serialization
|
||||||
|
T p1("Erik", 1, {{"haircuts", 2}}, "red");
|
||||||
|
CHECK(json(p1).dump() == "{\"json_age\":1,\"json_hair_color\":\"red\",\"json_metadata\":{\"haircuts\":2},\"json_name\":\"Erik\"}");
|
||||||
|
|
||||||
|
// deserialization
|
||||||
|
auto p2 = json(p1).get<T>();
|
||||||
|
CHECK(p2 == p1);
|
||||||
|
|
||||||
|
// roundtrip
|
||||||
|
CHECK(T(json(p1)) == p1);
|
||||||
|
CHECK(json(T(json(p1))) == json(p1));
|
||||||
|
|
||||||
|
// check exception in case of missing field
|
||||||
|
json j = json(p1);
|
||||||
|
j.erase("json_age");
|
||||||
|
CHECK_THROWS_WITH_AS(j.get<T>(), "[json.exception.out_of_range.403] key 'json_age' not found", json::out_of_range);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT", Pair, // NOLINT(readability-math-missing-parentheses, bugprone-throwing-static-initialization)
|
TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT", Pair, // NOLINT(readability-math-missing-parentheses, bugprone-throwing-static-initialization)
|
||||||
std::pair<nlohmann::json, persons::person_with_private_data_2>,
|
std::pair<nlohmann::json, persons::person_with_private_data_2>,
|
||||||
std::pair<nlohmann::json, persons::person_without_private_data_3>,
|
std::pair<nlohmann::json, persons::person_without_private_data_3>,
|
||||||
@@ -629,7 +999,77 @@ TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_DERIVED_TY
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE_TEMPLATE("Serialization/deserialization of classes with 26 public/private member variables via NLOHMANN_DEFINE_TYPE_INTRUSIVE and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE", Pair, // NOLINT(readability-math-missing-parentheses, bugprone-throwing-static-initialization)
|
TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT_WITH_NAMES and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT_WITH_NAMES", T, // NOLINT(readability-math-missing-parentheses, bugprone-throwing-static-initialization)
|
||||||
|
persons::person_with_private_data_4,
|
||||||
|
persons::person_without_private_data_6)
|
||||||
|
{
|
||||||
|
SECTION("person with default values")
|
||||||
|
{
|
||||||
|
// serialization of default constructed object
|
||||||
|
T p0;
|
||||||
|
CHECK(json(p0).dump() == "{\"json_age\":0,\"json_metadata\":null,\"json_name\":\"\"}");
|
||||||
|
|
||||||
|
// serialization
|
||||||
|
T p1("Erik", 1, {{"haircuts", 2}});
|
||||||
|
CHECK(json(p1).dump() == "{\"json_age\":1,\"json_metadata\":{\"haircuts\":2},\"json_name\":\"Erik\"}");
|
||||||
|
|
||||||
|
// deserialization
|
||||||
|
auto p2 = json(p1).get<T>();
|
||||||
|
CHECK(p2 == p1);
|
||||||
|
|
||||||
|
// roundtrip
|
||||||
|
CHECK(T(json(p1)) == p1);
|
||||||
|
CHECK(json(T(json(p1))) == json(p1));
|
||||||
|
|
||||||
|
// check default value in case of missing field
|
||||||
|
json j = json(p1);
|
||||||
|
j.erase("json_name");
|
||||||
|
j.erase("json_age");
|
||||||
|
j.erase("json_metadata");
|
||||||
|
T p3 = j.get<T>();
|
||||||
|
CHECK(p3.getName() == "");
|
||||||
|
CHECK(p3.getAge() == 0);
|
||||||
|
CHECK(p3.getMetadata() == nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT_WITH_NAMES and NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT_WITH_NAMES", T, // NOLINT(readability-math-missing-parentheses, bugprone-throwing-static-initialization)
|
||||||
|
persons::derived_person_with_private_data_4,
|
||||||
|
persons::derived_person_without_private_data_6)
|
||||||
|
{
|
||||||
|
SECTION("derived person with default values")
|
||||||
|
{
|
||||||
|
// serialization of default constructed object
|
||||||
|
T p0;
|
||||||
|
CHECK(json(p0).dump() == "{\"json_age\":0,\"json_hair_color\":\"blue\",\"json_metadata\":null,\"json_name\":\"\"}");
|
||||||
|
|
||||||
|
// serialization
|
||||||
|
T p1("Erik", 1, {{"haircuts", 2}}, "red");
|
||||||
|
CHECK(json(p1).dump() == "{\"json_age\":1,\"json_hair_color\":\"red\",\"json_metadata\":{\"haircuts\":2},\"json_name\":\"Erik\"}");
|
||||||
|
|
||||||
|
// deserialization
|
||||||
|
auto p2 = json(p1).get<T>();
|
||||||
|
CHECK(p2 == p1);
|
||||||
|
|
||||||
|
// roundtrip
|
||||||
|
CHECK(T(json(p1)) == p1);
|
||||||
|
CHECK(json(T(json(p1))) == json(p1));
|
||||||
|
|
||||||
|
// check default value in case of missing field
|
||||||
|
json j = json(p1);
|
||||||
|
j.erase("json_name");
|
||||||
|
j.erase("json_age");
|
||||||
|
j.erase("json_metadata");
|
||||||
|
j.erase("json_hair_color");
|
||||||
|
T p3 = j.get<T>();
|
||||||
|
CHECK(p3.getName() == "");
|
||||||
|
CHECK(p3.getAge() == 0);
|
||||||
|
CHECK(p3.getMetadata() == nullptr);
|
||||||
|
CHECK(p3.getHairColor() == "blue");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE_TEMPLATE("Serialization/deserialization of classes with 26 public/private member variables via NLOHMANN_DEFINE_TYPE_INTRUSIVE and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE", Pair, // NOLINT(readability-math-missing-parentheses, bugprone-throwing-static-initialization, bugprone-throwing-static-initialization)
|
||||||
std::pair<nlohmann::json, persons::person_with_private_alphabet>,
|
std::pair<nlohmann::json, persons::person_with_private_alphabet>,
|
||||||
std::pair<nlohmann::json, persons::person_with_public_alphabet>,
|
std::pair<nlohmann::json, persons::person_with_public_alphabet>,
|
||||||
std::pair<nlohmann::ordered_json, persons::person_with_private_alphabet>,
|
std::pair<nlohmann::ordered_json, persons::person_with_private_alphabet>,
|
||||||
@@ -648,7 +1088,7 @@ TEST_CASE_TEMPLATE("Serialization/deserialization of classes with 26 public/priv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE_TEMPLATE("Serialization of non-default-constructible classes via NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE", Pair, // NOLINT(readability-math-missing-parentheses, bugprone-throwing-static-initialization)
|
TEST_CASE_TEMPLATE("Serialization of non-default-constructible classes via NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE", Pair, // NOLINT(readability-math-missing-parentheses, bugprone-throwing-static-initialization, bugprone-throwing-static-initialization)
|
||||||
std::pair<nlohmann::json, persons::person_without_default_constructor_1>,
|
std::pair<nlohmann::json, persons::person_without_default_constructor_1>,
|
||||||
std::pair<nlohmann::json, persons::person_without_default_constructor_2>,
|
std::pair<nlohmann::json, persons::person_without_default_constructor_2>,
|
||||||
std::pair<nlohmann::ordered_json, persons::person_without_default_constructor_1>,
|
std::pair<nlohmann::ordered_json, persons::person_without_default_constructor_1>,
|
||||||
@@ -678,11 +1118,33 @@ TEST_CASE_TEMPLATE("Serialization of non-default-constructible classes via NLOHM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE_TEMPLATE("Serialization of non-default-constructible classes via NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES", T, // NOLINT(readability-math-missing-parentheses, bugprone-throwing-static-initialization)
|
||||||
|
persons::person_without_default_constructor_3,
|
||||||
|
persons::person_without_default_constructor_4)
|
||||||
|
{
|
||||||
|
SECTION("person")
|
||||||
|
{
|
||||||
|
{
|
||||||
|
// serialization of a single object
|
||||||
|
T person{"Erik", 1};
|
||||||
|
CHECK(json(person).dump() == "{\"json_age\":1,\"json_name\":\"Erik\"}");
|
||||||
|
|
||||||
|
// serialization of a container with objects
|
||||||
|
std::vector<T> const two_persons
|
||||||
|
{
|
||||||
|
{"Erik", 1},
|
||||||
|
{"Kyle", 2}
|
||||||
|
};
|
||||||
|
CHECK(json(two_persons).dump() == "[{\"json_age\":1,\"json_name\":\"Erik\"},{\"json_age\":2,\"json_name\":\"Kyle\"}]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE_TEMPLATE("Serialization of non-default-constructible classes via NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE and NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE", Pair, // NOLINT(readability-math-missing-parentheses, bugprone-throwing-static-initialization)
|
TEST_CASE_TEMPLATE("Serialization of non-default-constructible classes via NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE and NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE", Pair, // NOLINT(readability-math-missing-parentheses, bugprone-throwing-static-initialization)
|
||||||
std::pair<nlohmann::json, persons::derived_person_only_serialize_public>,
|
std::pair<nlohmann::json, persons::derived_person_only_serialize_public_1>,
|
||||||
std::pair<nlohmann::json, persons::derived_person_only_serialize_private>,
|
std::pair<nlohmann::json, persons::derived_person_only_serialize_private_1>,
|
||||||
std::pair<nlohmann::ordered_json, persons::derived_person_only_serialize_public>,
|
std::pair<nlohmann::ordered_json, persons::derived_person_only_serialize_public_1>,
|
||||||
std::pair<nlohmann::ordered_json, persons::derived_person_only_serialize_private>)
|
std::pair<nlohmann::ordered_json, persons::derived_person_only_serialize_private_1>)
|
||||||
{
|
{
|
||||||
using Json = typename Pair::first_type;
|
using Json = typename Pair::first_type;
|
||||||
using T = typename Pair::second_type;
|
using T = typename Pair::second_type;
|
||||||
@@ -707,3 +1169,25 @@ TEST_CASE_TEMPLATE("Serialization of non-default-constructible classes via NLOHM
|
|||||||
R"([{"age":1,"hair_color":"brown","name":"Erik"},{"age":2,"hair_color":"black","name":"Kyle"}])"));
|
R"([{"age":1,"hair_color":"brown","name":"Erik"},{"age":2,"hair_color":"black","name":"Kyle"}])"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE_TEMPLATE("Serialization of non-default-constructible classes via NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES and NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES", T, // NOLINT(readability-math-missing-parentheses, bugprone-throwing-static-initialization)
|
||||||
|
persons::derived_person_only_serialize_public_3,
|
||||||
|
persons::derived_person_only_serialize_private_3)
|
||||||
|
{
|
||||||
|
SECTION("derived person only serialize")
|
||||||
|
{
|
||||||
|
{
|
||||||
|
// serialization of a single object
|
||||||
|
T person{"Erik", 1, "brown"};
|
||||||
|
CHECK(json(person).dump() == "{\"json_age\":1,\"json_hair_color\":\"brown\",\"json_name\":\"Erik\"}");
|
||||||
|
|
||||||
|
// serialization of a container with objects
|
||||||
|
std::vector<T> const two_persons
|
||||||
|
{
|
||||||
|
{"Erik", 1, "brown"},
|
||||||
|
{"Kyle", 2, "black"}
|
||||||
|
};
|
||||||
|
CHECK(json(two_persons).dump() == "[{\"json_age\":1,\"json_hair_color\":\"brown\",\"json_name\":\"Erik\"},{\"json_age\":2,\"json_hair_color\":\"black\",\"json_name\":\"Kyle\"}]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user