Compare commits

..

40 Commits

Author SHA1 Message Date
Niels Lohmann
f9003d169b 🎨 fix indentation 2022-08-13 13:36:08 +02:00
Niels Lohmann
b116faa02d 💚 fix unit test 2022-08-13 13:29:11 +02:00
Niels Lohmann
d360b7e396 💚 fix unit test 2022-08-13 13:11:37 +02:00
Niels Lohmann
107e99ef1e 📝 fix example 2022-08-13 13:02:28 +02:00
Niels Lohmann
47934f8400 Merge branch 'develop' of https://github.com/nlohmann/json into bon8 2022-08-13 11:42:08 +02:00
Niels Lohmann
dfdbbc71bb Merge branch 'develop' of https://github.com/nlohmann/json into bon8
 Conflicts:
	docs/mkdocs/docs/api/basic_json/index.md
	docs/mkdocs/docs/features/binary_formats/index.md
	docs/mkdocs/mkdocs.yml
	tests/src/unit-binary_formats.cpp
2022-06-18 21:19:48 +02:00
Niels Lohmann
ad662d15bc 🎨 fix indendation 2022-05-02 07:10:03 +02:00
Niels Lohmann
b1e3165712 🚨 fix warnings 2022-05-01 22:50:40 +02:00
Niels Lohmann
a1e116f015 complete test suite 2022-05-01 20:50:09 +02:00
Niels Lohmann
5927ddc3b2 🚨 fix warnings 2022-05-01 20:08:44 +02:00
Niels Lohmann
4ada06d860 🔀 merge develop 2022-05-01 20:01:10 +02:00
Niels Lohmann
88fbbd3aa8 Merge branch 'develop' of https://github.com/nlohmann/json into bon8
 Conflicts:
	docs/examples/to_bon8.cpp
	docs/examples/to_bon8.output
	docs/mkdocs/docs/api/basic_json/to_bon8.md
	include/nlohmann/detail/input/binary_reader.hpp
	include/nlohmann/detail/input/input_adapters.hpp
	include/nlohmann/detail/output/binary_writer.hpp
	single_include/nlohmann/json.hpp
	test/CMakeLists.txt
	tests/src/unit-binary_formats.cpp
	tests/src/unit-bon8.cpp
2022-05-01 18:46:44 +02:00
Niels Lohmann
9105f5514e 🔀 merge develop branch 2021-12-31 14:57:35 +01:00
Niels Lohmann
9dfe422e65 Merge branch 'develop' of https://github.com/nlohmann/json into bon8
 Conflicts:
	doc/mkdocs/docs/api/basic_json/index.md
	doc/mkdocs/docs/features/binary_formats/bson.md
	doc/mkdocs/docs/features/binary_formats/index.md
	doc/mkdocs/mkdocs.yml
	include/nlohmann/json.hpp
	single_include/nlohmann/json.hpp
2021-12-31 14:53:13 +01:00
Niels Lohmann
7c26010380 Merge branch 'develop' of https://github.com/nlohmann/json into bon8 2021-11-01 13:31:49 +01:00
Niels Lohmann
d997d1b275 Merge branch 'develop' of https://github.com/nlohmann/json into bon8 2021-10-17 15:27:48 +02:00
Niels Lohmann
cec6b21695 🚨 fix warning 2021-09-12 22:48:34 +02:00
Niels Lohmann
cf81564797 improve coverage 2021-09-12 22:21:08 +02:00
Niels Lohmann
e6013608cc improve coverage 2021-09-12 19:04:24 +02:00
Niels Lohmann
96b9877d20 Merge branch 'develop' of https://github.com/nlohmann/json into bon8 2021-09-12 18:57:18 +02:00
Niels Lohmann
95d75c2346 🚨 fix warnings 2021-09-12 13:33:45 +02:00
Niels Lohmann
b932217c15 🚧 add object and string parser for BON8 2021-09-11 23:28:16 +02:00
Niels Lohmann
e27c127068 🚧 start BON8 parser 2021-09-11 22:46:49 +02:00
Niels Lohmann
627eefa5ad 🏁 set flag for MSVC for test-binary_formats 2021-09-11 16:01:10 +02:00
Niels Lohmann
e9b1ab4e0a 📝 update table for binary formats 2021-09-11 15:40:47 +02:00
Niels Lohmann
7c55a91004 📝 add documentation 2021-09-11 14:59:21 +02:00
Niels Lohmann
5221115ff1 ♻️ implement floating-point special values 2021-09-11 14:27:38 +02:00
Niels Lohmann
6bfd21e321 ♻️ adjust negative integer representation 2021-09-11 13:50:54 +02:00
Niels Lohmann
d798ca24aa ♻️ adjust positive integer representation 2021-09-11 13:22:23 +02:00
Niels Lohmann
623f0e96e2 improve coverage 2021-09-05 12:44:39 +02:00
Niels Lohmann
62487fcf68 improve coverage 2021-09-05 11:26:12 +02:00
Niels Lohmann
f444d9c14f improve coverage 2021-09-05 09:25:58 +02:00
Niels Lohmann
b4f2cf769a 🚨 fix warnings 2021-09-04 23:26:37 +02:00
Niels Lohmann
78e59f502b 🚨 fix warnings 2021-09-04 22:59:43 +02:00
Niels Lohmann
f16465c614 🚨 fix warnings 2021-09-04 22:48:08 +02:00
Niels Lohmann
526bee2bfb 🚨 fix warnings 2021-09-04 22:36:43 +02:00
Niels Lohmann
6cf42d1b55 🚨 fix warnings 2021-09-04 15:54:17 +02:00
Niels Lohmann
e6518ff2d6 🚧 add integer support 2021-09-04 14:54:54 +02:00
Niels Lohmann
c7440a6da2 Merge branch 'develop' of https://github.com/nlohmann/json into bon8 2021-09-01 20:49:24 +02:00
Niels Lohmann
f656f535e1 🚧 begin BON8 implementation 2021-08-31 15:04:06 +02:00
292 changed files with 33717 additions and 33531 deletions

View File

@@ -1,3 +1,4 @@
#AccessModifierOffset: 2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
#AlignConsecutiveBitFields: false
@@ -11,7 +12,7 @@ AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: true
#AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Empty
@@ -29,26 +30,27 @@ BraceWrapping:
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterNamespace: false
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
#BeforeLambdaBody: false
#BeforeWhile: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakStringLiterals: false
ColumnLimit: 160
ColumnLimit: 0
CompactNamespaces: false
ConstructorInitializerIndentWidth: 2
Cpp11BracedListStyle: false
Cpp11BracedListStyle: true
PointerAlignment: Left
FixNamespaceComments: true
IncludeBlocks: Preserve
#IndentCaseBlocks: false
IndentCaseLabels: true
IndentGotoLabels: false
@@ -58,6 +60,7 @@ KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ReflowComments: false
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
@@ -76,22 +79,6 @@ SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Latest
Standard: c++11
TabWidth: 4
UseTab: Never
# what to do with include blocks
SortIncludes: true
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^".*"'
Priority: 1
- Regex: '<[^\/]+>'
Priority: 2
- Regex: '^<(nlohmann)\/-*'
Priority: 3
- Regex: '.*'
Priority: 4
Macros:
- JSON_PRIVATE_UNLESS_TESTED=private

View File

@@ -6,8 +6,6 @@ Checks: '*,
-bugprone-easily-swappable-parameters,
-cert-err58-cpp,
-concurrency-mt-unsafe,
-cppcoreguidelines-avoid-const-or-ref-data-members,
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables,
@@ -17,7 +15,6 @@ Checks: '*,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-rvalue-reference-param-not-moved,
-cppcoreguidelines-virtual-class-destructor,
-fuchsia-default-arguments-calls,
-fuchsia-default-arguments-declarations,
@@ -36,17 +33,11 @@ Checks: '*,
-llvm-header-guard,
-llvm-include-order,
-llvmlibc-*,
-misc-use-anonymous-namespace,
-misc-confusable-identifiers,
-misc-include-cleaner,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-modernize-concat-nested-namespaces,
-modernize-type-traits,
-modernize-use-constraints,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-performance-enum-size,
-readability-function-cognitive-complexity,
-readability-function-size,
-readability-identifier-length,

4
.github/CODEOWNERS vendored
View File

@@ -1,5 +1,5 @@
# JSON for Modern C++ was originally written by Niels Lohmann.
# Since 2013, over 250 contributors have helped to improve the library.
# JSON for Modern C++ has been originally written by Niels Lohmann.
# Since 2013 over 140 contributors have helped to improve the library.
# This CODEOWNERS file is only to make sure that @nlohmann is requested
# for a code review in case of a pull request.

View File

@@ -32,7 +32,7 @@ To make changes, you need to edit the following files:
1. [`include/nlohmann/*`](https://github.com/nlohmann/json/tree/develop/include/nlohmann) - These files are the sources of the library. Before testing or creating a pull request, execute `make amalgamate` to regenerate `single_include/nlohmann/json.hpp` and `single_include/nlohmann/json_fwd.hpp`.
2. [`tests/src/unit-*.cpp`](https://github.com/nlohmann/json/tree/develop/tests/src) - These files contain the [doctest](https://github.com/onqtam/doctest) unit tests which currently cover [100 %](https://coveralls.io/github/nlohmann/json) of the library's code. Before creating a pull request, execute `make pretty` to make sure that the style is correct, as this will be checked by the CI.
2. [`tests/src/unit-*.cpp`](https://github.com/nlohmann/json/tree/develop/tests/src) - These files contain the [doctest](https://github.com/onqtam/doctest) unit tests which currently cover [100 %](https://coveralls.io/github/nlohmann/json) of the library's code.
If you add or change a feature, please also add a unit test to this file. The unit tests can be compiled and executed with
@@ -50,12 +50,12 @@ To make changes, you need to edit the following files:
## Note
- If you open a pull request, the code will be automatically tested with [Valgrind](http://valgrind.org)'s Memcheck tool to detect memory leaks. Please be aware that the execution with Valgrind _may_ in rare cases yield different behavior than running the code directly. This can result in failing unit tests which run successfully without Valgrind.
- There is a Makefile target `make pretty` which runs [Clang-Format](https://clang.llvm.org/docs/ClangFormat.html) to fix indentation. If possible, run it before opening the pull request. Otherwise, we shall run it afterward.
- There is a Makefile target `make pretty` which runs [Artistic Style](http://astyle.sourceforge.net) to fix indentation. If possible, run it before opening the pull request. Otherwise, we shall run it afterward.
## Please don't
- The C++11 support varies between different **compilers** and versions. Please note the [list of supported compilers](https://github.com/nlohmann/json/blob/master/README.md#supported-compilers). Some compilers like GCC 4.7 (and earlier), Clang 3.3 (and earlier), or Microsoft Visual Studio 13.0 and earlier are known not to work due to missing or incomplete C++11 support. Please refrain from proposing changes that work around these compiler's limitations with `#ifdef`s or other means.
- Specifically, I am aware of compilation problems with **Microsoft Visual Studio** (there even is an [issue label](https://github.com/nlohmann/json/issues?utf8=✓&q=label%3A%22visual+studio%22+) for this kind of bug). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project.
- Specifically, I am aware of compilation problems with **Microsoft Visual Studio** (there even is an [issue label](https://github.com/nlohmann/json/issues?utf8=✓&q=label%3A%22visual+studio%22+) for these kind of bugs). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project.
- Please refrain from proposing changes that would **break [JSON](https://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension.
- We shall not extend the library to **support comments**. There is quite some [controversy](https://www.reddit.com/r/programming/comments/4v6chu/why_json_doesnt_support_comments_douglas_crockford/) around this topic, and there were quite some [issues](https://github.com/nlohmann/json/issues/376) on this. We believe that JSON is fine without comments.
- We do not preserve the **insertion order of object elements**. The [JSON standard](https://tools.ietf.org/html/rfc8259.html) defines objects as "an unordered collection of zero or more name/value pairs". To this end, this library does not preserve insertion order of name/value pairs. (In fact, keys will be traversed in alphabetical order as `std::map` with `std::less` is used by default.) Note this behavior conforms to the standard, and we shall not change it to any other order. If you do want to preserve the insertion order, you can specialize the object type with containers like [`tsl::ordered_map`](https://github.com/Tessil/ordered-map) or [`nlohmann::fifo_map`](https://github.com/nlohmann/fifo_map).

View File

@@ -76,7 +76,7 @@ body:
label: Library version
description: >
Which version of the library did you use? If it is a released version,
please enter the version number (e.g., 3.11.3). Otherwise, please enter
please enter the version number (e.g., 3.11.2). Otherwise, please enter
the commit hash. If you got the library from another source as the
GitHub repository (e.g., via a package manager), please also state
this.

View File

@@ -14,6 +14,6 @@ Read the [Contribution Guidelines](https://github.com/nlohmann/json/blob/develop
## Please don't
- The C++11 support varies between different **compilers** and versions. Please note the [list of supported compilers](https://github.com/nlohmann/json/blob/master/README.md#supported-compilers). Some compilers like GCC 4.7 (and earlier), Clang 3.3 (and earlier), or Microsoft Visual Studio 13.0 and earlier are known not to work due to missing or incomplete C++11 support. Please refrain from proposing changes that work around these compiler's limitations with `#ifdef`s or other means.
- Specifically, I am aware of compilation problems with **Microsoft Visual Studio** (there even is an [issue label](https://github.com/nlohmann/json/issues?utf8=✓&q=label%3A%22visual+studio%22+) for this kind of bug). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project.
- Specifically, I am aware of compilation problems with **Microsoft Visual Studio** (there even is an [issue label](https://github.com/nlohmann/json/issues?utf8=✓&q=label%3A%22visual+studio%22+) for these kind of bugs). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project.
- Please refrain from proposing changes that would **break [JSON](https://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension.
- Please do not open pull requests that address **multiple issues**.

View File

@@ -1,17 +1,22 @@
arm_container:
image: gcc:latest
kind: pipeline
name: test-on-arm64
check_task:
check_script:
platform:
arch: arm64
steps:
- name: build
image: gcc
commands:
- wget https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2.tar.gz
- tar xfz cmake-3.20.2.tar.gz
- cd cmake-3.20.2
- ./configure
- make cmake ctest -j4
- make cmake ctest -j10
- cd ..
- mkdir build
- cd build
- ../cmake-3.20.2/bin/cmake .. -DJSON_FastTests=ON
- make -j4
- make -j10
- cd tests
- ../../cmake-3.20.2/bin/ctest -j4
- ../../cmake-3.20.2/bin/ctest -j10

View File

@@ -1,44 +0,0 @@
name: "Check amalgamation"
on:
pull_request:
permissions: read-all
jobs:
save:
runs-on: ubuntu-latest
steps:
- name: Save PR number
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/number
echo ${{ github.event.pull_request.user.login }} > ./pr/author
- uses: actions/upload-artifact@v2
with:
name: pr
path: pr/
check:
runs-on: ubuntu-latest
container: silkeh/clang:dev
env:
MAIN_DIR: ${{ github.workspace }}/main
steps:
- name: Checkout pull request
uses: actions/checkout@v3
with:
path: main
ref: ${{ github.event.pull_request.head.sha }}
- name: Checkout tools
uses: actions/checkout@v3
with:
path: tools
ref: develop
- name: Check amalgamation
run: |
cd $MAIN_DIR
make check-amalgamation

View File

@@ -1,30 +0,0 @@
name: CIFuzz
on: [pull_request]
permissions:
contents: read
jobs:
Fuzzing:
runs-on: ubuntu-latest
steps:
- name: Build Fuzzers
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'json'
dry-run: false
language: c++
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'json'
fuzz-seconds: 300
dry-run: false
language: c++
- name: Upload Crash
uses: actions/upload-artifact@v3
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
path: ./out/artifacts

View File

@@ -10,9 +10,6 @@ on:
schedule:
- cron: '0 19 * * 1'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
@@ -22,8 +19,6 @@ jobs:
CodeQL-Build:
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- name: Checkout repository
@@ -32,8 +27,6 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: c-cpp
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)

View File

@@ -1,75 +0,0 @@
name: Comment Check Amalgamation
on:
workflow_run:
workflows: ["Check amalgamation"]
types:
- completed
permissions: {}
jobs:
comment:
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
issues: read
pull-requests: write
steps:
- name: 'Download artifact'
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0
with:
script: |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr"
})[0];
var download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
- run: unzip pr.zip
- name: 'Comment on PR'
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
var fs = require('fs');
const author = fs.readFileSync('./author')
const issue_number = Number(fs.readFileSync('./number'));
const opts = github.rest.issues.listForRepo.endpoint.merge({
owner: context.repo.owner,
repo: context.repo.repo,
creator: author,
state: 'all'
})
let first = true
const issues = await github.paginate(opts)
for (const issue of issues) {
if (issue.number === issue_number) {
continue
}
if (issue.pull_request) {
first = false
break
}
}
await github.rest.issues.createComment({
issue_number: issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '## 🔴 Amalgamation check failed! 🔴\nThe source code has not been amalgamated.'
+ (first ? ' @' + author + ' Please read and follow the [Contribution Guidelines]'
+ '(https://github.com/nlohmann/json/blob/develop/.github/CONTRIBUTING.md#files-to-change).'
: '')
})

View File

@@ -4,8 +4,6 @@ on:
pull_request_target:
types: [opened, synchronize]
permissions: {}
jobs:
label:
permissions:

View File

@@ -9,9 +9,6 @@ on:
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
@@ -38,7 +35,7 @@ jobs:
runs-on: macos-12
strategy:
matrix:
xcode: ['13.1', '13.2.1', '13.3.1', '13.4.1', '14.0', '14.0.1', '14.1']
xcode: ['13.1', '13.2.1', '13.3.1', '13.4.1']
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
@@ -55,7 +52,9 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
standard: [11, 14, 17, 20, 23]
standard: [11, 14, 17, 20]
env:
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
steps:
- uses: actions/checkout@v3

View File

@@ -10,9 +10,6 @@ on:
- docs/examples/**
workflow_dispatch:
permissions:
contents: read
# we don't want to have concurrent jobs, and we don't want to cancel running jobs to avoid broken publications
concurrency:
group: documentation
@@ -31,11 +28,5 @@ jobs:
- name: Install virtual environment
run: make install_venv -C docs/mkdocs
- name: Build documentation
run: make build -C docs/mkdocs
- name: Deploy documentation
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/mkdocs/site
- name: Publish documentation
run: make publish -C docs/mkdocs

View File

@@ -8,9 +8,6 @@ on:
- release/*
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
@@ -19,13 +16,9 @@ concurrency:
jobs:
ci_test_clang:
runs-on: ubuntu-latest
container: silkeh/clang:dev
container: ghcr.io/nlohmann/json-ci:v2.4.0
steps:
- name: Install git and unzip
run: apt-get update ; apt-get install -y git unzip
- uses: actions/checkout@v3
- name: Get latest CMake and ninja
uses: lukka/get-cmake@v3.27.7
- name: Run CMake
run: cmake -S . -B build -DJSON_CI=On
- name: Build
@@ -46,7 +39,7 @@ jobs:
container: ghcr.io/nlohmann/json-ci:v2.4.0
strategy:
matrix:
target: [ci_cppcheck, ci_test_valgrind, ci_test_single_header, ci_single_binaries, ci_infer]
target: [ci_clang_tidy, ci_cppcheck, ci_test_valgrind, ci_test_clang_sanitizer, ci_test_amalgamation, ci_clang_analyze, ci_cpplint, ci_cmake_flags, ci_single_binaries, ci_reproducible_tests, ci_non_git_tests, ci_offline_testdata, ci_infer]
steps:
- uses: actions/checkout@v3
- name: Run CMake
@@ -54,61 +47,24 @@ jobs:
- name: Build
run: cmake --build build --target ${{ matrix.target }}
ci_test_amalgamation:
ci_test_single_header:
runs-on: ubuntu-latest
container: silkeh/clang:dev
container: ghcr.io/nlohmann/json-ci:v2.4.0
steps:
- uses: actions/checkout@v3
- name: Get latest CMake and ninja
uses: lukka/get-cmake@v3.27.7
- name: Run CMake
run: cmake -S . -B build -DJSON_CI=On
- name: Build
run: cmake --build build --target ci_test_amalgamation
ci_static_analysis_ubuntu:
runs-on: ubuntu-latest
strategy:
matrix:
target: [ci_cpplint, ci_reproducible_tests, ci_non_git_tests, ci_offline_testdata]
steps:
- uses: actions/checkout@v3
- name: Get latest CMake and ninja
uses: lukka/get-cmake@v3.27.7
- name: Run CMake
run: cmake -S . -B build -DJSON_CI=On
- name: Build
run: cmake --build build --target ${{ matrix.target }}
ci_static_analysis_clang:
runs-on: ubuntu-latest
container: silkeh/clang:dev
strategy:
matrix:
target: [ci_clang_tidy, ci_test_clang_sanitizer, ci_clang_analyze]
steps:
- name: Install git, clang-tools, and unzip
run: apt-get update ; apt-get install -y git clang-tools unzip
- uses: actions/checkout@v3
- name: Get latest CMake and ninja
uses: lukka/get-cmake@v3.27.7
- name: Run CMake
run: cmake -S . -B build -DJSON_CI=On
- name: Build
run: cmake --build build --target ${{ matrix.target }}
run: cmake --build build --target ci_test_single_header
ci_cmake_options:
runs-on: ubuntu-latest
container: ubuntu:focal
container: ghcr.io/nlohmann/json-ci:v2.4.0
strategy:
matrix:
target: [ci_cmake_flags, ci_test_diagnostics, ci_test_noexceptions, ci_test_noimplicitconversions, ci_test_legacycomparison, ci_test_noglobaludls]
target: [ci_test_diagnostics, ci_test_noexceptions, ci_test_noimplicitconversions, ci_test_legacycomparison, ci_test_noglobaludls]
steps:
- name: Install build-essential
run: apt-get update ; apt-get install -y build-essential unzip wget git
- uses: actions/checkout@v3
- name: Get latest CMake and ninja
uses: lukka/get-cmake@v3.27.7
- name: Run CMake
run: cmake -S . -B build -DJSON_CI=On
- name: Build
@@ -117,9 +73,6 @@ jobs:
ci_test_coverage:
runs-on: ubuntu-latest
container: ghcr.io/nlohmann/json-ci:v2.4.0
permissions:
contents: read
checks: write
steps:
- uses: actions/checkout@v3
- name: Run CMake
@@ -137,47 +90,12 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ${{ github.workspace }}/build/json.info.filtered.noexcept
ci_test_compilers_gcc:
runs-on: ubuntu-latest
strategy:
matrix:
compiler: ['4', '5', '6', '7', '8', '9', '10', '11', '12', 'latest']
container: gcc:${{ matrix.compiler }}
steps:
- uses: actions/checkout@v3
- name: Get latest CMake and ninja
uses: lukka/get-cmake@v3.27.7
- name: Run CMake
run: cmake -S . -B build -DJSON_CI=On
- name: Build
run: cmake --build build --target ci_test_compiler_default
ci_test_compilers_clang:
runs-on: ubuntu-latest
strategy:
matrix:
compiler: ['3.5', '3.6', '3.7', '3.8', '3.9', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15-bullseye', 'latest']
container: silkeh/clang:${{ matrix.compiler }}
steps:
- name: Install unzip and git
run: apt-get update ; apt-get install -y unzip git
- uses: actions/checkout@v3
- name: Get latest CMake and ninja
uses: lukka/get-cmake@v3.27.7
- name: Set env FORCE_STDCPPFS_FLAG for clang 7 / 8 / 9 / 10
run: echo "JSON_FORCED_GLOBAL_COMPILE_OPTIONS=-DJSON_HAS_FILESYSTEM=0;-DJSON_HAS_EXPERIMENTAL_FILESYSTEM=0" >> "$GITHUB_ENV"
if: ${{ matrix.compiler == '7' || matrix.compiler == '8' || matrix.compiler == '9' || matrix.compiler == '10' }}
- name: Run CMake
run: cmake -S . -B build -DJSON_CI=On
- name: Build
run: cmake --build build --target ci_test_compiler_default
ci_test_compilers:
runs-on: ubuntu-latest
container: ghcr.io/nlohmann/json-ci:v2.4.0
strategy:
matrix:
compiler: [g++-4.8]
compiler: [g++-4.8, g++-4.9, g++-5, g++-6, g++-7, g++-8, g++-9, g++-10, g++-11, clang++-3.5, clang++-3.6, clang++-3.7, clang++-3.8, clang++-3.9, clang++-4.0, clang++-5.0, clang++-6.0, clang++-7, clang++-8, clang++-9, clang++-10, clang++-11, clang++-12, clang++-13, clang++-14]
steps:
- uses: actions/checkout@v3
- name: Run CMake
@@ -185,35 +103,19 @@ jobs:
- name: Build
run: cmake --build build --target ci_test_compiler_${{ matrix.compiler }}
ci_test_standards_gcc:
ci_test_standards:
runs-on: ubuntu-latest
container: ghcr.io/nlohmann/json-ci:v2.4.0
strategy:
matrix:
standard: [11, 14, 17, 20, 23]
standard: [11, 14, 17, 20]
compiler: [gcc, clang]
steps:
- uses: actions/checkout@v3
- name: Run CMake
run: cmake -S . -B build -DJSON_CI=On
- name: Build
run: cmake --build build --target ci_test_gcc_cxx${{ matrix.standard }}
ci_test_standards_clang:
runs-on: ubuntu-latest
container: silkeh/clang:latest
strategy:
matrix:
standard: [11, 14, 17, 20, 23]
steps:
- name: Install git and unzip
run: apt-get update ; apt-get install -y git unzip
- uses: actions/checkout@v3
- name: Get latest CMake and ninja
uses: lukka/get-cmake@v3.27.7
- name: Run CMake
run: cmake -S . -B build -DJSON_CI=On
- name: Build
run: cmake --build build --target ci_test_clang_cxx${{ matrix.standard }}
run: cmake --build build --target ci_test_${{ matrix.compiler }}_cxx${{ matrix.standard }}
ci_cuda_example:
runs-on: ubuntu-latest

View File

@@ -9,27 +9,44 @@ on:
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
jobs:
mingw:
runs-on: windows-2019
runs-on: windows-latest
strategy:
matrix:
architecture: [x64, x86]
steps:
- uses: actions/checkout@v3
- name: Set up MinGW
uses: egor-tensin/setup-mingw@v2
with:
platform: ${{ matrix.architecture }}
version: 12.2.0 # https://github.com/egor-tensin/setup-mingw/issues/14
- name: Download MinGW 8.1.0
run: |
$headers = @{Authorization = 'Bearer ${{ secrets.GITHUB_TOKEN }}'}
$uri = 'https://nuget.pkg.github.com/falbrechtskirchinger/download/mingw/8.1.0/mingw.8.1.0.nupkg'
Invoke-WebRequest -Uri $uri -Headers $headers -OutFile mingw.8.1.0.nupkg
- name: Uninstall MinGW
continue-on-error: true
run: choco uninstall mingw
# Based on egor-tensin/setup-mingw
- name: Install MinGW 8.1.0
run: |
choco install mingw.8.1.0.nupkg ${{ matrix.architecture == 'x86' && '--x86' || '' }}
$prefix = "${{ matrix.architecture == 'x64' && 'x86_64-w64-mingw32' || 'i686-w64-mingw32' }}"
$mingw = "${{ matrix.architecture == 'x64' && 'mingw64' || 'mingw32' }}"
$mingw_install = Join-Path C: ProgramData chocolatey lib mingw tools install
$mingw_root = Join-Path $mingw_install $mingw
$mingw_bin = Join-Path $mingw_root bin
$mingw_lib = Join-Path $mingw_root $prefix lib
echo $mingw_bin >> $env:GITHUB_PATH
Remove-Item (Join-Path $mingw_lib 'libpthread.dll.a')
Remove-Item (Join-Path $mingw_lib 'libwinpthread.dll.a')
#- name: Set up MinGW
# uses: egor-tensin/setup-mingw@v2
# with:
# platform: ${{ matrix.architecture }}
- name: Run CMake
run: cmake -S . -B build -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
- name: Build
@@ -105,7 +122,7 @@ jobs:
runs-on: windows-2019
strategy:
matrix:
version: [11, 12, 13, 14, 15]
version: [11, 12]
steps:
- uses: actions/checkout@v3

3
.gitignore vendored
View File

@@ -39,6 +39,3 @@
/localhost.pem
/localhost-key.pem
/serve_header.yml
# Swift Package Manager build directory
/.build

View File

@@ -27,6 +27,10 @@ Files: tools/amalgamate/*
Copyright: 2012 Erik Edlund <erik.edlund@32767.se>
License: BSD-3-Clause
Files: tools/cpplint/*
Copyright: 2009 Google Inc. All rights reserved.
License: BSD-3-Clause
Files: tools/gdb_pretty_printer
Copyright: 2020 Hannes Domani <https://github.com/ssbssa>
License: MIT

View File

@@ -1,6 +1,6 @@
__ _____ _____ _____
__| | __| | | | JSON for Modern C++
| | |__ | | | | | | version 3.11.3
| | |__ | | | | | | version 3.11.2
|_____|_____|_____|_|___| https://github.com/nlohmann/json
{% for copyright_line in copyright_lines %}

View File

@@ -1,6 +1,6 @@
__ _____ _____ _____
__| | __| | | | JSON for Modern C++ (supporting code)
| | |__ | | | | | | version 3.11.3
| | |__ | | | | | | version 3.11.2
|_____|_____|_____|_|___| https://github.com/nlohmann/json
{% for copyright_line in copyright_lines %}

View File

@@ -1,53 +0,0 @@
cc_library(
name = "json",
hdrs = [
"include/nlohmann/adl_serializer.hpp",
"include/nlohmann/byte_container_with_subtype.hpp",
"include/nlohmann/detail/abi_macros.hpp",
"include/nlohmann/detail/conversions/from_json.hpp",
"include/nlohmann/detail/conversions/to_chars.hpp",
"include/nlohmann/detail/conversions/to_json.hpp",
"include/nlohmann/detail/exceptions.hpp",
"include/nlohmann/detail/hash.hpp",
"include/nlohmann/detail/input/binary_reader.hpp",
"include/nlohmann/detail/input/input_adapters.hpp",
"include/nlohmann/detail/input/json_sax.hpp",
"include/nlohmann/detail/input/lexer.hpp",
"include/nlohmann/detail/input/parser.hpp",
"include/nlohmann/detail/input/position_t.hpp",
"include/nlohmann/detail/iterators/internal_iterator.hpp",
"include/nlohmann/detail/iterators/iter_impl.hpp",
"include/nlohmann/detail/iterators/iteration_proxy.hpp",
"include/nlohmann/detail/iterators/iterator_traits.hpp",
"include/nlohmann/detail/iterators/json_reverse_iterator.hpp",
"include/nlohmann/detail/iterators/primitive_iterator.hpp",
"include/nlohmann/detail/json_custom_base_class.hpp",
"include/nlohmann/detail/json_pointer.hpp",
"include/nlohmann/detail/json_ref.hpp",
"include/nlohmann/detail/macro_scope.hpp",
"include/nlohmann/detail/macro_unscope.hpp",
"include/nlohmann/detail/meta/call_std/begin.hpp",
"include/nlohmann/detail/meta/call_std/end.hpp",
"include/nlohmann/detail/meta/cpp_future.hpp",
"include/nlohmann/detail/meta/detected.hpp",
"include/nlohmann/detail/meta/identity_tag.hpp",
"include/nlohmann/detail/meta/is_sax.hpp",
"include/nlohmann/detail/meta/std_fs.hpp",
"include/nlohmann/detail/meta/type_traits.hpp",
"include/nlohmann/detail/meta/void_t.hpp",
"include/nlohmann/detail/output/binary_writer.hpp",
"include/nlohmann/detail/output/output_adapters.hpp",
"include/nlohmann/detail/output/serializer.hpp",
"include/nlohmann/detail/string_concat.hpp",
"include/nlohmann/detail/string_escape.hpp",
"include/nlohmann/detail/value_t.hpp",
"include/nlohmann/json.hpp",
"include/nlohmann/json_fwd.hpp",
"include/nlohmann/ordered_map.hpp",
"include/nlohmann/thirdparty/hedley/hedley.hpp",
"include/nlohmann/thirdparty/hedley/hedley_undef.hpp",
],
includes = ["include"],
visibility = ["//visibility:public"],
alwayslink = True,
)

View File

@@ -7,8 +7,8 @@ authors:
email: mail@nlohmann.me
website: https://nlohmann.me
title: "JSON for Modern C++"
version: 3.11.3
date-released: 2023-11-28
version: 3.11.2
date-released: 2022-08-12
license: MIT
repository-code: "https://github.com/nlohmann"
url: https://json.nlohmann.me

View File

@@ -1,10 +1,10 @@
cmake_minimum_required(VERSION 3.1...3.14)
cmake_minimum_required(VERSION 3.1)
##
## PROJECT
## name and version
##
project(nlohmann_json VERSION 3.11.3 LANGUAGES CXX)
project(nlohmann_json VERSION 3.11.2 LANGUAGES CXX)
##
## MAIN_PROJECT CHECK
@@ -43,7 +43,7 @@ option(JSON_Diagnostics "Use extended diagnostic messages." O
option(JSON_GlobalUDLs "Place use-defined string literals in the global namespace." ON)
option(JSON_ImplicitConversions "Enable implicit conversions." ON)
option(JSON_DisableEnumSerialization "Disable default integer enum serialization." OFF)
option(JSON_LegacyDiscardedValueComparison "Enable legacy discarded value comparison." OFF)
option(JSON_LegacyDiscardedValueComparison "Enable legacy discarded value comparison." OFF)
option(JSON_Install "Install CMake targets during install step." ${MAIN_PROJECT})
option(JSON_MultipleHeaders "Use non-amalgamated version of the library." ON)
option(JSON_SystemInclude "Include as system headers (skip for clang-tidy)." OFF)
@@ -122,7 +122,7 @@ target_include_directories(
${NLOHMANN_JSON_TARGET_NAME}
${NLOHMANN_JSON_SYSTEM_INCLUDE} INTERFACE
$<BUILD_INTERFACE:${NLOHMANN_JSON_INCLUDE_BUILD_DIR}>
$<INSTALL_INTERFACE:${NLOHMANN_JSON_INCLUDE_INSTALL_DIR}>
$<INSTALL_INTERFACE:include>
)
## add debug view definition file for msvc (natvis)

View File

@@ -142,9 +142,32 @@ pvs_studio:
# Code format and source amalgamation
##########################################################################
# call the Clang-Format on all source files
# call the Artistic Style pretty printer on all source files
pretty:
clang-format --Werror --verbose -i $(SRCS) $(TESTS_SRCS) $(AMALGAMATED_FILE) $(AMALGAMATED_FWD_FILE)
astyle \
--style=allman \
--indent=spaces=4 \
--indent-modifiers \
--indent-switches \
--indent-preproc-block \
--indent-preproc-define \
--indent-col1-comments \
--pad-oper \
--pad-header \
--align-pointer=type \
--align-reference=type \
--add-brackets \
--convert-tabs \
--close-templates \
--lineend=linux \
--preserve-date \
--suffix=none \
--formatted \
$(SRCS) $(TESTS_SRCS) $(AMALGAMATED_FILE) $(AMALGAMATED_FWD_FILE) docs/examples/*.cpp
# call the Clang-Format on all source files
pretty_format:
for FILE in $(SRCS) $(TESTS_SRCS) $(AMALGAMATED_FILE) docs/examples/*.cpp; do echo $$FILE; clang-format -i $$FILE; done
# create single header files and pretty print
amalgamate: $(AMALGAMATED_FILE) $(AMALGAMATED_FWD_FILE)
@@ -169,8 +192,6 @@ check-amalgamation:
@mv $(AMALGAMATED_FILE)~ $(AMALGAMATED_FILE)
@mv $(AMALGAMATED_FWD_FILE)~ $(AMALGAMATED_FWD_FILE)
BUILD.bazel: $(SRCS)
cmake -P cmake/scripts/gen_bazel_build_file.cmake
##########################################################################
# ChangeLog
@@ -202,8 +223,8 @@ json.tar.xz:
# We use `-X` to make the resulting ZIP file reproducible, see
# <https://content.pivotal.io/blog/barriers-to-deterministic-reproducible-zip-files>.
include.zip: BUILD.bazel
zip -9 --recurse-paths -X include.zip $(SRCS) $(AMALGAMATED_FILE) $(AMALGAMATED_FWD_FILE) BUILD.bazel WORKSPACE.bazel meson.build LICENSE.MIT
include.zip:
zip -9 --recurse-paths -X include.zip $(SRCS) $(AMALGAMATED_FILE) meson.build LICENSE.MIT
# Create the files for a release and add signatures and hashes.
release: include.zip json.tar.xz

View File

@@ -1,22 +0,0 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "nlohmann-json",
platforms: [
.iOS(.v12), .macOS(.v10_13), .tvOS(.v12), .watchOS(.v4)
],
products: [
.library(name: "json", targets: ["json"])
],
targets: [
.target(
name: "json",
path: "single_include/nlohmann",
publicHeadersPath: "."
)
],
cxxLanguageStandard: .cxx11
)

167
README.md
View File

@@ -7,13 +7,12 @@
[![Coverage Status](https://coveralls.io/repos/github/nlohmann/json/badge.svg?branch=develop)](https://coveralls.io/github/nlohmann/json?branch=develop)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/5550/badge.svg)](https://scan.coverity.com/projects/nlohmann-json)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/e0d1a9d5d6fd46fcb655c4cb930bb3e8)](https://www.codacy.com/gh/nlohmann/json/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=nlohmann/json&amp;utm_campaign=Badge_Grade)
[![Cirrus CI](https://api.cirrus-ci.com/github/nlohmann/json.svg)](https://cirrus-ci.com/github/nlohmann/json)
[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/nlohmann/json.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/nlohmann/json/context:cpp)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/json.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:json)
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/1mp10JbaANo6FUc7)
[![Documentation](https://img.shields.io/badge/docs-mkdocs-blue.svg)](https://json.nlohmann.me)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nlohmann/json/master/LICENSE.MIT)
[![GitHub Releases](https://img.shields.io/github/release/nlohmann/json.svg)](https://github.com/nlohmann/json/releases)
[![Vcpkg Version](https://img.shields.io/vcpkg/v/nlohmann-json)](https://vcpkg.link/ports/nlohmann-json)
[![Packaging status](https://repology.org/badge/tiny-repos/nlohmann-json.svg)](https://repology.org/project/nlohmann-json/versions)
[![GitHub Downloads](https://img.shields.io/github/downloads/nlohmann/json/total)](https://github.com/nlohmann/json/releases)
[![GitHub Issues](https://img.shields.io/github/issues/nlohmann/json.svg)](https://github.com/nlohmann/json/issues)
@@ -77,7 +76,7 @@ You can sponsor this library at [GitHub Sponsors](https://github.com/sponsors/nl
### :office: Corporate Sponsor
[![](https://upload.wikimedia.org/wikipedia/commons/thumb/9/9e/Codacy-logo-black.svg/320px-Codacy-logo-black.svg.png)](https://github.com/codacy/About)
[![](https://upload.wikimedia.org/wikipedia/commons/thumb/9/9e/Codacy-logo-black.svg/320px-Codacy-logo-black.svg.png)](https://github.com/codacy)
### :label: Named Sponsors
@@ -86,7 +85,6 @@ You can sponsor this library at [GitHub Sponsors](https://github.com/sponsors/nl
- [Steve Sperandeo](https://github.com/homer6)
- [Robert Jefe Lindstädt](https://github.com/eljefedelrodeodeljefe)
- [Steve Wagner](https://github.com/ciroque)
- [Lion Yang](https://github.com/LionNatsu)
Thanks everyone!
@@ -270,7 +268,7 @@ Note that without appending the `_json` suffix, the passed string literal is not
value. That is, `json j = "{ \"happy\": true, \"pi\": 3.141 }"` would just store the string
`"{ "happy": true, "pi": 3.141 }"` rather than parsing the actual object.
The string literal should be brought into scope with `using namespace nlohmann::literals;`
The string literal should be brought into scope with with `using namespace nlohmann::literals;`
(see [`json::parse()`](https://json.nlohmann.me/api/operator_literal_json/)).
The above example can also be expressed explicitly using [`json::parse()`](https://json.nlohmann.me/api/basic_json/parse/):
@@ -302,7 +300,7 @@ Note the difference between serialization and assignment:
json j_string = "this is a string";
// retrieve the string value
auto cpp_string = j_string.template get<std::string>();
auto cpp_string = j_string.get<std::string>();
// retrieve the string value (alternative when a variable already exists)
std::string cpp_string2;
j_string.get_to(cpp_string2);
@@ -311,7 +309,7 @@ j_string.get_to(cpp_string2);
std::string serialized_string = j_string.dump();
// output of original string
std::cout << cpp_string << " == " << cpp_string2 << " == " << j_string.template get<std::string>() << '\n';
std::cout << cpp_string << " == " << cpp_string2 << " == " << j_string.get<std::string>() << '\n';
// output of serialized value
std::cout << j_string << " == " << serialized_string << std::endl;
```
@@ -484,7 +482,7 @@ for (auto& element : j) {
}
// getter/setter
const auto tmp = j[0].template get<std::string>();
const auto tmp = j[0].get<std::string>();
j[1] = 42;
bool foo = j.at(2);
@@ -692,7 +690,7 @@ You can switch off implicit conversions by defining `JSON_USE_IMPLICIT_CONVERSIO
// strings
std::string s1 = "Hello, world!";
json js = s1;
auto s2 = js.template get<std::string>();
auto s2 = js.get<std::string>();
// NOT RECOMMENDED
std::string s3 = js;
std::string s4;
@@ -701,7 +699,7 @@ s4 = js;
// Booleans
bool b1 = true;
json jb = b1;
auto b2 = jb.template get<bool>();
auto b2 = jb.get<bool>();
// NOT RECOMMENDED
bool b3 = jb;
bool b4;
@@ -710,7 +708,7 @@ b4 = jb;
// numbers
int i = 42;
json jn = i;
auto f = jn.template get<double>();
auto f = jn.get<double>();
// NOT RECOMMENDED
double f2 = jb;
double f3;
@@ -753,9 +751,9 @@ j["age"] = p.age;
// convert from JSON: copy each value from the JSON object
ns::person p {
j["name"].template get<std::string>(),
j["address"].template get<std::string>(),
j["age"].template get<int>()
j["name"].get<std::string>(),
j["address"].get<std::string>(),
j["age"].get<int>()
};
```
@@ -772,7 +770,7 @@ std::cout << j << std::endl;
// {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}
// conversion: json -> person
auto p2 = j.template get<ns::person>();
auto p2 = j.get<ns::person>();
// that's it
assert(p == p2);
@@ -799,13 +797,13 @@ namespace ns {
```
That's all! When calling the `json` constructor with your type, your custom `to_json` method will be automatically called.
Likewise, when calling `template get<your_type>()` or `get_to(your_type&)`, the `from_json` method will be called.
Likewise, when calling `get<your_type>()` or `get_to(your_type&)`, the `from_json` method will be called.
Some important things:
* Those methods **MUST** be in your type's namespace (which can be the global namespace), or the library will not be able to locate them (in this example, they are in namespace `ns`, where `person` is defined).
* Those methods **MUST** be available (e.g., proper headers must be included) everywhere you use these conversions. Look at [issue 1108](https://github.com/nlohmann/json/issues/1108) for errors that may occur otherwise.
* When using `template get<your_type>()`, `your_type` **MUST** be [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). (There is a way to bypass this requirement described later.)
* When using `get<your_type>()`, `your_type` **MUST** be [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). (There is a way to bypass this requirement described later.)
* In function `from_json`, use function [`at()`](https://json.nlohmann.me/api/basic_json/at/) to access the object values rather than `operator[]`. In case a key does not exist, `at` throws an exception that you can handle, whereas `operator[]` exhibits undefined behavior.
* You do not need to add serializers or deserializers for STL types like `std::vector`: the library already implements these.
@@ -890,8 +888,8 @@ namespace nlohmann {
if (j.is_null()) {
opt = boost::none;
} else {
opt = j.template get<T>(); // same as above, but with
// adl_serializer<T>::from_json
opt = j.get<T>(); // same as above, but with
// adl_serializer<T>::from_json
}
}
};
@@ -918,7 +916,7 @@ namespace nlohmann {
// note: the return type is no longer 'void', and the method only takes
// one argument
static move_only_type from_json(const json& j) {
return {j.template get<int>()};
return {j.get<int>()};
}
// Here's the catch! You must provide a to_json method! Otherwise, you
@@ -1022,11 +1020,11 @@ assert(j == "stopped");
// json string to enum
json j3 = "running";
assert(j3.template get<TaskState>() == TS_RUNNING);
assert(j3.get<TaskState>() == TS_RUNNING);
// undefined json value to enum (where the first map entry above is the default)
json jPi = 3.14;
assert(jPi.template get<TaskState>() == TS_INVALID );
assert(jPi.get<TaskState>() == TS_INVALID );
```
Just as in [Arbitrary Type Conversions](#arbitrary-types-conversions) above,
@@ -1034,7 +1032,7 @@ Just as in [Arbitrary Type Conversions](#arbitrary-types-conversions) above,
- It MUST be available (e.g., proper headers must be included) everywhere you use the conversions.
Other Important points:
- When using `template 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 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)
@@ -1111,7 +1109,7 @@ auto cbor = json::to_msgpack(j); // 0xD5 (fixext2), 0x10, 0xCA, 0xFE
## Supported compilers
Though it's 2023 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work:
Though it's 2022 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work:
- GCC 4.8 - 12.0 (and possibly later)
- Clang 3.4 - 15.0 (and possibly later)
@@ -1142,60 +1140,51 @@ Please note:
- Unsupported versions of GCC and Clang are rejected by `#error` directives. This can be switched off by defining `JSON_SKIP_UNSUPPORTED_COMPILER_CHECK`. Note that you can expect no support in this case.
The following compilers are currently used in continuous integration at [AppVeyor](https://ci.appveyor.com/project/nlohmann/json), [Cirrus CI](https://cirrus-ci.com/github/nlohmann/json), and [GitHub Actions](https://github.com/nlohmann/json/actions):
The following compilers are currently used in continuous integration at [AppVeyor](https://ci.appveyor.com/project/nlohmann/json), [Drone CI](https://cloud.drone.io/nlohmann/json), and [GitHub Actions](https://github.com/nlohmann/json/actions):
| Compiler | Operating System | CI Provider |
|--------------------------------------------------------------------------------------------------------|--------------------|----------------|
| Apple Clang 11.0.3 (clang-1103.0.32.62); Xcode 11.7 | macOS 11.7.1 | GitHub Actions |
| Apple Clang 12.0.0 (clang-1200.0.32.29); Xcode 12.4 | macOS 11.7.1 | GitHub Actions |
| Apple Clang 12.0.5 (clang-1205.0.22.11); Xcode 12.5.1 | macOS 11.7.1 | GitHub Actions |
| Apple Clang 13.0.0 (clang-1300.0.29.3); Xcode 13.0 | macOS 11.7.1 | GitHub Actions |
| Apple Clang 13.0.0 (clang-1300.0.29.3); Xcode 13.1 | macOS 12.6.1 | GitHub Actions |
| Apple Clang 13.0.0 (clang-1300.0.29.30); Xcode 13.2.1 | macOS 12.6.1 | GitHub Actions |
| Apple Clang 13.1.6 (clang-1316.0.21.2.3); Xcode 13.3.1 | macOS 12.6.1 | GitHub Actions |
| Apple Clang 13.1.6 (clang-1316.0.21.2.5); Xcode 13.4.1 | macOS 12.6.1 | GitHub Actions |
| Apple Clang 14.0.0 (clang-1400.0.29.102); Xcode 14.0 | macOS 12.6.1 | GitHub Actions |
| Apple Clang 14.0.0 (clang-1400.0.29.102); Xcode 14.0.1 | macOS 12.6.1 | GitHub Actions |
| Apple Clang 14.0.0 (clang-1400.0.29.202); Xcode 14.1 | macOS 12.6.1 | GitHub Actions |
| Clang 3.5.2 | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 3.6.2 | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 3.7.1 | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 3.8.1 | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 3.9.1 | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 4.0.1 | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 5.0.2 | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 6.0.1 | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 7.0.1 | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 8.0.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 9.0.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 10.0.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
| Apple Clang 11.0.3 (clang-1103.0.32.62); Xcode 11.7 | macOS 11.6.8 | GitHub Actions |
| Apple Clang 12.0.0 (clang-1200.0.32.29); Xcode 12.4 | macOS 11.6.8 | GitHub Actions |
| Apple Clang 12.0.5 (clang-1205.0.22.11); Xcode 12.5.1 | macOS 11.6.8 | GitHub Actions |
| Apple Clang 13.0.0 (clang-1300.0.29.3); Xcode 13.0 | macOS 11.6.8 | GitHub Actions |
| Apple Clang 13.0.0 (clang-1300.0.29.3); Xcode 13.1 | macOS 12.4 | GitHub Actions |
| Apple Clang 13.0.0 (clang-1300.0.29.30); Xcode 13.2.1 | macOS 12.4 | GitHub Actions |
| Apple Clang 13.1.6 (clang-1316.0.21.2.3); Xcode 13.3.1 | macOS 12.4 | GitHub Actions |
| Apple Clang 13.1.6 (clang-1316.0.21.2.5); Xcode 13.4.1 | macOS 12.4 | GitHub Actions |
| Clang 3.5.2 (3.5.2-3ubuntu1) | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 3.6.2 (3.6.2-3ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 3.7.1 (3.7.1-2ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 3.8.0 (3.8.0-2ubuntu4) | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 3.9.1 (3.9.1-4ubuntu3\~16.04.2) | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 4.0.0 (4.0.0-1ubuntu1\~16.04.2) | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 5.0.0 (5.0.0-3\~16.04.1) | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 6.0.1 (6.0.1-14) | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 7.0.1 (7.0.1-12) | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 8.0.1 (8.0.1-9) | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 9.0.1 (9.0.1-12) | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 10.0.0 (10.0.0-4ubuntu1) | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 10.0.0 with GNU-like command-line | Windows-10.0.17763 | GitHub Actions |
| Clang 11.0.0 with GNU-like command-line | Windows-10.0.17763 | GitHub Actions |
| Clang 11.0.0 with MSVC-like command-line | Windows-10.0.17763 | GitHub Actions |
| Clang 11.0.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 12.0.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 12.0.0 with GNU-like command-line | Windows-10.0.17763 | GitHub Actions |
| Clang 13.0.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 13.0.0 with GNU-like command-line | Windows-10.0.17763 | GitHub Actions |
| Clang 14.0.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 14.0.0 with GNU-like command-line | Windows-10.0.17763 | GitHub Actions |
| Clang 15.0.0 with GNU-like command-line | Windows-10.0.17763 | GitHub Actions |
| Clang 15.0.4 | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 16.0.0 (16.0.0-++20221031071727+500876226c60-1~exp1~20221031071831.439) | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 11.0.0 (11.0.0-2~ubuntu20.04.1) | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 12.0.0 (12.0.0-3ubuntu1~20.04.3) | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 13.0.1 (13.0.1-++20211015123032+cf15ccdeb6d5-1exp120211015003613.5) | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 14.0.5-++20220603124341+2f0a69c32a4c-1~exp1~20220603124352.149 | Ubuntu 20.04.3 LTS | GitHub Actions |
| Clang 15.0.0 (15.0.0-++20220530052901+b7d2b160c3ba-1~exp1~20220530172952.268) | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 4.8.5 (Ubuntu 4.8.5-4ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 4.9.4 | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 5.5.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 6.5.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 7.5.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 4.9.3 (Ubuntu 4.9.3-13ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 6.4.0 (Ubuntu 6.4.0-17ubuntu1) | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 7.5.0 (Ubuntu 7.5.0-6ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 8.1.0 (i686-posix-dwarf-rev0, Built by MinGW-W64 project) | Windows-10.0.17763 | GitHub Actions |
| GCC 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) | Windows-10.0.17763 | GitHub Actions |
| GCC 8.5.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 9.5.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 10.4.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 11.1.0 | Ubuntu (aarch64) | Cirrus CI |
| GCC 11.3.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 12.2.0 | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 13.0.0 20220605 (experimental) | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 8.4.0 (Ubuntu 8.4.0-3ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 10.2.0 (Ubuntu 10.2.0-5ubuntu1~20.04) | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 11.1.0 | Ubuntu (aarch64) | Drone CI |
| GCC 11.1.0 (Ubuntu 11.1.0-1ubuntu1~20.04) | Ubuntu 20.04.3 LTS | GitHub Actions |
| GCC 13.0.0 13.0.0 20220605 (experimental) | Ubuntu 20.04.3 LTS | GitHub Actions |
| Intel C++ Compiler 2021.5.0.20211109 | Ubuntu 20.04.3 LTS | GitHub Actions |
| NVCC 11.0.221 | Ubuntu 20.04.3 LTS | GitHub Actions |
| Visual Studio 14 2015 MSVC 19.0.24241.7 (Build Engine version 14.0.25420.1) | Windows-6.3.9600 | AppVeyor |
@@ -1273,7 +1262,7 @@ Example:
```cmake
include(FetchContent)
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz)
FetchContent_MakeAvailable(json)
target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json)
@@ -1320,9 +1309,7 @@ endif()
If you are using the [Meson Build System](https://mesonbuild.com), add this source tree as a [meson subproject](https://mesonbuild.com/Subprojects.html#using-a-subproject). You may also use the `include.zip` published in this project's [Releases](https://github.com/nlohmann/json/releases) to reduce the size of the vendored source tree. Alternatively, you can get a wrap file by downloading it from [Meson WrapDB](https://wrapdb.mesonbuild.com/nlohmann_json), or simply use `meson wrap install nlohmann_json`. Please see the meson project for any issues regarding the packaging.
The provided `meson.build` can also be used as an alternative to CMake for installing `nlohmann_json` system-wide in which case a pkg-config file is installed. To use it, simply have your build system require the `nlohmann_json` pkg-config dependency. In Meson, it is preferred to use the [`dependency()`](https://mesonbuild.com/Reference-manual.html#dependency) object with a subproject fallback, rather than using the subproject directly.
If you are using [Bazel](https://bazel.build/) you can simply reference this repository using `http_archive` or `git_repository` and depend on `@nlohmann_json//:json`.
The provided `meson.build` can also be used as an alternative to cmake for installing `nlohmann_json` system-wide in which case a pkg-config file is installed. To use it, simply have your build system require the `nlohmann_json` pkg-config dependency. In Meson, it is preferred to use the [`dependency()`](https://mesonbuild.com/Reference-manual.html#dependency) object with a subproject fallback, rather than using the subproject directly.
If you are using [Conan](https://www.conan.io/) to manage your dependencies, merely add [`nlohmann_json/x.y.z`](https://conan.io/center/nlohmann_json) to your `conanfile`'s requires, where `x.y.z` is the release version you want to use. Please file issues [here](https://github.com/conan-io/conan-center-index/issues) if you experience problems with the packages.
@@ -1338,8 +1325,6 @@ If you are using [cget](https://cget.readthedocs.io/en/latest/), you can install
If you are using [CocoaPods](https://cocoapods.org), you can use the library by adding pod `"nlohmann_json", '~>3.1.2'` to your podfile (see [an example](https://bitbucket.org/benman/nlohmann_json-cocoapod/src/master/)). Please file issues [here](https://bitbucket.org/benman/nlohmann_json-cocoapod/issues?status=new&status=open).
If you are using [Swift Package Manager](https://swift.org/package-manager/), you can use the library by adding a package dependency to this repository. And target dependency as `.product(name: "nlohmann-json", package: "json")`.
If you are using [NuGet](https://www.nuget.org), you can use the package [nlohmann.json](https://www.nuget.org/packages/nlohmann.json/). Please check [this extensive description](https://github.com/nlohmann/json/issues/1132#issuecomment-452250255) on how to use the package. Please file issues [here](https://github.com/hnkb/nlohmann-json-nuget/issues).
If you are using [conda](https://conda.io/), you can use the package [nlohmann_json](https://github.com/conda-forge/nlohmann_json-feedstock) from [conda-forge](https://conda-forge.org) executing `conda install -c conda-forge nlohmann_json`. Please file issues [here](https://github.com/conda-forge/nlohmann_json-feedstock/issues).
@@ -1733,36 +1718,6 @@ I deeply appreciate the help of the following people.
314. [Berkus Decker](https://github.com/berkus) fixed a typo in the README.
315. [Illia Polishchuk](https://github.com/effolkronium) improved the CMake testing.
316. [Ikko Ashimine](https://github.com/eltociear) fixed a typo.
317. [Raphael Grimm](https://github.com/barcode) added the possibility to define a custom base class.
318. [tocic](https://github.com/tocic) fixed typos in the documentation.
319. [Vertexwahn](https://github.com/Vertexwahn) added Bazel build support.
320. [Dirk Stolle](https://github.com/striezel) fixed typos in the documentation.
321. [DavidKorczynski](https://github.com/DavidKorczynski) added a CIFuzz CI GitHub action.
322. [Finkman](https://github.com/Finkman) fixed the debug pretty-printer.
323. [Florian Segginger](https://github.com/floriansegginger) bumped the years in the README.
324. [haadfida](https://github.com/haadfida) cleaned up the badges of used services.
325. [Arsen Arsenović](https://github.com/ArsenArsen) fixed a build error.
326. [theevilone45](https://github.com/theevilone45) fixed a typo in a CMake file.
327. [Sergei Trofimovich](https://github.com/trofi) fixed the custom allocator support.
328. [Joyce](https://github.com/joycebrum) fixed some security issues in the GitHub workflows.
329. [Nicolas Jakob](https://github.com/njakob) add vcpkg version badge.
330. [Tomerkm](https://github.com/Tomerkm) added tests.
331. [No.](https://github.com/tusooa) fixed the use of `get<>` calls.
332. [taro](https://github.com/tarolling) fixed a typo in the `CODEOWNERS` file.
333. [Ikko Eltociear Ashimine](https://github.com/eltociear) fixed a typo.
334. [Felix Yan](https://github.com/felixonmars) fixed a typo in the README.
335. [HO-COOH](https://github.com/HO-COOH) fixed a parentheses in the documentation.
336. [Ivor Wanders](https://github.com/iwanders) fixed the examples to catch exception by `const&`.
337. [miny1233](https://github.com/miny1233) fixed a parentheses in the documentation.
338. [tomalakgeretkal](https://github.com/tomalakgeretkal) fixed a compilation error.
339. [alferov](https://github.com/ALF-ONE) fixed a compilation error.
340. [Craig Scott](https://github.com/craigscott-crascit) fixed a deprecation warning in CMake.
341. [Vyacheslav Zhdanovskiy](https://github.com/ZeronSix) added macros for serialization-only types.
342. [Mathieu Westphal](https://github.com/mwestphal) fixed typos.
343. [scribam](https://github.com/scribam) fixed the MinGW workflow.
344. [Aleksei Sapitskii](https://github.com/aleksproger) added support for Apple's Swift Package Manager.
345. [Benjamin Buch](https://github.com/bebuch) fixed the installation path in CMake.
346. [Colby Haskell](https://github.com/colbychaskell) clarified the parse error message in case a file cannot be opened.
Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I forgot someone.
@@ -1774,8 +1729,8 @@ The library itself consists of a single header file licensed under the MIT licen
- [**amalgamate.py - Amalgamate C source and header files**](https://github.com/edlund/amalgamate) to create a single header file
- [**American fuzzy lop**](https://lcamtuf.coredump.cx/afl/) for fuzz testing
- [**AppVeyor**](https://www.appveyor.com) for [continuous integration](https://ci.appveyor.com/project/nlohmann/json) on Windows
- [**Artistic Style**](http://astyle.sourceforge.net) for automatic source code indentation
- [**Clang**](https://clang.llvm.org) for compilation with code sanitizers
- [**Clang-Format**](https://clang.llvm.org/docs/ClangFormat.html) for automatic source code indentation
- [**CMake**](https://cmake.org) for build automation
- [**Codacy**](https://www.codacy.com) for further [code analysis](https://www.codacy.com/app/nlohmann/json)
- [**Coveralls**](https://coveralls.io) to measure [code coverage](https://coveralls.io/github/nlohmann/json)

View File

@@ -1 +0,0 @@
workspace(name = "nlohmann_json")

View File

@@ -8,17 +8,17 @@ set(N 10)
include(FindPython3)
find_package(Python3 COMPONENTS Interpreter)
find_program(CLANG_TOOL NAMES clang++-HEAD clang++ clang++-17 clang++-16 clang++-15 clang++-14 clang++-13 clang++-12 clang++-11 clang++)
find_program(ASTYLE_TOOL NAMES astyle)
execute_process(COMMAND ${ASTYLE_TOOL} --version OUTPUT_VARIABLE ASTYLE_TOOL_VERSION ERROR_VARIABLE ASTYLE_TOOL_VERSION)
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" ASTYLE_TOOL_VERSION "${ASTYLE_TOOL_VERSION}")
message(STATUS "🔖 Artistic Style ${ASTYLE_TOOL_VERSION} (${ASTYLE_TOOL})")
find_program(CLANG_TOOL NAMES clang++-HEAD clang++-15 clang++-14 clang++-13 clang++-12 clang++-11 clang++)
execute_process(COMMAND ${CLANG_TOOL} --version OUTPUT_VARIABLE CLANG_TOOL_VERSION ERROR_VARIABLE CLANG_TOOL_VERSION)
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CLANG_TOOL_VERSION "${CLANG_TOOL_VERSION}")
message(STATUS "🔖 Clang ${CLANG_TOOL_VERSION} (${CLANG_TOOL})")
find_program(CLANG_FORMAT_TOOL NAMES clang-format)
execute_process(COMMAND ${CLANG_FORMAT_TOOL} --version OUTPUT_VARIABLE CLANG_FORMAT_TOOL_VERSION ERROR_VARIABLE CLANG_FORMAT_TOOL_VERSION)
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CLANG_FORMAT_TOOL_VERSION "${CLANG_FORMAT_TOOL_VERSION}")
message(STATUS "🔖 Clang-Format ${CLANG_FORMAT_TOOL_VERSION} (${CLANG_FORMAT_TOOL})")
find_program(CLANG_TIDY_TOOL NAMES clang-tidy-17 clang-tidy-16 clang-tidy-15 clang-tidy-14 clang-tidy-13 clang-tidy-12 clang-tidy-11 clang-tidy)
find_program(CLANG_TIDY_TOOL NAMES clang-tidy-15 clang-tidy-14 clang-tidy-13 clang-tidy-12 clang-tidy-11 clang-tidy)
execute_process(COMMAND ${CLANG_TIDY_TOOL} --version OUTPUT_VARIABLE CLANG_TIDY_TOOL_VERSION ERROR_VARIABLE CLANG_TIDY_TOOL_VERSION)
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CLANG_TIDY_TOOL_VERSION "${CLANG_TIDY_TOOL_VERSION}")
message(STATUS "🔖 Clang-Tidy ${CLANG_TIDY_TOOL_VERSION} (${CLANG_TIDY_TOOL})")
@@ -30,7 +30,7 @@ execute_process(COMMAND ${CPPCHECK_TOOL} --version OUTPUT_VARIABLE CPPCHECK_TOOL
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CPPCHECK_TOOL_VERSION "${CPPCHECK_TOOL_VERSION}")
message(STATUS "🔖 Cppcheck ${CPPCHECK_TOOL_VERSION} (${CPPCHECK_TOOL})")
find_program(GCC_TOOL NAMES g++-latest g++-HEAD g++-13 g++-12 g++-11 g++-10)
find_program(GCC_TOOL NAMES g++-latest g++-HEAD g++-11 g++-10)
execute_process(COMMAND ${GCC_TOOL} --version OUTPUT_VARIABLE GCC_TOOL_VERSION ERROR_VARIABLE GCC_TOOL_VERSION)
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" GCC_TOOL_VERSION "${GCC_TOOL_VERSION}")
message(STATUS "🔖 GCC ${GCC_TOOL_VERSION} (${GCC_TOOL})")
@@ -95,7 +95,6 @@ file(GLOB_RECURSE SRC_FILES ${PROJECT_SOURCE_DIR}/include/nlohmann/*.hpp)
# -Wno-extra-semi-stmt The library uses std::assert which triggers this warning.
# -Wno-padded We do not care about padding warnings.
# -Wno-covered-switch-default All switches list all cases and a default case.
# -Wno-unsafe-buffer-usage Otherwise Doctest would not compile.
# -Wno-weak-vtables The library is header-only.
# -Wreserved-identifier See https://github.com/onqtam/doctest/issues/536.
@@ -108,7 +107,6 @@ set(CLANG_CXXFLAGS
-Wno-extra-semi-stmt
-Wno-padded
-Wno-covered-switch-default
-Wno-unsafe-buffer-usage
-Wno-weak-vtables
-Wno-reserved-identifier
)
@@ -439,7 +437,7 @@ add_custom_target(ci_test_clang
# Different C++ Standards.
###############################################################################
foreach(CXX_STANDARD 11 14 17 20 23)
foreach(CXX_STANDARD 11 14 17 20)
add_custom_target(ci_test_gcc_cxx${CXX_STANDARD}
COMMAND CXX=${GCC_TOOL} CXXFLAGS="${GCC_CXXFLAGS}" ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
@@ -468,7 +466,7 @@ endforeach()
###############################################################################
add_custom_target(ci_test_noexceptions
COMMAND ${CMAKE_COMMAND}
COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DJSON_BuildTests=ON -DCMAKE_CXX_FLAGS=-DJSON_NOEXCEPTION -DDOCTEST_TEST_FILTER=--no-throw
-S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_noexceptions
@@ -482,7 +480,7 @@ add_custom_target(ci_test_noexceptions
###############################################################################
add_custom_target(ci_test_noimplicitconversions
COMMAND ${CMAKE_COMMAND}
COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DJSON_BuildTests=ON -DJSON_ImplicitConversions=OFF
-S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_noimplicitconversions
@@ -496,7 +494,7 @@ add_custom_target(ci_test_noimplicitconversions
###############################################################################
add_custom_target(ci_test_diagnostics
COMMAND ${CMAKE_COMMAND}
COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DJSON_BuildTests=ON -DJSON_Diagnostics=ON
-S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_diagnostics
@@ -510,7 +508,7 @@ add_custom_target(ci_test_diagnostics
###############################################################################
add_custom_target(ci_test_legacycomparison
COMMAND ${CMAKE_COMMAND}
COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DJSON_BuildTests=ON -DJSON_LegacyDiscardedValueComparison=ON
-S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_legacycomparison
@@ -524,7 +522,7 @@ add_custom_target(ci_test_legacycomparison
###############################################################################
add_custom_target(ci_test_noglobaludls
COMMAND ${CMAKE_COMMAND}
COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DJSON_BuildTests=ON -DJSON_FastTests=ON -DJSON_GlobalUDLs=OFF
-DCMAKE_CXX_FLAGS=-DJSON_TEST_NO_GLOBAL_UDLS
@@ -581,8 +579,33 @@ add_custom_target(ci_test_clang_sanitizer
# Check if header is amalgamated and sources are properly indented.
###############################################################################
set(ASTYLE_FLAGS --style=allman --indent=spaces=4 --indent-modifiers --indent-switches --indent-preproc-block --indent-preproc-define --indent-col1-comments --pad-oper --pad-header --align-pointer=type --align-reference=type --add-brackets --convert-tabs --close-templates --lineend=linux --preserve-date --formatted)
file(GLOB_RECURSE INDENT_FILES
${PROJECT_SOURCE_DIR}/include/nlohmann/*.hpp
${PROJECT_SOURCE_DIR}/tests/src/*.cpp
${PROJECT_SOURCE_DIR}/tests/src/*.hpp
${PROJECT_SOURCE_DIR}/tests/benchmarks/src/benchmarks.cpp
${PROJECT_SOURCE_DIR}/docs/examples/*.cpp
)
set(include_dir ${PROJECT_SOURCE_DIR}/single_include/nlohmann)
set(tool_dir ${PROJECT_SOURCE_DIR}/tools/amalgamate)
add_custom_target(ci_test_amalgamation
COMMAND make check-amalgamation
COMMAND rm -fr ${include_dir}/json.hpp~ ${include_dir}/json_fwd.hpp~
COMMAND cp ${include_dir}/json.hpp ${include_dir}/json.hpp~
COMMAND cp ${include_dir}/json_fwd.hpp ${include_dir}/json_fwd.hpp~
COMMAND ${Python3_EXECUTABLE} ${tool_dir}/amalgamate.py -c ${tool_dir}/config_json.json -s .
COMMAND ${Python3_EXECUTABLE} ${tool_dir}/amalgamate.py -c ${tool_dir}/config_json_fwd.json -s .
COMMAND ${ASTYLE_TOOL} ${ASTYLE_FLAGS} --suffix=none --quiet ${include_dir}/json.hpp ${include_dir}/json_fwd.hpp
COMMAND diff ${include_dir}/json.hpp~ ${include_dir}/json.hpp
COMMAND diff ${include_dir}/json_fwd.hpp~ ${include_dir}/json_fwd.hpp
COMMAND ${ASTYLE_TOOL} ${ASTYLE_FLAGS} ${INDENT_FILES}
COMMAND for FILE in `find . -name '*.orig'`\; do false \; done
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Check amalgamation and indentation"
)
@@ -644,11 +667,8 @@ add_custom_target(ci_cppcheck
###############################################################################
add_custom_target(ci_cpplint
COMMAND ${Python3_EXECUTABLE} -mvenv venv_cpplint
COMMAND venv_cpplint/bin/pip3 --quiet install cpplint
COMMAND venv_cpplint/bin/cpplint --filter=-whitespace,-legal,-runtime/references,-runtime/explicit,-runtime/indentation_namespace,-readability/casting,-readability/nolint --quiet --recursive ${SRC_FILES}
COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/cpplint/cpplint.py --filter=-whitespace,-legal,-runtime/references,-runtime/explicit,-runtime/indentation_namespace,-readability/casting,-readability/nolint --quiet --recursive ${SRC_FILES}
COMMENT "Check code with cpplint"
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)
###############################################################################
@@ -813,17 +833,27 @@ add_custom_target(ci_benchmarks
###############################################################################
function(ci_get_cmake version var)
set(${var} ${PROJECT_BINARY_DIR}/cmake-${version}/bin/cmake)
add_custom_command(
OUTPUT ${${var}}
COMMAND wget -nc https://github.com/Kitware/CMake/releases/download/v${version}/cmake-${version}.tar.gz
COMMAND tar xfz cmake-${version}.tar.gz
COMMAND rm cmake-${version}.tar.gz
COMMAND ${CMAKE_COMMAND} -S cmake-${version} -B cmake-${version}
COMMAND ${CMAKE_COMMAND} --build cmake-${version} --parallel 10
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Download CMake ${version}"
)
if (APPLE)
set(${var} ${PROJECT_BINARY_DIR}/cmake-${version}-Darwin64/CMake.app/Contents/bin/cmake)
add_custom_command(
OUTPUT ${${var}}
COMMAND wget -nc https://github.com/Kitware/CMake/releases/download/v${version}/cmake-${version}-Darwin64.tar.gz
COMMAND tar xfz cmake-${version}-Darwin64.tar.gz
COMMAND rm cmake-${version}-Darwin64.tar.gz
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Download CMake ${version}"
)
else()
set(${var} ${PROJECT_BINARY_DIR}/cmake-${version}-Linux-x86_64/bin/cmake)
add_custom_command(
OUTPUT ${${var}}
COMMAND wget -nc https://github.com/Kitware/CMake/releases/download/v${version}/cmake-${version}-Linux-x86_64.tar.gz
COMMAND tar xfz cmake-${version}-Linux-x86_64.tar.gz
COMMAND rm cmake-${version}-Linux-x86_64.tar.gz
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Download CMake ${version}"
)
endif()
set(${var} ${${var}} PARENT_SCOPE)
endfunction()
@@ -875,10 +905,15 @@ add_custom_target(ci_cmake_flags
# Use more installed compilers.
###############################################################################
foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 g++-11 clang++-3.5 clang++-3.6 clang++-3.7 clang++-3.8 clang++-3.9 clang++-4.0 clang++-5.0 clang++-6.0 clang++-7 clang++-8 clang++-9 clang++-10 clang++-11 clang++-12 clang++-13 clang++-14 clang++-15 clang++-16 clang++-17)
foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 g++-11 clang++-3.5 clang++-3.6 clang++-3.7 clang++-3.8 clang++-3.9 clang++-4.0 clang++-5.0 clang++-6.0 clang++-7 clang++-8 clang++-9 clang++-10 clang++-11 clang++-12 clang++-13 clang++-14)
find_program(COMPILER_TOOL NAMES ${COMPILER})
if (COMPILER_TOOL)
unset(ADDITIONAL_FLAGS)
if ("${COMPILER}" STREQUAL "clang++-9")
# fix for https://github.com/nlohmann/json/pull/3101#issuecomment-998788786 / https://stackoverflow.com/a/64051725/266378
set(ADDITIONAL_FLAGS "-DCMAKE_CXX_FLAGS=--gcc-toolchain=/root/gcc/9")
else()
unset(ADDITIONAL_FLAGS)
endif()
add_custom_target(ci_test_compiler_${COMPILER}
COMMAND CXX=${COMPILER} ${CMAKE_COMMAND}
@@ -894,17 +929,6 @@ foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 g++-11 cla
unset(COMPILER_TOOL CACHE)
endforeach()
add_custom_target(ci_test_compiler_default
COMMAND ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DJSON_BuildTests=ON -DJSON_FastTests=ON
-S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_compiler_default
${ADDITIONAL_FLAGS}
COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_compiler_default --parallel ${N}
COMMAND cd ${PROJECT_BINARY_DIR}/build_compiler_default && ${CMAKE_CTEST_COMMAND} --parallel ${N} --exclude-regex "test-unicode" -LE git_required --output-on-failure
COMMENT "Compile and test with default C++ compiler"
)
###############################################################################
# CUDA example
###############################################################################

View File

@@ -1,24 +0,0 @@
# generate Bazel BUILD file
set(PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}/../..")
set(BUILD_FILE "${PROJECT_ROOT}/BUILD.bazel")
file(GLOB_RECURSE HEADERS LIST_DIRECTORIES false RELATIVE "${PROJECT_ROOT}" "include/*.hpp")
file(WRITE "${BUILD_FILE}" [=[
cc_library(
name = "json",
hdrs = [
]=])
foreach(header ${HEADERS})
file(APPEND "${BUILD_FILE}" " \"${header}\",\n")
endforeach()
file(APPEND "${BUILD_FILE}" [=[
],
includes = ["include"],
visibility = ["//visibility:public"],
alwayslink = True,
)
]=])

View File

@@ -259,7 +259,7 @@ function(json_test_should_build_32bit_test build_32bit_var build_32bit_only_var
# check if compiler is targeting 32bit by default
include(CheckTypeSize)
check_type_size("size_t" sizeof_size_t LANGUAGE CXX)
if(${sizeof_size_t} AND ${sizeof_size_t} EQUAL 4)
if(sizeof_size_t AND ${sizeof_size_t} EQUAL 4)
message(STATUS "Auto-enabling 32bit unit test.")
set(${build_32bit_var} ON)
else()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 1.6 MiB

View File

@@ -175,7 +175,6 @@ INSERT INTO searchIndex(name, type, path) VALUES ('Element Access', 'Guide', 'fe
INSERT INTO searchIndex(name, type, path) VALUES ('Element Access: Access with default value: value', 'Guide', 'features/element_access/default_value/index.html');
INSERT INTO searchIndex(name, type, path) VALUES ('Element Access: Checked access: at', 'Guide', 'features/element_access/checked_access/index.html');
INSERT INTO searchIndex(name, type, path) VALUES ('Element Access: Unchecked access: operator[]', 'Guide', 'features/element_access/unchecked_access/index.html');
INSERT INTO searchIndex(name, type, path) VALUES ('Integration: Migration Guide', 'Guide', 'integration/migration_guide/index.html');
INSERT INTO searchIndex(name, type, path) VALUES ('Integration: CMake', 'Guide', 'integration/cmake/index.html');
INSERT INTO searchIndex(name, type, path) VALUES ('Integration: Header only', 'Guide', 'integration/index.html');
INSERT INTO searchIndex(name, type, path) VALUES ('Integration: Package Managers', 'Guide', 'integration/package_managers/index.html');

View File

@@ -1,6 +1,6 @@
{
"name": "JSON for Modern C++",
"version": "3.11.3",
"version": "3.11.2",
"archive": "JSON_for_Modern_C++.tgz",
"author": {
"name": "Niels Lohmann",

View File

@@ -35,13 +35,14 @@ int main()
// output the changed array
std::cout << j["array"] << '\n';
// out_of_range.106
try
{
// try to use an array index with leading '0'
json::reference ref = j.at("/array/01"_json_pointer);
}
catch (const json::parse_error& e)
catch (json::parse_error& e)
{
std::cout << e.what() << '\n';
}
@@ -52,7 +53,7 @@ int main()
// try to use an array index that is not a number
json::reference ref = j.at("/array/one"_json_pointer);
}
catch (const json::parse_error& e)
catch (json::parse_error& e)
{
std::cout << e.what() << '\n';
}
@@ -63,7 +64,7 @@ int main()
// try to use an invalid array index
json::reference ref = j.at("/array/4"_json_pointer);
}
catch (const json::out_of_range& e)
catch (json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
@@ -74,7 +75,7 @@ int main()
// try to use the array index '-'
json::reference ref = j.at("/array/-"_json_pointer);
}
catch (const json::out_of_range& e)
catch (json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
@@ -85,7 +86,7 @@ int main()
// try to use a JSON pointer to a nonexistent object key
json::const_reference ref = j.at("/foo"_json_pointer);
}
catch (const json::out_of_range& e)
catch (json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
@@ -96,7 +97,7 @@ int main()
// try to use a JSON pointer that cannot be resolved
json::reference ref = j.at("/number/foo"_json_pointer);
}
catch (const json::out_of_range& e)
catch (json::out_of_range& e)
{
std::cout << e.what() << '\n';
}

View File

@@ -29,7 +29,7 @@ int main()
// try to use an array index that is not a number
json::const_reference ref = j.at("/array/one"_json_pointer);
}
catch (const json::parse_error& e)
catch (json::parse_error& e)
{
std::cout << e.what() << '\n';
}
@@ -40,7 +40,7 @@ int main()
// try to use an invalid array index
json::const_reference ref = j.at("/array/4"_json_pointer);
}
catch (const json::out_of_range& e)
catch (json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
@@ -51,7 +51,7 @@ int main()
// try to use the array index '-'
json::const_reference ref = j.at("/array/-"_json_pointer);
}
catch (const json::out_of_range& e)
catch (json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
@@ -62,7 +62,7 @@ int main()
// try to use a JSON pointer to a nonexistent object key
json::const_reference ref = j.at("/foo"_json_pointer);
}
catch (const json::out_of_range& e)
catch (json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
@@ -73,7 +73,7 @@ int main()
// try to use a JSON pointer that cannot be resolved
json::const_reference ref = j.at("/number/foo"_json_pointer);
}
catch (const json::out_of_range& e)
catch (json::out_of_range& e)
{
std::cout << e.what() << '\n';
}

View File

@@ -24,6 +24,7 @@ int main()
// output changed array
std::cout << object << '\n';
// exception type_error.304
try
{
@@ -31,7 +32,7 @@ int main()
json str = "I am a string";
str.at("the good"sv) = "Another string";
}
catch (const json::type_error& e)
catch (json::type_error& e)
{
std::cout << e.what() << '\n';
}
@@ -42,7 +43,7 @@ int main()
// try to write at a nonexisting key using string_view
object.at("the fast"sv) = "il rapido";
}
catch (const json::out_of_range& e)
catch (json::out_of_range& e)
{
std::cout << e.what() << '\n';
}

View File

@@ -18,6 +18,7 @@ int main()
// output element with key "the ugly" using string_view
std::cout << object.at("the ugly"sv) << '\n';
// exception type_error.304
try
{
@@ -25,7 +26,7 @@ int main()
const json str = "I am a string";
std::cout << str.at("the good"sv) << '\n';
}
catch (const json::type_error& e)
catch (json::type_error& e)
{
std::cout << e.what() << '\n';
}
@@ -36,7 +37,7 @@ int main()
// try to read from a nonexisting key using string_view
std::cout << object.at("the fast"sv) << '\n';
}
catch (const json::out_of_range)
catch (json::out_of_range)
{
std::cout << "out of range" << '\n';
}

View File

@@ -22,6 +22,7 @@ int main()
// output changed array
std::cout << object << '\n';
// exception type_error.304
try
{
@@ -29,7 +30,7 @@ int main()
json str = "I am a string";
str.at("the good") = "Another string";
}
catch (const json::type_error& e)
catch (json::type_error& e)
{
std::cout << e.what() << '\n';
}
@@ -40,7 +41,7 @@ int main()
// try to write at a nonexisting key
object.at("the fast") = "il rapido";
}
catch (const json::out_of_range& e)
catch (json::out_of_range& e)
{
std::cout << e.what() << '\n';
}

View File

@@ -16,6 +16,7 @@ int main()
// output element with key "the ugly"
std::cout << object.at("the ugly") << '\n';
// exception type_error.304
try
{
@@ -23,7 +24,7 @@ int main()
const json str = "I am a string";
std::cout << str.at("the good") << '\n';
}
catch (const json::type_error& e)
catch (json::type_error& e)
{
std::cout << e.what() << '\n';
}
@@ -34,7 +35,7 @@ int main()
// try to read from a nonexisting key
std::cout << object.at("the fast") << '\n';
}
catch (const json::out_of_range)
catch (json::out_of_range)
{
std::cout << "out of range" << '\n';
}

View File

@@ -17,6 +17,7 @@ int main()
// output changed array
std::cout << array << '\n';
// exception type_error.304
try
{
@@ -24,7 +25,7 @@ int main()
json str = "I am a string";
str.at(0) = "Another string";
}
catch (const json::type_error& e)
catch (json::type_error& e)
{
std::cout << e.what() << '\n';
}
@@ -35,7 +36,7 @@ int main()
// try to write beyond the array limit
array.at(5) = "sixth";
}
catch (const json::out_of_range& e)
catch (json::out_of_range& e)
{
std::cout << e.what() << '\n';
}

View File

@@ -11,6 +11,7 @@ int main()
// output element at index 2 (third element)
std::cout << array.at(2) << '\n';
// exception type_error.304
try
{
@@ -18,7 +19,7 @@ int main()
const json str = "I am a string";
std::cout << str.at(0) << '\n';
}
catch (const json::type_error& e)
catch (json::type_error& e)
{
std::cout << e.what() << '\n';
}
@@ -29,7 +30,7 @@ int main()
// try to read beyond the array limit
std::cout << array.at(5) << '\n';
}
catch (const json::out_of_range& e)
catch (json::out_of_range& e)
{
std::cout << e.what() << '\n';
}

View File

@@ -31,7 +31,7 @@ int main()
json j_null;
j_null.back();
}
catch (const json::invalid_iterator& e)
catch (json::invalid_iterator& e)
{
std::cout << e.what() << '\n';
}

View File

@@ -55,6 +55,7 @@ int main()
std::cout << j_mmap << '\n';
std::cout << j_ummap << "\n\n";
// ===========
// array types
// ===========
@@ -116,6 +117,7 @@ int main()
std::cout << j_mset << '\n';
std::cout << j_umset << "\n\n";
// ============
// string types
// ============
@@ -136,6 +138,7 @@ int main()
std::cout << j_string_literal << '\n';
std::cout << j_stdstring << "\n\n";
// ============
// number types
// ============
@@ -200,6 +203,7 @@ int main()
std::cout << j_float_nan << '\n';
std::cout << j_double << "\n\n";
// =============
// boolean types
// =============

View File

@@ -25,7 +25,7 @@ int main()
{
json j_invalid(j_number.begin() + 1, j_number.end());
}
catch (const json::invalid_iterator& e)
catch (json::invalid_iterator& e)
{
std::cout << e.what() << '\n';
}

View File

@@ -13,7 +13,7 @@ int main()
{
auto b_throw_on_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::error);
}
catch (const json::parse_error& e)
catch (json::parse_error& e)
{
std::cout << e.what() << std::endl;
}

View File

@@ -26,7 +26,7 @@ int main()
// try to use an array index with leading '0'
j.contains("/array/01"_json_pointer);
}
catch (const json::parse_error& e)
catch (json::parse_error& e)
{
std::cout << e.what() << '\n';
}
@@ -36,7 +36,7 @@ int main()
// try to use an array index that is not a number
j.contains("/array/one"_json_pointer);
}
catch (const json::parse_error& e)
catch (json::parse_error& e)
{
std::cout << e.what() << '\n';
}

View File

@@ -15,7 +15,7 @@ int main()
{
int housenumber = j["address"]["housenumber"];
}
catch (const json::exception& e)
catch (json::exception& e)
{
std::cout << e.what() << '\n';
}

View File

@@ -13,7 +13,7 @@ int main()
{
int housenumber = j["address"]["housenumber"];
}
catch (const json::exception& e)
catch (json::exception& e)
{
std::cout << e.what() << '\n';
}

View File

@@ -35,7 +35,7 @@ int main()
{
std::cout << j_invalid.dump() << std::endl;
}
catch (const json::type_error& e)
catch (json::type_error& e)
{
std::cout << e.what() << std::endl;
}

View File

@@ -11,7 +11,7 @@ int main()
{
std::cout << j_invalid.dump() << std::endl;
}
catch (const json::type_error& e)
catch (json::type_error& e)
{
std::cout << e.what() << std::endl;
}

View File

@@ -11,7 +11,7 @@ int main()
json j = {{"foo", "bar"}};
json k = j.at("non-existing");
}
catch (const json::exception& e)
catch (json::exception& e)
{
// output exception information
std::cout << "message: " << e.what() << '\n'

View File

@@ -31,7 +31,7 @@ int main()
j["address"] = "744 Evergreen Terrace";
j["age"] = 60;
auto p = j.template get<ns::person>();
auto p = j.get<ns::person>();
std::cout << p.name << " (" << p.age << ") lives in " << p.address << std::endl;
}

View File

@@ -47,7 +47,7 @@ int main()
j["address"] = "744 Evergreen Terrace";
j["age"] = 60;
auto p = j.template get<ns::person>();
auto p = j.get<ns::person>();
std::cout << p.name << " (" << p.age << ") lives in " << p.address << std::endl;
}

View File

@@ -9,11 +9,11 @@ int main()
json value = 17;
// explicitly getting pointers
auto p1 = value.template get<const json::number_integer_t*>();
auto p2 = value.template get<json::number_integer_t*>();
auto p3 = value.template get<json::number_integer_t* const>();
auto p4 = value.template get<const json::number_integer_t* const>();
auto p5 = value.template get<json::number_float_t*>();
auto p1 = value.get<const json::number_integer_t*>();
auto p2 = value.get<json::number_integer_t*>();
auto p3 = value.get<json::number_integer_t* const>();
auto p4 = value.get<const json::number_integer_t* const>();
auto p5 = value.get<json::number_float_t*>();
// print the pointees
std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n';

View File

@@ -22,14 +22,14 @@ int main()
};
// use explicit conversions
auto v1 = json_types["boolean"].template get<bool>();
auto v2 = json_types["number"]["integer"].template get<int>();
auto v3 = json_types["number"]["integer"].template get<short>();
auto v4 = json_types["number"]["floating-point"].template get<float>();
auto v5 = json_types["number"]["floating-point"].template get<int>();
auto v6 = json_types["string"].template get<std::string>();
auto v7 = json_types["array"].template get<std::vector<short>>();
auto v8 = json_types.template get<std::unordered_map<std::string, json>>();
auto v1 = json_types["boolean"].get<bool>();
auto v2 = json_types["number"]["integer"].get<int>();
auto v3 = json_types["number"]["integer"].get<short>();
auto v4 = json_types["number"]["floating-point"].get<float>();
auto v5 = json_types["number"]["floating-point"].get<int>();
auto v6 = json_types["string"].get<std::string>();
auto v7 = json_types["array"].get<std::vector<short>>();
auto v8 = json_types.get<std::unordered_map<std::string, json>>();
// print the conversion results
std::cout << v1 << '\n';

View File

@@ -20,7 +20,7 @@ int main()
{
auto r3 = value.get_ref<json::number_float_t&>();
}
catch (const json::type_error& ex)
catch (json::type_error& ex)
{
std::cout << ex.what() << '\n';
}

View File

@@ -30,6 +30,7 @@ int main()
std::vector<short> v7;
std::unordered_map<std::string, json> v8;
// use explicit conversions
json_types["boolean"].get_to(v1);
json_types["number"]["integer"].get_to(v2);

View File

@@ -12,7 +12,7 @@ int main()
json::iterator it = j.begin();
auto k = it.key();
}
catch (const json::invalid_iterator& e)
catch (json::invalid_iterator& e)
{
// output exception information
std::cout << "message: " << e.what() << '\n'

View File

@@ -1,88 +0,0 @@
#include <iostream>
#include <nlohmann/json.hpp>
class visitor_adaptor_with_metadata
{
public:
template <class Fnc>
void visit(const Fnc& fnc) const;
int metadata = 42;
private:
template <class Ptr, class Fnc>
void do_visit(const Ptr& ptr, const Fnc& fnc) const;
};
using json = nlohmann::basic_json <
std::map,
std::vector,
std::string,
bool,
std::int64_t,
std::uint64_t,
double,
std::allocator,
nlohmann::adl_serializer,
std::vector<std::uint8_t>,
visitor_adaptor_with_metadata
>;
template <class Fnc>
void visitor_adaptor_with_metadata::visit(const Fnc& fnc) const
{
do_visit(json::json_pointer{}, fnc);
}
template <class Ptr, class Fnc>
void visitor_adaptor_with_metadata::do_visit(const Ptr& ptr, const Fnc& fnc) const
{
using value_t = nlohmann::detail::value_t;
const json& j = *static_cast<const json*>(this);
switch (j.type())
{
case value_t::object:
fnc(ptr, j);
for (const auto& entry : j.items())
{
entry.value().do_visit(ptr / entry.key(), fnc);
}
break;
case value_t::array:
fnc(ptr, j);
for (std::size_t i = 0; i < j.size(); ++i)
{
j.at(i).do_visit(ptr / std::to_string(i), fnc);
}
break;
case value_t::null:
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
fnc(ptr, j);
break;
case value_t::discarded:
default:
break;
}
}
int main()
{
// create a json object
json j;
j["null"];
j["object"]["uint"] = 1U;
j["object"].metadata = 21;
// visit and output
j.visit(
[&](const json::json_pointer & p,
const json & j)
{
std::cout << (p.empty() ? std::string{"/"} : p.to_string())
<< " - metadata = " << j.metadata << " -> " << j.dump() << '\n';
});
}

View File

@@ -1,4 +0,0 @@
/ - metadata = 42 -> {"null":null,"object":{"uint":1}}
/null - metadata = 42 -> null
/object - metadata = 21 -> {"uint":1}
/object/uint - metadata = 42 -> 1

View File

@@ -20,7 +20,7 @@ int main()
{
json::json_pointer p9("foo");
}
catch (const json::parse_error& e)
catch (json::parse_error& e)
{
std::cout << e.what() << '\n';
}
@@ -30,7 +30,7 @@ int main()
{
json::json_pointer p10("/foo/~");
}
catch (const json::parse_error& e)
catch (json::parse_error& e)
{
std::cout << e.what() << '\n';
}
@@ -40,7 +40,7 @@ int main()
{
json::json_pointer p11("/foo/~3");
}
catch (const json::parse_error& e)
catch (json::parse_error& e)
{
std::cout << e.what() << '\n';
}

View File

@@ -2,7 +2,7 @@
"compiler": {
"c++": "201103",
"family": "gcc",
"version": "12.3.0"
"version": "12.1.0"
},
"copyright": "(C) 2013-2022 Niels Lohmann",
"name": "JSON for Modern C++",
@@ -11,7 +11,7 @@
"version": {
"major": 3,
"minor": 11,
"patch": 3,
"string": "3.11.3"
"patch": 2,
"string": "3.11.2"
}
}

View File

@@ -45,15 +45,15 @@ int main()
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
auto p2 = j2.template get<ns::person>();
auto p2 = j2.get<ns::person>();
// incomplete deserialization:
json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
try
{
auto p3 = j3.template get<ns::person>();
auto p3 = j3.get<ns::person>();
}
catch (const json::exception& e)
catch (json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
}

View File

@@ -33,15 +33,15 @@ int main()
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
auto p2 = j2.template get<ns::person>();
auto p2 = j2.get<ns::person>();
// incomplete deserialization:
json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
try
{
auto p3 = j3.template get<ns::person>();
auto p3 = j3.get<ns::person>();
}
catch (const json::exception& e)
catch (json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
}

View File

@@ -1,38 +0,0 @@
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
namespace ns
{
class person
{
private:
std::string name = "John Doe";
std::string address = "123 Fake St";
int age = -1;
public:
// No default constructor
person(std::string name_, std::string address_, int age_)
: name(std::move(name_)), address(std::move(address_)), age(age_)
{}
friend void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t)
{
nlohmann_json_j["name"] = nlohmann_json_t.name;
nlohmann_json_j["address"] = nlohmann_json_t.address;
nlohmann_json_j["age"] = 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;
}

View File

@@ -1 +0,0 @@
serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}

View File

@@ -1,33 +0,0 @@
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
namespace ns
{
class person
{
private:
std::string name = "John Doe";
std::string address = "123 Fake St";
int age = -1;
public:
// No default constructor
person(std::string name_, std::string address_, int age_)
: name(std::move(name_)), address(std::move(address_)), age(age_)
{}
NLOHMANN_DEFINE_TYPE_INTRUSIVE(person, name, address, 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;
}

View File

@@ -1 +0,0 @@
serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}

View File

@@ -46,10 +46,10 @@ int main()
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
auto p2 = j2.template get<ns::person>();
auto p2 = j2.get<ns::person>();
// incomplete deserialization:
json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
auto p3 = j3.template get<ns::person>();
auto p3 = j3.get<ns::person>();
std::cout << "roundtrip: " << json(p3) << std::endl;
}

View File

@@ -33,10 +33,10 @@ int main()
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
auto p2 = j2.template get<ns::person>();
auto p2 = j2.get<ns::person>();
// incomplete deserialization:
json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
auto p3 = j3.template get<ns::person>();
auto p3 = j3.get<ns::person>();
std::cout << "roundtrip: " << json(p3) << std::endl;
}

View File

@@ -38,15 +38,15 @@ int main()
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
auto p2 = j2.template get<ns::person>();
auto p2 = j2.get<ns::person>();
// incomplete deserialization:
json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
try
{
auto p3 = j3.template get<ns::person>();
auto p3 = j3.get<ns::person>();
}
catch (const json::exception& e)
catch (json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
}

View File

@@ -26,15 +26,15 @@ int main()
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
auto p2 = j2.template get<ns::person>();
auto p2 = j2.get<ns::person>();
// incomplete deserialization:
json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
try
{
auto p3 = j3.template get<ns::person>();
auto p3 = j3.get<ns::person>();
}
catch (const json::exception& e)
catch (json::exception& e)
{
std::cout << "deserialization failed: " << e.what() << std::endl;
}

View File

@@ -1,31 +0,0 @@
#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;
};
void to_json(nlohmann::json& nlohmann_json_j, const person& nlohmann_json_t)
{
nlohmann_json_j["name"] = nlohmann_json_t.name;
nlohmann_json_j["address"] = nlohmann_json_t.address;
nlohmann_json_j["age"] = 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;
}

View File

@@ -1 +0,0 @@
serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}

View File

@@ -1,26 +0,0 @@
#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_ONLY_SERIALIZE(person, name, address, 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;
}

View File

@@ -1 +0,0 @@
serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}

View File

@@ -44,10 +44,10 @@ int main()
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
auto p2 = j2.template get<ns::person>();
auto p2 = j2.get<ns::person>();
// incomplete deserialization:
json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
auto p3 = j3.template get<ns::person>();
auto p3 = j3.get<ns::person>();
std::cout << "roundtrip: " << json(p3) << std::endl;
}

View File

@@ -31,10 +31,10 @@ int main()
// deserialization: json -> person
json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json;
auto p2 = j2.template get<ns::person>();
auto p2 = j2.get<ns::person>();
// incomplete deserialization:
json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json;
auto p3 = j3.template get<ns::person>();
auto p3 = j3.get<ns::person>();
std::cout << "roundtrip: " << json(p3) << std::endl;
}

View File

@@ -1 +1 @@
nlohmann::json_abi_v3_11_3
nlohmann::json_abi_v3_11_2

View File

@@ -44,16 +44,16 @@ int main()
// deserialization
json j_running = "running";
json j_blue = "blue";
auto running = j_running.template get<ns::TaskState>();
auto blue = j_blue.template get<ns::Color>();
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;
// deserializing undefined JSON value to enum
// (where the first map entry above is the default)
json j_pi = 3.14;
auto invalid = j_pi.template get<ns::TaskState>();
auto unknown = j_pi.template get<ns::Color>();
auto invalid = j_pi.get<ns::TaskState>();
auto unknown = j_pi.get<ns::Color>();
std::cout << j_pi << " -> " << invalid << ", "
<< j_pi << " -> " << static_cast<int>(unknown) << std::endl;
}

View File

@@ -26,8 +26,8 @@ int main()
// deserialization
json j_rot = "rot";
auto rot = j_rot.template get<ns::Color>();
auto red = j_red.template get<ns::Color>();
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;
}

View File

@@ -1 +1 @@
JSON for Modern C++ version 3.11.3
JSON for Modern C++ version 3.11.2

View File

@@ -21,7 +21,7 @@ int main()
// can only create an object from a list of pairs
json j_invalid_object = json::object({{ "one", 1, 2 }});
}
catch (const json::type_error& e)
catch (json::type_error& e)
{
std::cout << e.what() << '\n';
}

View File

@@ -53,7 +53,7 @@ int main()
{
bool v1 = json_types["string"];
}
catch (const json::type_error& e)
catch (json::type_error& e)
{
std::cout << e.what() << '\n';
}

View File

@@ -32,6 +32,7 @@ int main()
json string = "foo";
json discarded = json(json::value_t::discarded);
// output values and comparisons
std::cout << array_1 << " <=> " << array_2 << " := " << to_string(array_1 <=> array_2) << '\n'; // *NOPAD*
std::cout << object_1 << " <=> " << object_2 << " := " << to_string(object_1 <=> object_2) << '\n'; // *NOPAD*

View File

@@ -31,6 +31,7 @@ int main()
json number = 17;
json string = "17";
// output values and comparisons
std::cout << std::boolalpha << std::fixed;
std::cout << boolean << " <=> " << true << " := " << to_string(boolean <=> true) << '\n'; // *NOPAD*

View File

@@ -21,7 +21,7 @@ int main()
}])"_json;
value.patch(patch);
}
catch (const json::other_error& e)
catch (json::other_error& e)
{
// output exception information
std::cout << "message: " << e.what() << '\n'

View File

@@ -11,7 +11,7 @@ int main()
json j = {1, 2, 3, 4};
j.at(4) = 10;
}
catch (const json::out_of_range& e)
catch (json::out_of_range& e)
{
// output exception information
std::cout << "message: " << e.what() << '\n'

View File

@@ -17,7 +17,7 @@ int main()
{
json j = json::parse(text);
}
catch (const json::parse_error& e)
catch (json::parse_error& e)
{
std::cout << e.what() << std::endl;
}

View File

@@ -33,6 +33,7 @@ int main()
json j_complete = json::parse(ss);
std::cout << std::setw(4) << j_complete << "\n\n";
// define parser callback
json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
{

View File

@@ -28,6 +28,7 @@ int main()
json j_complete = json::parse(text);
std::cout << std::setw(4) << j_complete << "\n\n";
// define parser callback
json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
{

View File

@@ -10,7 +10,7 @@ int main()
// parsing input with a syntax error
json::parse("[1,2,3,]");
}
catch (const json::parse_error& e)
catch (json::parse_error& e)
{
// output exception information
std::cout << "message: " << e.what() << '\n'

22
docs/examples/to_bon8.cpp Normal file
View File

@@ -0,0 +1,22 @@
#include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
int main()
{
// create a JSON value
json j = R"({"compact": true, "schema": 0})"_json;
// serialize it to BON8
std::vector<uint8_t> v = json::to_bon8(j);
// print the vector content
for (auto& byte : v)
{
std::cout << "0x" << std::hex << std::setw(2) << std::setfill('0') << (int)byte << " ";
}
std::cout << std::endl;
}

View File

@@ -0,0 +1 @@
0x88 0x63 0x6f 0x6d 0x70 0x61 0x63 0x74 0xf9 0x73 0x63 0x68 0x65 0x6d 0x61 0x90

View File

@@ -11,7 +11,7 @@ int main()
json j = "string";
j.push_back("another string");
}
catch (const json::type_error& e)
catch (json::type_error& e)
{
// output exception information
std::cout << "message: " << e.what() << '\n'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 1.6 MiB

View File

@@ -21,7 +21,7 @@ style_check:
clean:
rm -fr docs/images/json.gif docs/examples
# publish site to GitHub pages (not working in GitHub Actions; need special action)
# publish site to GitHub pages
publish: prepare_files
venv/bin/mkdocs gh-deploy --clean --force

View File

@@ -14,7 +14,7 @@ noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))
```
This function is usually called by the [`get()`](../basic_json/get.md) function of the [basic_json](../basic_json/index.md)
This function is usually called by the [`get()`](../basic_json/get.md) function of the [basic_json](../basic_json)
class (either explicitly or via the conversion operators).
1. This function is chosen for default-constructible value types.
@@ -37,7 +37,7 @@ Copy of the JSON value, converted to `ValueType`
??? example "Example: (1) Default-constructible type"
The example below shows how a `from_json` function can be implemented for a user-defined type. This function is
called by the `adl_serializer` when `template get<ns::person>()` is called.
called by the `adl_serializer` when `get<ns::person>()` is called.
```cpp
--8<-- "examples/from_json__default_constructible.cpp"

View File

@@ -7,7 +7,7 @@ static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
-> decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
```
This function is usually called by the constructors of the [basic_json](../basic_json/index.md) class.
This function is usually called by the constructors of the [basic_json](../basic_json) class.
## Parameters

View File

@@ -68,7 +68,7 @@ constructor.
## See also
[List of exceptions](../../home/exceptions.md)
[List of exceptions](127.0.0.1:8000/home/exceptions/)
## Version history

Some files were not shown because too many files have changed in this diff Show More