diff --git a/.cirrus.yml b/.cirrus.yml deleted file mode 100644 index be63315062..0000000000 --- a/.cirrus.yml +++ /dev/null @@ -1,17 +0,0 @@ -arm_container: - image: gcc:latest - -check_task: - check_script: - - wget https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2.tar.gz - - tar xfz cmake-3.20.2.tar.gz - - cd cmake-3.20.2 - - ./configure - - make cmake ctest -j4 - - cd .. - - mkdir build - - cd build - - ../cmake-3.20.2/bin/cmake .. -DJSON_FastTests=ON - - make -j4 - - cd tests - - ../../cmake-3.20.2/bin/ctest -j4 diff --git a/.clang-format b/.clang-format deleted file mode 100644 index 5b9e3fd530..0000000000 --- a/.clang-format +++ /dev/null @@ -1,84 +0,0 @@ -#AccessModifierOffset: 2 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -#AlignConsecutiveBitFields: false -AlignConsecutiveDeclarations: false -AlignConsecutiveMacros: false -AlignEscapedNewlines: Right -#AlignOperands: AlignAfterOperator -AlignTrailingComments: true -AllowAllArgumentsOnNextLine: false -AllowAllConstructorInitializersOnNextLine: false -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: Empty -AllowShortCaseLabelsOnASingleLine: false -#AllowShortEnumsOnASingleLine: true -AllowShortFunctionsOnASingleLine: Empty -AllowShortIfStatementsOnASingleLine: Never -AllowShortLambdasOnASingleLine: Empty -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: Yes -BinPackArguments: false -BinPackParameters: false -#BitFieldColonSpacing: Both -BreakBeforeBraces: Custom # or Allman -BraceWrapping: - AfterCaseLabel: true - AfterClass: true - AfterControlStatement: Always - AfterEnum: true - AfterFunction: true - AfterNamespace: false - AfterStruct: true - AfterUnion: true - AfterExternBlock: false - BeforeCatch: true - BeforeElse: true - #BeforeLambdaBody: false - #BeforeWhile: false - SplitEmptyFunction: false - SplitEmptyRecord: false - SplitEmptyNamespace: false -BreakBeforeTernaryOperators: true -BreakConstructorInitializers: BeforeComma -BreakStringLiterals: false -ColumnLimit: 0 -CompactNamespaces: false -ConstructorInitializerIndentWidth: 2 -Cpp11BracedListStyle: true -PointerAlignment: Left -FixNamespaceComments: true -IncludeBlocks: Preserve -#IndentCaseBlocks: false -IndentCaseLabels: true -IndentGotoLabels: false -IndentPPDirectives: BeforeHash -IndentWidth: 4 -KeepEmptyLinesAtTheStartOfBlocks: false -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -ReflowComments: false -SortIncludes: true -SortUsingDeclarations: true -SpaceAfterCStyleCast: false -SpaceAfterLogicalNot: false -SpaceAfterTemplateKeyword: false -SpaceBeforeAssignmentOperators: true -SpaceBeforeCpp11BracedList: false -SpaceBeforeParens: ControlStatements -SpaceBeforeRangeBasedForLoopColon: true -SpaceBeforeSquareBrackets: false -SpaceInEmptyBlock: false -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 2 -SpacesInAngles: false -SpacesInCStyleCastParentheses: false -SpacesInConditionalStatement: false -SpacesInContainerLiterals: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: c++11 -TabWidth: 4 -UseTab: Never diff --git a/.clang-tidy b/.clang-tidy deleted file mode 100644 index 1b0fff5ce0..0000000000 --- a/.clang-tidy +++ /dev/null @@ -1,63 +0,0 @@ -Checks: '*, - -altera-id-dependent-backward-branch, - -altera-struct-pack-align, - -altera-unroll-loops, - -android-cloexec-fopen, - -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, - -cppcoreguidelines-macro-usage, - -cppcoreguidelines-pro-bounds-array-to-pointer-decay, - -cppcoreguidelines-pro-bounds-constant-array-index, - -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, - -fuchsia-overloaded-operator, - -google-explicit-constructor, - -google-readability-function-size, - -google-runtime-int, - -google-runtime-references, - -hicpp-avoid-goto, - -hicpp-explicit-conversions, - -hicpp-function-size, - -hicpp-no-array-decay, - -hicpp-no-assembler, - -hicpp-signed-bitwise, - -hicpp-uppercase-literal-suffix, - -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-nodiscard, - -modernize-use-trailing-return-type, - -readability-function-cognitive-complexity, - -readability-function-size, - -readability-identifier-length, - -readability-magic-numbers, - -readability-redundant-access-specifiers, - -readability-simplify-boolean-expr, - -readability-uppercase-literal-suffix' - -CheckOptions: - - key: hicpp-special-member-functions.AllowSoleDefaultDtor - value: 1 - -WarningsAsErrors: '*' - -#HeaderFilterRegex: '.*nlohmann.*' -HeaderFilterRegex: '.*hpp$' diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index 4d5ee04402..0000000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1,6 +0,0 @@ -# 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. - -* @nlohmann diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md deleted file mode 100644 index 770b8173e1..0000000000 --- a/.github/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,46 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at mail@nlohmann.me. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] - -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md deleted file mode 100644 index 4d33c67bf2..0000000000 --- a/.github/CONTRIBUTING.md +++ /dev/null @@ -1,71 +0,0 @@ -[![Issue Stats](http://issuestats.com/github/nlohmann/json/badge/pr?style=flat)](http://issuestats.com/github/nlohmann/json) [![Issue Stats](http://issuestats.com/github/nlohmann/json/badge/issue?style=flat)](http://issuestats.com/github/nlohmann/json) - -# How to contribute - -This project started as a little excuse to exercise some of the cool new C++11 features. Over time, people actually started to use the JSON library (yey!) and started to help improve it by proposing features, finding bugs, or even fixing my mistakes. I am really [thankful](https://github.com/nlohmann/json/blob/master/README.md#thanks) for this and try to keep track of all the helpers. - -To make it as easy as possible for you to contribute and for me to keep an overview, here are a few guidelines which should help us avoid all kinds of unnecessary work or disappointment. And of course, this document is subject to discussion, so please [create an issue](https://github.com/nlohmann/json/issues/new/choose) or a pull request if you find a way to improve it! - -## Private reports - -Usually, all issues are tracked publicly on [GitHub](https://github.com/nlohmann/json/issues). If you want to make a private report (e.g., for a vulnerability or to attach an example that is not meant to be published), please send an email to . - -## Prerequisites - -Please [create an issue](https://github.com/nlohmann/json/issues/new/choose), assuming one does not already exist, and describe your concern. Note you need a [GitHub account](https://github.com/signup/free) for this. - -## Describe your issue - -Clearly describe the issue: - -- If it is a bug, please describe how to **reproduce** it. If possible, attach a complete example which demonstrates the error. Please also state what you **expected** to happen instead of the error. -- If you propose a change or addition, try to give an **example** how the improved code could look like or how to use it. -- If you found a compilation error, please tell us which **compiler** (version and operating system) you used and paste the (relevant part of) the error messages to the ticket. - -Please stick to the provided issue template ([bug report](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE/bug.yml) if possible. For questions, feature or support requests, please [open a discussion](https://github.com/nlohmann/json/discussions/new). - -## Files to change - -:exclamation: Before you make any changes, note the single-header files [`single_include/nlohmann/json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp) and [`single_include/nlohmann/json_fwd.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json_fwd.hpp) are **generated** from the source files in the [`include/nlohmann` directory](https://github.com/nlohmann/json/tree/develop/include/nlohmann). Please **do not** edit the files `single_include/nlohmann/json.hpp` and `single_include/nlohmann/json_fwd.hpp` directly, but change the `include/nlohmann` sources and regenerate the files by executing `make amalgamate`. - -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. - - 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 - - ```sh - $ mkdir build - $ cd build - $ cmake .. - $ cmake --build . - $ ctest - ``` - - The test cases are also executed with several different compilers on [Travis](https://travis-ci.org/nlohmann/json) once you open a pull request. - - -## 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 [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. -- 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). - -- Please do not open pull requests that address **multiple issues**. - -## Wanted - -The following areas really need contribution: - -- Extending the **continuous integration** toward more exotic compilers such as Android NDK, Intel's Compiler, or the bleeding-edge versions Clang. -- Improving the efficiency of the **JSON parser**. The current parser is implemented as a naive recursive descent parser with hand coded string handling. More sophisticated approaches like LALR parsers would be really appreciated. That said, parser generators like Bison or ANTLR do not play nice with single-header files -- I really would like to keep the parser inside the `json.hpp` header, and I am not aware of approaches similar to [`re2c`](http://re2c.org) for parsing. -- Extending and updating existing **benchmarks** to include (the most recent version of) this library. Though efficiency is not everything, speed and memory consumption are very important characteristics for C++ developers, so having proper comparisons would be interesting. diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index a6c972e819..0000000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,2 +0,0 @@ -github: nlohmann -custom: http://paypal.me/nlohmann diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml deleted file mode 100644 index 571a1cc447..0000000000 --- a/.github/ISSUE_TEMPLATE/bug.yaml +++ /dev/null @@ -1,93 +0,0 @@ -name: Bug Report -description: Create a bug report -labels: - - 'kind: bug' -body: - - type: markdown - attributes: - value: > - Thanks for taking the time to fill out this bug report! - - Make sure you give it a short and specific **title** so that the report - is searchable and uniquely identifiable. - - Note that this form is for bug reports only. Please - [open a discussion](https://github.com/nlohmann/json/discussions/new) - for questions, feature requests, or support requests - - type: textarea - id: summary - attributes: - label: Description - description: > - Please provide an abstract description of the issue to the developers, - and why you consider it to be a bug. Please include any specific links - to the documentation, JSON specification, or code. - validations: - required: true - - type: textarea - id: reproduce - attributes: - label: Reproduction steps - description: > - How do you trigger the bug? Please walk us through step by step. Be as - specific as possible. - validations: - required: true - - type: textarea - id: results - attributes: - label: Expected vs. actual results - description: > - Please describe what you expected to happen after the steps above and - what actually happened. - validations: - required: true - - type: textarea - id: code - attributes: - label: Minimal code example - description: > - If possible, provide a small and self-contained example that triggers - the bug. Please understand that we cannot analyze and debug large code - bases. Please do not paste screenshots here. - render: Shell - - type: textarea - id: output - attributes: - label: Error messages - description: > - Please provide any kind of error output (compilation errors, exception - messages, stack traces, etc.) which can help to diagnose the error. - render: Shell - - type: input - id: compiler - attributes: - label: Compiler and operating system - description: > - On which operating systems and compilers have you observed the issue? - Include as many relevant details about the environment you experienced - the bug in. Make sure you use a - [supported compiler](https://github.com/nlohmann/json#supported-compilers). - validations: - required: true - - type: input - id: version - attributes: - 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.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. - validations: - required: true - - type: checkboxes - id: validation - attributes: - label: Validation - description: > - Please check these additional steps: - options: - - label: The bug also occurs if the latest version from the [`develop`](https://github.com/nlohmann/json/tree/develop) branch is used. - - label: I can successfully [compile and run the unit tests](https://github.com/nlohmann/json#execute-unit-tests). diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index 0e96633842..0000000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,5 +0,0 @@ -blank_issues_enabled: false -contact_links: - - name: Ask a question - url: https://github.com/nlohmann/json/discussions - about: Ask questions and discuss with other community members diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c9c7cb7931..0000000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,19 +0,0 @@ -[Describe your pull request here. Please read the text below the line, and make sure you follow the checklist.] - -* * * - -## Pull request checklist - -Read the [Contribution Guidelines](https://github.com/nlohmann/json/blob/develop/.github/CONTRIBUTING.md) for detailed information. - -- [ ] Changes are described in the pull request, or an [existing issue is referenced](https://github.com/nlohmann/json/issues). -- [ ] The test suite [compiles and runs](https://github.com/nlohmann/json/blob/develop/README.md#execute-unit-tests) without error. -- [ ] [Code coverage](https://coveralls.io/github/nlohmann/json) is 100%. Test cases can be added by editing the [test suite](https://github.com/nlohmann/json/tree/develop/test/src). -- [ ] The source code is amalgamated; that is, after making changes to the sources in the `include/nlohmann` directory, run `make amalgamate` to create the single-header files `single_include/nlohmann/json.hpp` and `single_include/nlohmann/json_fwd.hpp`. The whole process is described [here](https://github.com/nlohmann/json/blob/develop/.github/CONTRIBUTING.md#files-to-change). - -## 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. -- 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**. diff --git a/.github/SECURITY.md b/.github/SECURITY.md deleted file mode 100644 index 4d010ebda9..0000000000 --- a/.github/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security Policy - -## Reporting a Vulnerability - -Usually, all issues are tracked publicly on [GitHub](https://github.com/nlohmann/json/issues). If you want to make a private report (e.g., for a vulnerability or to attach an example that is not meant to be published), please send an email to . You can use [this key](https://keybase.io/nlohmann/pgp_keys.asc?fingerprint=797167ae41c0a6d9232e48457f3cea63ae251b69) for encryption. diff --git a/.github/config.yml b/.github/config.yml deleted file mode 100644 index 7a8f41e6d6..0000000000 --- a/.github/config.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Configuration for sentiment-bot - https://github.com/behaviorbot/sentiment-bot - -# *Required* toxicity threshold between 0 and .99 with the higher numbers being the most toxic -# Anything higher than this threshold will be marked as toxic and commented on -sentimentBotToxicityThreshold: .7 - -# *Required* Comment to reply with -sentimentBotReplyComment: > - Please be sure to review the [code of conduct](https://github.com/nlohmann/json/blob/develop/CODE_OF_CONDUCT.md) and be respectful of other users. cc/ @nlohmann - - -# Configuration for request-info - https://github.com/behaviorbot/request-info - -# *Required* Comment to reply with -requestInfoReplyComment: > - We would appreciate it if you could provide us with more info about this issue or pull request! Please check the [issue template](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE.md) and the [pull request template](https://github.com/nlohmann/json/blob/develop/.github/PULL_REQUEST_TEMPLATE.md). - -# *OPTIONAL* Label to be added to Issues and Pull Requests with insufficient information given -requestInfoLabelToAdd: "state: needs more info" diff --git a/.github/external_ci/appveyor.yml b/.github/external_ci/appveyor.yml deleted file mode 100644 index 126ed99b35..0000000000 --- a/.github/external_ci/appveyor.yml +++ /dev/null @@ -1,91 +0,0 @@ -version: '{build}' - -# only build PRs and commits to develop branch -# (see https://help.appveyor.com/discussions/questions/55079-two-builds-per-commit-to-pull-request) -branches: - only: - - develop - -only_commits: - files: - - .github/external_ci/appveyor.yml - - cmake/ - - include/ - - tests/ - - CMakeLists.txt - -environment: - matrix: - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - configuration: Debug - platform: x86 - CXX_FLAGS: "/W4 /WX" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 14 2015 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - configuration: Release - platform: x86 - CXX_FLAGS: "/W4 /WX" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 14 2015 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - configuration: Release - platform: x86 - name: with_win_header - CXX_FLAGS: "/W4 /WX" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 14 2015 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - configuration: Release - platform: x86 - CXX_FLAGS: "/permissive- /std:c++latest /utf-8 /W4 /WX" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 15 2017 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - configuration: Release - platform: x86 - CXX_FLAGS: "/W4 /WX" - CMAKE_OPTIONS: "-DJSON_ImplicitConversions=OFF" - GENERATOR: Visual Studio 16 2019 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - configuration: Release - platform: x64 - CXX_FLAGS: "/W4 /WX" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 14 2015 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - configuration: Release - platform: x64 - CXX_FLAGS: "/permissive- /std:c++latest /Zc:__cplusplus /utf-8 /W4 /WX" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 15 2017 - -init: - - cmake --version - - msbuild /version - -install: - - if "%platform%"=="x86" set GENERATOR_PLATFORM=Win32 - -before_build: - # for with_win_header build, inject the inclusion of Windows.h to the single-header library - - ps: if ($env:name -Eq "with_win_header") { $header_path = "single_include\nlohmann\json.hpp" } - - ps: if ($env:name -Eq "with_win_header") { "#include `n" + (Get-Content $header_path | Out-String) | Set-Content $header_path } - - cmake . -G "%GENERATOR%" -A "%GENERATOR_PLATFORM%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On "%CMAKE_OPTIONS%" - -build_script: - - cmake --build . --config "%configuration%" --parallel 2 - -test_script: - - if "%configuration%"=="Release" ctest -C "%configuration%" --parallel 2 --output-on-failure - # On Debug builds, skip test-unicode_all - # as it is extremely slow to run and cause - # occasional timeouts on AppVeyor. - # More info: https://github.com/nlohmann/json/pull/1570 - - if "%configuration%"=="Debug" ctest --exclude-regex "test-unicode" -C "%configuration%" --parallel 2 --output-on-failure diff --git a/.github/labeler.yml b/.github/labeler.yml deleted file mode 100644 index 024d3e6da2..0000000000 --- a/.github/labeler.yml +++ /dev/null @@ -1,38 +0,0 @@ -version: 1 - -labels: -- label: "documentation" - files: - - "README.md" - -- label: "documentation" - files: - - "docs/.*" - -- label: "tests" - files: - - "tests/.*" - -- label: "CMake" - files: - - ".*CMakeLists.txt" - -- label: "CMake" - files: - - "cmake/.*" - -- label: "CI" - files: - - "github/workflows/.*" - -- label: "CI" - files: - - "github/external_ci/.*" - -- label: "S" - size-below: 10 -- label: "M" - size-above: 9 - size-below: 100 -- label: "L" - size-above: 100 diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index d30c78be77..0000000000 --- a/.github/stale.yml +++ /dev/null @@ -1,17 +0,0 @@ -# Number of days of inactivity before an issue becomes stale -daysUntilStale: 30 -# Number of days of inactivity before a stale issue is closed -daysUntilClose: 7 -# Issues with these labels will never be considered stale -exemptLabels: - - pinned - - security -# Label to use when marking an issue as stale -staleLabel: "state: stale" -# Comment to post when marking an issue as stale. Set to `false` to disable -markComment: > - This issue has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. Thank you - for your contributions. -# Comment to post when closing a stale issue. Set to `false` to disable -closeComment: false diff --git a/.github/workflows/check_amalgamation.yml b/.github/workflows/check_amalgamation.yml deleted file mode 100644 index 0fadb52065..0000000000 --- a/.github/workflows/check_amalgamation.yml +++ /dev/null @@ -1,70 +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 - env: - MAIN_DIR: ${{ github.workspace }}/main - INCLUDE_DIR: ${{ github.workspace }}/main/single_include/nlohmann - TOOL_DIR: ${{ github.workspace }}/tools/tools/amalgamate - 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 - - 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: Install astyle - run: | - sudo apt-get update - sudo apt-get install astyle - - - name: Check amalgamation - run: | - cd $MAIN_DIR - - rm -fr $INCLUDE_DIR/json.hpp~ $INCLUDE_DIR/json_fwd.hpp~ - cp $INCLUDE_DIR/json.hpp $INCLUDE_DIR/json.hpp~ - cp $INCLUDE_DIR/json_fwd.hpp $INCLUDE_DIR/json_fwd.hpp~ - - python3 $TOOL_DIR/amalgamate.py -c $TOOL_DIR/config_json.json -s . - python3 $TOOL_DIR/amalgamate.py -c $TOOL_DIR/config_json_fwd.json -s . - echo "Format (1)" - astyle $ASTYLE_FLAGS --suffix=none --quiet $INCLUDE_DIR/json.hpp $INCLUDE_DIR/json_fwd.hpp - - diff $INCLUDE_DIR/json.hpp~ $INCLUDE_DIR/json.hpp - diff $INCLUDE_DIR/json_fwd.hpp~ $INCLUDE_DIR/json_fwd.hpp - - astyle $ASTYLE_FLAGS $(find docs/examples include tests -type f \( -name '*.hpp' -o -name '*.cpp' -o -name '*.cu' \) -not -path 'tests/thirdparty/*' -not -path 'tests/abi/include/nlohmann/*' | sort) - echo Check - find $MAIN_DIR -name '*.orig' -exec false {} \+ diff --git a/.github/workflows/cifuzz.yml b/.github/workflows/cifuzz.yml deleted file mode 100644 index 0fd355bce5..0000000000 --- a/.github/workflows/cifuzz.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 9a87e828d1..0000000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: "Code scanning - action" - -on: - push: - branches: - - develop - - master - - release/* - pull_request: - schedule: - - cron: '0 19 * * 1' - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - CodeQL-Build: - - runs-on: ubuntu-latest - permissions: - security-events: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/comment_check_amalgamation.yml b/.github/workflows/comment_check_amalgamation.yml deleted file mode 100644 index 2ab5ebb978..0000000000 --- a/.github/workflows/comment_check_amalgamation.yml +++ /dev/null @@ -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).' - : '') - }) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml deleted file mode 100644 index 11925e1af0..0000000000 --- a/.github/workflows/labeler.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: "Pull Request Labeler" - -on: - pull_request_target: - types: [opened, synchronize] - -permissions: {} - -jobs: - label: - permissions: - contents: read - pull-requests: write - - runs-on: ubuntu-latest - - steps: - - uses: srvaroa/labeler@master - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml deleted file mode 100644 index 9ac1fe3fa7..0000000000 --- a/.github/workflows/macos.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: macOS - -on: - push: - branches: - - develop - - master - - release/* - pull_request: - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - xcode_1: - runs-on: macos-11 - strategy: - matrix: - xcode: ['11.7', '12.4', '12.5.1', '13.0'] - env: - DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer - - steps: - - uses: actions/checkout@v3 - - name: Run CMake - run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON - - name: Build - run: cmake --build build --parallel 10 - - name: Test - run: cd build ; ctest -j 10 --output-on-failure - - xcode_2: - 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'] - env: - DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer - - steps: - - uses: actions/checkout@v3 - - name: Run CMake - run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON - - name: Build - run: cmake --build build --parallel 10 - - name: Test - run: cd build ; ctest -j 10 --output-on-failure - - xcode_standards: - runs-on: macos-latest - strategy: - matrix: - standard: [11, 14, 17, 20, 23] - - steps: - - uses: actions/checkout@v3 - - name: Run CMake - run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_TestStandards=${{ matrix.standard }} - - name: Build - run: cmake --build build --parallel 10 - - name: Test - run: cd build ; ctest -j 10 --output-on-failure diff --git a/.github/workflows/publish_documentation.yml b/.github/workflows/publish_documentation.yml deleted file mode 100644 index f5e5c2c754..0000000000 --- a/.github/workflows/publish_documentation.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Publish documentation - -# publish the documentation on every merge to develop branch -on: - push: - branches: - - develop - paths: - - docs/mkdocs/** - - docs/examples/** - workflow_dispatch: - -permissions: - contents: read - -# we don't want to have concurrent jobs, and we don't want to cancel running jobs to avoid broken publications -concurrency: - group: documentation - cancel-in-progress: false - -jobs: - publish_documentation: - if: github.repository == 'nlohmann/json' - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - - name: Install and update PlantUML - run: sudo apt-get update ; sudo apt-get install -y plantuml - - - name: Install virtual environment - run: make install_venv -C docs/mkdocs - - - name: Publish documentation - run: make publish -C docs/mkdocs diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml deleted file mode 100644 index 9040d83722..0000000000 --- a/.github/workflows/ubuntu.yml +++ /dev/null @@ -1,248 +0,0 @@ -name: Ubuntu - -on: - push: - branches: - - develop - - master - - release/* - pull_request: - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - ci_test_clang: - runs-on: ubuntu-latest - container: silkeh/clang:dev - 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@latest - - name: Run CMake - run: cmake -S . -B build -DJSON_CI=On - - name: Build - run: cmake --build build --target ci_test_clang - - ci_test_gcc: - runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:v2.4.0 - 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 - - ci_static_analysis: - runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:v2.4.0 - strategy: - matrix: - target: [ci_cppcheck, ci_test_valgrind, ci_test_amalgamation, ci_test_single_header, ci_single_binaries, ci_infer] - steps: - - uses: actions/checkout@v3 - - name: Run CMake - run: cmake -S . -B build -DJSON_CI=On - - name: Build - run: cmake --build build --target ${{ matrix.target }} - - 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@latest - - 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@latest - - name: Run CMake - run: cmake -S . -B build -DJSON_CI=On - - name: Build - run: cmake --build build --target ${{ matrix.target }} - - ci_cmake_options: - runs-on: ubuntu-latest - container: ubuntu:focal - strategy: - matrix: - target: [ci_cmake_flags, 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@latest - - name: Run CMake - run: cmake -S . -B build -DJSON_CI=On - - name: Build - run: cmake --build build --target ${{ matrix.target }} - - 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 - run: cmake -S . -B build -DJSON_CI=On - - name: Build - run: cmake --build build --target ci_test_coverage - - name: Archive coverage report - uses: actions/upload-artifact@v3 - with: - name: code-coverage-report - path: ${{ github.workspace }}/build/html - - name: Publish report to Coveralls - uses: coverallsapp/github-action@master - with: - 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@latest - - 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@latest - - 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] - 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_compiler_${{ matrix.compiler }} - - ci_test_standards_gcc: - runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:v2.4.0 - strategy: - matrix: - standard: [11, 14, 17, 20, 23] - 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@latest - - name: Run CMake - run: cmake -S . -B build -DJSON_CI=On - - name: Build - run: cmake --build build --target ci_test_clang_cxx${{ matrix.standard }} - - ci_cuda_example: - runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:v2.4.0 - steps: - - uses: actions/checkout@v3 - - name: Run CMake - run: cmake -S . -B build -DJSON_CI=On - - name: Build - run: cmake --build build --target ci_cuda_example - - ci_icpc: - runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:v2.2.0 - steps: - - uses: actions/checkout@v2 - - name: Run CMake - run: cmake -S . -B build -DJSON_CI=On - - name: Build - run: | - . /opt/intel/oneapi/setvars.sh - cmake --build build --target ci_icpc - - ci_reuse_compliance: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 - - name: Install REUSE tool - run: python -m pip install reuse - - name: Run REUSE lint - run: reuse lint - - ci_test_documentation: - runs-on: ubuntu-latest - strategy: - matrix: - target: [ci_test_examples, ci_test_api_documentation] - steps: - - uses: actions/checkout@v3 - - name: Run CMake - run: cmake -S . -B build -DJSON_CI=On - - name: Build - run: cmake --build build --target ${{ matrix.target }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml deleted file mode 100644 index f4d4152272..0000000000 --- a/.github/workflows/windows.yml +++ /dev/null @@ -1,133 +0,0 @@ -name: Windows - -on: - push: - branches: - - develop - - master - - release/* - 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 - strategy: - matrix: - architecture: [x64, x86] - - steps: - - uses: actions/checkout@v3 - - 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 - run: cmake --build build --parallel 10 - - name: Test - run: cd build ; ctest -j 10 -C Debug --output-on-failure - - msvc2019: - runs-on: windows-2019 - strategy: - matrix: - build_type: [Debug, Release] - architecture: [Win32, x64] - - steps: - - uses: actions/checkout@v3 - - name: Run CMake - run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/W4 /WX" - if: matrix.build_type == 'Release' - - name: Run CMake - run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON -DCMAKE_CXX_FLAGS="/W4 /WX" - if: matrix.build_type == 'Debug' - - name: Build - run: cmake --build build --config ${{ matrix.build_type }} --parallel 10 - - name: Test - run: cd build ; ctest -j 10 -C ${{ matrix.build_type }} --output-on-failure - - msvc2019_latest: - runs-on: windows-2019 - - steps: - - uses: actions/checkout@v3 - - name: Run CMake - run: cmake -S . -B build -G "Visual Studio 16 2019" -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4 /WX" - - name: Build - run: cmake --build build --config Release --parallel 10 - - name: Test - run: cd build ; ctest -j 10 -C Release --output-on-failure - - msvc2022: - runs-on: windows-2022 - strategy: - matrix: - build_type: [Debug, Release] - architecture: [Win32, x64] - - steps: - - uses: actions/checkout@v3 - - name: Run CMake - run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/W4 /WX" - if: matrix.build_type == 'Release' - - name: Run CMake - run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON -DCMAKE_CXX_FLAGS="/W4 /WX" - if: matrix.build_type == 'Debug' - - name: Build - run: cmake --build build --config ${{ matrix.build_type }} --parallel 10 - - name: Test - run: cd build ; ctest -j 10 -C ${{ matrix.build_type }} --output-on-failure - - msvc2022_latest: - runs-on: windows-2022 - - steps: - - uses: actions/checkout@v3 - - name: Run CMake - run: cmake -S . -B build -G "Visual Studio 17 2022" -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="/permissive- /std:c++latest /utf-8 /W4 /WX" - - name: Build - run: cmake --build build --config Release --parallel 10 - - name: Test - run: cd build ; ctest -j 10 -C Release --output-on-failure - - clang: - runs-on: windows-2019 - strategy: - matrix: - version: [11, 12, 13, 14, 15] - - steps: - - uses: actions/checkout@v3 - - name: Install Clang - run: curl -fsSL -o LLVM${{ matrix.version }}.exe https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ matrix.version }}.0.0/LLVM-${{ matrix.version }}.0.0-win64.exe ; 7z x LLVM${{ matrix.version }}.exe -y -o"C:/Program Files/LLVM" - - name: Run CMake - run: cmake -S . -B build -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang++.exe" -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On - - name: Build - run: cmake --build build --parallel 10 - - name: Test - run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure - - clang-cl-11: - runs-on: windows-2019 - strategy: - matrix: - architecture: [Win32, x64] - - steps: - - uses: actions/checkout@v3 - - name: Run CMake - run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -T ClangCL -DJSON_BuildTests=On - - name: Build - run: cmake --build build --config Debug --parallel 10 - - name: Test - run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 30b62bfcf9..0000000000 --- a/.gitignore +++ /dev/null @@ -1,41 +0,0 @@ -*.dSYM -*.o -*.gcno -*.gcda -.DS_Store - -.wsjcpp-logs/* -.wsjcpp/* - -/.idea -/cmake-build-* - -# Visual Studio / Visual Studio Code -/.vs/ -/.vscode/ -/out/ - -# clangd cache -/.cache/ - -# build directories (vscode-cmake-tools, user-defined, ...) -/build*/ - -# fuzzers -/tests/corpus_* -/tests/parse_*_fuzzer - -# documentation -/docs/docset/docSet.dsidx -/docs/docset/JSON_for_Modern_C++.docset/ -/docs/docset/JSON_for_Modern_C++.tgz -/docs/mkdocs/docs/__pycache__/ -/docs/mkdocs/docs/examples/ -/docs/mkdocs/docs/images/json.gif -/docs/mkdocs/site/ -/docs/mkdocs/venv/ - -# serve_header -/localhost.pem -/localhost-key.pem -/serve_header.yml diff --git a/.lgtm.yml b/.lgtm.yml deleted file mode 100644 index b62f9fb37b..0000000000 --- a/.lgtm.yml +++ /dev/null @@ -1,4 +0,0 @@ -path_classifiers: - thirdparty: - - /tools/amalgamate - - /tools/cpplint diff --git a/.reuse/README.md b/.reuse/README.md deleted file mode 100644 index 29c2b67a1d..0000000000 --- a/.reuse/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# REUSE Software - -This directory contains supporting files to make the project compliant with the REUSE specification. - -The root `Makefile` contains a target `reuse` that updates copyright headers and checks for compliance. - -See for more information. diff --git a/.reuse/dep5 b/.reuse/dep5 deleted file mode 100644 index 315cae923b..0000000000 --- a/.reuse/dep5 +++ /dev/null @@ -1,32 +0,0 @@ -Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: json -Upstream-Contact: Niels Lohmann -Source: https://github.com/nlohmann/json - -Files: * -Copyright: 2013-2022 Niels Lohmann -License: MIT - -Files: tests/thirdparty/doctest/* -Copyright: 2016-2021 Viktor Kirilov -License: MIT - -Files: tests/thirdparty/fifo_map/* -Copyright: 2015-2017 Niels Lohmann -License: MIT - -Files: tests/thirdparty/Fuzzer/* -Copyright: 2003-2022, LLVM Project. -License: Apache-2.0 - -Files: tests/thirdparty/imapdl/* -Copyright: 2017 Georg Sauthoff -License: GPL-3.0-only - -Files: tools/amalgamate/* -Copyright: 2012 Erik Edlund -License: BSD-3-Clause - -Files: tools/gdb_pretty_printer -Copyright: 2020 Hannes Domani -License: MIT diff --git a/.reuse/templates/json.jinja2 b/.reuse/templates/json.jinja2 deleted file mode 100644 index 4abf481b74..0000000000 --- a/.reuse/templates/json.jinja2 +++ /dev/null @@ -1,11 +0,0 @@ - __ _____ _____ _____ - __| | __| | | | JSON for Modern C++ -| | |__ | | | | | | version 3.11.2 -|_____|_____|_____|_|___| https://github.com/nlohmann/json - -{% for copyright_line in copyright_lines %} -{{ copyright_line }} -{% endfor %} -{% for expression in spdx_expressions %} -SPDX-License-Identifier: {{ expression }} -{% endfor %} diff --git a/.reuse/templates/json_support.jinja2 b/.reuse/templates/json_support.jinja2 deleted file mode 100644 index 1fab99fab7..0000000000 --- a/.reuse/templates/json_support.jinja2 +++ /dev/null @@ -1,11 +0,0 @@ - __ _____ _____ _____ - __| | __| | | | JSON for Modern C++ (supporting code) -| | |__ | | | | | | version 3.11.2 -|_____|_____|_____|_|___| https://github.com/nlohmann/json - -{% for copyright_line in copyright_lines %} -{{ copyright_line }} -{% endfor %} -{% for expression in spdx_expressions %} -SPDX-License-Identifier: {{ expression }} -{% endfor %} diff --git a/BUILD.bazel b/BUILD.bazel deleted file mode 100644 index 15d84f16be..0000000000 --- a/BUILD.bazel +++ /dev/null @@ -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, -) diff --git a/CITATION.cff b/CITATION.cff deleted file mode 100644 index cc9d7022d8..0000000000 --- a/CITATION.cff +++ /dev/null @@ -1,14 +0,0 @@ -cff-version: 1.2.0 -message: "If you use this software, please cite it as below." -authors: - - family-names: Lohmann - given-names: Niels - orcid: https://orcid.org/0000-0001-9037-795X - email: mail@nlohmann.me - website: https://nlohmann.me -title: "JSON for Modern C++" -version: 3.11.2 -date-released: 2022-08-12 -license: MIT -repository-code: "https://github.com/nlohmann" -url: https://json.nlohmann.me diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index f942e04ab1..0000000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,209 +0,0 @@ -cmake_minimum_required(VERSION 3.1) - -## -## PROJECT -## name and version -## -project(nlohmann_json VERSION 3.11.2 LANGUAGES CXX) - -## -## MAIN_PROJECT CHECK -## determine if nlohmann_json is built as a subproject (using add_subdirectory) or if it is the main project -## -set(MAIN_PROJECT OFF) -if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) - set(MAIN_PROJECT ON) -endif() - -## -## INCLUDE -## -## -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) -include(ExternalProject) - -## -## OPTIONS -## - -if (POLICY CMP0077) - # Allow CMake 3.13+ to override options when using FetchContent / add_subdirectory. - cmake_policy(SET CMP0077 NEW) -endif () - -# VERSION_GREATER_EQUAL is not available in CMake 3.1 -if(${MAIN_PROJECT} AND (${CMAKE_VERSION} VERSION_EQUAL 3.13 OR ${CMAKE_VERSION} VERSION_GREATER 3.13)) - set(JSON_BuildTests_INIT ON) -else() - set(JSON_BuildTests_INIT OFF) -endif() -option(JSON_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ${JSON_BuildTests_INIT}) -option(JSON_CI "Enable CI build targets." OFF) -option(JSON_Diagnostics "Use extended diagnostic messages." OFF) -option(JSON_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_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) - -if (JSON_CI) - include(ci) -endif () - -## -## CONFIGURATION -## -include(GNUInstallDirs) - -set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME}) -set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}" CACHE INTERNAL "") -set(NLOHMANN_JSON_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}") -set(NLOHMANN_JSON_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets") -set(NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE "cmake/config.cmake.in") -set(NLOHMANN_JSON_CMAKE_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}") -set(NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}ConfigVersion.cmake") -set(NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Config.cmake") -set(NLOHMANN_JSON_CMAKE_PROJECT_TARGETS_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Targets.cmake") -set(NLOHMANN_JSON_PKGCONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/pkgconfig") - -if (JSON_MultipleHeaders) - set(NLOHMANN_JSON_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/include/") - message(STATUS "Using the multi-header code from ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}") -else() - set(NLOHMANN_JSON_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/single_include/") - message(STATUS "Using the single-header code from ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}") -endif() - -if (NOT JSON_ImplicitConversions) - message(STATUS "Implicit conversions are disabled") -endif() - -if (JSON_DisableEnumSerialization) - message(STATUS "Enum integer serialization is disabled") -endif() - -if (JSON_LegacyDiscardedValueComparison) - message(STATUS "Legacy discarded value comparison enabled") -endif() - -if (JSON_Diagnostics) - message(STATUS "Diagnostics enabled") -endif() - -if (JSON_SystemInclude) - set(NLOHMANN_JSON_SYSTEM_INCLUDE "SYSTEM") -endif() - -## -## TARGET -## create target and add include path -## -add_library(${NLOHMANN_JSON_TARGET_NAME} INTERFACE) -add_library(${PROJECT_NAME}::${NLOHMANN_JSON_TARGET_NAME} ALIAS ${NLOHMANN_JSON_TARGET_NAME}) -if (${CMAKE_VERSION} VERSION_LESS "3.8.0") - target_compile_features(${NLOHMANN_JSON_TARGET_NAME} INTERFACE cxx_range_for) -else() - target_compile_features(${NLOHMANN_JSON_TARGET_NAME} INTERFACE cxx_std_11) -endif() - -target_compile_definitions( - ${NLOHMANN_JSON_TARGET_NAME} - INTERFACE - $<$>:JSON_USE_GLOBAL_UDLS=0> - $<$>:JSON_USE_IMPLICIT_CONVERSIONS=0> - $<$:JSON_DISABLE_ENUM_SERIALIZATION=1> - $<$:JSON_DIAGNOSTICS=1> - $<$:JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON=1> -) - -target_include_directories( - ${NLOHMANN_JSON_TARGET_NAME} - ${NLOHMANN_JSON_SYSTEM_INCLUDE} INTERFACE - $ - $ -) - -## add debug view definition file for msvc (natvis) -if (MSVC) - set(NLOHMANN_ADD_NATVIS TRUE) - set(NLOHMANN_NATVIS_FILE "nlohmann_json.natvis") - target_sources( - ${NLOHMANN_JSON_TARGET_NAME} - INTERFACE - $ - $ - ) -endif() - -# Install a pkg-config file, so other tools can find this. -CONFIGURE_FILE( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkg-config.pc.in" - "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" -) - -## -## TESTS -## create and configure the unit test target -## -if (JSON_BuildTests) - include(CTest) - enable_testing() - add_subdirectory(tests) -endif() - -## -## INSTALL -## install header files, generate and install cmake config files for find_package() -## -include(CMakePackageConfigHelpers) -# use a custom package version config file instead of -# write_basic_package_version_file to ensure that it's architecture-independent -# https://github.com/nlohmann/json/issues/1697 -configure_file( - "cmake/nlohmann_jsonConfigVersion.cmake.in" - ${NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE} - @ONLY -) -configure_file( - ${NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE} - ${NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE} - @ONLY -) - -if(JSON_Install) - install( - DIRECTORY ${NLOHMANN_JSON_INCLUDE_BUILD_DIR} - DESTINATION ${NLOHMANN_JSON_INCLUDE_INSTALL_DIR} - ) - install( - FILES ${NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE} ${NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE} - DESTINATION ${NLOHMANN_JSON_CONFIG_INSTALL_DIR} - ) - if (NLOHMANN_ADD_NATVIS) - install( - FILES ${NLOHMANN_NATVIS_FILE} - DESTINATION . - ) - endif() - export( - TARGETS ${NLOHMANN_JSON_TARGET_NAME} - NAMESPACE ${PROJECT_NAME}:: - FILE ${NLOHMANN_JSON_CMAKE_PROJECT_TARGETS_FILE} - ) - install( - TARGETS ${NLOHMANN_JSON_TARGET_NAME} - EXPORT ${NLOHMANN_JSON_TARGETS_EXPORT_NAME} - INCLUDES DESTINATION ${NLOHMANN_JSON_INCLUDE_INSTALL_DIR} - ) - install( - EXPORT ${NLOHMANN_JSON_TARGETS_EXPORT_NAME} - NAMESPACE ${PROJECT_NAME}:: - DESTINATION ${NLOHMANN_JSON_CONFIG_INSTALL_DIR} - ) - install( - FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" - DESTINATION ${NLOHMANN_JSON_PKGCONFIG_INSTALL_DIR} - ) -endif() diff --git a/ChangeLog.md b/ChangeLog.md deleted file mode 100644 index 656d68bcfc..0000000000 --- a/ChangeLog.md +++ /dev/null @@ -1,2943 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). - -## [3.11.2](https://github.com/nlohmann/json/releases/tag/3.11.2) (2022-08-12) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.11.1...3.11.2) - -- MSVC natvis visualizer does not work after introduction of inline ABI namespace [\#3696](https://github.com/nlohmann/json/issues/3696) -- The use of parenthesis gives compilation errors in some situations [\#3682](https://github.com/nlohmann/json/issues/3682) -- extern from/to\_json result in linker error [\#3657](https://github.com/nlohmann/json/issues/3657) -- json\_fwd.hpp no longer standalone [\#3656](https://github.com/nlohmann/json/issues/3656) -- regression: `.value` is compilation error. [\#3655](https://github.com/nlohmann/json/issues/3655) -- Regression: no match for 'operator!=' comparing json\_pointer and const char \*/string\_t [\#3654](https://github.com/nlohmann/json/issues/3654) -- Regression: call to member function 'value' is ambiguous [\#3652](https://github.com/nlohmann/json/issues/3652) -- macOS 10.15 Actions runner image deprecation [\#3612](https://github.com/nlohmann/json/issues/3612) - -- generate\_natvis.py: validate version number; cleanup [\#3698](https://github.com/nlohmann/json/pull/3698) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Add Python script for generating Natvis file and update file for 3.11.2 [\#3697](https://github.com/nlohmann/json/pull/3697) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- fix typo in json\_pointer.md [\#3692](https://github.com/nlohmann/json/pull/3692) ([eltociear](https://github.com/eltociear)) -- Add amalgamated json-fwd.hpp to release [\#3687](https://github.com/nlohmann/json/pull/3687) ([nlohmann](https://github.com/nlohmann)) -- Documentation updates for 3.11.2 [\#3686](https://github.com/nlohmann/json/pull/3686) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Make json\_pointer usable as map key \(again\) [\#3685](https://github.com/nlohmann/json/pull/3685) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Deprecate json\_pointer/string\_t comparisons [\#3684](https://github.com/nlohmann/json/pull/3684) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Restructure inline namespace and allow version component to be disabled [\#3683](https://github.com/nlohmann/json/pull/3683) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Properly constrain non-string json\_pointer overloads [\#3681](https://github.com/nlohmann/json/pull/3681) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Amalgamate the forward declaration header [\#3679](https://github.com/nlohmann/json/pull/3679) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Fix 'const' qualifier on bool& has no effect [\#3678](https://github.com/nlohmann/json/pull/3678) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Fix whitespace in workflow files [\#3675](https://github.com/nlohmann/json/pull/3675) ([nlohmann](https://github.com/nlohmann)) -- Attempt to fix labeler permissions [\#3674](https://github.com/nlohmann/json/pull/3674) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Refine 'Publish documentation' workflow [\#3673](https://github.com/nlohmann/json/pull/3673) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Documentation change [\#3672](https://github.com/nlohmann/json/pull/3672) ([nlohmann](https://github.com/nlohmann)) -- Add labeler action [\#3671](https://github.com/nlohmann/json/pull/3671) ([nlohmann](https://github.com/nlohmann)) -- Complete contributor list [\#3670](https://github.com/nlohmann/json/pull/3670) ([nlohmann](https://github.com/nlohmann)) -- Add json\_pointer/string\_t equality comparison operators [\#3664](https://github.com/nlohmann/json/pull/3664) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Reimplement value\(\) access functions [\#3663](https://github.com/nlohmann/json/pull/3663) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Complete contributor list [\#3662](https://github.com/nlohmann/json/pull/3662) ([nlohmann](https://github.com/nlohmann)) -- Adjust naming of GitHub action jobs [\#3661](https://github.com/nlohmann/json/pull/3661) ([nlohmann](https://github.com/nlohmann)) -- Publish documentation on push to develop branch [\#3660](https://github.com/nlohmann/json/pull/3660) ([nlohmann](https://github.com/nlohmann)) -- Add Discord badge to README [\#3651](https://github.com/nlohmann/json/pull/3651) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Miscellaneous small fixes [\#3643](https://github.com/nlohmann/json/pull/3643) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Minor BJData fixes [\#3637](https://github.com/nlohmann/json/pull/3637) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Update CI [\#3626](https://github.com/nlohmann/json/pull/3626) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) - -## [v3.11.1](https://github.com/nlohmann/json/releases/tag/v3.11.1) (2022-08-01) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.11.0...v3.11.1) - -- Regression: no matching literal operator for call to 'operator""\_json' [\#3645](https://github.com/nlohmann/json/issues/3645) -- \_json operator""\(\) [\#3644](https://github.com/nlohmann/json/issues/3644) - -- Fix global UDLs [\#3646](https://github.com/nlohmann/json/pull/3646) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) - -## [v3.11.0](https://github.com/nlohmann/json/releases/tag/v3.11.0) (2022-08-01) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.5...v3.11.0) - -- ICPC: warning \#1098: the qualifier on this friend declaration is ignored [\#3632](https://github.com/nlohmann/json/issues/3632) -- Starting with 3.10.4, just adding `\#include json.hpp` causes compile error: `overload resolution selected deleted operator '=' [\#3620](https://github.com/nlohmann/json/issues/3620) -- xwidgets doesn't compile with version \>3.10.3 [\#3602](https://github.com/nlohmann/json/issues/3602) -- json\_pointer\_\_pop\_back.cpp example does not compile [\#3600](https://github.com/nlohmann/json/issues/3600) -- nlohmann::json::array 'push\_back' is ambiguous [\#3589](https://github.com/nlohmann/json/issues/3589) -- Multiple versions causing conflict [\#3588](https://github.com/nlohmann/json/issues/3588) -- ERROR: ThreadSanitizer: SEGV on unknown address [\#3584](https://github.com/nlohmann/json/issues/3584) -- unicode4 test consistently fails on RISC-V hardware [\#3579](https://github.com/nlohmann/json/issues/3579) -- sax\_parse\(iterator, json\_sax\_t \*\) string callback clobbers spaces [\#3574](https://github.com/nlohmann/json/issues/3574) -- Nlohmann JSON Parse crash with raylib-cpp [\#3570](https://github.com/nlohmann/json/issues/3570) -- ordered\_json doesn't accept keys of types other than string\_t \(e.g., string\_view\) [\#3558](https://github.com/nlohmann/json/issues/3558) -- turning an object into an array [\#3547](https://github.com/nlohmann/json/issues/3547) -- json:parse\_bjdata\_fuzzer: ASSERT: ref\_stack.back\(\)-\>is\_array\(\) [\#3541](https://github.com/nlohmann/json/issues/3541) -- Warning about potential null dereference in GCC 12.1 \(Fedora 36\) [\#3525](https://github.com/nlohmann/json/issues/3525) -- Enable 32bit unit test in CI [\#3524](https://github.com/nlohmann/json/issues/3524) -- Error when roundtripping BJData [\#3519](https://github.com/nlohmann/json/issues/3519) -- ASSERT error while parsing BJData [\#3513](https://github.com/nlohmann/json/issues/3513) -- An exception occurred when sending a string with double quotes [\#3504](https://github.com/nlohmann/json/issues/3504) -- Binary reader for BJData creates incorrect SAX events [\#3503](https://github.com/nlohmann/json/issues/3503) -- It can't support "nan", "inf", "-inf" for float type [\#3494](https://github.com/nlohmann/json/issues/3494) -- ASAN error while parsing BJData \(Heap-buffer-overflow READ 1\) [\#3492](https://github.com/nlohmann/json/issues/3492) -- UBSAN error while parsing BJData \(Null-dereference\) [\#3491](https://github.com/nlohmann/json/issues/3491) -- UBSAN error while parsing BJData \(Invalid-bool-value\) [\#3490](https://github.com/nlohmann/json/issues/3490) -- json:parse\_bjdata\_fuzzer reaches assertion [\#3475](https://github.com/nlohmann/json/issues/3475) -- Compilation with -fmodules-ts and use inside of a module [\#3472](https://github.com/nlohmann/json/issues/3472) -- json.exception.parse\_error.101 only occurs outside of IDE [\#3467](https://github.com/nlohmann/json/issues/3467) -- json:parse\_bjdata\_fuzzer reaches assertion [\#3461](https://github.com/nlohmann/json/issues/3461) -- NLOHMANN\_DEFINE\_TYPE\_NON\_INTRUSIVE\_WITH\_DEFAULT can not parse { "key" : null} [\#3458](https://github.com/nlohmann/json/issues/3458) -- Unable to compile when using Microsoft's \_CRTDBG [\#3457](https://github.com/nlohmann/json/issues/3457) -- Compilation errors when including `` and using `--std=c++17` or above \(MinGW/Win10\) [\#3449](https://github.com/nlohmann/json/issues/3449) -- Weird things on for statement [\#3447](https://github.com/nlohmann/json/issues/3447) -- Parsing error when there is a json string within a Json [\#3445](https://github.com/nlohmann/json/issues/3445) -- ordered\_json vs json types comparison [\#3443](https://github.com/nlohmann/json/issues/3443) -- Error occurred when converting nlohmann::json to std::any [\#3428](https://github.com/nlohmann/json/issues/3428) -- I was forced to report an assertion error when copying an array of strings [\#3419](https://github.com/nlohmann/json/issues/3419) -- About Serialization Error invalid UTF-8 byte at index [\#3414](https://github.com/nlohmann/json/issues/3414) -- Comparison of NaN differs between json and float [\#3409](https://github.com/nlohmann/json/issues/3409) -- when i use it in C++ sserver,it it constantly show that fatal error: adl\_serializer.hpp: No such file or directory [\#3404](https://github.com/nlohmann/json/issues/3404) -- parse error [\#3403](https://github.com/nlohmann/json/issues/3403) -- CMake script MAIN\_PROJECT always OFF [\#3390](https://github.com/nlohmann/json/issues/3390) -- Parser unable to handle large floating point numbers [\#3389](https://github.com/nlohmann/json/issues/3389) -- Compilation error if json\_pointer is used with alternative string type [\#3388](https://github.com/nlohmann/json/issues/3388) -- Unit tests conversions & items fail to build \(Clang \<4.0/C++14 only\) [\#3384](https://github.com/nlohmann/json/issues/3384) -- Regression test for \#3070 is not being run and fails when enabled [\#3377](https://github.com/nlohmann/json/issues/3377) -- Refactor unit tests to use more convenient doctest assertion macros [\#3365](https://github.com/nlohmann/json/issues/3365) -- An json.h issue reported in a static code analyzer [\#3361](https://github.com/nlohmann/json/issues/3361) -- Mixing different JSON\_DIAGNOSTICS settings in separately compiled units leads to core [\#3360](https://github.com/nlohmann/json/issues/3360) -- json::out\_of\_range exception matches against lot of others while testing [\#3352](https://github.com/nlohmann/json/issues/3352) -- use mipsel-openwrt-linux-g++ -std=c++11 to compile, it has some errors "error: 'snprintf' is not a member of 'std'" [\#3349](https://github.com/nlohmann/json/issues/3349) -- Add proper issue templates [\#3348](https://github.com/nlohmann/json/issues/3348) -- switch from json to ordered\_json [\#3343](https://github.com/nlohmann/json/issues/3343) -- Json dump use to compilation errors [\#3339](https://github.com/nlohmann/json/issues/3339) -- Ambiguous conversion from nlohmann::basic\_json\<\> to custom class. [\#3333](https://github.com/nlohmann/json/issues/3333) -- Iterator doesn't satisfy std::incrementable because post-increment may change constness [\#3331](https://github.com/nlohmann/json/issues/3331) -- Inconsistent handling of floating point numbers after parse\(\) [\#3329](https://github.com/nlohmann/json/issues/3329) -- Documentation for `ordered_json` should show proper use of the `parse()` function. [\#3325](https://github.com/nlohmann/json/issues/3325) -- "type must be boolean, but is object" error thrown on non-boolean object [\#3319](https://github.com/nlohmann/json/issues/3319) -- Incomplete Type in request parms [\#3318](https://github.com/nlohmann/json/issues/3318) -- 小米 MIX4 MIUI13 bug [\#3316](https://github.com/nlohmann/json/issues/3316) -- json.exception.parse\_error.101 when parsing data received over a socket [\#3313](https://github.com/nlohmann/json/issues/3313) -- Parse to custom class from unordered\_json breaks on G++11.2.0 with C++20 [\#3312](https://github.com/nlohmann/json/issues/3312) -- try to assign dumped string to a class member varible [\#3300](https://github.com/nlohmann/json/issues/3300) -- includedir in pkgconfig is error if install\_headers\(\) has subdir argument. [\#3284](https://github.com/nlohmann/json/issues/3284) -- SHA-256 sum of json-3.10.5.tar.xz changes over time \(but not the content itself\) [\#3281](https://github.com/nlohmann/json/issues/3281) -- items\(\) method does not follow order of json message [\#3278](https://github.com/nlohmann/json/issues/3278) -- Perplexing template deduction failure serialising a 3rd party type using base class [\#3267](https://github.com/nlohmann/json/issues/3267) -- json.hpp 'isfinite' is not a member of 'std' also isinf; snprintf; stoull and to\_string members of std [\#3263](https://github.com/nlohmann/json/issues/3263) -- JSON build fails for C++ cmake [\#3256](https://github.com/nlohmann/json/issues/3256) -- Unexpected implicit conversion [\#3254](https://github.com/nlohmann/json/issues/3254) -- Add a function that checks for valid json in a C++ string [\#3245](https://github.com/nlohmann/json/issues/3245) -- Replace use of standard IO from error handling [\#3239](https://github.com/nlohmann/json/issues/3239) -- Use Catch for unit tests [\#3232](https://github.com/nlohmann/json/issues/3232) -- Exception thrown during initialization causes a memory leak [\#3215](https://github.com/nlohmann/json/issues/3215) -- Tests failing when compiling with c++20 [\#3207](https://github.com/nlohmann/json/issues/3207) -- ambiguous regression [\#3204](https://github.com/nlohmann/json/issues/3204) -- Deserialization: if class is\_constructible from std::string wrong from\_json overload is being selected, compilation failed [\#3171](https://github.com/nlohmann/json/issues/3171) -- 'clang++ ./json.hpp' with no usage: Compiler syntax problem in clang 3.7.0 \(tizen :/ \) [\#3153](https://github.com/nlohmann/json/issues/3153) -- build failure on upcoming gcc-12: test/src/unit-regression1.cpp:392:22: error: ambiguous overload for 'operator=' [\#3138](https://github.com/nlohmann/json/issues/3138) -- Applying JSON patch creates parent object [\#3134](https://github.com/nlohmann/json/issues/3134) -- Iterators cannot be used with range-v3 [\#3130](https://github.com/nlohmann/json/issues/3130) -- std::shared\_ptr\ == nlohmann::json compiles, which seem undesirable [\#3026](https://github.com/nlohmann/json/issues/3026) -- Error in test\download\_test\_data.vcxproj custom build step when compiling with Visual Studio 2019 16.7.7 msbuild on Windows 10 [\#2593](https://github.com/nlohmann/json/issues/2593) -- Consider putting the user-defined literals in a namespace [\#1682](https://github.com/nlohmann/json/issues/1682) -- Using versioned namespaces [\#1539](https://github.com/nlohmann/json/issues/1539) -- How can I use std::string\_view as the json\_key to "operator \[\]" ? [\#1529](https://github.com/nlohmann/json/issues/1529) -- serialize std::variant\<...\> [\#1261](https://github.com/nlohmann/json/issues/1261) - -- Prepare 3.11.0 release [\#3635](https://github.com/nlohmann/json/pull/3635) ([nlohmann](https://github.com/nlohmann)) -- Fix warning [\#3634](https://github.com/nlohmann/json/pull/3634) ([nlohmann](https://github.com/nlohmann)) -- Add license header to new files [\#3633](https://github.com/nlohmann/json/pull/3633) ([nlohmann](https://github.com/nlohmann)) -- Add a unit test including windows.h [\#3631](https://github.com/nlohmann/json/pull/3631) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Fixed latest build error in msvc platform [\#3630](https://github.com/nlohmann/json/pull/3630) ([KsaNL](https://github.com/KsaNL)) -- Add regression tests for \#3204 and \#3333 [\#3629](https://github.com/nlohmann/json/pull/3629) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Fix patch::add creating nonexistent parents [\#3628](https://github.com/nlohmann/json/pull/3628) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Adjust JSON Pointer examples [\#3622](https://github.com/nlohmann/json/pull/3622) ([nlohmann](https://github.com/nlohmann)) -- Disable exceptions on ICPC [\#3621](https://github.com/nlohmann/json/pull/3621) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- build: install .pc and .cmake files to share/ [\#3619](https://github.com/nlohmann/json/pull/3619) ([Tachi107](https://github.com/Tachi107)) -- Fix MinGW CI failures [\#3618](https://github.com/nlohmann/json/pull/3618) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Fix Unicode test timeout \(for real this time!\) [\#3614](https://github.com/nlohmann/json/pull/3614) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Use 'concurrency' in GitHub workflows [\#3610](https://github.com/nlohmann/json/pull/3610) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Use swap\(\) by ADL [\#3609](https://github.com/nlohmann/json/pull/3609) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Move UDLs out of the global namespace [\#3605](https://github.com/nlohmann/json/pull/3605) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Re-add value\_type detection to distinguish string types [\#3604](https://github.com/nlohmann/json/pull/3604) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Add operator\<\<\(json\_pointer\) [\#3601](https://github.com/nlohmann/json/pull/3601) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Add documentation for comparing json and ordered\_json [\#3599](https://github.com/nlohmann/json/pull/3599) ([nlohmann](https://github.com/nlohmann)) -- Clean up after \#3581 [\#3596](https://github.com/nlohmann/json/pull/3596) ([nlohmann](https://github.com/nlohmann)) -- Add assertion if nullptr is passed to parse function [\#3593](https://github.com/nlohmann/json/pull/3593) ([nlohmann](https://github.com/nlohmann)) -- Minor documentation fixes [\#3592](https://github.com/nlohmann/json/pull/3592) ([nlohmann](https://github.com/nlohmann)) -- Add versioned, ABI-tagged inline namespace and namespace macros [\#3590](https://github.com/nlohmann/json/pull/3590) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Add badge for https://repology.org/project/nlohmann-json/versions [\#3586](https://github.com/nlohmann/json/pull/3586) ([nlohmann](https://github.com/nlohmann)) -- Add error message if test suite cannot be found [\#3585](https://github.com/nlohmann/json/pull/3585) ([nlohmann](https://github.com/nlohmann)) -- add patch\_inplace function [\#3581](https://github.com/nlohmann/json/pull/3581) ([wolfv](https://github.com/wolfv)) -- Enable overriding test properties and set Unicode test timeouts [\#3580](https://github.com/nlohmann/json/pull/3580) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Ignore output directory [\#3572](https://github.com/nlohmann/json/pull/3572) ([NN---](https://github.com/NN---)) -- Optimize output vector adapter write [\#3569](https://github.com/nlohmann/json/pull/3569) ([romainreignier](https://github.com/romainreignier)) -- Add overloads for more key types to ordered\_map and fix ordered\_map::erase\(first, last\) with first == last [\#3564](https://github.com/nlohmann/json/pull/3564) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Make certain usage patterns more prominent in the README [\#3557](https://github.com/nlohmann/json/pull/3557) ([jez](https://github.com/jez)) -- CI: fix "JSON\_MultipleHeaders" option spelling [\#3555](https://github.com/nlohmann/json/pull/3555) ([karzhenkov](https://github.com/karzhenkov)) -- More documentation updates for 3.11.0 [\#3553](https://github.com/nlohmann/json/pull/3553) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Use DOCTEST\_\* compiler macros and suppress pragmas warning [\#3550](https://github.com/nlohmann/json/pull/3550) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Add unit test to make sure iterator\_input\_adapter advances iterators correctly [\#3548](https://github.com/nlohmann/json/pull/3548) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Use REUSE framework [\#3546](https://github.com/nlohmann/json/pull/3546) ([nlohmann](https://github.com/nlohmann)) -- Use `std::iterator_traits` to extract `iterator_category` [\#3544](https://github.com/nlohmann/json/pull/3544) ([Mike-Leo-Smith](https://github.com/Mike-Leo-Smith)) -- BJData dimension length can not be string\_t::npos, fix \#3541 [\#3543](https://github.com/nlohmann/json/pull/3543) ([fangq](https://github.com/fangq)) -- Allow disabling default enum conversions [\#3536](https://github.com/nlohmann/json/pull/3536) ([zxey](https://github.com/zxey)) -- Add to\_json\(\) for std::vector\::reference [\#3534](https://github.com/nlohmann/json/pull/3534) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- CI: Enable 32bit unit test \(3\) [\#3532](https://github.com/nlohmann/json/pull/3532) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Use new CI image [\#3528](https://github.com/nlohmann/json/pull/3528) ([nlohmann](https://github.com/nlohmann)) -- Fix ndarray dimension signedness, fix ndarray length overflow \(2\); add 32bit unit test [\#3523](https://github.com/nlohmann/json/pull/3523) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Small documentation fixes [\#3520](https://github.com/nlohmann/json/pull/3520) ([nlohmann](https://github.com/nlohmann)) -- Add assertion to converting constructor [\#3517](https://github.com/nlohmann/json/pull/3517) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- CI: Remove -Wstrict-overflow [\#3516](https://github.com/nlohmann/json/pull/3516) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Fix nlohmann/json\#3513, explain is\_ndarray flag [\#3514](https://github.com/nlohmann/json/pull/3514) ([fangq](https://github.com/fangq)) -- Prevent ndarray size vector from recursive use, fix nlohmann/json\#3503 [\#3505](https://github.com/nlohmann/json/pull/3505) ([fangq](https://github.com/fangq)) -- prevent ndarray dimension vector from recusive array, nlohmann/json\#3500 [\#3502](https://github.com/nlohmann/json/pull/3502) ([fangq](https://github.com/fangq)) -- Discard optimized containers with negative counts in UBJSON/BJData \(\#3491,\#3492,\#3490\) [\#3500](https://github.com/nlohmann/json/pull/3500) ([fangq](https://github.com/fangq)) -- Update json.hpp [\#3499](https://github.com/nlohmann/json/pull/3499) ([ivanovmp](https://github.com/ivanovmp)) -- Add assertion for invariant in SAX-DOM parser [\#3498](https://github.com/nlohmann/json/pull/3498) ([nlohmann](https://github.com/nlohmann)) -- Add more macOS builders [\#3485](https://github.com/nlohmann/json/pull/3485) ([nlohmann](https://github.com/nlohmann)) -- change bjdata ndarray flag to detect negative size, as part of \#3475 [\#3479](https://github.com/nlohmann/json/pull/3479) ([fangq](https://github.com/fangq)) -- Document fuzzer usage [\#3478](https://github.com/nlohmann/json/pull/3478) ([nlohmann](https://github.com/nlohmann)) -- Add build step for ICPC \(with fixes\) [\#3465](https://github.com/nlohmann/json/pull/3465) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Complete documentation for 3.11.0 [\#3464](https://github.com/nlohmann/json/pull/3464) ([nlohmann](https://github.com/nlohmann)) -- Handle invalid BJData optimized type, fix \#3461 [\#3463](https://github.com/nlohmann/json/pull/3463) ([fangq](https://github.com/fangq)) -- Reorganize directories [\#3462](https://github.com/nlohmann/json/pull/3462) ([nlohmann](https://github.com/nlohmann)) -- Enable rapid testing and development on Compiler Explorer [\#3456](https://github.com/nlohmann/json/pull/3456) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- cpplint 1.6.0 [\#3454](https://github.com/nlohmann/json/pull/3454) ([nlohmann](https://github.com/nlohmann)) -- Disable regression test for \#3070 on GCC \<8.4 [\#3451](https://github.com/nlohmann/json/pull/3451) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Fix C++20/gcc-12 issues \(Part 2\) [\#3446](https://github.com/nlohmann/json/pull/3446) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Overwork documentation [\#3444](https://github.com/nlohmann/json/pull/3444) ([nlohmann](https://github.com/nlohmann)) -- Fix typo in basic\_json documentation [\#3439](https://github.com/nlohmann/json/pull/3439) ([jhnlee](https://github.com/jhnlee)) -- Exclude std::any from implicit conversion \(fixes \#3428\) [\#3437](https://github.com/nlohmann/json/pull/3437) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Document which version introduced the macros [\#3431](https://github.com/nlohmann/json/pull/3431) ([nlohmann](https://github.com/nlohmann)) -- Fix constraints on from\_json\(\) for strings \(fixes \#3171, \#3267, \#3312, \#3384\) [\#3427](https://github.com/nlohmann/json/pull/3427) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- at.md: fix typo [\#3426](https://github.com/nlohmann/json/pull/3426) ([heinemml](https://github.com/heinemml)) -- Implement support for string\_view \(attempt no. 3\) [\#3423](https://github.com/nlohmann/json/pull/3423) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- CI: speedup AppVeyor builds by ~30% [\#3422](https://github.com/nlohmann/json/pull/3422) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Restore disabled check for \#3070 \(except on MSVC\) [\#3421](https://github.com/nlohmann/json/pull/3421) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Update CI image [\#3420](https://github.com/nlohmann/json/pull/3420) ([nlohmann](https://github.com/nlohmann)) -- Add check if different version is also included [\#3418](https://github.com/nlohmann/json/pull/3418) ([nlohmann](https://github.com/nlohmann)) -- Report the right \_\_cplusplus value for MSVC in basic\_json meta\(\) [\#3417](https://github.com/nlohmann/json/pull/3417) ([flagarde](https://github.com/flagarde)) -- CI: windows-2016 has been deprecated; remove jobs [\#3416](https://github.com/nlohmann/json/pull/3416) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Re-template json\_pointer on string type [\#3415](https://github.com/nlohmann/json/pull/3415) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Refactor unit tests to use more convenient doctest assertion macros \(Part 2\) [\#3405](https://github.com/nlohmann/json/pull/3405) ([kkarbowiak](https://github.com/kkarbowiak)) -- Refactor unit tests to use more convenient doctest assertion macros [\#3393](https://github.com/nlohmann/json/pull/3393) ([kkarbowiak](https://github.com/kkarbowiak)) -- Improve unit testing \(Part 1\) [\#3380](https://github.com/nlohmann/json/pull/3380) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Fix C++20/gcc-12 issues \(Part 1\) [\#3379](https://github.com/nlohmann/json/pull/3379) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Add clarification to avoid misunderstanding that cause \#3360 [\#3378](https://github.com/nlohmann/json/pull/3378) ([puffetto](https://github.com/puffetto)) -- Fix ordered\_map ctor with initializer\_list \(fixes \#3343\) [\#3370](https://github.com/nlohmann/json/pull/3370) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Fix and update CI [\#3368](https://github.com/nlohmann/json/pull/3368) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- FetchContent\_MakeAvailable [\#3351](https://github.com/nlohmann/json/pull/3351) ([nlohmann](https://github.com/nlohmann)) -- Avoid clash with Arduino defines [\#3338](https://github.com/nlohmann/json/pull/3338) ([DarkZeros](https://github.com/DarkZeros)) -- Support UBJSON-derived Binary JData \(BJData\) format [\#3336](https://github.com/nlohmann/json/pull/3336) ([fangq](https://github.com/fangq)) -- Make iterator operator++/--\(int\) equality-preserving [\#3332](https://github.com/nlohmann/json/pull/3332) ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) -- Add note on parsing ordered\_json [\#3326](https://github.com/nlohmann/json/pull/3326) ([nlohmann](https://github.com/nlohmann)) -- Fix CITATION.cff and add automatic validation of your citation metadata [\#3320](https://github.com/nlohmann/json/pull/3320) ([fdiblen](https://github.com/fdiblen)) -- .github/workflows/windows.yml: Add support for Visual Studio 2022 [\#3295](https://github.com/nlohmann/json/pull/3295) ([t-b](https://github.com/t-b)) -- Add maintainer targets to create source archive [\#3289](https://github.com/nlohmann/json/pull/3289) ([nlohmann](https://github.com/nlohmann)) -- Fix a typo [\#3265](https://github.com/nlohmann/json/pull/3265) ([fhuberts](https://github.com/fhuberts)) -- Fix typo [\#3249](https://github.com/nlohmann/json/pull/3249) ([rex4539](https://github.com/rex4539)) -- Add documentation for JSON Lines [\#3247](https://github.com/nlohmann/json/pull/3247) ([nlohmann](https://github.com/nlohmann)) -- Improve documentation InputType and IteratorType [\#3246](https://github.com/nlohmann/json/pull/3246) ([nlohmann](https://github.com/nlohmann)) -- Remove stringstream [\#3244](https://github.com/nlohmann/json/pull/3244) ([nlohmann](https://github.com/nlohmann)) -- fix \_MSC\_VER version to check for std::filesystem [\#3240](https://github.com/nlohmann/json/pull/3240) ([gcerretani](https://github.com/gcerretani)) -- Add macros NLOHMANN\_DEFINE\_TYPE\_INTRUSIVE\_WITH\_DEFAULT and ...\_NON\_INTRUSIVE\_WITH\_DEFAULT [\#3143](https://github.com/nlohmann/json/pull/3143) ([pketelsen](https://github.com/pketelsen)) - -## [v3.10.5](https://github.com/nlohmann/json/releases/tag/v3.10.5) (2022-01-03) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.4...v3.10.5) - -- \#include \ doesn't work with gcc-7 when `-std=c++17` is specified. [\#3203](https://github.com/nlohmann/json/issues/3203) -- Not able to use nlohmann json with c++ code built using emscripten to wasm [\#3200](https://github.com/nlohmann/json/issues/3200) -- Warning for shadowed variables [\#3188](https://github.com/nlohmann/json/issues/3188) -- Accessing missing keys on const json object leads to assert [\#3183](https://github.com/nlohmann/json/issues/3183) -- Data member is available, but null is reported, and program throws error [\#3173](https://github.com/nlohmann/json/issues/3173) -- serialization problem, from\_json need construct new object [\#3169](https://github.com/nlohmann/json/issues/3169) -- std::filesystem unavailable on macOS lower deployment targets [\#3156](https://github.com/nlohmann/json/issues/3156) -- \[json.exception.type\_error.305\] cannot use operator\[\] with a string argument with string [\#3151](https://github.com/nlohmann/json/issues/3151) -- json::dump\(\) is not compatible with C++ standards [\#3147](https://github.com/nlohmann/json/issues/3147) -- Issue with json::parse decoding codepoints [\#3142](https://github.com/nlohmann/json/issues/3142) -- Simple parse of json object thinks it should be an array [\#3136](https://github.com/nlohmann/json/issues/3136) -- How to properly read a Json string that may be null in some cases? [\#3135](https://github.com/nlohmann/json/issues/3135) -- Deadlock on create json - windows only [\#3129](https://github.com/nlohmann/json/issues/3129) -- Wrong parsing of int64 values nearest of limit [\#3126](https://github.com/nlohmann/json/issues/3126) -- ordered\_json doesn't support range based erase [\#3108](https://github.com/nlohmann/json/issues/3108) -- Apple build failed with json/single\_include/nlohmann/json.hpp:4384:57: 'path' is unavailable [\#3097](https://github.com/nlohmann/json/issues/3097) -- GCC 7.5.0 with --std=c++17: filesystem: No such file or directory [\#3090](https://github.com/nlohmann/json/issues/3090) -- Drop Travis CI [\#3087](https://github.com/nlohmann/json/issues/3087) -- ordered\_json::reset\(\) compile error with nvcc [\#3013](https://github.com/nlohmann/json/issues/3013) -- Support for unordered\_map as object\_t [\#2932](https://github.com/nlohmann/json/issues/2932) -- Compiler warning with Intel compiler, same as \#755 [\#2712](https://github.com/nlohmann/json/issues/2712) -- Compiler warnings with NVCC 11.2 [\#2676](https://github.com/nlohmann/json/issues/2676) -- some static analysis warning at line 11317 [\#1390](https://github.com/nlohmann/json/issues/1390) -- Compiling with icpc [\#755](https://github.com/nlohmann/json/issues/755) - -- Fix compilation error with NVCC [\#3234](https://github.com/nlohmann/json/pull/3234) ([nlohmann](https://github.com/nlohmann)) -- Remove Travis CI [\#3233](https://github.com/nlohmann/json/pull/3233) ([nlohmann](https://github.com/nlohmann)) -- Add build step for NVCC and fix a warning [\#3227](https://github.com/nlohmann/json/pull/3227) ([nlohmann](https://github.com/nlohmann)) -- Update cpplint [\#3225](https://github.com/nlohmann/json/pull/3225) ([nlohmann](https://github.com/nlohmann)) -- Fix: Warning for shadowed variables \(\#3188\) [\#3193](https://github.com/nlohmann/json/pull/3193) ([kernie](https://github.com/kernie)) -- Fix FAQ hyperlink typo in readme [\#3148](https://github.com/nlohmann/json/pull/3148) ([Prince-Mendiratta](https://github.com/Prince-Mendiratta)) -- Docs: Update `skip_comments` to `ignore_comments` [\#3145](https://github.com/nlohmann/json/pull/3145) ([daniel-kun](https://github.com/daniel-kun)) -- fix typos in documentation [\#3140](https://github.com/nlohmann/json/pull/3140) ([striezel](https://github.com/striezel)) -- Fix spelling [\#3125](https://github.com/nlohmann/json/pull/3125) ([axic](https://github.com/axic)) -- Extend std specializations [\#3121](https://github.com/nlohmann/json/pull/3121) ([nlohmann](https://github.com/nlohmann)) -- Add missing erase\(first, last\) function to ordered\_map [\#3109](https://github.com/nlohmann/json/pull/3109) ([nlohmann](https://github.com/nlohmann)) -- Fix typos in operator\[\] documentation [\#3102](https://github.com/nlohmann/json/pull/3102) ([axnsan12](https://github.com/axnsan12)) -- Add C++17 copies of the test binaries [\#3101](https://github.com/nlohmann/json/pull/3101) ([nlohmann](https://github.com/nlohmann)) -- Add examples for parsing from iterator pair [\#3100](https://github.com/nlohmann/json/pull/3100) ([nlohmann](https://github.com/nlohmann)) -- Update CI [\#3088](https://github.com/nlohmann/json/pull/3088) ([nlohmann](https://github.com/nlohmann)) -- Consolidate documentation [\#3071](https://github.com/nlohmann/json/pull/3071) ([nlohmann](https://github.com/nlohmann)) -- Add recursive update function [\#3069](https://github.com/nlohmann/json/pull/3069) ([nlohmann](https://github.com/nlohmann)) - -## [v3.10.4](https://github.com/nlohmann/json/releases/tag/v3.10.4) (2021-10-16) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.3...v3.10.4) - -- Compiler error in output serializer due to 'incompatible initializer' [\#3081](https://github.com/nlohmann/json/issues/3081) -- Strange behaviour when using std::sort on std::vector\ [\#3080](https://github.com/nlohmann/json/issues/3080) -- Unhandled exception: nlohmann::detail::parse\_error [\#3078](https://github.com/nlohmann/json/issues/3078) -- explicit constructor with default does not compile [\#3077](https://github.com/nlohmann/json/issues/3077) -- Parse an object but get an array using GCC [\#3076](https://github.com/nlohmann/json/issues/3076) -- Version 3.10.3 breaks backward-compatibility with 3.10.2 [\#3070](https://github.com/nlohmann/json/issues/3070) -- Feature request, Add to\_json/from\_json to align with other to/from binary api. [\#3067](https://github.com/nlohmann/json/issues/3067) -- vcpkg is out of date [\#3066](https://github.com/nlohmann/json/issues/3066) - -- Revert invalid fix [\#3082](https://github.com/nlohmann/json/pull/3082) ([nlohmann](https://github.com/nlohmann)) -- Allow to use get with explicit constructor [\#3079](https://github.com/nlohmann/json/pull/3079) ([nlohmann](https://github.com/nlohmann)) -- fix std::filesystem::path regression [\#3073](https://github.com/nlohmann/json/pull/3073) ([theodelrieu](https://github.com/theodelrieu)) - -## [v3.10.3](https://github.com/nlohmann/json/releases/tag/v3.10.3) (2021-10-08) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.2...v3.10.3) - -- Parsing an emtpy string returns a string with size 1 instead of expected 0 [\#3057](https://github.com/nlohmann/json/issues/3057) -- Linking error "duplicate symbol: std::type\_info::operator==" on static build with MinGW [\#3042](https://github.com/nlohmann/json/issues/3042) -- Yet another assertion failure when inserting into arrays with JSON\_DIAGNOSTICS set [\#3032](https://github.com/nlohmann/json/issues/3032) -- accept and parse function not work well with a pure number string [\#3029](https://github.com/nlohmann/json/issues/3029) -- push\_back doesn't work for serializing containers [\#3027](https://github.com/nlohmann/json/issues/3027) -- Strange behaviour when creating array with single element [\#3025](https://github.com/nlohmann/json/issues/3025) -- Input ordered\_json doesn't work [\#3023](https://github.com/nlohmann/json/issues/3023) -- Issue iterating through 'items' [\#3021](https://github.com/nlohmann/json/issues/3021) -- Cannot spell the namespace right [\#3015](https://github.com/nlohmann/json/issues/3015) -- JSON Parse error when reading json object from file [\#3011](https://github.com/nlohmann/json/issues/3011) -- Parent pointer not properly set when using update\(\) [\#3007](https://github.com/nlohmann/json/issues/3007) -- Overwriting terminated null character [\#3001](https://github.com/nlohmann/json/issues/3001) -- 'operator =' is ambiguous on VS2017 [\#2997](https://github.com/nlohmann/json/issues/2997) -- JSON Patch for Array Elements [\#2994](https://github.com/nlohmann/json/issues/2994) -- JSON Parse throwing error [\#2983](https://github.com/nlohmann/json/issues/2983) -- to\_{binary format} does not provide a mechanism for specifying a custom allocator for the returned type. [\#2982](https://github.com/nlohmann/json/issues/2982) -- 3.10.1 zip json.hpp has version number 3.10.0 instead of 3.10.1 [\#2973](https://github.com/nlohmann/json/issues/2973) -- Assertion failure when serializing array with JSON\_DIAGNOSTICS set [\#2926](https://github.com/nlohmann/json/issues/2926) - -- Fix Clang version [\#3040](https://github.com/nlohmann/json/pull/3040) ([nlohmann](https://github.com/nlohmann)) -- Fix assertion failure for JSON\_DIAGNOSTICS [\#3037](https://github.com/nlohmann/json/pull/3037) ([carlsmedstad](https://github.com/carlsmedstad)) -- meta: fix is\_compatible/constructible traits [\#3020](https://github.com/nlohmann/json/pull/3020) ([theodelrieu](https://github.com/theodelrieu)) -- Set parent pointers for values inserted via update\(\) \(fixes \#3007\). [\#3008](https://github.com/nlohmann/json/pull/3008) ([AnthonyVH](https://github.com/AnthonyVH)) -- Allow allocators for output\_vector\_adapter [\#2989](https://github.com/nlohmann/json/pull/2989) ([nlohmann](https://github.com/nlohmann)) -- Re-add Clang 12 [\#2986](https://github.com/nlohmann/json/pull/2986) ([nlohmann](https://github.com/nlohmann)) -- Use new Docker image [\#2981](https://github.com/nlohmann/json/pull/2981) ([nlohmann](https://github.com/nlohmann)) -- Update docset generation script [\#2967](https://github.com/nlohmann/json/pull/2967) ([nlohmann](https://github.com/nlohmann)) - -## [v3.10.2](https://github.com/nlohmann/json/releases/tag/v3.10.2) (2021-08-26) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.1...v3.10.2) - -- Annoying -Wundef on new JSON\_DIAGNOSTICS macro [\#2975](https://github.com/nlohmann/json/issues/2975) -- += issue with multiple redirection. [\#2970](https://github.com/nlohmann/json/issues/2970) -- "incomplete type ‘nlohmann::detail::wide\_string\_input\_helper" compilation error [\#2969](https://github.com/nlohmann/json/issues/2969) - -- Fix -Wunused warnings on JSON\_DIAGNOSTICS [\#2976](https://github.com/nlohmann/json/pull/2976) ([gcerretani](https://github.com/gcerretani)) - -## [v3.10.1](https://github.com/nlohmann/json/releases/tag/v3.10.1) (2021-08-24) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.0...v3.10.1) - -- JSON\_DIAGNOSTICS assertion for ordered\_json [\#2962](https://github.com/nlohmann/json/issues/2962) -- Inserting in unordered json using a pointer retains the leading slash [\#2958](https://github.com/nlohmann/json/issues/2958) -- Test \#9: test-cbor test case sample.json fails in debug mode - Stack overflow [\#2955](https://github.com/nlohmann/json/issues/2955) -- 3.10.0 broke at least the Bear project [\#2953](https://github.com/nlohmann/json/issues/2953) -- 2 tests fail in 3.10.0: cmake\_fetch\_content\_configure, cmake\_fetch\_content\_build [\#2951](https://github.com/nlohmann/json/issues/2951) -- ctest \(58+60,/67 cmake\_import\_configure\) fails when build with -D JSON\_Install:BOOL=OFF because of missing nlohmann\_jsonTargets.cmake [\#2946](https://github.com/nlohmann/json/issues/2946) -- Document vcpkg usage [\#2944](https://github.com/nlohmann/json/issues/2944) -- Linker error LNK2005 when compiling \(x64\) json-3.10.0.zip with Visual Studio 2019 16.11.1 [\#2941](https://github.com/nlohmann/json/issues/2941) -- Move Travis jobs to travis-ci.com [\#2938](https://github.com/nlohmann/json/issues/2938) - -- Fixed typo in docs/api/basic\_json/parse.md [\#2968](https://github.com/nlohmann/json/pull/2968) ([mbadhan](https://github.com/mbadhan)) -- Add link to Homebrew package [\#2966](https://github.com/nlohmann/json/pull/2966) ([nlohmann](https://github.com/nlohmann)) -- Fix parent update for diagnostics with ordered\_json [\#2963](https://github.com/nlohmann/json/pull/2963) ([nlohmann](https://github.com/nlohmann)) -- Set stack size for some unit tests when using MSVC [\#2961](https://github.com/nlohmann/json/pull/2961) ([nlohmann](https://github.com/nlohmann)) -- Add regression test [\#2960](https://github.com/nlohmann/json/pull/2960) ([nlohmann](https://github.com/nlohmann)) -- Update Travis badge [\#2959](https://github.com/nlohmann/json/pull/2959) ([nlohmann](https://github.com/nlohmann)) -- Fix some extra ";" clang warnings [\#2957](https://github.com/nlohmann/json/pull/2957) ([Hallot](https://github.com/Hallot)) -- Add documentation for integration via vcpkg [\#2954](https://github.com/nlohmann/json/pull/2954) ([nlohmann](https://github.com/nlohmann)) -- Avoid duplicate AppVeyor builds [\#2952](https://github.com/nlohmann/json/pull/2952) ([nlohmann](https://github.com/nlohmann)) -- 🚨 fix gdb\_pretty\_printer failure on basic types [\#2950](https://github.com/nlohmann/json/pull/2950) ([senyai](https://github.com/senyai)) -- Add header to use value\_t [\#2948](https://github.com/nlohmann/json/pull/2948) ([nlohmann](https://github.com/nlohmann)) -- Skip some tests if JSON\_Install is not set [\#2947](https://github.com/nlohmann/json/pull/2947) ([nlohmann](https://github.com/nlohmann)) -- Remove outdated json\_unit test binary [\#2945](https://github.com/nlohmann/json/pull/2945) ([nlohmann](https://github.com/nlohmann)) -- Updating the Homebrew Command [\#2943](https://github.com/nlohmann/json/pull/2943) ([amirmasoudabdol](https://github.com/amirmasoudabdol)) - -## [v3.10.0](https://github.com/nlohmann/json/releases/tag/v3.10.0) (2021-08-17) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.9.1...v3.10.0) - -- Latest version 3.9.1 uses throw instead of JSON\_THROW in the amalgamated json.hpp file [\#2934](https://github.com/nlohmann/json/issues/2934) -- Copy to a variable inside a Structure [\#2933](https://github.com/nlohmann/json/issues/2933) -- warning C4068: unknown pragma 'GCC' on MSVC/cl [\#2924](https://github.com/nlohmann/json/issues/2924) -- Errors during ninja test [\#2918](https://github.com/nlohmann/json/issues/2918) -- compiler warning: "not return a value" [\#2917](https://github.com/nlohmann/json/issues/2917) -- Comparison floating points causes warning [\#2909](https://github.com/nlohmann/json/issues/2909) -- Why can't I have std::vector\ testList? [\#2900](https://github.com/nlohmann/json/issues/2900) -- \[json.hpp\] from releases doesnt work [\#2897](https://github.com/nlohmann/json/issues/2897) -- g++ \(11\) -Wuseless-cast gives lots of warnings [\#2893](https://github.com/nlohmann/json/issues/2893) -- Cannot serialize and immediatly deserialize json to/from bson [\#2892](https://github.com/nlohmann/json/issues/2892) -- Floating-point precision conversion error [\#2876](https://github.com/nlohmann/json/issues/2876) -- How to avoid escaping for an already escaped string in .dump\(\) [\#2870](https://github.com/nlohmann/json/issues/2870) -- can't parse std::vector\ [\#2869](https://github.com/nlohmann/json/issues/2869) -- ASAN detects memory leaks [\#2865](https://github.com/nlohmann/json/issues/2865) -- Binary subtype field cannot represent all CBOR tags [\#2863](https://github.com/nlohmann/json/issues/2863) -- string literals possibly being parsed as another type due to the presence of only digits and full-stops [\#2852](https://github.com/nlohmann/json/issues/2852) -- json::parse\(\) works only with absolute paths [\#2851](https://github.com/nlohmann/json/issues/2851) -- Compiler Warnings on Raspberry Pi OS [\#2850](https://github.com/nlohmann/json/issues/2850) -- Braced initialization and aggregate initialization behavior is different for `json::array()` function call. [\#2848](https://github.com/nlohmann/json/issues/2848) -- 3.9.1: test suite is failing [\#2845](https://github.com/nlohmann/json/issues/2845) -- Documentation for macro JSON\_NO\_IO is missing [\#2842](https://github.com/nlohmann/json/issues/2842) -- Assertion failure when inserting into arrays with JSON\_DIAGNOSTICS set [\#2838](https://github.com/nlohmann/json/issues/2838) -- HELP! There is a memory leak in the code?! [\#2837](https://github.com/nlohmann/json/issues/2837) -- Elegant conversion of a 2-D-json array to a standard C++ array [\#2805](https://github.com/nlohmann/json/issues/2805) -- Swift Package Manager support [\#2802](https://github.com/nlohmann/json/issues/2802) -- Referencing a subkey which doesn't exist gives crash [\#2797](https://github.com/nlohmann/json/issues/2797) -- Failed benchmark due to renamed branch [\#2796](https://github.com/nlohmann/json/issues/2796) -- Build Errors with VS 2019 and json Version 3.9.1 when attempting to replicate SAX Example [\#2782](https://github.com/nlohmann/json/issues/2782) -- Value with spaces cannot be parsed [\#2781](https://github.com/nlohmann/json/issues/2781) -- \[Question\] CBOR rfc support. [\#2779](https://github.com/nlohmann/json/issues/2779) -- Using JSON.hpp header file in Visual Studio 2013 \(C++ Project\) [\#2775](https://github.com/nlohmann/json/issues/2775) -- compilation error on clang-8 + C++17 [\#2759](https://github.com/nlohmann/json/issues/2759) -- Undefined symbol EOF [\#2755](https://github.com/nlohmann/json/issues/2755) -- Parsing a string into json object behaves differently under g++ and MinGW compilers. [\#2746](https://github.com/nlohmann/json/issues/2746) -- big git history size [\#2742](https://github.com/nlohmann/json/issues/2742) -- How to get reference of std::vector\ [\#2735](https://github.com/nlohmann/json/issues/2735) -- CMake failure in VS2019 Community [\#2734](https://github.com/nlohmann/json/issues/2734) -- Possibility to use with custom c++ version to use in intel sgx enclaves [\#2730](https://github.com/nlohmann/json/issues/2730) -- Possibility to use without the dependency to file io and streams to use in intel sgx enclaves [\#2728](https://github.com/nlohmann/json/issues/2728) -- error C2784& error C2839... in my visual studio 2015 compiler [\#2726](https://github.com/nlohmann/json/issues/2726) -- `-fno-expection` not respected anymore in 3.9.1 [\#2725](https://github.com/nlohmann/json/issues/2725) -- When exceptions disabled with JSON\_NOEXCEPTION, lib just aborts without any message [\#2724](https://github.com/nlohmann/json/issues/2724) -- Critical error detected c0000374 on windows10 msvc 2019 16.8.5 [\#2710](https://github.com/nlohmann/json/issues/2710) -- unused parameter error/warning [\#2706](https://github.com/nlohmann/json/issues/2706) -- How to store data into a Map from json file [\#2691](https://github.com/nlohmann/json/issues/2691) -- Tests do not compile with pre-release glibc [\#2686](https://github.com/nlohmann/json/issues/2686) -- compile errors .... chromium-style [\#2680](https://github.com/nlohmann/json/issues/2680) -- .dump\(\) not allowing compact form [\#2678](https://github.com/nlohmann/json/issues/2678) -- error: no matching function for call to ‘nlohmann::basic\_json\<\>::value\(int, std::set\&\)’ [\#2671](https://github.com/nlohmann/json/issues/2671) -- Compiler warning: unused parameter [\#2668](https://github.com/nlohmann/json/issues/2668) -- Deserializing to a struct as shown on the project homepage throws compile time errors [\#2665](https://github.com/nlohmann/json/issues/2665) -- Unable to compile on MSVC 2019 with SDL checking enabled: This function or variable may be unsafe [\#2664](https://github.com/nlohmann/json/issues/2664) -- terminating with uncaught exception of type nlohmann::detail::type\_error: \[json.exception.type\_error.302\] type must be array, but is object [\#2661](https://github.com/nlohmann/json/issues/2661) -- unused-parameter on OSX when Diagnostics is off [\#2658](https://github.com/nlohmann/json/issues/2658) -- std::pair wrong serialization [\#2655](https://github.com/nlohmann/json/issues/2655) -- The result of json is\_number\_integer\(\) function is wrong when read a json file [\#2653](https://github.com/nlohmann/json/issues/2653) -- 2 backslash cause problem [\#2652](https://github.com/nlohmann/json/issues/2652) -- No support for using an external/system copy of Hedley [\#2651](https://github.com/nlohmann/json/issues/2651) -- error: incomplete type 'qfloat16' used in type trait expression [\#2650](https://github.com/nlohmann/json/issues/2650) -- Unused variable in exception class when not using improved diagnostics [\#2646](https://github.com/nlohmann/json/issues/2646) -- I am trying to do this - converting from wstring works incorrectly! [\#2642](https://github.com/nlohmann/json/issues/2642) -- Exception 207 On ARM Processor During Literal String Parsing [\#2634](https://github.com/nlohmann/json/issues/2634) -- double free or corruption \(!prev\) error on Json push\_back and write [\#2632](https://github.com/nlohmann/json/issues/2632) -- nlohmann::detail::parse\_error: syntax error while parsing CBOR string: expected length specification \(0x60-0x7B\) or indefinite string type \(0x7F\) [\#2629](https://github.com/nlohmann/json/issues/2629) -- please allow disabling implicit conversions in non-single-file use [\#2621](https://github.com/nlohmann/json/issues/2621) -- Preserve decimal formatting [\#2618](https://github.com/nlohmann/json/issues/2618) -- Visual Studio Visual Assist code issues reported by VA code inspection of file json.hpp [\#2615](https://github.com/nlohmann/json/issues/2615) -- Missing get function and no viable overloaded '=' on mac [\#2610](https://github.com/nlohmann/json/issues/2610) -- corruption when parse from string [\#2603](https://github.com/nlohmann/json/issues/2603) -- Parse from byte-vector results in compile error [\#2602](https://github.com/nlohmann/json/issues/2602) -- Memory leak when working on ARM Linux [\#2601](https://github.com/nlohmann/json/issues/2601) -- Unhandled exception in test-cbor.exe Stack overflow when debugging project with Visual Studio 2019 16.7.7 compiled with c++17 or c++latest [\#2598](https://github.com/nlohmann/json/issues/2598) -- Error in download\_test\_data.vcxproj when compiling with Visual Studio 2019 16.7.7 Professional msbuild on Windows 10 2004 Professional [\#2594](https://github.com/nlohmann/json/issues/2594) -- Warnings C4715 and C4127 when building json-3.9.1 with Visual Studio 2019 16.7.7 [\#2592](https://github.com/nlohmann/json/issues/2592) -- I tried some change to dump\(\) for \[1,2,3...\] [\#2584](https://github.com/nlohmann/json/issues/2584) -- try/catch block does not catch parsing error [\#2579](https://github.com/nlohmann/json/issues/2579) -- Serializing uint64\_t is broken for large values [\#2578](https://github.com/nlohmann/json/issues/2578) -- deserializing arrays should be part of the library [\#2575](https://github.com/nlohmann/json/issues/2575) -- Deserialization to std::array with non-default constructable types fails [\#2574](https://github.com/nlohmann/json/issues/2574) -- Compilation error when trying to use same type for number\_integer\_t and number\_unsigned\_t in basic\_json template specification. [\#2573](https://github.com/nlohmann/json/issues/2573) -- compiler error: directive output may be truncated writing between 2 and 8 bytes [\#2572](https://github.com/nlohmann/json/issues/2572) -- Incorrect convert map to json when key cannot construct an string i.e. int [\#2564](https://github.com/nlohmann/json/issues/2564) -- no matching function for call to ‘nlohmann::basic\_json\<\>::basic\_json\(\\)’ [\#2559](https://github.com/nlohmann/json/issues/2559) -- type\_error factory creates a dangling pointer \(in VisualStudio 2019\) [\#2535](https://github.com/nlohmann/json/issues/2535) -- Cannot assign from ordered\_json vector\ to value in not ordered json [\#2528](https://github.com/nlohmann/json/issues/2528) -- Qt6: Break changes [\#2519](https://github.com/nlohmann/json/issues/2519) -- valgrind memcheck Illegal instruction when use nlohmann::json::parse [\#2518](https://github.com/nlohmann/json/issues/2518) -- Buffer overflow [\#2515](https://github.com/nlohmann/json/issues/2515) -- Including CTest in the top-level CMakeLists.txt sets BUILD\_TESTING=ON for parent projects [\#2513](https://github.com/nlohmann/json/issues/2513) -- Compilation error when using NLOHMANN\_JSON\_SERIALIZE\_ENUM ordered\_json on libc++ [\#2491](https://github.com/nlohmann/json/issues/2491) -- Missing "void insert\( InputIt first, InputIt last \);" overload in nlohmann::ordered\_map [\#2490](https://github.com/nlohmann/json/issues/2490) -- Could not find a package configuration file provided by "nlohmann\_json" [\#2482](https://github.com/nlohmann/json/issues/2482) -- json becomes empty for unknown reason [\#2470](https://github.com/nlohmann/json/issues/2470) -- Using std::wstring as StringType fails compiling [\#2459](https://github.com/nlohmann/json/issues/2459) -- Sample code in GIF slide outdated \(cannot use emplace\(\) with array\) [\#2457](https://github.com/nlohmann/json/issues/2457) -- from\_json\ is treated as an array on latest MSVC [\#2453](https://github.com/nlohmann/json/issues/2453) -- MemorySanitizer: use-of-uninitialized-value [\#2449](https://github.com/nlohmann/json/issues/2449) -- I need help [\#2441](https://github.com/nlohmann/json/issues/2441) -- type conversion failing with clang ext\_vector\_type [\#2436](https://github.com/nlohmann/json/issues/2436) -- json::parse\(\) can't be resolved under specific circumstances [\#2427](https://github.com/nlohmann/json/issues/2427) -- from\_\*\(ptr, len\) deprecation [\#2426](https://github.com/nlohmann/json/issues/2426) -- Error ONLY in release mode [\#2425](https://github.com/nlohmann/json/issues/2425) -- "Custom data source" exemple make no sense [\#2423](https://github.com/nlohmann/json/issues/2423) -- Refuses to compile in project [\#2419](https://github.com/nlohmann/json/issues/2419) -- Compilation failure of tests with C++20 standard \(caused by change of u8 literals\) [\#2413](https://github.com/nlohmann/json/issues/2413) -- No matching function for call to 'input\_adapter' under Xcode of with nlohmann version 3.9.1 [\#2412](https://github.com/nlohmann/json/issues/2412) -- Git tags are not valid semvers [\#2409](https://github.com/nlohmann/json/issues/2409) -- after dump, stderr output disappear [\#2403](https://github.com/nlohmann/json/issues/2403) -- Using custom string. [\#2398](https://github.com/nlohmann/json/issues/2398) -- value\(\) throws unhandled exception for partially specified json object [\#2393](https://github.com/nlohmann/json/issues/2393) -- assertion on runtime causes program to stop when accessing const json with missing key [\#2392](https://github.com/nlohmann/json/issues/2392) -- Usage with -fno-elide-constructors causes dump\(\) output to be array of `null`s [\#2387](https://github.com/nlohmann/json/issues/2387) -- Build fails with clang-cl due to override of CMAKE\_CXX\_COMPILER\(?\) [\#2384](https://github.com/nlohmann/json/issues/2384) -- std::optional not working with primitive types [\#2383](https://github.com/nlohmann/json/issues/2383) -- Unexpected array when initializing a json const& on gcc 4.8.5 using uniform syntax [\#2370](https://github.com/nlohmann/json/issues/2370) -- setprecision support [\#2362](https://github.com/nlohmann/json/issues/2362) -- json::parse\(allow\_exceptions = false\) documentation is misleading. [\#2360](https://github.com/nlohmann/json/issues/2360) -- std::begin and std::end usage without specifying std namespace [\#2359](https://github.com/nlohmann/json/issues/2359) -- Custom object conversion to json hangs in background thread [\#2358](https://github.com/nlohmann/json/issues/2358) -- Add support of nullable fields to NLOHMANN\_DEFINE\_TYPE\_NON\_INTRUSIVE and NLOHMANN\_DEFINE\_TYPE\_INTRUSIVE [\#2356](https://github.com/nlohmann/json/issues/2356) -- the portfile for the vcpkg is not working. [\#2351](https://github.com/nlohmann/json/issues/2351) -- Compiler warns of implicit fallthrough when defining preprocessor macro NDEBUG [\#2348](https://github.com/nlohmann/json/issues/2348) -- Compile error on Intel compiler running in Windows [\#2346](https://github.com/nlohmann/json/issues/2346) -- Build error caused by overwriting CMAKE\_CXX\_COMPILER [\#2343](https://github.com/nlohmann/json/issues/2343) -- Error: an attribute list cannot appear here JSON\_HEDLEY\_DEPRECATED\_FOR [\#2342](https://github.com/nlohmann/json/issues/2342) -- compiler warning [\#2341](https://github.com/nlohmann/json/issues/2341) -- 3.9.0: tests make build non-reproducible [\#2324](https://github.com/nlohmann/json/issues/2324) -- Initialization different between gcc/clang [\#2311](https://github.com/nlohmann/json/issues/2311) -- Attempt to `get()` a numeric value as a type which cannot represent it should throw [\#2310](https://github.com/nlohmann/json/issues/2310) -- Surprising behaviour with overloaded operators [\#2256](https://github.com/nlohmann/json/issues/2256) -- ADL issue in input\_adapter [\#2248](https://github.com/nlohmann/json/issues/2248) -- Output adapters should be templated. [\#2172](https://github.com/nlohmann/json/issues/2172) -- error when using nlohmann::json, std::function and std::bind [\#2147](https://github.com/nlohmann/json/issues/2147) -- Remove undefined behavior for const operator\[\] [\#2111](https://github.com/nlohmann/json/issues/2111) -- json\({}\) gives null instead of empty object with GCC and -std=c++17 [\#2046](https://github.com/nlohmann/json/issues/2046) -- GDB pretty printing support [\#1952](https://github.com/nlohmann/json/issues/1952) -- Always compile tests with all warnings enabled and error out on warnings [\#1798](https://github.com/nlohmann/json/issues/1798) -- Fixes Cppcheck warnings [\#1759](https://github.com/nlohmann/json/issues/1759) -- How to get position info or parser context with custom from\_json\(\) that may throw exceptions? [\#1508](https://github.com/nlohmann/json/issues/1508) -- Suggestion to improve value\(\) accessors with respect to move semantics [\#1275](https://github.com/nlohmann/json/issues/1275) -- Add Key name to Exception [\#932](https://github.com/nlohmann/json/issues/932) - -- Overwork warning flags [\#2936](https://github.com/nlohmann/json/pull/2936) ([nlohmann](https://github.com/nlohmann)) -- Treat MSVC warnings as errors [\#2930](https://github.com/nlohmann/json/pull/2930) ([nlohmann](https://github.com/nlohmann)) -- All: fix warnings when compiling with -Wswitch-enum [\#2927](https://github.com/nlohmann/json/pull/2927) ([fhuberts](https://github.com/fhuberts)) -- Guard GCC pragmas [\#2925](https://github.com/nlohmann/json/pull/2925) ([nlohmann](https://github.com/nlohmann)) -- Supress -Wfloat-equal on intended float comparisions [\#2911](https://github.com/nlohmann/json/pull/2911) ([Finkman](https://github.com/Finkman)) -- Fix binary subtypes [\#2908](https://github.com/nlohmann/json/pull/2908) ([nlohmann](https://github.com/nlohmann)) -- Fix useless-cast warnings [\#2902](https://github.com/nlohmann/json/pull/2902) ([nlohmann](https://github.com/nlohmann)) -- Add regression test [\#2898](https://github.com/nlohmann/json/pull/2898) ([nlohmann](https://github.com/nlohmann)) -- Refactor Unicode tests [\#2889](https://github.com/nlohmann/json/pull/2889) ([nlohmann](https://github.com/nlohmann)) -- CMake cleanup [\#2885](https://github.com/nlohmann/json/pull/2885) ([nlohmann](https://github.com/nlohmann)) -- Avoid string in case of empty CBOR objects [\#2879](https://github.com/nlohmann/json/pull/2879) ([nlohmann](https://github.com/nlohmann)) -- Suppress C4127 warning in unit-json\_pointer.cpp [\#2875](https://github.com/nlohmann/json/pull/2875) ([nlohmann](https://github.com/nlohmann)) -- Fix truncation warning [\#2874](https://github.com/nlohmann/json/pull/2874) ([nlohmann](https://github.com/nlohmann)) -- Fix memory leak in to\_json [\#2872](https://github.com/nlohmann/json/pull/2872) ([nlohmann](https://github.com/nlohmann)) -- Fix assertion failure in diagnostics [\#2866](https://github.com/nlohmann/json/pull/2866) ([nlohmann](https://github.com/nlohmann)) -- Update documentation [\#2861](https://github.com/nlohmann/json/pull/2861) ([nlohmann](https://github.com/nlohmann)) -- Consistency with `using` in README.md [\#2826](https://github.com/nlohmann/json/pull/2826) ([justanotheranonymoususer](https://github.com/justanotheranonymoususer)) -- Properly constrain the basic\_json conversion operator [\#2825](https://github.com/nlohmann/json/pull/2825) ([ldionne](https://github.com/ldionne)) -- Fix CI [\#2817](https://github.com/nlohmann/json/pull/2817) ([nlohmann](https://github.com/nlohmann)) -- Specified git branch for google benchmark fetch in benchmark test [\#2795](https://github.com/nlohmann/json/pull/2795) ([grafail](https://github.com/grafail)) -- Add C++ standards to macOS matrix [\#2790](https://github.com/nlohmann/json/pull/2790) ([nlohmann](https://github.com/nlohmann)) -- Update URLs to HTTPS [\#2789](https://github.com/nlohmann/json/pull/2789) ([TotalCaesar659](https://github.com/TotalCaesar659)) -- Link to Conan Center package added [\#2771](https://github.com/nlohmann/json/pull/2771) ([offa](https://github.com/offa)) -- Keep consistent formatting [\#2770](https://github.com/nlohmann/json/pull/2770) ([jasmcaus](https://github.com/jasmcaus)) -- Add a cmake option to use SYSTEM in target\_include\_directories [\#2762](https://github.com/nlohmann/json/pull/2762) ([jpl-mac](https://github.com/jpl-mac)) -- replace EOF with std::char\_traits\::eof\(\) [\#2756](https://github.com/nlohmann/json/pull/2756) ([nlohmann](https://github.com/nlohmann)) -- Fix typo in README [\#2754](https://github.com/nlohmann/json/pull/2754) ([mortenfyhn](https://github.com/mortenfyhn)) -- Update documentation [\#2749](https://github.com/nlohmann/json/pull/2749) ([nlohmann](https://github.com/nlohmann)) -- Add documentation for numbers [\#2747](https://github.com/nlohmann/json/pull/2747) ([nlohmann](https://github.com/nlohmann)) -- Use Clang 12 in CI [\#2737](https://github.com/nlohmann/json/pull/2737) ([nlohmann](https://github.com/nlohmann)) -- Fixes \#2730 [\#2731](https://github.com/nlohmann/json/pull/2731) ([theShmoo](https://github.com/theShmoo)) -- Possibility to use without the dependency to file io and streams to use in intel sgx enclaves [\#2729](https://github.com/nlohmann/json/pull/2729) ([theShmoo](https://github.com/theShmoo)) -- Update json.hpp [\#2707](https://github.com/nlohmann/json/pull/2707) ([raduteo](https://github.com/raduteo)) -- pkg-config.pc.in: Don't concatenate paths [\#2690](https://github.com/nlohmann/json/pull/2690) ([doronbehar](https://github.com/doronbehar)) -- add more CI steps [\#2689](https://github.com/nlohmann/json/pull/2689) ([nlohmann](https://github.com/nlohmann)) -- Update doctest from 2.4.4 to 2.4.6 \(fixes \#2686\) [\#2687](https://github.com/nlohmann/json/pull/2687) ([musicinmybrain](https://github.com/musicinmybrain)) -- License fix [\#2683](https://github.com/nlohmann/json/pull/2683) ([nlohmann](https://github.com/nlohmann)) -- Update parse\_exceptions.md - correct `json::exception::parse_error` [\#2679](https://github.com/nlohmann/json/pull/2679) ([frasermarlow](https://github.com/frasermarlow)) -- Remove HEDLEY annotation from exception::what\(\) [\#2673](https://github.com/nlohmann/json/pull/2673) ([remyjette](https://github.com/remyjette)) -- Fix amount of entries in the json object [\#2659](https://github.com/nlohmann/json/pull/2659) ([abbaswasim](https://github.com/abbaswasim)) -- Fix missing 1.78 in example in README.md [\#2625](https://github.com/nlohmann/json/pull/2625) ([wawiesel](https://github.com/wawiesel)) -- Add GDB pretty printer [\#2607](https://github.com/nlohmann/json/pull/2607) ([nlohmann](https://github.com/nlohmann)) -- readme: fix tilde character display [\#2582](https://github.com/nlohmann/json/pull/2582) ([bl-ue](https://github.com/bl-ue)) -- Add support for deserialization of STL containers of non-default constructable types \(fixes \#2574\). [\#2576](https://github.com/nlohmann/json/pull/2576) ([AnthonyVH](https://github.com/AnthonyVH)) -- Better diagnostics [\#2562](https://github.com/nlohmann/json/pull/2562) ([nlohmann](https://github.com/nlohmann)) -- CI targets [\#2561](https://github.com/nlohmann/json/pull/2561) ([nlohmann](https://github.com/nlohmann)) -- Add switch to skip non-reproducible tests. [\#2560](https://github.com/nlohmann/json/pull/2560) ([nlohmann](https://github.com/nlohmann)) -- Fix compilation of input\_adapter\(container\) in edge cases [\#2553](https://github.com/nlohmann/json/pull/2553) ([jasujm](https://github.com/jasujm)) -- Allow parsing from std::byte containers [\#2550](https://github.com/nlohmann/json/pull/2550) ([nlohmann](https://github.com/nlohmann)) -- Travis doesn't run any tests in C++17 mode [\#2540](https://github.com/nlohmann/json/pull/2540) ([karzhenkov](https://github.com/karzhenkov)) -- Doctest is updated to v2.4.3 [\#2538](https://github.com/nlohmann/json/pull/2538) ([YarikTH](https://github.com/YarikTH)) -- Fix warnings [\#2537](https://github.com/nlohmann/json/pull/2537) ([nlohmann](https://github.com/nlohmann)) -- Fix a shadowing warning [\#2536](https://github.com/nlohmann/json/pull/2536) ([nlohmann](https://github.com/nlohmann)) -- Clarify license of is\_complete\_type implementation [\#2534](https://github.com/nlohmann/json/pull/2534) ([nlohmann](https://github.com/nlohmann)) -- Do not unconditionally redefine C++14 constructs [\#2533](https://github.com/nlohmann/json/pull/2533) ([nlohmann](https://github.com/nlohmann)) -- Doctest is updated to v2.4.1 [\#2525](https://github.com/nlohmann/json/pull/2525) ([YarikTH](https://github.com/YarikTH)) -- Add MAIN\_PROJECT check for test and install options [\#2514](https://github.com/nlohmann/json/pull/2514) ([globberwops](https://github.com/globberwops)) -- Ranged insert test section is added in unit-ordered\_json.cpp [\#2512](https://github.com/nlohmann/json/pull/2512) ([YarikTH](https://github.com/YarikTH)) -- Add asserts to suppress C28020 [\#2447](https://github.com/nlohmann/json/pull/2447) ([jbzdarkid](https://github.com/jbzdarkid)) -- Change argument name "subtype" in byte\_container\_with\_subtype [\#2444](https://github.com/nlohmann/json/pull/2444) ([linev](https://github.com/linev)) -- 📝 add CPM.Cmake example [\#2406](https://github.com/nlohmann/json/pull/2406) ([leozz37](https://github.com/leozz37)) -- Fix move constructor of json\_ref [\#2405](https://github.com/nlohmann/json/pull/2405) ([karzhenkov](https://github.com/karzhenkov)) -- Properly select "Release" build for Travis [\#2375](https://github.com/nlohmann/json/pull/2375) ([karzhenkov](https://github.com/karzhenkov)) -- Update Hedley [\#2367](https://github.com/nlohmann/json/pull/2367) ([nlohmann](https://github.com/nlohmann)) -- Fix and extend documentation of discarded values [\#2363](https://github.com/nlohmann/json/pull/2363) ([nlohmann](https://github.com/nlohmann)) -- Fix typos in documentation [\#2354](https://github.com/nlohmann/json/pull/2354) ([rbuch](https://github.com/rbuch)) -- Remove "\#define private public" from tests [\#2352](https://github.com/nlohmann/json/pull/2352) ([nlohmann](https://github.com/nlohmann)) -- Remove -Wimplicit-fallthrough warning [\#2349](https://github.com/nlohmann/json/pull/2349) ([nlohmann](https://github.com/nlohmann)) -- Fix code to work without exceptions [\#2347](https://github.com/nlohmann/json/pull/2347) ([nlohmann](https://github.com/nlohmann)) -- fix cmake script overwriting compiler path [\#2344](https://github.com/nlohmann/json/pull/2344) ([ongjunjie](https://github.com/ongjunjie)) - -## [v3.9.1](https://github.com/nlohmann/json/releases/tag/v3.9.1) (2020-08-06) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.9.0...v3.9.1) - -- Can't parse not formatted JSON. [\#2340](https://github.com/nlohmann/json/issues/2340) -- parse returns desired array contained in array when JSON text begins with square bracket on gcc 7.5.0 [\#2339](https://github.com/nlohmann/json/issues/2339) -- Unexpected deserialization difference between Mac and Linux [\#2338](https://github.com/nlohmann/json/issues/2338) -- Reading ordered\_json from file causes compile error [\#2331](https://github.com/nlohmann/json/issues/2331) -- ignore\_comment=true fails on multiple consecutive lines starting with comments [\#2330](https://github.com/nlohmann/json/issues/2330) -- Update documentation about Homebrew installation and CMake integration - Homebrew [\#2326](https://github.com/nlohmann/json/issues/2326) -- Chinese character initialize error [\#2325](https://github.com/nlohmann/json/issues/2325) -- json.update and vector\does not work with ordered\_json [\#2315](https://github.com/nlohmann/json/issues/2315) -- Ambiguous call to overloaded function [\#2210](https://github.com/nlohmann/json/issues/2210) - -- Fix fallthrough warning [\#2333](https://github.com/nlohmann/json/pull/2333) ([nlohmann](https://github.com/nlohmann)) -- Fix lexer to properly cope with repeated comments [\#2332](https://github.com/nlohmann/json/pull/2332) ([nlohmann](https://github.com/nlohmann)) -- Fix name of Homebrew formula in documentation [\#2327](https://github.com/nlohmann/json/pull/2327) ([nlohmann](https://github.com/nlohmann)) -- fix typo [\#2320](https://github.com/nlohmann/json/pull/2320) ([wx257osn2](https://github.com/wx257osn2)) -- Fix a bug due to missing overloads in ordered\_map container [\#2319](https://github.com/nlohmann/json/pull/2319) ([nlohmann](https://github.com/nlohmann)) -- cmake: install pkg-config file relative to current\_binary\_dir [\#2318](https://github.com/nlohmann/json/pull/2318) ([eli-schwartz](https://github.com/eli-schwartz)) -- Fixed installation of pkg-config file on other than Ubuntu [\#2314](https://github.com/nlohmann/json/pull/2314) ([xvitaly](https://github.com/xvitaly)) - -## [v3.9.0](https://github.com/nlohmann/json/releases/tag/v3.9.0) (2020-07-27) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.8.0...v3.9.0) - -- Unknown Type Name clang error when using NLOHMANN\_DEFINE\_TYPE\_NON\_INTRUSIVE [\#2313](https://github.com/nlohmann/json/issues/2313) -- Clang 10.0 / GCC 10.1 warnings on disabled exceptions [\#2304](https://github.com/nlohmann/json/issues/2304) -- Application stalls indefinitely with message byte size 10 [\#2293](https://github.com/nlohmann/json/issues/2293) -- linker error [\#2292](https://github.com/nlohmann/json/issues/2292) -- Add support for high-precision numbers in UBJSON encoding [\#2286](https://github.com/nlohmann/json/issues/2286) -- NLOHMANN\_DEFINE\_TYPE\_NON\_INTRUSIVE fails if the length of the argument is 10 [\#2280](https://github.com/nlohmann/json/issues/2280) -- Custom types : MACRO expansion bug [\#2267](https://github.com/nlohmann/json/issues/2267) -- to/from\_json Failing To Convert String [\#2238](https://github.com/nlohmann/json/issues/2238) -- clang 9.0 report warning: unused type alias 'size\_type' \[-Wunused-local-typedef\] [\#2221](https://github.com/nlohmann/json/issues/2221) -- Enormous array created when working with map\ [\#2220](https://github.com/nlohmann/json/issues/2220) -- Can I disable sorting of json values [\#2219](https://github.com/nlohmann/json/issues/2219) -- Getting Qt types to work [\#2217](https://github.com/nlohmann/json/issues/2217) -- Convert to Qt QVariant [\#2216](https://github.com/nlohmann/json/issues/2216) -- How to custom serialize same data type of vector? [\#2215](https://github.com/nlohmann/json/issues/2215) -- json constructor does not support std::optional [\#2214](https://github.com/nlohmann/json/issues/2214) -- Failing to Parse Valid JSON [\#2209](https://github.com/nlohmann/json/issues/2209) -- \(De-\)Serialization of std::variant with namespaces [\#2208](https://github.com/nlohmann/json/issues/2208) -- Addint support for complex type [\#2207](https://github.com/nlohmann/json/issues/2207) -- array\_index possible out of range [\#2205](https://github.com/nlohmann/json/issues/2205) -- Object deserialized as array [\#2204](https://github.com/nlohmann/json/issues/2204) -- Sending to a function a reference to a sub-branch [\#2200](https://github.com/nlohmann/json/issues/2200) -- How to Serialize derived class to JSON object? [\#2199](https://github.com/nlohmann/json/issues/2199) -- JSON incorrectly serialized [\#2198](https://github.com/nlohmann/json/issues/2198) -- Exception Unhandled out\_of\_range error [\#2197](https://github.com/nlohmann/json/issues/2197) -- msgpack serialisation : float is treated as 64bit float, not 32bit float. [\#2196](https://github.com/nlohmann/json/issues/2196) -- Is it possible to use compile-time type guarantees for JSON structures? [\#2195](https://github.com/nlohmann/json/issues/2195) -- Question : performance against python dict [\#2194](https://github.com/nlohmann/json/issues/2194) -- vs2017 compile error [\#2192](https://github.com/nlohmann/json/issues/2192) -- Check if a key exists [\#2191](https://github.com/nlohmann/json/issues/2191) -- Failed to run tests due to missing test data on builders without Internet access [\#2190](https://github.com/nlohmann/json/issues/2190) -- 3.8.0: unit-cbor.cpp test failures [\#2189](https://github.com/nlohmann/json/issues/2189) -- 'nlohmann/json.hpp' file not found [\#2188](https://github.com/nlohmann/json/issues/2188) -- How to send json data over the wire? [\#2185](https://github.com/nlohmann/json/issues/2185) -- Ubuntu 16 not supporting nlohmann/json? [\#2184](https://github.com/nlohmann/json/issues/2184) -- .get\ causing emdash errors [\#2180](https://github.com/nlohmann/json/issues/2180) -- Object properties should not be re-sorted alphabetically [\#2179](https://github.com/nlohmann/json/issues/2179) -- Custom type registration : instrusive API [\#2175](https://github.com/nlohmann/json/issues/2175) -- Many version of the function "void to\_json\(json& j, const MyStruct& struct\)" [\#2171](https://github.com/nlohmann/json/issues/2171) -- How should strings be escaped? [\#2155](https://github.com/nlohmann/json/issues/2155) -- Adding a value to an existing json puts it at the beginning instead of the end [\#2149](https://github.com/nlohmann/json/issues/2149) -- The header file is big, can we use what we need. [\#2134](https://github.com/nlohmann/json/issues/2134) -- Changing the default format for unordered\_map \(or other set\) [\#2132](https://github.com/nlohmann/json/issues/2132) -- Getting size of deserialized bson document [\#2131](https://github.com/nlohmann/json/issues/2131) -- implicit conversion failure [\#2128](https://github.com/nlohmann/json/issues/2128) -- Error thrown when parsing in a subclass [\#2124](https://github.com/nlohmann/json/issues/2124) -- explicit conversion to string not considered for std::map keys in GCC8 [\#2096](https://github.com/nlohmann/json/issues/2096) -- Add support for JSONC [\#2061](https://github.com/nlohmann/json/issues/2061) -- Library provides template arg for string\_type but assumes std::string in some places [\#2059](https://github.com/nlohmann/json/issues/2059) -- incremental parsing with sax\_parser [\#2030](https://github.com/nlohmann/json/issues/2030) -- Question about flatten and unflatten [\#1989](https://github.com/nlohmann/json/issues/1989) -- CBOR parser doesn't skip tags [\#1968](https://github.com/nlohmann/json/issues/1968) -- Compilation failure using Clang on Windows [\#1898](https://github.com/nlohmann/json/issues/1898) -- Fail to build when including json.hpp as a system include [\#1818](https://github.com/nlohmann/json/issues/1818) -- Parsing string into json doesn't preserve the order correctly. [\#1817](https://github.com/nlohmann/json/issues/1817) -- \[C++17\] Allow std::optional to convert to nlohmann::json [\#1749](https://github.com/nlohmann/json/issues/1749) -- How can I save json object in file in order? [\#1717](https://github.com/nlohmann/json/issues/1717) -- Support for Comments [\#1513](https://github.com/nlohmann/json/issues/1513) -- clang compiler: error : unknown type name 'not' [\#1119](https://github.com/nlohmann/json/issues/1119) -- dump\(\) without alphabetical order [\#1106](https://github.com/nlohmann/json/issues/1106) -- operator T\(\) considered harmful [\#958](https://github.com/nlohmann/json/issues/958) -- Order of the elements in JSON object [\#952](https://github.com/nlohmann/json/issues/952) -- How to prevent alphabetical sorting of data? [\#727](https://github.com/nlohmann/json/issues/727) -- Why is an object ordering values by Alphabetical Order? [\#660](https://github.com/nlohmann/json/issues/660) -- Feature request: Comments [\#597](https://github.com/nlohmann/json/issues/597) -- Head Elements Sorting [\#543](https://github.com/nlohmann/json/issues/543) -- Automatic ordered JSON [\#424](https://github.com/nlohmann/json/issues/424) -- Support for comments. [\#376](https://github.com/nlohmann/json/issues/376) -- Optional comment support. [\#363](https://github.com/nlohmann/json/issues/363) -- Strip comments / Minify [\#294](https://github.com/nlohmann/json/issues/294) -- maintaining order of keys during iteration [\#106](https://github.com/nlohmann/json/issues/106) - -- Update documentation [\#2312](https://github.com/nlohmann/json/pull/2312) ([nlohmann](https://github.com/nlohmann)) -- Fix bug in CBOR tag handling [\#2308](https://github.com/nlohmann/json/pull/2308) ([nlohmann](https://github.com/nlohmann)) -- added inline to NLOHMANN\_DEFINE\_TYPE\_NON\_INTRUSIVE macro [\#2306](https://github.com/nlohmann/json/pull/2306) ([jwittbrodt](https://github.com/jwittbrodt)) -- fixes unused variable 'ex' for \#2304 [\#2305](https://github.com/nlohmann/json/pull/2305) ([AODQ](https://github.com/AODQ)) -- Cleanup [\#2303](https://github.com/nlohmann/json/pull/2303) ([nlohmann](https://github.com/nlohmann)) -- Add test with multiple translation units [\#2301](https://github.com/nlohmann/json/pull/2301) ([nlohmann](https://github.com/nlohmann)) -- Merge GitHub actions [\#2300](https://github.com/nlohmann/json/pull/2300) ([nlohmann](https://github.com/nlohmann)) -- Fix unused parameter [\#2299](https://github.com/nlohmann/json/pull/2299) ([nlohmann](https://github.com/nlohmann)) -- Add support for high-precision numbers in UBJSON encoding [\#2297](https://github.com/nlohmann/json/pull/2297) ([nlohmann](https://github.com/nlohmann)) -- fix eof for get\_binary and get\_string [\#2294](https://github.com/nlohmann/json/pull/2294) ([jprochazk](https://github.com/jprochazk)) -- Serialisation macros: increase upper bound on number of member variables [\#2287](https://github.com/nlohmann/json/pull/2287) ([pfeatherstone](https://github.com/pfeatherstone)) -- add inline specifier for detail::combine [\#2285](https://github.com/nlohmann/json/pull/2285) ([T0b1-iOS](https://github.com/T0b1-iOS)) -- Add static assertion for missing binary function in SAX interface [\#2282](https://github.com/nlohmann/json/pull/2282) ([nlohmann](https://github.com/nlohmann)) -- Add test for target\_include\_directories [\#2279](https://github.com/nlohmann/json/pull/2279) ([nlohmann](https://github.com/nlohmann)) -- Clean up maintainer Makefiles and fix some linter warnings [\#2274](https://github.com/nlohmann/json/pull/2274) ([nlohmann](https://github.com/nlohmann)) -- Add option to ignore CBOR tags [\#2273](https://github.com/nlohmann/json/pull/2273) ([nlohmann](https://github.com/nlohmann)) -- Hash function without allocation [\#2269](https://github.com/nlohmann/json/pull/2269) ([nlohmann](https://github.com/nlohmann)) -- Add ClangCL for MSVC [\#2268](https://github.com/nlohmann/json/pull/2268) ([t-b](https://github.com/t-b)) -- Makefile: Always use SED variable [\#2264](https://github.com/nlohmann/json/pull/2264) ([t-b](https://github.com/t-b)) -- Add Xcode 12 CI [\#2262](https://github.com/nlohmann/json/pull/2262) ([nlohmann](https://github.com/nlohmann)) -- Make library work with Clang on Windows [\#2259](https://github.com/nlohmann/json/pull/2259) ([nlohmann](https://github.com/nlohmann)) -- Add ordered\_json specialization with ordered object keys [\#2258](https://github.com/nlohmann/json/pull/2258) ([nlohmann](https://github.com/nlohmann)) -- Add pkg-config file [\#2253](https://github.com/nlohmann/json/pull/2253) ([ericonr](https://github.com/ericonr)) -- Fix regression from \#2181 [\#2251](https://github.com/nlohmann/json/pull/2251) ([nlohmann](https://github.com/nlohmann)) -- Tag binary values in cbor if set [\#2244](https://github.com/nlohmann/json/pull/2244) ([matthewbauer](https://github.com/matthewbauer)) -- Make assert configurable via JSON\_ASSERT [\#2242](https://github.com/nlohmann/json/pull/2242) ([nlohmann](https://github.com/nlohmann)) -- Add specialization of get\_to [\#2233](https://github.com/nlohmann/json/pull/2233) ([nlohmann](https://github.com/nlohmann)) -- Refine documentation of error\_handler parameter [\#2232](https://github.com/nlohmann/json/pull/2232) ([nlohmann](https://github.com/nlohmann)) -- Simplify conversion from/to custom types [\#2225](https://github.com/nlohmann/json/pull/2225) ([nlohmann](https://github.com/nlohmann)) -- Remove unused typedefs [\#2224](https://github.com/nlohmann/json/pull/2224) ([nlohmann](https://github.com/nlohmann)) -- Enable CMake policy CMP0077 [\#2222](https://github.com/nlohmann/json/pull/2222) ([alexreinking](https://github.com/alexreinking)) -- Add option to ignore comments in parse/accept functions [\#2212](https://github.com/nlohmann/json/pull/2212) ([nlohmann](https://github.com/nlohmann)) -- Fix Clang-Tidy warnings [\#2211](https://github.com/nlohmann/json/pull/2211) ([nlohmann](https://github.com/nlohmann)) -- Simple ordered\_json that works on all supported compilers [\#2206](https://github.com/nlohmann/json/pull/2206) ([gatopeich](https://github.com/gatopeich)) -- Use unsigned indizies for array index in json pointer [\#2203](https://github.com/nlohmann/json/pull/2203) ([t-b](https://github.com/t-b)) -- Add option to not rely on Internet connectivity during test stage [\#2202](https://github.com/nlohmann/json/pull/2202) ([nlohmann](https://github.com/nlohmann)) -- Serialize floating-point numbers with 32 bit when possible \(MessagePack\) [\#2201](https://github.com/nlohmann/json/pull/2201) ([nlohmann](https://github.com/nlohmann)) -- Fix consistency in function `int_to_string()` [\#2193](https://github.com/nlohmann/json/pull/2193) ([dota17](https://github.com/dota17)) -- Fix issue\#1275 [\#2181](https://github.com/nlohmann/json/pull/2181) ([dota17](https://github.com/dota17)) -- C++20 support by removing swap specialization [\#2176](https://github.com/nlohmann/json/pull/2176) ([gracicot](https://github.com/gracicot)) -- Feat/explicit conversion operator [\#1559](https://github.com/nlohmann/json/pull/1559) ([theodelrieu](https://github.com/theodelrieu)) - -## [v3.8.0](https://github.com/nlohmann/json/releases/tag/v3.8.0) (2020-06-14) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.7.3...v3.8.0) - -- sorry delete this issue, i'm stupid [\#2187](https://github.com/nlohmann/json/issues/2187) -- Append to a std::nlohmann::json type [\#2186](https://github.com/nlohmann/json/issues/2186) -- Some troubles to compile the last revision [\#2177](https://github.com/nlohmann/json/issues/2177) -- ​\#​ Top level CMakeLists.txt​ -​project​\(FOO\) -... -​option​\(FOO\_USE\_EXTERNAL\_JSON ​"Use an external JSON library"​ ​OFF​\) -... -​add\_subdirectory​\(thirdparty\) -... -​add\_library​\(foo ...\) -... -​\#​ Note that the namespaced target will always be available regardless of the​ -​\#​ import method​ -​target\_link\_libraries​\(foo ​PRIVATE​ nlohmann\_json::nlohmann\_json\) [\#2170](https://github.com/nlohmann/json/issues/2170) -- https://www.github.com/nlohmann/json/tree/develop/include%2Fnlohmann%2Fjson\_fwd.hpp [\#2169](https://github.com/nlohmann/json/issues/2169) -- templated from\_json of non primitive types causes gcc error [\#2168](https://github.com/nlohmann/json/issues/2168) -- few warnings/errors in copy assignment [\#2167](https://github.com/nlohmann/json/issues/2167) -- Different output when upgrading from clang 9 to clang 10 [\#2166](https://github.com/nlohmann/json/issues/2166) -- Cannot build with VS 2019 / C++17 [\#2163](https://github.com/nlohmann/json/issues/2163) -- Q: When I received an illegal string,How the program knows? [\#2162](https://github.com/nlohmann/json/issues/2162) -- Problem while reading a json file [\#2161](https://github.com/nlohmann/json/issues/2161) -- converting std::chrono::system\_clock::time\_point to json. [\#2159](https://github.com/nlohmann/json/issues/2159) -- how to parse vector\ format [\#2157](https://github.com/nlohmann/json/issues/2157) -- nlohmann::json and =nullptr [\#2156](https://github.com/nlohmann/json/issues/2156) -- test-cbor fails [\#2154](https://github.com/nlohmann/json/issues/2154) -- Accessing array inside array syntax? [\#2151](https://github.com/nlohmann/json/issues/2151) -- Best way to catch errors when querying json [\#2150](https://github.com/nlohmann/json/issues/2150) -- JSON Data Mapping Key-Value from other Key-Value [\#2148](https://github.com/nlohmann/json/issues/2148) -- Conflicts with std \ compiling with GCC 10 [\#2146](https://github.com/nlohmann/json/issues/2146) -- Incorrect CMake FetchContent example [\#2142](https://github.com/nlohmann/json/issues/2142) -- Help for a Beginner? [\#2141](https://github.com/nlohmann/json/issues/2141) -- Read Json from File [\#2139](https://github.com/nlohmann/json/issues/2139) -- How to feed a predefined integer value into json string [\#2138](https://github.com/nlohmann/json/issues/2138) -- getting json array inside json object [\#2135](https://github.com/nlohmann/json/issues/2135) -- Add .contains example to doc [\#2133](https://github.com/nlohmann/json/issues/2133) -- Is it safe to return string.c\_str\(\) received from get\(\)? [\#2130](https://github.com/nlohmann/json/issues/2130) -- GCC 10: Compilation error when including any before including json header in C++17 mode [\#2129](https://github.com/nlohmann/json/issues/2129) -- Intersection of two json files [\#2127](https://github.com/nlohmann/json/issues/2127) -- App crashes when dump method called for non ascii chars. [\#2126](https://github.com/nlohmann/json/issues/2126) -- iterator based erase method [\#2122](https://github.com/nlohmann/json/issues/2122) -- quick and convenient api to get/set nested json values [\#2120](https://github.com/nlohmann/json/issues/2120) -- assigning nullptr to std::string [\#2118](https://github.com/nlohmann/json/issues/2118) -- usless\_cast warnings with gcc 9.3 and 10.1 \(C++17\) [\#2114](https://github.com/nlohmann/json/issues/2114) -- clang 10 warning [\#2113](https://github.com/nlohmann/json/issues/2113) -- Possible incorrect \_MSC\_VER reference [\#2112](https://github.com/nlohmann/json/issues/2112) -- warning under gcc 10.1 [\#2110](https://github.com/nlohmann/json/issues/2110) -- Wdeprecated-declarations from GCC v10.1.0 [\#2109](https://github.com/nlohmann/json/issues/2109) -- Global std::vector from json [\#2108](https://github.com/nlohmann/json/issues/2108) -- heap-buffer-overflow when using nlohmann/json, ASAN, and gtest [\#2107](https://github.com/nlohmann/json/issues/2107) -- exception 0x770DC5AF when i read an special char in json file [\#2106](https://github.com/nlohmann/json/issues/2106) -- json::parse\(\) fails to parse a dump\(2,' '\) output, yet does successfully parse dump\(\) [\#2105](https://github.com/nlohmann/json/issues/2105) -- run test-udt error in MSVC 19.16.27034.0 [\#2103](https://github.com/nlohmann/json/issues/2103) -- Unable to dump to stringstream [\#2102](https://github.com/nlohmann/json/issues/2102) -- Can't ad an object in another objet [\#2101](https://github.com/nlohmann/json/issues/2101) -- Implicit conversion causes "cannot use operator\[\] with a string argument with string" [\#2098](https://github.com/nlohmann/json/issues/2098) -- C++20: char8\_t [\#2097](https://github.com/nlohmann/json/issues/2097) -- Compilation issues when included in project [\#2094](https://github.com/nlohmann/json/issues/2094) -- string value with null character causes infinite loop [\#2093](https://github.com/nlohmann/json/issues/2093) -- corrupted size vs. prev\_size \(aborted\) [\#2092](https://github.com/nlohmann/json/issues/2092) -- Get string field content without return std::string copy [\#2091](https://github.com/nlohmann/json/issues/2091) -- JSON Comments \(JSON 5\) [\#2090](https://github.com/nlohmann/json/issues/2090) -- Remove \#include \ [\#2089](https://github.com/nlohmann/json/issues/2089) -- JSON library as a git submodule [\#2088](https://github.com/nlohmann/json/issues/2088) -- Apple Clang 11.0.3 on MacOS Catalina 10.15.4 not compiling [\#2087](https://github.com/nlohmann/json/issues/2087) -- Value function return empty object even if it exist [\#2086](https://github.com/nlohmann/json/issues/2086) -- Cannot debug but Run works [\#2085](https://github.com/nlohmann/json/issues/2085) -- Question about serialization. [\#2084](https://github.com/nlohmann/json/issues/2084) -- How to include in an external project [\#2083](https://github.com/nlohmann/json/issues/2083) -- Missing tests for binary values [\#2082](https://github.com/nlohmann/json/issues/2082) -- How to override default string serialization? [\#2079](https://github.com/nlohmann/json/issues/2079) -- Can't have a json type as a property in an arbitrary type [\#2078](https://github.com/nlohmann/json/issues/2078) -- New release? [\#2075](https://github.com/nlohmann/json/issues/2075) -- CMake FetchContent \> Updating the documentation? [\#2073](https://github.com/nlohmann/json/issues/2073) -- How to convert STL Vector \(of user defined type\) to Json [\#2072](https://github.com/nlohmann/json/issues/2072) -- how to make an array of objects [\#2070](https://github.com/nlohmann/json/issues/2070) -- ‘\_\_int64’ was not declared [\#2068](https://github.com/nlohmann/json/issues/2068) -- \[json.exception.type\_error.317\] cannot serialize binary data to text JSON [\#2067](https://github.com/nlohmann/json/issues/2067) -- Unexpected end of input; expected '\[', '{', or a literal [\#2066](https://github.com/nlohmann/json/issues/2066) -- Json structure can be nested? [\#2065](https://github.com/nlohmann/json/issues/2065) -- Bug: returning reference to local temporary object [\#2064](https://github.com/nlohmann/json/issues/2064) -- Allow to use non strict parsing [\#2063](https://github.com/nlohmann/json/issues/2063) -- Crashing on json::at [\#2062](https://github.com/nlohmann/json/issues/2062) -- How to convert a const std::vector\ message to a json, to be able to parse it and extract information from it? Can you point to any examples? [\#2058](https://github.com/nlohmann/json/issues/2058) -- Nice library [\#2057](https://github.com/nlohmann/json/issues/2057) -- json.hpp:15372:22: error: expected unqualified-id if \(not std::isfinite\(x\)\): Started getting this bug after updating my XCode [\#2056](https://github.com/nlohmann/json/issues/2056) -- Confused as how I can extract the values from the JSON object. [\#2055](https://github.com/nlohmann/json/issues/2055) -- Warnings with GCC 10 [\#2052](https://github.com/nlohmann/json/issues/2052) -- Warnings with Clang 10 [\#2049](https://github.com/nlohmann/json/issues/2049) -- Update doctest [\#2048](https://github.com/nlohmann/json/issues/2048) -- Unclear error message: "cannot use operator\[\] with a string argument with array" [\#2047](https://github.com/nlohmann/json/issues/2047) -- Serializing std::variant\\> [\#2045](https://github.com/nlohmann/json/issues/2045) -- Crash when parse big jsonfile [\#2042](https://github.com/nlohmann/json/issues/2042) -- How to check if a key exists without silently generating null objects on the path [\#2041](https://github.com/nlohmann/json/issues/2041) -- Crash when traversing over items\(\) of temporary json objects [\#2040](https://github.com/nlohmann/json/issues/2040) -- How to parse multiple line value ? [\#2039](https://github.com/nlohmann/json/issues/2039) -- SAX API uses unsigned std::size\_t but -1 if element size is not known; [\#2037](https://github.com/nlohmann/json/issues/2037) -- How to parse big decimal data [\#2036](https://github.com/nlohmann/json/issues/2036) -- how use template \ struct adl\_serializer [\#2035](https://github.com/nlohmann/json/issues/2035) -- auto iterator returned by find to handle value depending if is string or numeric. [\#2032](https://github.com/nlohmann/json/issues/2032) -- pass find returned iterator to numeric variable. [\#2031](https://github.com/nlohmann/json/issues/2031) -- Parse error on valid json file [\#2029](https://github.com/nlohmann/json/issues/2029) -- Is here any elegant way to combine serialization and deserialization code? [\#2028](https://github.com/nlohmann/json/issues/2028) -- Notes about dump function [\#2027](https://github.com/nlohmann/json/issues/2027) -- Different JSON printouts for empty dictionary on Linux and Mac. [\#2026](https://github.com/nlohmann/json/issues/2026) -- easier way to get exception reason out of json\_sax\_dom\_callback\_parser without exceptions [\#2024](https://github.com/nlohmann/json/issues/2024) -- Using fifo\_map with base class and derived class [\#2023](https://github.com/nlohmann/json/issues/2023) -- Error reading JSON File [\#2022](https://github.com/nlohmann/json/issues/2022) -- Parse causing crash on android. Cannot catch. [\#2021](https://github.com/nlohmann/json/issues/2021) -- Extra backslashes in nested json [\#2020](https://github.com/nlohmann/json/issues/2020) -- How to create patch for merge\_patch input ? [\#2018](https://github.com/nlohmann/json/issues/2018) -- CppUTest/include/CppUTestExt/MockSupport.h:40: error: default argument for ‘MockFailureReporter\* failureReporterForThisCall’ has type ‘void\*’ [\#2017](https://github.com/nlohmann/json/issues/2017) -- including another file [\#2016](https://github.com/nlohmann/json/issues/2016) -- GNU PREREQ Error with gcc 9.3.0 [\#2015](https://github.com/nlohmann/json/issues/2015) -- Parse error: json.exception.parse\_error.101 - invalid string: ill-formed UTF-8 byte [\#2014](https://github.com/nlohmann/json/issues/2014) -- Add more flexibility to basic\_json's ObjectType \(and ArrayType\) [\#2013](https://github.com/nlohmann/json/issues/2013) -- afl persistent mode [\#2012](https://github.com/nlohmann/json/issues/2012) -- Compiler Errors under VS2019 in Appveyor CI [\#2009](https://github.com/nlohmann/json/issues/2009) -- Another compilation failure with Visual Studio [\#2007](https://github.com/nlohmann/json/issues/2007) -- Implicit cast to std::string broken again with VS2019 16.5.0 [\#2006](https://github.com/nlohmann/json/issues/2006) -- error: no matching member function for call to 'AddRaw' [\#2005](https://github.com/nlohmann/json/issues/2005) -- When I re-create an object again after the network request, an error is reported [\#2003](https://github.com/nlohmann/json/issues/2003) -- How to merge \(and not replace\) different Json::Value objects in jsoncpp [\#2001](https://github.com/nlohmann/json/issues/2001) -- scalar transforms to list [\#2000](https://github.com/nlohmann/json/issues/2000) -- Dump JSON containing multibyte characters [\#1999](https://github.com/nlohmann/json/issues/1999) -- Build error when modify value [\#1998](https://github.com/nlohmann/json/issues/1998) -- How do i include a vector of pointers in my json? [\#1997](https://github.com/nlohmann/json/issues/1997) -- Compiler error wrt incomplete types changed in gcc8.3.0-26 [\#1996](https://github.com/nlohmann/json/issues/1996) -- NaN-like comparison behavior of discarded is inconvenient [\#1988](https://github.com/nlohmann/json/issues/1988) -- Maintaining JSON package in my CMake [\#1987](https://github.com/nlohmann/json/issues/1987) -- reading int number and string number [\#1986](https://github.com/nlohmann/json/issues/1986) -- Build error: keyword is hidden by macro definition! [\#1985](https://github.com/nlohmann/json/issues/1985) -- JSON patch diff for op=add formation is not as per standard \(RFC 6902\) [\#1983](https://github.com/nlohmann/json/issues/1983) -- json\_pointer.contains\(\) exception is incorrectly raised [\#1982](https://github.com/nlohmann/json/issues/1982) -- Error with non existing key [\#1981](https://github.com/nlohmann/json/issues/1981) -- Closed [\#1978](https://github.com/nlohmann/json/issues/1978) -- Where is the library built and what is the name? [\#1977](https://github.com/nlohmann/json/issues/1977) -- The cmake\_import example does not build [\#1976](https://github.com/nlohmann/json/issues/1976) -- Dumping core when reading invalid file [\#1975](https://github.com/nlohmann/json/issues/1975) -- Abort in dump\(\) method [\#1973](https://github.com/nlohmann/json/issues/1973) -- Unclear docs regarding parser\_callback\_t callbacks [\#1972](https://github.com/nlohmann/json/issues/1972) -- Possible memory leak on push\_back [\#1971](https://github.com/nlohmann/json/issues/1971) -- Is it possible to get a safe mutable reference/pointer to internal variant used in nlohmann json? [\#1970](https://github.com/nlohmann/json/issues/1970) -- Getting a flatten json to map\ [\#1957](https://github.com/nlohmann/json/issues/1957) -- forced type conversion or lexical cast without exception. [\#1955](https://github.com/nlohmann/json/issues/1955) -- Add json\_view type support to avoid excessive copying [\#1954](https://github.com/nlohmann/json/issues/1954) -- Adding "examples" section for real-life usages [\#1953](https://github.com/nlohmann/json/issues/1953) -- Add nlohmann::json::key\_type [\#1951](https://github.com/nlohmann/json/issues/1951) -- cannot use operator\[\] with a string argument with string [\#1949](https://github.com/nlohmann/json/issues/1949) -- std::ifstream \>\> json error [\#1948](https://github.com/nlohmann/json/issues/1948) -- Cannot update json data in an iterator? [\#1947](https://github.com/nlohmann/json/issues/1947) -- How can i build this library in VS 2017? [\#1943](https://github.com/nlohmann/json/issues/1943) -- json\_pointer.contains\(\) exceptions when path not found [\#1942](https://github.com/nlohmann/json/issues/1942) -- Nested objects serialize/deserialize [\#1941](https://github.com/nlohmann/json/issues/1941) -- Compile warning on architectures that are not x86 [\#1939](https://github.com/nlohmann/json/issues/1939) -- Version of nlohmann-json-dev in debian packages [\#1938](https://github.com/nlohmann/json/issues/1938) -- Create a json object for every cycle [\#1937](https://github.com/nlohmann/json/issues/1937) -- How to get the object name? [\#1936](https://github.com/nlohmann/json/issues/1936) -- Reserve and resize function for basic json [\#1935](https://github.com/nlohmann/json/issues/1935) -- How to use json parse in tsl::ordread\_map? [\#1934](https://github.com/nlohmann/json/issues/1934) -- C++14 support is not enabled with msvc2015 [\#1932](https://github.com/nlohmann/json/issues/1932) -- Need help with to\_json for derived class, keep getting "cannot use operator" [\#1931](https://github.com/nlohmann/json/issues/1931) -- How to handle std::vector\ [\#1930](https://github.com/nlohmann/json/issues/1930) -- Heap corruption issue [\#1929](https://github.com/nlohmann/json/issues/1929) -- Add `std::wistream` support. [\#1928](https://github.com/nlohmann/json/issues/1928) -- This i can write and read any file thanks [\#1927](https://github.com/nlohmann/json/issues/1927) -- How can I get this simple example working? [\#1926](https://github.com/nlohmann/json/issues/1926) -- emplace\_back does not seems to work with the int 0 [\#1925](https://github.com/nlohmann/json/issues/1925) -- Why nlohmann does not release memory [\#1924](https://github.com/nlohmann/json/issues/1924) -- Is it possible to have template `json::parse` with `noexcept` specifier? [\#1922](https://github.com/nlohmann/json/issues/1922) -- JSON to wstring? [\#1921](https://github.com/nlohmann/json/issues/1921) -- GCC 10 tests build failure [\#1920](https://github.com/nlohmann/json/issues/1920) -- Size of binary json representations [\#1919](https://github.com/nlohmann/json/issues/1919) -- Accessing strings \(for example in keys or values\) without having the lib create a copy of it. [\#1916](https://github.com/nlohmann/json/issues/1916) -- operator== documentation should show how to apply custom comparison function [\#1915](https://github.com/nlohmann/json/issues/1915) -- char8\_t and std::u8string support [\#1914](https://github.com/nlohmann/json/issues/1914) -- std::is\_pod is deprecated in C++20 [\#1913](https://github.com/nlohmann/json/issues/1913) -- Incomplete types reported by \(experimental\) GCC10 [\#1912](https://github.com/nlohmann/json/issues/1912) -- Compile warnings on MSVC 14.2 [\#1911](https://github.com/nlohmann/json/issues/1911) -- How to parse json file with type composition of std::optional and std::variant [\#1910](https://github.com/nlohmann/json/issues/1910) -- why root\_schema be implemented as unique\_ptr in json-validator.cpp,could I use it as shared\_ptr? [\#1908](https://github.com/nlohmann/json/issues/1908) -- compile error in gcc-6.3.0 [\#1906](https://github.com/nlohmann/json/issues/1906) -- Scalar constexpr is odr-used when used as json initializer [\#1905](https://github.com/nlohmann/json/issues/1905) -- install Slack app [\#1904](https://github.com/nlohmann/json/issues/1904) -- typo in a comment [\#1903](https://github.com/nlohmann/json/issues/1903) -- Watch JSON variables in Debug [\#1902](https://github.com/nlohmann/json/issues/1902) -- does Json sdk cares about dfc dfd utf8 issue? [\#1901](https://github.com/nlohmann/json/issues/1901) -- Allow multiple line string value in JSON [\#1897](https://github.com/nlohmann/json/issues/1897) -- Writing map to json file [\#1896](https://github.com/nlohmann/json/issues/1896) -- Small documentation mistake [\#1895](https://github.com/nlohmann/json/issues/1895) -- why static function `parse` cann't find in visual studio 2019 [\#1894](https://github.com/nlohmann/json/issues/1894) -- Best way to handle json files with missing key value pairs. [\#1893](https://github.com/nlohmann/json/issues/1893) -- accessing json object as multimap [\#1892](https://github.com/nlohmann/json/issues/1892) -- What is the best way to parse vec3s into glm::vec3 [\#1891](https://github.com/nlohmann/json/issues/1891) -- Get array of items without using vector [\#1890](https://github.com/nlohmann/json/issues/1890) -- Build errors \(clang 11.0.0\) on macOS 10.15.2 [\#1889](https://github.com/nlohmann/json/issues/1889) -- Multiple arrays to vectors help [\#1888](https://github.com/nlohmann/json/issues/1888) -- json::parse\(begin, end\) parse error on first character using uchar\* [\#1887](https://github.com/nlohmann/json/issues/1887) -- issue in free\(\) [\#1886](https://github.com/nlohmann/json/issues/1886) -- is\_number\_unsigned\(\) returns false for positive integers \(int or 0 or 1 literals\) [\#1885](https://github.com/nlohmann/json/issues/1885) -- MSVC build failure with /Zc:\_\_cplusplus and C++17 [\#1883](https://github.com/nlohmann/json/issues/1883) -- RFC 6901 op:replace & arrays [\#1882](https://github.com/nlohmann/json/issues/1882) -- Problem with serialization of my custom template doubly-linked list [\#1881](https://github.com/nlohmann/json/issues/1881) -- is\_array\(\) is True, but raise 'cannot use operator\[\] for object iterators' [\#1880](https://github.com/nlohmann/json/issues/1880) -- Serialize dynamic array [\#1879](https://github.com/nlohmann/json/issues/1879) -- Serialization of struct object. [\#1877](https://github.com/nlohmann/json/issues/1877) -- warning:c4503 [\#1875](https://github.com/nlohmann/json/issues/1875) -- Why are flattened empty objects/arrays not representable? [\#1874](https://github.com/nlohmann/json/issues/1874) -- Container Overflow \(ASAN\) when using operator \>\> on an ifs [\#1873](https://github.com/nlohmann/json/issues/1873) -- Sub-array to vector or map object? [\#1870](https://github.com/nlohmann/json/issues/1870) -- WIP: QT \(cute\) type supports [\#1869](https://github.com/nlohmann/json/issues/1869) -- Compiler flags to disable features and shrink code size [\#1868](https://github.com/nlohmann/json/issues/1868) -- null strings [\#1867](https://github.com/nlohmann/json/issues/1867) -- Struct with array of struct and \_\_attribute\_\_\(\(packed\)\) [\#1866](https://github.com/nlohmann/json/issues/1866) -- Best way to extract numbers in the string? [\#1865](https://github.com/nlohmann/json/issues/1865) -- Displaying \\?\Volume{guid} from string to json giving error [\#1864](https://github.com/nlohmann/json/issues/1864) -- not working when compiling as x86 [\#1863](https://github.com/nlohmann/json/issues/1863) -- Skipping evaluation of log line expressions with a macro, is it possible? [\#1862](https://github.com/nlohmann/json/issues/1862) -- Suppress warnings [\#1861](https://github.com/nlohmann/json/issues/1861) -- conflit with g++ compile option -mwindows [\#1860](https://github.com/nlohmann/json/issues/1860) -- How to serialize nested classes to semi-flat JSON object? [\#1859](https://github.com/nlohmann/json/issues/1859) -- Memory Requirement for large json file [\#1858](https://github.com/nlohmann/json/issues/1858) -- Query a binary format \(BSON, CBOR, MessagePack, UBJSON\) [\#1856](https://github.com/nlohmann/json/issues/1856) -- Documentation on operator\[\] behavior with missing keys [\#1855](https://github.com/nlohmann/json/issues/1855) -- Problem in converting string into JSON; Can't parse successfully. [\#1854](https://github.com/nlohmann/json/issues/1854) -- json.at\_or\_default\(key, defaultval\) [\#1852](https://github.com/nlohmann/json/issues/1852) -- please improve the enum conversion documentation \(my example gist provided\) [\#1851](https://github.com/nlohmann/json/issues/1851) -- Default value returned on ValueType nlohmann::basic\_json::value \(const typename object\_t::key\_type& key, const ValueType& default\_value\) [\#1850](https://github.com/nlohmann/json/issues/1850) -- Accounting for arbitrary precision numerical literals [\#1849](https://github.com/nlohmann/json/issues/1849) -- While trying to make a simple array, I get a nested array instead [\#1848](https://github.com/nlohmann/json/issues/1848) -- How to reuse the parser and serializer intermediate storage? [\#1847](https://github.com/nlohmann/json/issues/1847) -- Too much content in json.hpp leads to slow compilation [\#1845](https://github.com/nlohmann/json/issues/1845) -- Cannot read some data in json file [\#1843](https://github.com/nlohmann/json/issues/1843) -- Precompiled JSON library? [\#1842](https://github.com/nlohmann/json/issues/1842) -- Please change assert into throw\(maybe\) in line 17946 [\#1841](https://github.com/nlohmann/json/issues/1841) -- JSON for modern C++ ECCN information [\#1840](https://github.com/nlohmann/json/issues/1840) -- CI: reduce build time for Travis valgrind [\#1836](https://github.com/nlohmann/json/issues/1836) -- How do I traverse a json object and add new elements into the hierarchy [\#1834](https://github.com/nlohmann/json/issues/1834) -- Invalid UTF-8 byte at index 1: 0x65 [\#1831](https://github.com/nlohmann/json/issues/1831) -- Serialize big data in json [\#1828](https://github.com/nlohmann/json/issues/1828) -- Backslash '\' in value causes exception [\#1827](https://github.com/nlohmann/json/issues/1827) -- from\_json for non default constructible class with dependency injection [\#1819](https://github.com/nlohmann/json/issues/1819) -- Semi-frequent timeouts in `test-unicode_all` with 3.6.1 \(aarch64\) [\#1816](https://github.com/nlohmann/json/issues/1816) -- input\_adapter not user extensible [\#1813](https://github.com/nlohmann/json/issues/1813) -- crash at json::destroy on android [\#1812](https://github.com/nlohmann/json/issues/1812) -- Logs are repeating while cmake [\#1809](https://github.com/nlohmann/json/issues/1809) -- Add a the possibility to add dynamic json objects [\#1795](https://github.com/nlohmann/json/issues/1795) -- Unnecessary test data file in the release [\#1790](https://github.com/nlohmann/json/issues/1790) -- Add support for parse stack limiting [\#1788](https://github.com/nlohmann/json/issues/1788) -- GCC -Wuseless-cast warnings [\#1777](https://github.com/nlohmann/json/issues/1777) -- compilation issue with NVCC 9.0 [\#1773](https://github.com/nlohmann/json/issues/1773) -- Unexpected behavior with fifo\_map json when copy and append [\#1763](https://github.com/nlohmann/json/issues/1763) -- Parse error [\#1761](https://github.com/nlohmann/json/issues/1761) -- Assignment \(using value\(\)\) to nonexistent element behaves differently on Xcode 8 vs Xcode 10 [\#1758](https://github.com/nlohmann/json/issues/1758) -- Readme out of date [\#1756](https://github.com/nlohmann/json/issues/1756) -- cmake\_\* tests don't use the build system's compiler [\#1747](https://github.com/nlohmann/json/issues/1747) -- Static assertions for template type properties required [\#1729](https://github.com/nlohmann/json/issues/1729) -- Use float and possibly half in json::to\_cbor [\#1719](https://github.com/nlohmann/json/issues/1719) -- json::from\_cbor does not respect allow\_exceptions = false when input is string literal [\#1715](https://github.com/nlohmann/json/issues/1715) -- /Zc:\_\_cplusplus leads to C2416 [\#1695](https://github.com/nlohmann/json/issues/1695) -- `unflatten` vs objects with number-ish keys [\#1575](https://github.com/nlohmann/json/issues/1575) -- A "thinner" source code tar as part of release? [\#1572](https://github.com/nlohmann/json/issues/1572) -- Repository is almost 450MB [\#1497](https://github.com/nlohmann/json/issues/1497) -- Substantial performance penalty caused by polymorphic input adapter [\#1457](https://github.com/nlohmann/json/issues/1457) -- Move tests to a separate repo [\#1235](https://github.com/nlohmann/json/issues/1235) -- reduce repos size [\#1185](https://github.com/nlohmann/json/issues/1185) -- CMakeLists.txt in release zips? [\#1184](https://github.com/nlohmann/json/issues/1184) -- Minimal branch? [\#1066](https://github.com/nlohmann/json/issues/1066) -- Move test blobs to a submodule? [\#732](https://github.com/nlohmann/json/issues/732) -- \[Question\] When using this as git submodule, will it clone the whole thing include test data and benchmark? [\#620](https://github.com/nlohmann/json/issues/620) -- Need to improve ignores.. [\#567](https://github.com/nlohmann/json/issues/567) -- Minimal repository \(current size very large\) [\#556](https://github.com/nlohmann/json/issues/556) -- For a header-only library you have to clone 214MB [\#482](https://github.com/nlohmann/json/issues/482) -- 17 MB / 90 MB repo size!? [\#96](https://github.com/nlohmann/json/issues/96) - -- Improve parse\_ubjson\_fuzzer [\#2182](https://github.com/nlohmann/json/pull/2182) ([tanuj208](https://github.com/tanuj208)) -- Add input adapter tests [\#2178](https://github.com/nlohmann/json/pull/2178) ([nlohmann](https://github.com/nlohmann)) -- Fix warnings [\#2174](https://github.com/nlohmann/json/pull/2174) ([nlohmann](https://github.com/nlohmann)) -- Fix PR\#1006 [\#2158](https://github.com/nlohmann/json/pull/2158) ([dota17](https://github.com/dota17)) -- Fix issue\#1972 [\#2153](https://github.com/nlohmann/json/pull/2153) ([dota17](https://github.com/dota17)) -- Update URLs to HTTPS [\#2152](https://github.com/nlohmann/json/pull/2152) ([TotalCaesar659](https://github.com/TotalCaesar659)) -- Fix Issue\#1813: user defined input adapters [\#2145](https://github.com/nlohmann/json/pull/2145) ([FrancoisChabot](https://github.com/FrancoisChabot)) -- Fix issue\#1939: Cast character to unsigned for comparison [\#2144](https://github.com/nlohmann/json/pull/2144) ([XyFreak](https://github.com/XyFreak)) -- Fix issue\#2142: readme: fix typo in CMake FetchContent example [\#2143](https://github.com/nlohmann/json/pull/2143) ([quentin-dev](https://github.com/quentin-dev)) -- Respect allow\_exceptions=false for binary formats [\#2140](https://github.com/nlohmann/json/pull/2140) ([nlohmann](https://github.com/nlohmann)) -- Fix issue 2112 [\#2137](https://github.com/nlohmann/json/pull/2137) ([dota17](https://github.com/dota17)) -- Add bleeding edge GCC to CI [\#2136](https://github.com/nlohmann/json/pull/2136) ([aokellermann](https://github.com/aokellermann)) -- Clean up implementation of binary type [\#2125](https://github.com/nlohmann/json/pull/2125) ([nlohmann](https://github.com/nlohmann)) -- Fixed a compilation error in MSVC [\#2121](https://github.com/nlohmann/json/pull/2121) ([gistrec](https://github.com/gistrec)) -- Overwork CI [\#2119](https://github.com/nlohmann/json/pull/2119) ([nlohmann](https://github.com/nlohmann)) -- Fix warnings from Clang 10 and GCC 9 [\#2116](https://github.com/nlohmann/json/pull/2116) ([nlohmann](https://github.com/nlohmann)) -- Do not include \ when using C++17 [\#2115](https://github.com/nlohmann/json/pull/2115) ([nlohmann](https://github.com/nlohmann)) -- Fix issue\#2086: disallow json::value\_t type parameter in value\(\) [\#2104](https://github.com/nlohmann/json/pull/2104) ([dota17](https://github.com/dota17)) -- Fix Coveralls integration [\#2100](https://github.com/nlohmann/json/pull/2100) ([nlohmann](https://github.com/nlohmann)) -- Add tests for binary values [\#2099](https://github.com/nlohmann/json/pull/2099) ([nlohmann](https://github.com/nlohmann)) -- Use external test data [\#2081](https://github.com/nlohmann/json/pull/2081) ([nlohmann](https://github.com/nlohmann)) -- Remove Doozer CI [\#2080](https://github.com/nlohmann/json/pull/2080) ([nlohmann](https://github.com/nlohmann)) -- Fix README.md. Missing ``` [\#2077](https://github.com/nlohmann/json/pull/2077) ([ArthurSonzogni](https://github.com/ArthurSonzogni)) -- Fix error message about invalid surrogate pairs [\#2076](https://github.com/nlohmann/json/pull/2076) ([rmisev](https://github.com/rmisev)) -- Add CMake fetchcontent documentation and tests [\#2074](https://github.com/nlohmann/json/pull/2074) ([ArthurSonzogni](https://github.com/ArthurSonzogni)) -- Properly pass serialize\_binary to dump function [\#2071](https://github.com/nlohmann/json/pull/2071) ([nlohmann](https://github.com/nlohmann)) -- Fix returning reference to local temporary object [\#2069](https://github.com/nlohmann/json/pull/2069) ([nlohmann](https://github.com/nlohmann)) -- updated wandbox link [\#2060](https://github.com/nlohmann/json/pull/2060) ([alexandermyasnikov](https://github.com/alexandermyasnikov)) -- Fix bug in diff function [\#2054](https://github.com/nlohmann/json/pull/2054) ([nlohmann](https://github.com/nlohmann)) -- Fix GCC compiler warnings [\#2053](https://github.com/nlohmann/json/pull/2053) ([nlohmann](https://github.com/nlohmann)) -- Fix Clang compiler warnings [\#2051](https://github.com/nlohmann/json/pull/2051) ([nlohmann](https://github.com/nlohmann)) -- Update doctest to 2.3.7 [\#2050](https://github.com/nlohmann/json/pull/2050) ([nlohmann](https://github.com/nlohmann)) -- Fix issue\#1719 [\#2044](https://github.com/nlohmann/json/pull/2044) ([dota17](https://github.com/dota17)) -- Add missing testcase about NaN in unit-constructor1.cpp [\#2043](https://github.com/nlohmann/json/pull/2043) ([dota17](https://github.com/dota17)) -- Templatize basic\_json constructor from json\_ref [\#2034](https://github.com/nlohmann/json/pull/2034) ([ArtemSarmini](https://github.com/ArtemSarmini)) -- Replace deprecated std::is\_pod [\#2033](https://github.com/nlohmann/json/pull/2033) ([nlohmann](https://github.com/nlohmann)) -- Fixes \#1971 \(memory leak in basic\_json::push\_back\) [\#2025](https://github.com/nlohmann/json/pull/2025) ([ArtemSarmini](https://github.com/ArtemSarmini)) -- fix \#1982:json\_pointer.contains\(\) exception is incorrectly raised [\#2019](https://github.com/nlohmann/json/pull/2019) ([dota17](https://github.com/dota17)) -- Update LICENSE.MIT [\#2010](https://github.com/nlohmann/json/pull/2010) ([magamig](https://github.com/magamig)) -- PR for \#2006 to test in AppVeyor. [\#2008](https://github.com/nlohmann/json/pull/2008) ([garethsb](https://github.com/garethsb)) -- Added wsjcpp.yml [\#2004](https://github.com/nlohmann/json/pull/2004) ([sea-kg](https://github.com/sea-kg)) -- fix error 'setw' is not a member of 'std' in Wandbox example [\#2002](https://github.com/nlohmann/json/pull/2002) ([alexandermyasnikov](https://github.com/alexandermyasnikov)) -- catch exceptions for json\_pointer : ..../+99 [\#1990](https://github.com/nlohmann/json/pull/1990) ([dota17](https://github.com/dota17)) -- Modify the document about operator== [\#1984](https://github.com/nlohmann/json/pull/1984) ([dota17](https://github.com/dota17)) -- Rename argument array\_index to array\_indx in json\_pointer methods [\#1980](https://github.com/nlohmann/json/pull/1980) ([linev](https://github.com/linev)) -- README: Fix string representation of `dump`ed `json` [\#1979](https://github.com/nlohmann/json/pull/1979) ([alexweej](https://github.com/alexweej)) -- fix warnings in serializer.hpp for VS2019 [\#1969](https://github.com/nlohmann/json/pull/1969) ([dota17](https://github.com/dota17)) -- Fix C26451 warnnings in to\_chars.hpp [\#1967](https://github.com/nlohmann/json/pull/1967) ([dota17](https://github.com/dota17)) -- appveyor.yml: Compile and test with latest version for \_\_cplusplus ma… [\#1958](https://github.com/nlohmann/json/pull/1958) ([t-b](https://github.com/t-b)) -- Fix typo in examples [\#1956](https://github.com/nlohmann/json/pull/1956) ([dota17](https://github.com/dota17)) -- templated input adapters [\#1950](https://github.com/nlohmann/json/pull/1950) ([FrancoisChabot](https://github.com/FrancoisChabot)) -- Update README.md : add a FAQ about memory release [\#1933](https://github.com/nlohmann/json/pull/1933) ([dota17](https://github.com/dota17)) -- Some typos [\#1923](https://github.com/nlohmann/json/pull/1923) ([Coeur](https://github.com/Coeur)) -- Fix link to parse function in README [\#1918](https://github.com/nlohmann/json/pull/1918) ([kastiglione](https://github.com/kastiglione)) -- Readme: Updated links to hunter repo & docs [\#1917](https://github.com/nlohmann/json/pull/1917) ([jothepro](https://github.com/jothepro)) -- Adds instruction for using Build2's package manager [\#1909](https://github.com/nlohmann/json/pull/1909) ([Klaim](https://github.com/Klaim)) -- Update README.md [\#1907](https://github.com/nlohmann/json/pull/1907) ([pauljurczak](https://github.com/pauljurczak)) -- Fix warning: ignoring return value [\#1871](https://github.com/nlohmann/json/pull/1871) ([sonulohani](https://github.com/sonulohani)) -- docs: add central repository as conan source to readme [\#1857](https://github.com/nlohmann/json/pull/1857) ([gocarlos](https://github.com/gocarlos)) -- README: Package in MSYS2 renamed to nlohmann-json [\#1853](https://github.com/nlohmann/json/pull/1853) ([podsvirov](https://github.com/podsvirov)) -- Fix msvc warnings [\#1846](https://github.com/nlohmann/json/pull/1846) ([MBalszun](https://github.com/MBalszun)) -- Update tests that generate CMake projects to use main project's C++ compiler [\#1844](https://github.com/nlohmann/json/pull/1844) ([Tridacnid](https://github.com/Tridacnid)) -- make CMake's version config file architecture-independent [\#1746](https://github.com/nlohmann/json/pull/1746) ([uhoreg](https://github.com/uhoreg)) -- Add binary type support to all binary file formats, as well as an internally represented binary type [\#1662](https://github.com/nlohmann/json/pull/1662) ([OmnipotentEntity](https://github.com/OmnipotentEntity)) - -## [v3.7.3](https://github.com/nlohmann/json/releases/tag/v3.7.3) (2019-11-17) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.7.2...v3.7.3) - -- Project branches [\#1839](https://github.com/nlohmann/json/issues/1839) -- Quadratic destruction complexity introduced in \#1436 [\#1837](https://github.com/nlohmann/json/issues/1837) -- Trying to open a file [\#1814](https://github.com/nlohmann/json/issues/1814) -- Comparing data type with value\_t::number\_integer fails [\#1783](https://github.com/nlohmann/json/issues/1783) -- CMake version config file is architecture-dependent [\#1697](https://github.com/nlohmann/json/issues/1697) - -- Fix quadratic destruction complexity [\#1838](https://github.com/nlohmann/json/pull/1838) ([nickaein](https://github.com/nickaein)) - -## [v3.7.2](https://github.com/nlohmann/json/releases/tag/v3.7.2) (2019-11-10) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.7.1...v3.7.2) - -- Segmentation fault in destructor in case of large inputs [\#1835](https://github.com/nlohmann/json/issues/1835) -- type\_name\(\) is not consistent with type\(\) [\#1833](https://github.com/nlohmann/json/issues/1833) -- json::parse is not a member [\#1832](https://github.com/nlohmann/json/issues/1832) -- How do you deal with json\* ? [\#1829](https://github.com/nlohmann/json/issues/1829) -- Combined find\_package/add\_subdirectory not linking libraries [\#1771](https://github.com/nlohmann/json/issues/1771) -- example code for ifstream reading a json file results in no operator error [\#1766](https://github.com/nlohmann/json/issues/1766) -- Warning: unsequenced modification and access to 'range' [\#1674](https://github.com/nlohmann/json/issues/1674) -- Segmentation fault \(stack overflow\) due to unbounded recursion [\#1419](https://github.com/nlohmann/json/issues/1419) -- Stack-overflow \(OSS-Fuzz 4234\) [\#832](https://github.com/nlohmann/json/issues/832) - -- Configure WhiteSource Bolt for GitHub [\#1830](https://github.com/nlohmann/json/pull/1830) ([mend-bolt-for-github[bot]](https://github.com/apps/mend-bolt-for-github)) -- Prevent stackoverflow caused by recursive deconstruction [\#1436](https://github.com/nlohmann/json/pull/1436) ([nickaein](https://github.com/nickaein)) - -## [v3.7.1](https://github.com/nlohmann/json/releases/tag/v3.7.1) (2019-11-06) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.7.0...v3.7.1) - -- std::is\_constructible is always true with tuple [\#1825](https://github.com/nlohmann/json/issues/1825) -- Can't compile from\_json\(std::valarray\\). [\#1824](https://github.com/nlohmann/json/issues/1824) -- json class should have a get\_or member function [\#1823](https://github.com/nlohmann/json/issues/1823) -- NLOHMANN\_JSON\_SERIALIZE\_ENUM macro capture's json objects by value [\#1822](https://github.com/nlohmann/json/issues/1822) -- Parse fails when number literals start with zero [\#1820](https://github.com/nlohmann/json/issues/1820) -- Weird behaviour of `contains` with `json_pointer` [\#1815](https://github.com/nlohmann/json/issues/1815) -- strange behaviour with json\_pointer and .contains\(\) [\#1811](https://github.com/nlohmann/json/issues/1811) -- Can \#1695 be re-opened? [\#1808](https://github.com/nlohmann/json/issues/1808) -- Merge two json objects [\#1807](https://github.com/nlohmann/json/issues/1807) -- std::is\_constructible\\> when to\_json not defined [\#1805](https://github.com/nlohmann/json/issues/1805) -- Private data on parsing [\#1802](https://github.com/nlohmann/json/issues/1802) -- Capturing Line and Position when querying [\#1800](https://github.com/nlohmann/json/issues/1800) -- json error on parsing DBL\_MAX from string [\#1796](https://github.com/nlohmann/json/issues/1796) -- De/Serialisation of vector of tupple object with nested obect need Help please [\#1794](https://github.com/nlohmann/json/issues/1794) -- Output json is corrupted [\#1793](https://github.com/nlohmann/json/issues/1793) -- variable name byte sometimes used as a \#define [\#1792](https://github.com/nlohmann/json/issues/1792) -- Can't read json file [\#1791](https://github.com/nlohmann/json/issues/1791) -- Problems with special German letters [\#1789](https://github.com/nlohmann/json/issues/1789) -- Support for trailing commas [\#1787](https://github.com/nlohmann/json/issues/1787) -- json\_pointer construction bug [\#1786](https://github.com/nlohmann/json/issues/1786) -- Visual Studio 2017 warning [\#1784](https://github.com/nlohmann/json/issues/1784) -- ciso646 header become obsolete [\#1782](https://github.com/nlohmann/json/issues/1782) -- Migrate LGTM.com installation from OAuth to GitHub App [\#1781](https://github.com/nlohmann/json/issues/1781) -- JSON comparison, contains and operator& [\#1778](https://github.com/nlohmann/json/issues/1778) -- pass a json object to a class contructor adds an array around the object [\#1776](https://github.com/nlohmann/json/issues/1776) -- 'Float' number\_float\_function\_t template parameter name conflicts with C '\#define Float float' [\#1775](https://github.com/nlohmann/json/issues/1775) -- A weird building problem :-\( [\#1774](https://github.com/nlohmann/json/issues/1774) -- What is this json\_ref? [\#1772](https://github.com/nlohmann/json/issues/1772) -- Interoperability with other languages [\#1770](https://github.com/nlohmann/json/issues/1770) -- Json dump [\#1768](https://github.com/nlohmann/json/issues/1768) -- json\_pointer\<\>::back\(\) should be const [\#1764](https://github.com/nlohmann/json/issues/1764) -- How to get value from array [\#1762](https://github.com/nlohmann/json/issues/1762) -- Merge two jsons [\#1757](https://github.com/nlohmann/json/issues/1757) -- Unable to locate nlohmann\_jsonConfig.cmake [\#1755](https://github.com/nlohmann/json/issues/1755) -- json.hpp won;t compile VS2019 CLR/CLI app but does in console app [\#1754](https://github.com/nlohmann/json/issues/1754) -- \[Nested Json Objects\] Segmentation fault [\#1753](https://github.com/nlohmann/json/issues/1753) -- remove/replace assert with exceptions [\#1752](https://github.com/nlohmann/json/issues/1752) -- Add array support for update\(\) function [\#1751](https://github.com/nlohmann/json/issues/1751) -- Is there a reason the `get_to` method is defined in `include/nlohmann/json.hpp` but not in `single_include/nlohmann/json.hpp`? [\#1750](https://github.com/nlohmann/json/issues/1750) -- how to validate json object before calling dump\(\) [\#1748](https://github.com/nlohmann/json/issues/1748) -- Unable to invoke accessors on json objects in lldb [\#1745](https://github.com/nlohmann/json/issues/1745) -- Escaping string before parsing [\#1743](https://github.com/nlohmann/json/issues/1743) -- Construction in a member initializer list using curly braces is set as 'array' [\#1742](https://github.com/nlohmann/json/issues/1742) -- Read a subkey from json object [\#1740](https://github.com/nlohmann/json/issues/1740) -- Serialize vector of glm:vec2 [\#1739](https://github.com/nlohmann/json/issues/1739) -- Support nlohmann::basic\_json::value with JSON\_NOEXCEPTION [\#1738](https://github.com/nlohmann/json/issues/1738) -- how to know the parse is error [\#1737](https://github.com/nlohmann/json/issues/1737) -- How to check if a given key exists in a JSON object [\#1736](https://github.com/nlohmann/json/issues/1736) -- Allow The Colon Key-Value Delimiter To Have A Space Before It \[@ READ ONLY\] [\#1735](https://github.com/nlohmann/json/issues/1735) -- Allow Tail { "Key": "Value" } Comma \[@ READ ONLY\] [\#1734](https://github.com/nlohmann/json/issues/1734) -- No-throw json::value\(\) [\#1733](https://github.com/nlohmann/json/issues/1733) -- JsonObject.dump\(\) [\#1732](https://github.com/nlohmann/json/issues/1732) -- basic\_json has no member "parse" [\#1731](https://github.com/nlohmann/json/issues/1731) -- Exception "type must be string, but is array" [\#1730](https://github.com/nlohmann/json/issues/1730) -- json::contains usage to find a path [\#1727](https://github.com/nlohmann/json/issues/1727) -- How to create JSON Object from my Structures of Data and Json File from that Object [\#1726](https://github.com/nlohmann/json/issues/1726) -- please provide an API to read JSON from file directly. [\#1725](https://github.com/nlohmann/json/issues/1725) -- How to modify a value stored at a key? [\#1723](https://github.com/nlohmann/json/issues/1723) -- CMake not correctly finding the configuration package for 3.7.0 [\#1721](https://github.com/nlohmann/json/issues/1721) -- name typo in the "spack package management" section of README.md [\#1720](https://github.com/nlohmann/json/issues/1720) -- How to add json to another json? [\#1718](https://github.com/nlohmann/json/issues/1718) -- json::parse\(\) ubsan regression with v3.7.0 [\#1716](https://github.com/nlohmann/json/issues/1716) -- What I am doing wrong?!? [\#1714](https://github.com/nlohmann/json/issues/1714) -- Potential memory leak detected by Valgrind [\#1713](https://github.com/nlohmann/json/issues/1713) -- json::parse is not thread safe? [\#1712](https://github.com/nlohmann/json/issues/1712) -- static analysis alarm by cppcheck [\#1711](https://github.com/nlohmann/json/issues/1711) -- The compilation time is slow [\#1710](https://github.com/nlohmann/json/issues/1710) -- not linking properly with cmake [\#1709](https://github.com/nlohmann/json/issues/1709) -- Error in dump\(\) with int64\_t minimum value [\#1708](https://github.com/nlohmann/json/issues/1708) -- Crash on trying to deserialize json string on 3ds homebrew [\#1707](https://github.com/nlohmann/json/issues/1707) -- Can't compile VS2019. 13 Errors [\#1706](https://github.com/nlohmann/json/issues/1706) -- find an object that matches the search criteria [\#1705](https://github.com/nlohmann/json/issues/1705) -- IntelliSense goes crazy on VS2019 [\#1704](https://github.com/nlohmann/json/issues/1704) -- Installing on Ubuntu 16.04 [\#1703](https://github.com/nlohmann/json/issues/1703) -- Where is json::parse now? [\#1702](https://github.com/nlohmann/json/issues/1702) -- Forward header should't be amalgamated [\#1700](https://github.com/nlohmann/json/issues/1700) -- Json support for Cmake version 2.8.12 [\#1699](https://github.com/nlohmann/json/issues/1699) -- Intruisive scientific notation when using .dump\(\); [\#1698](https://github.com/nlohmann/json/issues/1698) -- Is there support for automatic serialization/deserialization? [\#1696](https://github.com/nlohmann/json/issues/1696) -- on MSVC dump\(\) will hard crash for larger json [\#1693](https://github.com/nlohmann/json/issues/1693) -- puzzled implicit conversions [\#1692](https://github.com/nlohmann/json/issues/1692) -- Information: My project uses this awesome library [\#1691](https://github.com/nlohmann/json/issues/1691) -- Consider listing files explicitly instead of using GLOB [\#1686](https://github.com/nlohmann/json/issues/1686) -- Failing tests on MSVC with VS2019 15.9.13 x64 [\#1685](https://github.com/nlohmann/json/issues/1685) -- Change from v2 to v3. Encoding with cp1252 [\#1680](https://github.com/nlohmann/json/issues/1680) -- How to add Fifo\_map into json using Cmake [\#1679](https://github.com/nlohmann/json/issues/1679) -- include.zip should contain meson.build [\#1672](https://github.com/nlohmann/json/issues/1672) -- \[Question\] How do I parse JSON into custom types? [\#1669](https://github.com/nlohmann/json/issues/1669) -- Binary \(0x05\) data type for BSON to JSON conversion [\#1668](https://github.com/nlohmann/json/issues/1668) -- Possible to call dump from lldb? [\#1666](https://github.com/nlohmann/json/issues/1666) -- Segmentation fault when linked with libunwind [\#1665](https://github.com/nlohmann/json/issues/1665) -- Should I include single-header after my to\_json and from\_json custom functions declaration? Why not? [\#1663](https://github.com/nlohmann/json/issues/1663) -- Errors/Warnings in VS 2019 when Including Header File [\#1659](https://github.com/nlohmann/json/issues/1659) -- Return null object from object's const operator\[\] as well. [\#1658](https://github.com/nlohmann/json/issues/1658) -- Can't stream json object in to std::basic\_stringstream\ [\#1656](https://github.com/nlohmann/json/issues/1656) -- C2440 in vs2015 cannot convert from 'initializer-list' to nlohmann::basic\_json [\#1655](https://github.com/nlohmann/json/issues/1655) -- Issues around get and pointers [\#1653](https://github.com/nlohmann/json/issues/1653) -- Non-member operator== breaks enum \(de\)serialization [\#1647](https://github.com/nlohmann/json/issues/1647) -- Valgrind: bytes in 1 blocks are definitely lost [\#1646](https://github.com/nlohmann/json/issues/1646) -- Convenient way to make 'basic\_json' accept 'QString' as an key type as well? [\#1640](https://github.com/nlohmann/json/issues/1640) -- mongodb: nan, inf [\#1599](https://github.com/nlohmann/json/issues/1599) -- Error in adl\_serializer [\#1590](https://github.com/nlohmann/json/issues/1590) -- Injecting class during serialization [\#1584](https://github.com/nlohmann/json/issues/1584) -- output\_adapter not user extensible [\#1534](https://github.com/nlohmann/json/issues/1534) -- Inclusion of nlohmann/json.hpp causes OS/ABI to change on Linux [\#1410](https://github.com/nlohmann/json/issues/1410) -- Add library versioning using inline namespaces [\#1394](https://github.com/nlohmann/json/issues/1394) -- CBOR byte string support [\#1129](https://github.com/nlohmann/json/issues/1129) -- How to deserialize array with derived objects [\#716](https://github.com/nlohmann/json/issues/716) - -- Add restriction for tuple specialization of to\_json [\#1826](https://github.com/nlohmann/json/pull/1826) ([cbegue](https://github.com/cbegue)) -- Fix for \#1647 [\#1821](https://github.com/nlohmann/json/pull/1821) ([AnthonyVH](https://github.com/AnthonyVH)) -- Fix issue \#1805 [\#1806](https://github.com/nlohmann/json/pull/1806) ([cbegue](https://github.com/cbegue)) -- Fix some spelling errors - mostly in comments & documentation. [\#1803](https://github.com/nlohmann/json/pull/1803) ([flopp](https://github.com/flopp)) -- Update Hedley to v11. [\#1799](https://github.com/nlohmann/json/pull/1799) ([nemequ](https://github.com/nemequ)) -- iteration\_proxy: Fix integer truncation from std::size\_t to int [\#1797](https://github.com/nlohmann/json/pull/1797) ([t-b](https://github.com/t-b)) -- appveyor.yml: Add MSVC 16 2019 support [\#1780](https://github.com/nlohmann/json/pull/1780) ([t-b](https://github.com/t-b)) -- test/CMakeLists.txt: Use an explicit list instead of GLOB [\#1779](https://github.com/nlohmann/json/pull/1779) ([t-b](https://github.com/t-b)) -- Make json\_pointer::back const \(resolves \#1764\) [\#1769](https://github.com/nlohmann/json/pull/1769) ([chris0x44](https://github.com/chris0x44)) -- did you mean 'serialization'? [\#1767](https://github.com/nlohmann/json/pull/1767) ([0xflotus](https://github.com/0xflotus)) -- Allow items\(\) to be used with custom string [\#1765](https://github.com/nlohmann/json/pull/1765) ([crazyjul](https://github.com/crazyjul)) -- Cppcheck fixes [\#1760](https://github.com/nlohmann/json/pull/1760) ([Xav83](https://github.com/Xav83)) -- Fix and add test's for SFINAE problem [\#1741](https://github.com/nlohmann/json/pull/1741) ([tete17](https://github.com/tete17)) -- Fix clang sanitizer invocation [\#1728](https://github.com/nlohmann/json/pull/1728) ([t-b](https://github.com/t-b)) -- Add gcc 9 and compile with experimental C++20 support [\#1724](https://github.com/nlohmann/json/pull/1724) ([t-b](https://github.com/t-b)) -- Fix int64 min issue [\#1722](https://github.com/nlohmann/json/pull/1722) ([t-b](https://github.com/t-b)) -- release: add singleinclude and meson.build to include.zip [\#1694](https://github.com/nlohmann/json/pull/1694) ([eli-schwartz](https://github.com/eli-schwartz)) - -## [v3.7.0](https://github.com/nlohmann/json/releases/tag/v3.7.0) (2019-07-28) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.6.1...v3.7.0) - -- How can I retrieve uknown strings from json file in my C++ program. [\#1684](https://github.com/nlohmann/json/issues/1684) -- contains\(\) is sometimes causing stack-based buffer overrun exceptions [\#1683](https://github.com/nlohmann/json/issues/1683) -- How to deserialize arrays from json [\#1681](https://github.com/nlohmann/json/issues/1681) -- Compilation failed in VS2015 [\#1678](https://github.com/nlohmann/json/issues/1678) -- Why the compiled object file is so huge? [\#1677](https://github.com/nlohmann/json/issues/1677) -- From Version 2.1.1 to 3.6.1 serialize std::set [\#1676](https://github.com/nlohmann/json/issues/1676) -- Qt deprecation model halting compiltion [\#1675](https://github.com/nlohmann/json/issues/1675) -- Build For Raspberry pi , Rapbery with new Compiler C++17 [\#1671](https://github.com/nlohmann/json/issues/1671) -- Build from Raspberry pi [\#1667](https://github.com/nlohmann/json/issues/1667) -- Can not translate map with integer key to dict string ? [\#1664](https://github.com/nlohmann/json/issues/1664) -- Double type converts to scientific notation [\#1661](https://github.com/nlohmann/json/issues/1661) -- Missing v3.6.1 tag on master branch [\#1657](https://github.com/nlohmann/json/issues/1657) -- Support Fleese Binary Data Format [\#1654](https://github.com/nlohmann/json/issues/1654) -- Suggestion: replace alternative tokens for !, && and || with their symbols [\#1652](https://github.com/nlohmann/json/issues/1652) -- Build failure test-allocator.vcxproj [\#1651](https://github.com/nlohmann/json/issues/1651) -- How to provide function json& to\_json\(\) which is similar as 'void to\_json\(json&j, const CObject& obj\)' ? [\#1650](https://github.com/nlohmann/json/issues/1650) -- Can't throw exception when starting file is a number [\#1649](https://github.com/nlohmann/json/issues/1649) -- to\_json / from\_json with nested type [\#1648](https://github.com/nlohmann/json/issues/1648) -- How to create a json object from a std::string, created by j.dump? [\#1645](https://github.com/nlohmann/json/issues/1645) -- Problem getting vector \(array\) of strings [\#1644](https://github.com/nlohmann/json/issues/1644) -- json.hpp compilation issue with other typedefs with same name [\#1642](https://github.com/nlohmann/json/issues/1642) -- nlohmann::adl\_serializer\::to\_json no matching overloaded function found [\#1641](https://github.com/nlohmann/json/issues/1641) -- overwrite adl\_serializer\ to change behaviour [\#1638](https://github.com/nlohmann/json/issues/1638) -- json.SelectToken\("Manufacturers.Products.Price"\); [\#1637](https://github.com/nlohmann/json/issues/1637) -- Add json type as value [\#1636](https://github.com/nlohmann/json/issues/1636) -- Unit conversion test error: conversion from 'nlohmann::json' to non-scalar type 'std::string\_view' requested [\#1634](https://github.com/nlohmann/json/issues/1634) -- nlohmann VS JsonCpp by C++17 [\#1633](https://github.com/nlohmann/json/issues/1633) -- To integrate an inline helper function that return type name as string [\#1632](https://github.com/nlohmann/json/issues/1632) -- Return JSON as reference [\#1631](https://github.com/nlohmann/json/issues/1631) -- Updating from an older version causes problems with assing a json object to a struct [\#1630](https://github.com/nlohmann/json/issues/1630) -- Can without default constructor function for user defined classes when only to\_json is needed? [\#1629](https://github.com/nlohmann/json/issues/1629) -- Compilation fails with clang 6.x-8.x in C++14 mode [\#1628](https://github.com/nlohmann/json/issues/1628) -- Treating floating point as string [\#1627](https://github.com/nlohmann/json/issues/1627) -- error parsing character å [\#1626](https://github.com/nlohmann/json/issues/1626) -- \[Help\] How to Improve Json Output Performance with Large Json Arrays [\#1624](https://github.com/nlohmann/json/issues/1624) -- Suggested link changes for reporting new issues \[blob/develop/REAME.md and blob/develop/.github/CONTRIBUTING.md\] [\#1623](https://github.com/nlohmann/json/issues/1623) -- Broken link to issue template in CONTRIBUTING.md [\#1622](https://github.com/nlohmann/json/issues/1622) -- Missing word in README.md file [\#1621](https://github.com/nlohmann/json/issues/1621) -- Package manager instructions in README for brew is incorrect [\#1620](https://github.com/nlohmann/json/issues/1620) -- Building with Visual Studio 2019 [\#1619](https://github.com/nlohmann/json/issues/1619) -- Precedence of to\_json and builtin harmful [\#1617](https://github.com/nlohmann/json/issues/1617) -- The type json is missing from the html documentation [\#1616](https://github.com/nlohmann/json/issues/1616) -- variant is not support in Release 3.6.1? [\#1615](https://github.com/nlohmann/json/issues/1615) -- Replace assert with throw for const operator\[\] [\#1614](https://github.com/nlohmann/json/issues/1614) -- Memory Overhead is Too High \(10x or more\) [\#1613](https://github.com/nlohmann/json/issues/1613) -- program crash everytime, when other data type incomming in json stream as expected [\#1612](https://github.com/nlohmann/json/issues/1612) -- Improved Enum Support [\#1611](https://github.com/nlohmann/json/issues/1611) -- is it possible convert json object back to stl container ? [\#1610](https://github.com/nlohmann/json/issues/1610) -- Add C++17-like emplace.back\(\) for arrays. [\#1609](https://github.com/nlohmann/json/issues/1609) -- is\_nothrow\_copy\_constructible fails for json::const\_iterator on MSVC2015 x86 Debug build [\#1608](https://github.com/nlohmann/json/issues/1608) -- Reading and writing array elements [\#1607](https://github.com/nlohmann/json/issues/1607) -- Converting json::value to int [\#1605](https://github.com/nlohmann/json/issues/1605) -- I have a vector of keys and and a string of value and i want to create nested json array [\#1604](https://github.com/nlohmann/json/issues/1604) -- In compatible JSON object from nlohmann::json to nohman::json - unexpected end of input; expected '\[', '{', or a literal [\#1603](https://github.com/nlohmann/json/issues/1603) -- json parser crash if having a large number integer in message [\#1602](https://github.com/nlohmann/json/issues/1602) -- Value method with undocumented throwing 302 exception [\#1601](https://github.com/nlohmann/json/issues/1601) -- Accessing value with json pointer adds key if not existing [\#1600](https://github.com/nlohmann/json/issues/1600) -- README.md broken link to project documentation [\#1597](https://github.com/nlohmann/json/issues/1597) -- Random Kudos: Thanks for your work on this! [\#1596](https://github.com/nlohmann/json/issues/1596) -- json::parse return value and errors [\#1595](https://github.com/nlohmann/json/issues/1595) -- initializer list constructor makes curly brace initialization fragile [\#1594](https://github.com/nlohmann/json/issues/1594) -- trying to log message for missing keyword, difference between \["foo"\] and at\("foo"\) [\#1593](https://github.com/nlohmann/json/issues/1593) -- std::string and std::wstring `to_json` [\#1592](https://github.com/nlohmann/json/issues/1592) -- I have a C structure which I need to convert to a JSON. How do I do it? Haven't found proper examples so far. [\#1591](https://github.com/nlohmann/json/issues/1591) -- dump\_escaped possible error ? [\#1589](https://github.com/nlohmann/json/issues/1589) -- json::parse\(\) into a vector\ results in unhandled exception [\#1587](https://github.com/nlohmann/json/issues/1587) -- push\_back\(\)/emplace\_back\(\) on array invalidates pointers to existing array items [\#1586](https://github.com/nlohmann/json/issues/1586) -- Getting nlohmann::detail::parse\_error on JSON generated by nlohmann::json not sure why [\#1583](https://github.com/nlohmann/json/issues/1583) -- getting error terminate called after throwing an instance of 'std::domain\_error' what\(\): cannot use at\(\) with string [\#1582](https://github.com/nlohmann/json/issues/1582) -- how i create json file [\#1581](https://github.com/nlohmann/json/issues/1581) -- prevent rounding of double datatype values [\#1580](https://github.com/nlohmann/json/issues/1580) -- Documentation Container Overview Doesn't Reference Const Methods [\#1579](https://github.com/nlohmann/json/issues/1579) -- Writing an array into a nlohmann::json object [\#1578](https://github.com/nlohmann/json/issues/1578) -- compilation error when using with another library [\#1577](https://github.com/nlohmann/json/issues/1577) -- Homebrew on OSX doesn't install cmake config file [\#1576](https://github.com/nlohmann/json/issues/1576) -- JSON Parse Out of Range Error [\#1574](https://github.com/nlohmann/json/issues/1574) -- Integrating into existing CMake Project [\#1573](https://github.com/nlohmann/json/issues/1573) -- conversion to std::string failed [\#1571](https://github.com/nlohmann/json/issues/1571) -- jPtr operation does not throw [\#1569](https://github.com/nlohmann/json/issues/1569) -- How to generate dll file for this project [\#1568](https://github.com/nlohmann/json/issues/1568) -- how to pass variable data to json in c [\#1567](https://github.com/nlohmann/json/issues/1567) -- I want to achieve an upgraded function. [\#1566](https://github.com/nlohmann/json/issues/1566) -- How to determine the type of elements read from a JSON array? [\#1564](https://github.com/nlohmann/json/issues/1564) -- try\_get\_to [\#1563](https://github.com/nlohmann/json/issues/1563) -- example code compile error [\#1562](https://github.com/nlohmann/json/issues/1562) -- How to iterate over nested json object [\#1561](https://github.com/nlohmann/json/issues/1561) -- Build Option/Separate Function to Allow to Throw on Duplicate Keys [\#1560](https://github.com/nlohmann/json/issues/1560) -- Compiler Switches -Weffc++ & -Wshadow are throwing errors [\#1558](https://github.com/nlohmann/json/issues/1558) -- warning: use of the 'nodiscard' attribute is a C++17 extension [\#1557](https://github.com/nlohmann/json/issues/1557) -- Import/Export compressed JSON files [\#1556](https://github.com/nlohmann/json/issues/1556) -- GDB renderers for json library [\#1554](https://github.com/nlohmann/json/issues/1554) -- Is it possible to construct a json string object from a binary buffer? [\#1553](https://github.com/nlohmann/json/issues/1553) -- json objects in list [\#1552](https://github.com/nlohmann/json/issues/1552) -- Matrix output [\#1550](https://github.com/nlohmann/json/issues/1550) -- Using json merge\_patch on ordered non-alphanumeric datasets [\#1549](https://github.com/nlohmann/json/issues/1549) -- Invalid parsed value for big integer [\#1548](https://github.com/nlohmann/json/issues/1548) -- Integrating with android ndk issues. [\#1547](https://github.com/nlohmann/json/issues/1547) -- add noexcept json::value\("key", default\) method variant? [\#1546](https://github.com/nlohmann/json/issues/1546) -- Thank you! 🙌 [\#1545](https://github.com/nlohmann/json/issues/1545) -- Output and input matrix [\#1544](https://github.com/nlohmann/json/issues/1544) -- Add regression tests for MSVC [\#1543](https://github.com/nlohmann/json/issues/1543) -- \[Help Needed!\] Season of Docs [\#1542](https://github.com/nlohmann/json/issues/1542) -- program still abort\(\) or exit\(\) with try catch [\#1541](https://github.com/nlohmann/json/issues/1541) -- Have a json::type\_error exception because of JSON object [\#1540](https://github.com/nlohmann/json/issues/1540) -- Quoted numbers [\#1538](https://github.com/nlohmann/json/issues/1538) -- Reading a JSON file into an object [\#1537](https://github.com/nlohmann/json/issues/1537) -- Releases 3.6.0 and 3.6.1 don't build on conda / windows [\#1536](https://github.com/nlohmann/json/issues/1536) -- \[Clang\] warning: use of the 'nodiscard' attribute is a C++17 extension \[-Wc++17-extensions\] [\#1535](https://github.com/nlohmann/json/issues/1535) -- wchar\_t/std::wstring json can be created but not accessed [\#1533](https://github.com/nlohmann/json/issues/1533) -- json stringify [\#1532](https://github.com/nlohmann/json/issues/1532) -- How can I use it from gcc on RPI [\#1528](https://github.com/nlohmann/json/issues/1528) -- std::pair treated as an array instead of key-value in `std::vector>` [\#1520](https://github.com/nlohmann/json/issues/1520) -- Excessive Memory Usage for Large Json File [\#1516](https://github.com/nlohmann/json/issues/1516) -- SAX dumper [\#1512](https://github.com/nlohmann/json/issues/1512) -- Conversion to user type containing a std::vector not working with documented approach [\#1511](https://github.com/nlohmann/json/issues/1511) -- Inconsistent use of type alias. [\#1507](https://github.com/nlohmann/json/issues/1507) -- Is there a current way to represent strings as json int? [\#1503](https://github.com/nlohmann/json/issues/1503) -- Intermittent issues with loadJSON [\#1484](https://github.com/nlohmann/json/issues/1484) -- use json construct std::string [\#1462](https://github.com/nlohmann/json/issues/1462) -- JSON Creation [\#1461](https://github.com/nlohmann/json/issues/1461) -- Null bytes in files are treated like EOF [\#1095](https://github.com/nlohmann/json/issues/1095) -- Feature: to\_string\(const json& j\); [\#916](https://github.com/nlohmann/json/issues/916) - -- Use GNUInstallDirs instead of hard-coded path. [\#1673](https://github.com/nlohmann/json/pull/1673) ([ghost](https://github.com/ghost)) -- Package Manager: MSYS2 \(pacman\) [\#1670](https://github.com/nlohmann/json/pull/1670) ([podsvirov](https://github.com/podsvirov)) -- Fix json.hpp compilation issue with other typedefs with same name \(Issue \#1642\) [\#1643](https://github.com/nlohmann/json/pull/1643) ([kevinlul](https://github.com/kevinlul)) -- Add explicit conversion from json to std::string\_view in conversion unit test [\#1639](https://github.com/nlohmann/json/pull/1639) ([taylorhoward92](https://github.com/taylorhoward92)) -- Minor fixes in docs [\#1625](https://github.com/nlohmann/json/pull/1625) ([nickaein](https://github.com/nickaein)) -- Fix broken links to documentation [\#1598](https://github.com/nlohmann/json/pull/1598) ([nickaein](https://github.com/nickaein)) -- Added to\_string and added basic tests [\#1585](https://github.com/nlohmann/json/pull/1585) ([Macr0Nerd](https://github.com/Macr0Nerd)) -- Regression tests for MSVC [\#1570](https://github.com/nlohmann/json/pull/1570) ([nickaein](https://github.com/nickaein)) -- Fix/1511 [\#1555](https://github.com/nlohmann/json/pull/1555) ([theodelrieu](https://github.com/theodelrieu)) -- Remove C++17 extension warning from clang; \#1535 [\#1551](https://github.com/nlohmann/json/pull/1551) ([heavywatal](https://github.com/heavywatal)) -- moved from Catch to doctest for unit tests [\#1439](https://github.com/nlohmann/json/pull/1439) ([onqtam](https://github.com/onqtam)) - -## [v3.6.1](https://github.com/nlohmann/json/releases/tag/v3.6.1) (2019-03-20) - -[Full Changelog](https://github.com/nlohmann/json/compare/3.6.1...v3.6.1) - -## [3.6.1](https://github.com/nlohmann/json/releases/tag/3.6.1) (2019-03-20) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.6.0...3.6.1) - -- Failed to build with \ [\#1531](https://github.com/nlohmann/json/issues/1531) -- Compiling 3.6.0 with GCC \> 7, array vs std::array \#590 is back [\#1530](https://github.com/nlohmann/json/issues/1530) -- 3.6.0: warning: missing initializer for member 'std::array\::\_M\_elems' \[-Wmissing-field-initializers\] [\#1527](https://github.com/nlohmann/json/issues/1527) -- unable to parse json [\#1525](https://github.com/nlohmann/json/issues/1525) - -## [v3.6.0](https://github.com/nlohmann/json/releases/tag/v3.6.0) (2019-03-19) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.5.0...v3.6.0) - -- How can I turn a string of a json array into a json array? [\#1526](https://github.com/nlohmann/json/issues/1526) -- Minor: missing a std:: namespace tag [\#1521](https://github.com/nlohmann/json/issues/1521) -- how to precision to four decimal for double when use to\_json [\#1519](https://github.com/nlohmann/json/issues/1519) -- error parse [\#1518](https://github.com/nlohmann/json/issues/1518) -- Compile error: template argument deduction/substitution failed [\#1515](https://github.com/nlohmann/json/issues/1515) -- std::complex type [\#1510](https://github.com/nlohmann/json/issues/1510) -- CBOR byte string support [\#1509](https://github.com/nlohmann/json/issues/1509) -- Compilation error getting a std::pair\<\> on latest VS 2017 compiler [\#1506](https://github.com/nlohmann/json/issues/1506) -- "Integration" section of documentation needs update? [\#1505](https://github.com/nlohmann/json/issues/1505) -- Json object from string from a TCP socket [\#1504](https://github.com/nlohmann/json/issues/1504) -- MSVC warning C4946 \("reinterpret\_cast used between related classes"\) compiling json.hpp [\#1502](https://github.com/nlohmann/json/issues/1502) -- How to programmatically fill an n-th dimensional JSON object? [\#1501](https://github.com/nlohmann/json/issues/1501) -- Error compiling with clang and `JSON_NOEXCEPTION`: need to include `cstdlib` [\#1500](https://github.com/nlohmann/json/issues/1500) -- The code compiles unsuccessfully with android-ndk-r10e [\#1499](https://github.com/nlohmann/json/issues/1499) -- Cmake 3.1 in develop, when is it likely to make it into a stable release? [\#1498](https://github.com/nlohmann/json/issues/1498) -- Some Help please object inside array [\#1494](https://github.com/nlohmann/json/issues/1494) -- How to get data into vector of user-defined type from a Json object [\#1493](https://github.com/nlohmann/json/issues/1493) -- how to find subelement without loop [\#1490](https://github.com/nlohmann/json/issues/1490) -- json to std::map [\#1487](https://github.com/nlohmann/json/issues/1487) -- Type in README.md [\#1486](https://github.com/nlohmann/json/issues/1486) -- Error in parsing and reading msgpack-lite [\#1485](https://github.com/nlohmann/json/issues/1485) -- Compiling issues with libc 2.12 [\#1483](https://github.com/nlohmann/json/issues/1483) -- How do I use reference or pointer binding values? [\#1482](https://github.com/nlohmann/json/issues/1482) -- Compilation fails in MSVC with the Microsoft Language Extensions disabled [\#1481](https://github.com/nlohmann/json/issues/1481) -- Functional visit [\#1480](https://github.com/nlohmann/json/issues/1480) -- \[Question\] Unescaped dump [\#1479](https://github.com/nlohmann/json/issues/1479) -- Some Help please [\#1478](https://github.com/nlohmann/json/issues/1478) -- Global variables are stored within the JSON file, how do I declare them as global variables when I read them out in my C++ program? [\#1476](https://github.com/nlohmann/json/issues/1476) -- Unable to modify one of the values within the JSON file, and save it [\#1475](https://github.com/nlohmann/json/issues/1475) -- Documentation of parse function has two identical @pre causes [\#1473](https://github.com/nlohmann/json/issues/1473) -- GCC 9.0 build failure [\#1472](https://github.com/nlohmann/json/issues/1472) -- Can we have an `exists()` method? [\#1471](https://github.com/nlohmann/json/issues/1471) -- How to parse multi object json from file? [\#1470](https://github.com/nlohmann/json/issues/1470) -- How to returns the name of the upper object? [\#1467](https://github.com/nlohmann/json/issues/1467) -- Error: "tuple\_size" has already been declared in the current scope [\#1466](https://github.com/nlohmann/json/issues/1466) -- Checking keys of two jsons against eachother [\#1465](https://github.com/nlohmann/json/issues/1465) -- Disable installation when used as meson subproject [\#1463](https://github.com/nlohmann/json/issues/1463) -- Unpack list of integers to a std::vector\ [\#1460](https://github.com/nlohmann/json/issues/1460) -- Implement DRY definition of JSON representation of a c++ class [\#1459](https://github.com/nlohmann/json/issues/1459) -- json.exception.type\_error.305 with GCC 4.9 when using C++ {} initializer [\#1458](https://github.com/nlohmann/json/issues/1458) -- API to convert an "uninitialized" json into an empty object or empty array [\#1456](https://github.com/nlohmann/json/issues/1456) -- How to parse a vector of objects with const attributes [\#1453](https://github.com/nlohmann/json/issues/1453) -- NLOHMANN\_JSON\_SERIALIZE\_ENUM potentially requires duplicate definitions [\#1450](https://github.com/nlohmann/json/issues/1450) -- Question about making json object from file directory [\#1449](https://github.com/nlohmann/json/issues/1449) -- .get\(\) throws error if used with userdefined structs in unordered\_map [\#1448](https://github.com/nlohmann/json/issues/1448) -- Integer Overflow \(OSS-Fuzz 12506\) [\#1447](https://github.com/nlohmann/json/issues/1447) -- If a string has too many invalid UTF-8 characters, json::dump attempts to index an array out of bounds. [\#1445](https://github.com/nlohmann/json/issues/1445) -- Setting values of .JSON file [\#1444](https://github.com/nlohmann/json/issues/1444) -- alias object\_t::key\_type in basic\_json [\#1442](https://github.com/nlohmann/json/issues/1442) -- Latest Ubuntu package is 2.1.1 [\#1438](https://github.com/nlohmann/json/issues/1438) -- lexer.hpp\(1363\) '\_snprintf': is not a member | Visualstudio 2017 [\#1437](https://github.com/nlohmann/json/issues/1437) -- Static method invites inadvertent logic error. [\#1433](https://github.com/nlohmann/json/issues/1433) -- EOS compilation produces "fatal error: 'nlohmann/json.hpp' file not found" [\#1432](https://github.com/nlohmann/json/issues/1432) -- Support for bad commas [\#1429](https://github.com/nlohmann/json/issues/1429) -- Please have one base exception class for all json exceptions [\#1427](https://github.com/nlohmann/json/issues/1427) -- Compilation warning: 'tuple\_size' defined as a class template here but previously declared as a struct template [\#1426](https://github.com/nlohmann/json/issues/1426) -- Which version can be used with GCC 4.8.2 ? [\#1424](https://github.com/nlohmann/json/issues/1424) -- Ignore nullptr values on constructing json object from a container [\#1422](https://github.com/nlohmann/json/issues/1422) -- Support for custom float precision via unquoted strings [\#1421](https://github.com/nlohmann/json/issues/1421) -- It is possible to call `json::find` with a json\_pointer as argument. This causes runtime UB/crash. [\#1418](https://github.com/nlohmann/json/issues/1418) -- Dump throwing exception [\#1416](https://github.com/nlohmann/json/issues/1416) -- Build error [\#1415](https://github.com/nlohmann/json/issues/1415) -- Append version to include.zip [\#1412](https://github.com/nlohmann/json/issues/1412) -- error C2039: '\_snprintf': is not a member of 'std' - Windows [\#1408](https://github.com/nlohmann/json/issues/1408) -- Deserializing to vector [\#1407](https://github.com/nlohmann/json/issues/1407) -- Efficient way to set a `json` object as value into another `json` key [\#1406](https://github.com/nlohmann/json/issues/1406) -- Document return value of parse\(\) when allow\_exceptions == false and parsing fails [\#1405](https://github.com/nlohmann/json/issues/1405) -- Unexpected behaviour with structured binding [\#1404](https://github.com/nlohmann/json/issues/1404) -- Which native types does get\\(\) allow? [\#1403](https://github.com/nlohmann/json/issues/1403) -- Add something like Json::StaticString [\#1402](https://github.com/nlohmann/json/issues/1402) -- -Wmismatched-tags in 3.5.0? [\#1401](https://github.com/nlohmann/json/issues/1401) -- Coverity Scan reports an UNCAUGHT\_EXCEPT issue [\#1400](https://github.com/nlohmann/json/issues/1400) -- fff [\#1399](https://github.com/nlohmann/json/issues/1399) -- sorry this is not an issue, just a Question, How to change a key value in a file and save it ? [\#1398](https://github.com/nlohmann/json/issues/1398) -- appveyor x64 builds appear to be using Win32 toolset [\#1374](https://github.com/nlohmann/json/issues/1374) -- Serializing/Deserializing a Class containing a vector of itself [\#1373](https://github.com/nlohmann/json/issues/1373) -- Retrieving array elements. [\#1369](https://github.com/nlohmann/json/issues/1369) -- Deserialize [\#1366](https://github.com/nlohmann/json/issues/1366) -- call of overloaded for push\_back and operator+= is ambiguous [\#1352](https://github.com/nlohmann/json/issues/1352) -- got an error and cann't figure it out [\#1351](https://github.com/nlohmann/json/issues/1351) -- Improve number-to-string conversion [\#1334](https://github.com/nlohmann/json/issues/1334) -- Implicit type conversion error on MSVC [\#1333](https://github.com/nlohmann/json/issues/1333) -- NuGet Package [\#1132](https://github.com/nlohmann/json/issues/1132) - -- Change macros to numeric\_limits [\#1514](https://github.com/nlohmann/json/pull/1514) ([naszta](https://github.com/naszta)) -- fix GCC 7.1.1 - 7.2.1 on CentOS [\#1496](https://github.com/nlohmann/json/pull/1496) ([lieff](https://github.com/lieff)) -- Update Buckaroo instructions in README.md [\#1495](https://github.com/nlohmann/json/pull/1495) ([njlr](https://github.com/njlr)) -- Fix gcc9 build error test/src/unit-allocator.cpp \(Issue \#1472\) [\#1492](https://github.com/nlohmann/json/pull/1492) ([stac47](https://github.com/stac47)) -- Fix typo in README.md [\#1491](https://github.com/nlohmann/json/pull/1491) ([nickaein](https://github.com/nickaein)) -- Do proper endian conversions [\#1489](https://github.com/nlohmann/json/pull/1489) ([andreas-schwab](https://github.com/andreas-schwab)) -- Fix documentation [\#1477](https://github.com/nlohmann/json/pull/1477) ([nickaein](https://github.com/nickaein)) -- Implement contains\(\) member function [\#1474](https://github.com/nlohmann/json/pull/1474) ([nickaein](https://github.com/nickaein)) -- Add operator/= and operator/ to construct a JSON pointer by appending two JSON pointers [\#1469](https://github.com/nlohmann/json/pull/1469) ([garethsb](https://github.com/garethsb)) -- Disable Clang -Wmismatched-tags warning on tuple\_size / tuple\_element [\#1468](https://github.com/nlohmann/json/pull/1468) ([past-due](https://github.com/past-due)) -- Disable installation when used as meson subproject. \#1463 [\#1464](https://github.com/nlohmann/json/pull/1464) ([elvisoric](https://github.com/elvisoric)) -- docs: README typo [\#1455](https://github.com/nlohmann/json/pull/1455) ([wythe](https://github.com/wythe)) -- remove extra semicolon from readme [\#1451](https://github.com/nlohmann/json/pull/1451) ([Afforix](https://github.com/Afforix)) -- attempt to fix \#1445, flush buffer in serializer::dump\_escaped in UTF8\_REJECT case. [\#1446](https://github.com/nlohmann/json/pull/1446) ([scinart](https://github.com/scinart)) -- Use C++11 features supported by CMake 3.1. [\#1441](https://github.com/nlohmann/json/pull/1441) ([iwanders](https://github.com/iwanders)) -- :rotating\_light: fixed unused variable warning [\#1435](https://github.com/nlohmann/json/pull/1435) ([pboettch](https://github.com/pboettch)) -- allow push\_back\(\) and pop\_back\(\) calls on json\_pointer [\#1434](https://github.com/nlohmann/json/pull/1434) ([pboettch](https://github.com/pboettch)) -- Add instructions about using nlohmann/json with the conda package manager [\#1430](https://github.com/nlohmann/json/pull/1430) ([nicoddemus](https://github.com/nicoddemus)) -- Updated year in README.md [\#1425](https://github.com/nlohmann/json/pull/1425) ([jef](https://github.com/jef)) -- Fixed broken links in the README file [\#1423](https://github.com/nlohmann/json/pull/1423) ([skypjack](https://github.com/skypjack)) -- Fixed broken links in the README file [\#1420](https://github.com/nlohmann/json/pull/1420) ([skypjack](https://github.com/skypjack)) -- docs: typo in README [\#1417](https://github.com/nlohmann/json/pull/1417) ([wythe](https://github.com/wythe)) -- Fix x64 target platform for appveyor [\#1414](https://github.com/nlohmann/json/pull/1414) ([nickaein](https://github.com/nickaein)) -- Improve dump\_integer performance [\#1411](https://github.com/nlohmann/json/pull/1411) ([nickaein](https://github.com/nickaein)) -- buildsystem: relax requirement on cmake version [\#1409](https://github.com/nlohmann/json/pull/1409) ([yann-morin-1998](https://github.com/yann-morin-1998)) -- CMake: Optional Install if Embedded [\#1330](https://github.com/nlohmann/json/pull/1330) ([ax3l](https://github.com/ax3l)) - -## [v3.5.0](https://github.com/nlohmann/json/releases/tag/v3.5.0) (2018-12-21) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.4.0...v3.5.0) - -- Copyconstructor inserts original into array with single element [\#1397](https://github.com/nlohmann/json/issues/1397) -- Get value without explicit typecasting [\#1395](https://github.com/nlohmann/json/issues/1395) -- Big file parsing [\#1393](https://github.com/nlohmann/json/issues/1393) -- Adding Structured Binding Support [\#1388](https://github.com/nlohmann/json/issues/1388) -- map\ exhibits unexpected behavior [\#1387](https://github.com/nlohmann/json/issues/1387) -- Error Code Return [\#1386](https://github.com/nlohmann/json/issues/1386) -- using unordered\_map as object type [\#1385](https://github.com/nlohmann/json/issues/1385) -- float precision [\#1384](https://github.com/nlohmann/json/issues/1384) -- \[json.exception.type\_error.316\] invalid UTF-8 byte at index 1: 0xC3 [\#1383](https://github.com/nlohmann/json/issues/1383) -- Inconsistent Constructor \(GCC vs. Clang\) [\#1381](https://github.com/nlohmann/json/issues/1381) -- \#define or || [\#1379](https://github.com/nlohmann/json/issues/1379) -- How to iterate inside the values ? [\#1377](https://github.com/nlohmann/json/issues/1377) -- items\(\) unable to get the elements [\#1375](https://github.com/nlohmann/json/issues/1375) -- conversion json to std::map doesn't work for types \ [\#1372](https://github.com/nlohmann/json/issues/1372) -- A minor issue in the build instructions [\#1371](https://github.com/nlohmann/json/issues/1371) -- Using this library without stream ? [\#1370](https://github.com/nlohmann/json/issues/1370) -- Writing and reading BSON data [\#1368](https://github.com/nlohmann/json/issues/1368) -- Retrieving array elements from object type iterator. [\#1367](https://github.com/nlohmann/json/issues/1367) -- json::dump\(\) silently crashes if items contain accented letters [\#1365](https://github.com/nlohmann/json/issues/1365) -- warnings in MSVC \(2015\) in 3.4.0 related to bool... [\#1364](https://github.com/nlohmann/json/issues/1364) -- Cant compile with -C++17 and beyond compiler options [\#1362](https://github.com/nlohmann/json/issues/1362) -- json to concrete type conversion through reference or pointer fails [\#1361](https://github.com/nlohmann/json/issues/1361) -- the first attributes of JSON string is misplaced [\#1360](https://github.com/nlohmann/json/issues/1360) -- Copy-construct using initializer-list converts objects to arrays [\#1359](https://github.com/nlohmann/json/issues/1359) -- About value\(key, default\_value\) and operator\[\]\(key\) [\#1358](https://github.com/nlohmann/json/issues/1358) -- Problem with printing json response object [\#1356](https://github.com/nlohmann/json/issues/1356) -- Serializing pointer segfaults [\#1355](https://github.com/nlohmann/json/issues/1355) -- Read `long long int` data as a number. [\#1354](https://github.com/nlohmann/json/issues/1354) -- eclipse oxygen in ubuntu get\ is ambiguous [\#1353](https://github.com/nlohmann/json/issues/1353) -- Can't build on Visual Studio 2017 v15.8.9 [\#1350](https://github.com/nlohmann/json/issues/1350) -- cannot parse from string? [\#1349](https://github.com/nlohmann/json/issues/1349) -- Error: out\_of\_range [\#1348](https://github.com/nlohmann/json/issues/1348) -- expansion pattern 'CompatibleObjectType' contains no argument packs, with CUDA 10 [\#1347](https://github.com/nlohmann/json/issues/1347) -- Unable to update a value for a nested\(multi-level\) json file [\#1344](https://github.com/nlohmann/json/issues/1344) -- Fails to compile when std::iterator\_traits is not SFINAE friendly. [\#1341](https://github.com/nlohmann/json/issues/1341) -- EOF flag not set on exhausted input streams. [\#1340](https://github.com/nlohmann/json/issues/1340) -- Shadowed Member in merge\_patch [\#1339](https://github.com/nlohmann/json/issues/1339) -- Periods/literal dots in keys? [\#1338](https://github.com/nlohmann/json/issues/1338) -- Protect macro expansion of commonly defined macros [\#1337](https://github.com/nlohmann/json/issues/1337) -- How to validate an input before parsing? [\#1336](https://github.com/nlohmann/json/issues/1336) -- Non-verifying dump\(\) alternative for debugging/logging needed [\#1335](https://github.com/nlohmann/json/issues/1335) -- Json Libarary is not responding for me in c++ [\#1332](https://github.com/nlohmann/json/issues/1332) -- Question - how to find an object in an array [\#1331](https://github.com/nlohmann/json/issues/1331) -- Nesting additional data in json object [\#1328](https://github.com/nlohmann/json/issues/1328) -- can to\_json\(\) be defined inside a class? [\#1324](https://github.com/nlohmann/json/issues/1324) -- CodeBlocks IDE can't find `json.hpp` header [\#1318](https://github.com/nlohmann/json/issues/1318) -- Change json\_pointer to provide an iterator begin/end/etc, don't use vectors, and also enable string\_view [\#1312](https://github.com/nlohmann/json/issues/1312) -- Xcode - adding it to library [\#1300](https://github.com/nlohmann/json/issues/1300) -- unicode: accept char16\_t, char32\_t sequences [\#1298](https://github.com/nlohmann/json/issues/1298) -- unicode: char16\_t\* is compiler error, but char16\_t\[\] is accepted [\#1297](https://github.com/nlohmann/json/issues/1297) -- Dockerfile Project Help Needed [\#1296](https://github.com/nlohmann/json/issues/1296) -- Comparisons between large unsigned and negative signed integers [\#1295](https://github.com/nlohmann/json/issues/1295) -- CMake alias to `nlohmann::json` [\#1291](https://github.com/nlohmann/json/issues/1291) -- Release zips without tests [\#1285](https://github.com/nlohmann/json/issues/1285) -- separate object\_t::key\_type from basic\_json::key\_type, and use an allocator which returns object\_t::key\_type [\#1274](https://github.com/nlohmann/json/issues/1274) -- Is there a nice way to associate external values with json elements? [\#1256](https://github.com/nlohmann/json/issues/1256) -- Delete by json\_pointer [\#1248](https://github.com/nlohmann/json/issues/1248) -- Expose lexer, as a StAX parser [\#1219](https://github.com/nlohmann/json/issues/1219) -- Subclassing json\(\) & error on recursive load [\#1201](https://github.com/nlohmann/json/issues/1201) -- Check value for existence by json\_pointer [\#1194](https://github.com/nlohmann/json/issues/1194) - -- Feature/add file input adapter [\#1392](https://github.com/nlohmann/json/pull/1392) ([dumarjo](https://github.com/dumarjo)) -- Added Support for Structured Bindings [\#1391](https://github.com/nlohmann/json/pull/1391) ([pratikpc](https://github.com/pratikpc)) -- Link to issue \#958 broken [\#1382](https://github.com/nlohmann/json/pull/1382) ([kjpus](https://github.com/kjpus)) -- readme: fix typo [\#1380](https://github.com/nlohmann/json/pull/1380) ([manu-chroma](https://github.com/manu-chroma)) -- recommend using explicit from JSON conversions [\#1363](https://github.com/nlohmann/json/pull/1363) ([theodelrieu](https://github.com/theodelrieu)) -- Fix merge\_patch shadow warning [\#1346](https://github.com/nlohmann/json/pull/1346) ([ax3l](https://github.com/ax3l)) -- Allow installation via Meson [\#1345](https://github.com/nlohmann/json/pull/1345) ([mpoquet](https://github.com/mpoquet)) -- Set eofbit on exhausted input stream. [\#1343](https://github.com/nlohmann/json/pull/1343) ([mefyl](https://github.com/mefyl)) -- Add a SFINAE friendly iterator\_traits and use that instead. [\#1342](https://github.com/nlohmann/json/pull/1342) ([dgavedissian](https://github.com/dgavedissian)) -- Fix EOL Whitespaces & CMake Spelling [\#1329](https://github.com/nlohmann/json/pull/1329) ([ax3l](https://github.com/ax3l)) - -## [v3.4.0](https://github.com/nlohmann/json/releases/tag/v3.4.0) (2018-10-30) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.3.0...v3.4.0) - -- Big uint64\_t values are serialized wrong [\#1327](https://github.com/nlohmann/json/issues/1327) -- \[Question\] Efficient check for equivalency? [\#1325](https://github.com/nlohmann/json/issues/1325) -- Can't use ifstream and .clear\(\) [\#1321](https://github.com/nlohmann/json/issues/1321) -- \[Warning\] -Wparentheses on line 555 on single\_include [\#1319](https://github.com/nlohmann/json/issues/1319) -- Compilation error using at and find with enum struct [\#1316](https://github.com/nlohmann/json/issues/1316) -- Parsing JSON from a web address [\#1311](https://github.com/nlohmann/json/issues/1311) -- How to convert JSON to Struct with embeded subject [\#1310](https://github.com/nlohmann/json/issues/1310) -- Null safety/coalescing function? [\#1309](https://github.com/nlohmann/json/issues/1309) -- Building fails using single include file: json.hpp [\#1308](https://github.com/nlohmann/json/issues/1308) -- json::parse\(std::string\) Exception inside packaged Lib [\#1306](https://github.com/nlohmann/json/issues/1306) -- Problem in Dockerfile with installation of library [\#1304](https://github.com/nlohmann/json/issues/1304) -- compile error in from\_json converting to container with std::pair [\#1299](https://github.com/nlohmann/json/issues/1299) -- Json that I am trying to parse, and I am lost Structure Array below top level [\#1293](https://github.com/nlohmann/json/issues/1293) -- Serializing std::variant causes stack overflow [\#1292](https://github.com/nlohmann/json/issues/1292) -- How do I go about customising from\_json to support \_\_int128\_t/\_\_uint128\_t? [\#1290](https://github.com/nlohmann/json/issues/1290) -- merge\_patch: inconsistent behaviour merging empty sub-object [\#1289](https://github.com/nlohmann/json/issues/1289) -- Buffer over/underrun using UBJson? [\#1288](https://github.com/nlohmann/json/issues/1288) -- Enable the latest C++ standard with Visual Studio [\#1287](https://github.com/nlohmann/json/issues/1287) -- truncation of constant value in to\_cbor\(\) [\#1286](https://github.com/nlohmann/json/issues/1286) -- eosio.wasmsdk error [\#1284](https://github.com/nlohmann/json/issues/1284) -- use the same interface for writing arrays and non-arrays [\#1283](https://github.com/nlohmann/json/issues/1283) -- How to read json file with optional entries and entries with different types [\#1281](https://github.com/nlohmann/json/issues/1281) -- merge result not as espected [\#1279](https://github.com/nlohmann/json/issues/1279) -- how to get only "name" from below json [\#1278](https://github.com/nlohmann/json/issues/1278) -- syntax error on right json string [\#1276](https://github.com/nlohmann/json/issues/1276) -- Parsing JSON Array where members have no key, using custom types [\#1267](https://github.com/nlohmann/json/issues/1267) -- I get a json exception periodically from json::parse for the same json [\#1263](https://github.com/nlohmann/json/issues/1263) -- GCC 8.2.1. Compilation error: invalid conversion from... [\#1246](https://github.com/nlohmann/json/issues/1246) -- BSON support [\#1244](https://github.com/nlohmann/json/issues/1244) -- enum to json mapping [\#1208](https://github.com/nlohmann/json/issues/1208) -- Soften the landing when dumping non-UTF8 strings \(type\_error.316 exception\) [\#1198](https://github.com/nlohmann/json/issues/1198) - -- Add macro to define enum/JSON mapping [\#1323](https://github.com/nlohmann/json/pull/1323) ([nlohmann](https://github.com/nlohmann)) -- Add BSON support [\#1320](https://github.com/nlohmann/json/pull/1320) ([nlohmann](https://github.com/nlohmann)) -- Properly convert constants to CharType [\#1315](https://github.com/nlohmann/json/pull/1315) ([nlohmann](https://github.com/nlohmann)) -- Allow to set error handler for decoding errors [\#1314](https://github.com/nlohmann/json/pull/1314) ([nlohmann](https://github.com/nlohmann)) -- Add Meson related info to README [\#1305](https://github.com/nlohmann/json/pull/1305) ([koponomarenko](https://github.com/koponomarenko)) -- Improve diagnostic messages for binary formats [\#1303](https://github.com/nlohmann/json/pull/1303) ([nlohmann](https://github.com/nlohmann)) -- add new is\_constructible\_\* traits used in from\_json [\#1301](https://github.com/nlohmann/json/pull/1301) ([theodelrieu](https://github.com/theodelrieu)) -- add constraints for variadic json\_ref constructors [\#1294](https://github.com/nlohmann/json/pull/1294) ([theodelrieu](https://github.com/theodelrieu)) -- Improve diagnostic messages [\#1282](https://github.com/nlohmann/json/pull/1282) ([nlohmann](https://github.com/nlohmann)) -- Removed linter warnings [\#1280](https://github.com/nlohmann/json/pull/1280) ([nlohmann](https://github.com/nlohmann)) -- Thirdparty benchmark: Fix Clang detection. [\#1277](https://github.com/nlohmann/json/pull/1277) ([Lord-Kamina](https://github.com/Lord-Kamina)) - -## [v3.3.0](https://github.com/nlohmann/json/releases/tag/v3.3.0) (2018-10-05) - -[Full Changelog](https://github.com/nlohmann/json/compare/3.3.0...v3.3.0) - -## [3.3.0](https://github.com/nlohmann/json/releases/tag/3.3.0) (2018-10-05) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.2.0...3.3.0) - -- When key is not found print the key name into error too [\#1273](https://github.com/nlohmann/json/issues/1273) -- Visual Studio 2017 15.8.5 "conditional expression is constant" warning on Line 1851 in json.hpp [\#1268](https://github.com/nlohmann/json/issues/1268) -- how can we get this working on WSL? [\#1264](https://github.com/nlohmann/json/issues/1264) -- Help needed [\#1259](https://github.com/nlohmann/json/issues/1259) -- A way to get to a JSON values "key" [\#1258](https://github.com/nlohmann/json/issues/1258) -- While compiling got 76 errors [\#1255](https://github.com/nlohmann/json/issues/1255) -- Two blackslashes on json output file [\#1253](https://github.com/nlohmann/json/issues/1253) -- Including nlohmann the badwrong way. [\#1250](https://github.com/nlohmann/json/issues/1250) -- how to build with clang? [\#1247](https://github.com/nlohmann/json/issues/1247) -- Cmake target\_link\_libraries unable to find nlohmann\_json since version 3.2.0 [\#1243](https://github.com/nlohmann/json/issues/1243) -- \[Question\] Access to end\(\) iterator reference [\#1242](https://github.com/nlohmann/json/issues/1242) -- Parsing different json format [\#1241](https://github.com/nlohmann/json/issues/1241) -- Parsing Multiple JSON Files [\#1240](https://github.com/nlohmann/json/issues/1240) -- Doesn't compile under C++17 [\#1239](https://github.com/nlohmann/json/issues/1239) -- Conversion operator for nlohmann::json is not SFINAE friendly [\#1237](https://github.com/nlohmann/json/issues/1237) -- Custom deserialization of number\_float\_t [\#1236](https://github.com/nlohmann/json/issues/1236) -- deprecated-declarations warnings when compiling tests with GCC 8.2.1. [\#1233](https://github.com/nlohmann/json/issues/1233) -- Incomplete type with json\_fwd.hpp [\#1232](https://github.com/nlohmann/json/issues/1232) -- Parse Error [\#1229](https://github.com/nlohmann/json/issues/1229) -- json::get function with argument [\#1227](https://github.com/nlohmann/json/issues/1227) -- questions regarding from\_json [\#1226](https://github.com/nlohmann/json/issues/1226) -- Lambda in unevaluated context [\#1225](https://github.com/nlohmann/json/issues/1225) -- NLohmann doesn't compile when enabling strict warning policies [\#1224](https://github.com/nlohmann/json/issues/1224) -- Creating array of objects [\#1223](https://github.com/nlohmann/json/issues/1223) -- Somewhat unhelpful error message "cannot use operator\[\] with object" [\#1220](https://github.com/nlohmann/json/issues/1220) -- single\_include json.hpp [\#1218](https://github.com/nlohmann/json/issues/1218) -- Maps with enum class keys which are convertible to JSON strings should be converted to JSON dictionaries [\#1217](https://github.com/nlohmann/json/issues/1217) -- Adding JSON Array to the Array [\#1216](https://github.com/nlohmann/json/issues/1216) -- Best way to output a vector of a given type to json [\#1215](https://github.com/nlohmann/json/issues/1215) -- compiler warning: double definition of macro JSON\_INTERNAL\_CATCH [\#1213](https://github.com/nlohmann/json/issues/1213) -- Compilation error when using MOCK\_METHOD1 from GMock and nlohmann::json [\#1212](https://github.com/nlohmann/json/issues/1212) -- Issues parsing a previously encoded binary \(non-UTF8\) string. [\#1211](https://github.com/nlohmann/json/issues/1211) -- Yet another ordering question: char \* and parse\(\) [\#1209](https://github.com/nlohmann/json/issues/1209) -- Error using gcc 8.1.0 on Ubuntu 14.04 [\#1207](https://github.com/nlohmann/json/issues/1207) -- "type must be string, but is " std::string\(j.type\_name\(\) [\#1206](https://github.com/nlohmann/json/issues/1206) -- Returning empty json object from a function of type const json& ? [\#1205](https://github.com/nlohmann/json/issues/1205) -- VS2017 compiler suggests using constexpr if [\#1204](https://github.com/nlohmann/json/issues/1204) -- Template instatiation error on compiling [\#1203](https://github.com/nlohmann/json/issues/1203) -- BUG - json dump field with unicode -\> array of ints \(instead of string\) [\#1197](https://github.com/nlohmann/json/issues/1197) -- Compile error using Code::Blocks // mingw-w64 GCC 8.1.0 - "Incomplete Type" [\#1193](https://github.com/nlohmann/json/issues/1193) -- SEGFAULT on arm target [\#1190](https://github.com/nlohmann/json/issues/1190) -- Compiler crash with old Clang [\#1179](https://github.com/nlohmann/json/issues/1179) -- Custom Precision on floating point numbers [\#1170](https://github.com/nlohmann/json/issues/1170) -- Can we have a json\_view class like std::string\_view? [\#1158](https://github.com/nlohmann/json/issues/1158) -- improve error handling [\#1152](https://github.com/nlohmann/json/issues/1152) -- We should remove static\_asserts [\#960](https://github.com/nlohmann/json/issues/960) - -- Fix warning C4127: conditional expression is constant [\#1272](https://github.com/nlohmann/json/pull/1272) ([antonioborondo](https://github.com/antonioborondo)) -- Turn off additional deprecation warnings for GCC. [\#1271](https://github.com/nlohmann/json/pull/1271) ([chuckatkins](https://github.com/chuckatkins)) -- docs: Add additional CMake documentation [\#1270](https://github.com/nlohmann/json/pull/1270) ([chuckatkins](https://github.com/chuckatkins)) -- unit-testsuites.cpp: fix hangup if file not found [\#1262](https://github.com/nlohmann/json/pull/1262) ([knilch0r](https://github.com/knilch0r)) -- Fix broken cmake imported target alias [\#1260](https://github.com/nlohmann/json/pull/1260) ([chuckatkins](https://github.com/chuckatkins)) -- GCC 48 [\#1257](https://github.com/nlohmann/json/pull/1257) ([henryiii](https://github.com/henryiii)) -- Add version and license to meson.build [\#1252](https://github.com/nlohmann/json/pull/1252) ([koponomarenko](https://github.com/koponomarenko)) -- \#1179 Reordered the code. It seems to stop clang 3.4.2 in RHEL 7 from crash… [\#1249](https://github.com/nlohmann/json/pull/1249) ([LEgregius](https://github.com/LEgregius)) -- Use a version check to provide backwards comatible CMake imported target names [\#1245](https://github.com/nlohmann/json/pull/1245) ([chuckatkins](https://github.com/chuckatkins)) -- Fix issue \#1237 [\#1238](https://github.com/nlohmann/json/pull/1238) ([theodelrieu](https://github.com/theodelrieu)) -- Add a get overload taking a parameter. [\#1231](https://github.com/nlohmann/json/pull/1231) ([theodelrieu](https://github.com/theodelrieu)) -- Move lambda out of unevaluated context [\#1230](https://github.com/nlohmann/json/pull/1230) ([mandreyel](https://github.com/mandreyel)) -- Remove static asserts [\#1228](https://github.com/nlohmann/json/pull/1228) ([theodelrieu](https://github.com/theodelrieu)) -- Better error 305 [\#1221](https://github.com/nlohmann/json/pull/1221) ([rivertam](https://github.com/rivertam)) -- Fix \#1213 [\#1214](https://github.com/nlohmann/json/pull/1214) ([simnalamburt](https://github.com/simnalamburt)) -- Export package to allow builds without installing [\#1202](https://github.com/nlohmann/json/pull/1202) ([dennisfischer](https://github.com/dennisfischer)) - -## [v3.2.0](https://github.com/nlohmann/json/releases/tag/v3.2.0) (2018-08-20) - -[Full Changelog](https://github.com/nlohmann/json/compare/3.2.0...v3.2.0) - -## [3.2.0](https://github.com/nlohmann/json/releases/tag/3.2.0) (2018-08-20) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.1.2...3.2.0) - -- Am I doing this wrong? Getting an empty string [\#1199](https://github.com/nlohmann/json/issues/1199) -- Incompatible Pointer Type [\#1196](https://github.com/nlohmann/json/issues/1196) -- json.exception.type\_error.316 [\#1195](https://github.com/nlohmann/json/issues/1195) -- Strange warnings in Code::Blocks 17.12, GNU GCC [\#1192](https://github.com/nlohmann/json/issues/1192) -- \[Question\] Current place in code to change floating point resolution [\#1191](https://github.com/nlohmann/json/issues/1191) -- Add key name when throwing type error [\#1189](https://github.com/nlohmann/json/issues/1189) -- Not able to include in visual studio code? [\#1188](https://github.com/nlohmann/json/issues/1188) -- Get an Index or row number of an element [\#1186](https://github.com/nlohmann/json/issues/1186) -- Difference between `merge_patch` and `update` [\#1183](https://github.com/nlohmann/json/issues/1183) -- Is there a way to get an element from a JSON without throwing an exception on failure? [\#1182](https://github.com/nlohmann/json/issues/1182) -- to\_string? [\#1181](https://github.com/nlohmann/json/issues/1181) -- How to cache a json object's pointer into a map? [\#1180](https://github.com/nlohmann/json/issues/1180) -- Can this library work within a Qt project for Android using Qt Creator? [\#1178](https://github.com/nlohmann/json/issues/1178) -- How to get all keys of one object? [\#1177](https://github.com/nlohmann/json/issues/1177) -- How can I only parse the first level and get the value as string? [\#1175](https://github.com/nlohmann/json/issues/1175) -- I have a query regarding nlohmann::basic\_json::basic\_json [\#1174](https://github.com/nlohmann/json/issues/1174) -- unordered\_map with vectors won't convert to json? [\#1173](https://github.com/nlohmann/json/issues/1173) -- return json objects from functions [\#1172](https://github.com/nlohmann/json/issues/1172) -- Problem when exporting to CBOR [\#1171](https://github.com/nlohmann/json/issues/1171) -- Roundtripping null to nullptr does not work [\#1169](https://github.com/nlohmann/json/issues/1169) -- MSVC fails to compile std::swap specialization for nlohmann::json [\#1168](https://github.com/nlohmann/json/issues/1168) -- Unexpected behaviour of is\_null - Part II [\#1167](https://github.com/nlohmann/json/issues/1167) -- Floating point imprecision [\#1166](https://github.com/nlohmann/json/issues/1166) -- Combine json objects into one? [\#1165](https://github.com/nlohmann/json/issues/1165) -- Is there any way to know if the object has changed? [\#1164](https://github.com/nlohmann/json/issues/1164) -- Value throws on null string [\#1163](https://github.com/nlohmann/json/issues/1163) -- Weird template issue in large project [\#1162](https://github.com/nlohmann/json/issues/1162) -- \_json returns a different result vs ::parse [\#1161](https://github.com/nlohmann/json/issues/1161) -- Showing difference between two json objects [\#1160](https://github.com/nlohmann/json/issues/1160) -- no instance of overloaded function "std::swap" matches the specified type [\#1159](https://github.com/nlohmann/json/issues/1159) -- resize\(...\)? [\#1157](https://github.com/nlohmann/json/issues/1157) -- Issue with struct nested in class' to\_json [\#1155](https://github.com/nlohmann/json/issues/1155) -- Deserialize std::map with std::nan [\#1154](https://github.com/nlohmann/json/issues/1154) -- Parse throwing errors [\#1149](https://github.com/nlohmann/json/issues/1149) -- cocoapod integration [\#1148](https://github.com/nlohmann/json/issues/1148) -- wstring parsing [\#1147](https://github.com/nlohmann/json/issues/1147) -- Is it possible to dump a two-dimensional array to "\[\[null\],\[1,2,3\]\]"? [\#1146](https://github.com/nlohmann/json/issues/1146) -- Want to write a class member variable and a struct variable \( this structure is inside the class\) to the json file [\#1145](https://github.com/nlohmann/json/issues/1145) -- Does json support converting an instance of a struct into json string? [\#1143](https://github.com/nlohmann/json/issues/1143) -- \#Most efficient way to search for child parameters \(recursive find?\) [\#1141](https://github.com/nlohmann/json/issues/1141) -- could not find to\_json\(\) method in T's namespace [\#1140](https://github.com/nlohmann/json/issues/1140) -- chars get treated as JSON numbers not JSON strings [\#1139](https://github.com/nlohmann/json/issues/1139) -- How do I count number of objects in array? [\#1137](https://github.com/nlohmann/json/issues/1137) -- Serializing a vector of classes? [\#1136](https://github.com/nlohmann/json/issues/1136) -- Compile error. Unable convert form nullptr to nullptr&& [\#1135](https://github.com/nlohmann/json/issues/1135) -- std::unordered\_map in struct, serialization [\#1133](https://github.com/nlohmann/json/issues/1133) -- dump\(\) can't handle umlauts [\#1131](https://github.com/nlohmann/json/issues/1131) -- Add a way to get a key reference from the iterator [\#1127](https://github.com/nlohmann/json/issues/1127) -- can't not parse "\\“ string [\#1123](https://github.com/nlohmann/json/issues/1123) -- if json file contain Internationalization chars , get exception [\#1122](https://github.com/nlohmann/json/issues/1122) -- How to use a json::iterator dereferenced value in code? [\#1120](https://github.com/nlohmann/json/issues/1120) -- Disable implicit conversions from json to std::initializer\_list\ for any T [\#1118](https://github.com/nlohmann/json/issues/1118) -- Implicit conversions to complex types can lead to surprising and confusing errors [\#1116](https://github.com/nlohmann/json/issues/1116) -- How can I write from\_json for a complex datatype that is not default constructible? [\#1115](https://github.com/nlohmann/json/issues/1115) -- Compile error in VS2015 when compiling unit-conversions.cpp [\#1114](https://github.com/nlohmann/json/issues/1114) -- ADL Serializer for std::any / boost::any [\#1113](https://github.com/nlohmann/json/issues/1113) -- Unexpected behaviour of is\_null [\#1112](https://github.com/nlohmann/json/issues/1112) -- How to resolve " undefined reference to `std::\_\_throw\_bad\_cast\(\)'" [\#1111](https://github.com/nlohmann/json/issues/1111) -- cannot compile on ubuntu 18.04 and 16.04 [\#1110](https://github.com/nlohmann/json/issues/1110) -- JSON representation for floating point values has too many digits [\#1109](https://github.com/nlohmann/json/issues/1109) -- Not working for classes containing "\_declspec\(dllimport\)" in their declaration [\#1108](https://github.com/nlohmann/json/issues/1108) -- Get keys from json object [\#1107](https://github.com/nlohmann/json/issues/1107) -- Cannot deserialize types using std::ratio [\#1105](https://github.com/nlohmann/json/issues/1105) -- i want to learn json [\#1104](https://github.com/nlohmann/json/issues/1104) -- Type checking during compile [\#1103](https://github.com/nlohmann/json/issues/1103) -- Iterate through sub items [\#1102](https://github.com/nlohmann/json/issues/1102) -- cppcheck failing for version 3.1.2 [\#1101](https://github.com/nlohmann/json/issues/1101) -- Deserializing std::map [\#1100](https://github.com/nlohmann/json/issues/1100) -- accessing key by reference [\#1098](https://github.com/nlohmann/json/issues/1098) -- clang 3.8.0 croaks while trying to compile with debug symbols [\#1097](https://github.com/nlohmann/json/issues/1097) -- Serialize a list of class objects with json [\#1096](https://github.com/nlohmann/json/issues/1096) -- Small question [\#1094](https://github.com/nlohmann/json/issues/1094) -- Upgrading to 3.x: to\_/from\_json with enum class [\#1093](https://github.com/nlohmann/json/issues/1093) -- Q: few questions about json construction [\#1092](https://github.com/nlohmann/json/issues/1092) -- general crayCC compilation failure [\#1091](https://github.com/nlohmann/json/issues/1091) -- Merge Patch clears original data [\#1090](https://github.com/nlohmann/json/issues/1090) -- \[Question\] how to use nlohmann/json in c++? [\#1088](https://github.com/nlohmann/json/issues/1088) -- C++17 decomposition declaration support [\#1087](https://github.com/nlohmann/json/issues/1087) -- \[Question\] Access multi-level json objects [\#1086](https://github.com/nlohmann/json/issues/1086) -- Serializing vector [\#1085](https://github.com/nlohmann/json/issues/1085) -- update nested value in multi hierarchy json object [\#1084](https://github.com/nlohmann/json/issues/1084) -- Overriding default values? [\#1083](https://github.com/nlohmann/json/issues/1083) -- detail namespace collision with Cereal? [\#1082](https://github.com/nlohmann/json/issues/1082) -- Error using json.dump\(\); [\#1081](https://github.com/nlohmann/json/issues/1081) -- Consuming TCP Stream [\#1080](https://github.com/nlohmann/json/issues/1080) -- Compilation error with strong typed enums in map in combination with namespaces [\#1079](https://github.com/nlohmann/json/issues/1079) -- cassert error [\#1076](https://github.com/nlohmann/json/issues/1076) -- Valid json data not being parsed [\#1075](https://github.com/nlohmann/json/issues/1075) -- Feature request :: Better testing for key existance without try/catch [\#1074](https://github.com/nlohmann/json/issues/1074) -- Hi, I have input like a.b.c and want to convert it to \"a\"{\"b\": \"c\"} form. Any suggestions how do I do this? Thanks. [\#1073](https://github.com/nlohmann/json/issues/1073) -- ADL deserializer not picked up for non default-constructible type [\#1072](https://github.com/nlohmann/json/issues/1072) -- Deserializing std::array doesn't compiler \(no insert\(\)\) [\#1071](https://github.com/nlohmann/json/issues/1071) -- Serializing OpenCV Mat problem [\#1070](https://github.com/nlohmann/json/issues/1070) -- Compilation error with ICPC compiler [\#1068](https://github.com/nlohmann/json/issues/1068) -- Not existing value, crash [\#1065](https://github.com/nlohmann/json/issues/1065) -- cyryllic symbols [\#1064](https://github.com/nlohmann/json/issues/1064) -- newbie usage question [\#1063](https://github.com/nlohmann/json/issues/1063) -- Trying j\["strTest"\] = "%A" produces "strTest": "-0X1.CCCCCCCCCCCCCP+205" [\#1062](https://github.com/nlohmann/json/issues/1062) -- convert json value to std::string??? [\#1061](https://github.com/nlohmann/json/issues/1061) -- Commented out test cases, should they be removed? [\#1060](https://github.com/nlohmann/json/issues/1060) -- different behaviour between clang and gcc with braced initialization [\#1059](https://github.com/nlohmann/json/issues/1059) -- json array: initialize with prescribed size and `resize` method. [\#1057](https://github.com/nlohmann/json/issues/1057) -- Is it possible to use exceptions istead of assertions? [\#1056](https://github.com/nlohmann/json/issues/1056) -- when using assign operator in with json object a static assertion fails.. [\#1055](https://github.com/nlohmann/json/issues/1055) -- Iterate over leafs of a JSON data structure: enrich the JSON pointer API [\#1054](https://github.com/nlohmann/json/issues/1054) -- \[Feature request\] Access by path [\#1053](https://github.com/nlohmann/json/issues/1053) -- document that implicit js -\> primitive conversion does not work for std::string::value\_type and why [\#1052](https://github.com/nlohmann/json/issues/1052) -- error: ‘BasicJsonType’ in namespace ‘::’ does not name a type [\#1051](https://github.com/nlohmann/json/issues/1051) -- Destructor is called when filling object through assignement [\#1050](https://github.com/nlohmann/json/issues/1050) -- Is this thing thread safe for reads? [\#1049](https://github.com/nlohmann/json/issues/1049) -- clang-tidy: Call to virtual function during construction [\#1046](https://github.com/nlohmann/json/issues/1046) -- Using STL algorithms with JSON containers with expected results? [\#1045](https://github.com/nlohmann/json/issues/1045) -- Usage with gtest/gmock not working as expected [\#1044](https://github.com/nlohmann/json/issues/1044) -- Consequences of from\_json / to\_json being in namespace of data struct. [\#1042](https://github.com/nlohmann/json/issues/1042) -- const\_reference operator\[\]\(const typename object\_t::key\_type& key\) const throw instead of assert [\#1039](https://github.com/nlohmann/json/issues/1039) -- Trying to retrieve data from nested objects [\#1038](https://github.com/nlohmann/json/issues/1038) -- Direct download link for json\_fwd.hpp? [\#1037](https://github.com/nlohmann/json/issues/1037) -- I know the library supports UTF-8, but failed to dump the value [\#1036](https://github.com/nlohmann/json/issues/1036) -- Putting a Vec3-like vector into a json object [\#1035](https://github.com/nlohmann/json/issues/1035) -- Ternary operator crash [\#1034](https://github.com/nlohmann/json/issues/1034) -- Issued with Clion Inspection Resolution since 2018.1 [\#1033](https://github.com/nlohmann/json/issues/1033) -- Some testcases fail and one never finishes [\#1032](https://github.com/nlohmann/json/issues/1032) -- Can this class work with wchar\_t / std::wstring? [\#1031](https://github.com/nlohmann/json/issues/1031) -- Makefile: Valgrind flags have no effect [\#1030](https://github.com/nlohmann/json/issues/1030) -- 「==」 Should be 「\>」 [\#1029](https://github.com/nlohmann/json/issues/1029) -- HOCON reader? [\#1027](https://github.com/nlohmann/json/issues/1027) -- add json string in previous string?? [\#1025](https://github.com/nlohmann/json/issues/1025) -- RFC: fluent parsing interface [\#1023](https://github.com/nlohmann/json/issues/1023) -- Does it support chinese character? [\#1022](https://github.com/nlohmann/json/issues/1022) -- to/from\_msgpack only works with standard typization [\#1021](https://github.com/nlohmann/json/issues/1021) -- Build failure using latest clang and GCC compilers [\#1020](https://github.com/nlohmann/json/issues/1020) -- can two json objects be concatenated? [\#1019](https://github.com/nlohmann/json/issues/1019) -- Erase by integer index [\#1018](https://github.com/nlohmann/json/issues/1018) -- Function find overload taking a json\_pointer [\#1017](https://github.com/nlohmann/json/issues/1017) -- I think should implement an parser function [\#1016](https://github.com/nlohmann/json/issues/1016) -- Readme gif [\#1015](https://github.com/nlohmann/json/issues/1015) -- Python bindings [\#1014](https://github.com/nlohmann/json/issues/1014) -- how to add two json string in single object?? [\#1012](https://github.com/nlohmann/json/issues/1012) -- how to serialize class Object \(convert data in object into json\)?? [\#1011](https://github.com/nlohmann/json/issues/1011) -- Enable forward declaration of json by making json a class instead of a using declaration [\#997](https://github.com/nlohmann/json/issues/997) -- compilation error while using intel c++ compiler 2018 [\#994](https://github.com/nlohmann/json/issues/994) -- How to create a json variable? [\#990](https://github.com/nlohmann/json/issues/990) -- istream \>\> json --- 1st character skipped in stream [\#976](https://github.com/nlohmann/json/issues/976) -- Add a SAX parser [\#971](https://github.com/nlohmann/json/issues/971) -- How to solve large json file? [\#927](https://github.com/nlohmann/json/issues/927) -- json\_pointer public push\_back, pop\_back [\#837](https://github.com/nlohmann/json/issues/837) -- Using input\_adapter in a slightly unexpected way [\#834](https://github.com/nlohmann/json/issues/834) - -- Fix -Wno-sometimes-uninitialized by initializing "result" in parse\_sax [\#1200](https://github.com/nlohmann/json/pull/1200) ([thyu](https://github.com/thyu)) -- \[RFC\] Introduce a new macro function: JSON\_INTERNAL\_CATCH [\#1187](https://github.com/nlohmann/json/pull/1187) ([simnalamburt](https://github.com/simnalamburt)) -- Fix unit tests that were silently skipped or crashed \(depending on the compiler\) [\#1176](https://github.com/nlohmann/json/pull/1176) ([grembo](https://github.com/grembo)) -- Refactor/no virtual sax [\#1153](https://github.com/nlohmann/json/pull/1153) ([theodelrieu](https://github.com/theodelrieu)) -- Fixed compiler error in VS 2015 for debug mode [\#1151](https://github.com/nlohmann/json/pull/1151) ([sonulohani](https://github.com/sonulohani)) -- Fix links to cppreference named requirements \(formerly concepts\) [\#1144](https://github.com/nlohmann/json/pull/1144) ([jrakow](https://github.com/jrakow)) -- meson: fix include directory [\#1142](https://github.com/nlohmann/json/pull/1142) ([jrakow](https://github.com/jrakow)) -- Feature/unordered map conversion [\#1138](https://github.com/nlohmann/json/pull/1138) ([theodelrieu](https://github.com/theodelrieu)) -- fixed compile error for \#1045 [\#1134](https://github.com/nlohmann/json/pull/1134) ([Daniel599](https://github.com/Daniel599)) -- test \(non\)equality for alt\_string implementation [\#1130](https://github.com/nlohmann/json/pull/1130) ([agrianius](https://github.com/agrianius)) -- remove stringstream dependency [\#1117](https://github.com/nlohmann/json/pull/1117) ([TinyTinni](https://github.com/TinyTinni)) -- Provide a from\_json overload for std::map [\#1089](https://github.com/nlohmann/json/pull/1089) ([theodelrieu](https://github.com/theodelrieu)) -- fix typo in README [\#1078](https://github.com/nlohmann/json/pull/1078) ([martin-mfg](https://github.com/martin-mfg)) -- Fix typo [\#1058](https://github.com/nlohmann/json/pull/1058) ([dns13](https://github.com/dns13)) -- Misc cmake packaging enhancements [\#1048](https://github.com/nlohmann/json/pull/1048) ([chuckatkins](https://github.com/chuckatkins)) -- Fixed incorrect LLVM version number in README [\#1047](https://github.com/nlohmann/json/pull/1047) ([jammehcow](https://github.com/jammehcow)) -- Fix trivial typo in comment. [\#1043](https://github.com/nlohmann/json/pull/1043) ([coryan](https://github.com/coryan)) -- Package Manager: Spack [\#1041](https://github.com/nlohmann/json/pull/1041) ([ax3l](https://github.com/ax3l)) -- CMake: 3.8+ is Sufficient [\#1040](https://github.com/nlohmann/json/pull/1040) ([ax3l](https://github.com/ax3l)) -- Added support for string\_view in C++17 [\#1028](https://github.com/nlohmann/json/pull/1028) ([gracicot](https://github.com/gracicot)) -- Added public target\_compile\_features for auto and constexpr [\#1026](https://github.com/nlohmann/json/pull/1026) ([ktonon](https://github.com/ktonon)) - -## [v3.1.2](https://github.com/nlohmann/json/releases/tag/v3.1.2) (2018-03-14) - -[Full Changelog](https://github.com/nlohmann/json/compare/3.1.2...v3.1.2) - -## [3.1.2](https://github.com/nlohmann/json/releases/tag/3.1.2) (2018-03-14) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.1.1...3.1.2) - -- STL containers are always serialized to a nested array like \[\[1,2,3\]\] [\#1013](https://github.com/nlohmann/json/issues/1013) -- The library doesn't want to insert an unordered\_map [\#1010](https://github.com/nlohmann/json/issues/1010) -- Convert Json to uint8\_t [\#1008](https://github.com/nlohmann/json/issues/1008) -- How to compare two JSON objects? [\#1007](https://github.com/nlohmann/json/issues/1007) -- Syntax checking [\#1003](https://github.com/nlohmann/json/issues/1003) -- more than one operator '=' matches these operands [\#1002](https://github.com/nlohmann/json/issues/1002) -- How to check if key existed [\#1000](https://github.com/nlohmann/json/issues/1000) -- nlohmann::json::parse exhaust memory in go binding [\#999](https://github.com/nlohmann/json/issues/999) -- Range-based iteration over a non-array object [\#998](https://github.com/nlohmann/json/issues/998) -- get\ for types that are not default constructible [\#996](https://github.com/nlohmann/json/issues/996) -- Prevent Null values to appear in .dump\(\) [\#995](https://github.com/nlohmann/json/issues/995) -- number parsing [\#993](https://github.com/nlohmann/json/issues/993) -- C2664 \(C++/CLR\) cannot convert 'nullptr' to 'nullptr &&' [\#987](https://github.com/nlohmann/json/issues/987) -- Uniform initialization from another json object differs between gcc and clang. [\#985](https://github.com/nlohmann/json/issues/985) -- Problem with adding the lib as a submodule [\#983](https://github.com/nlohmann/json/issues/983) -- UTF-8/Unicode error [\#982](https://github.com/nlohmann/json/issues/982) -- "forcing MSVC stacktrace to show which T we're talking about." error [\#980](https://github.com/nlohmann/json/issues/980) -- reverse order of serialization [\#979](https://github.com/nlohmann/json/issues/979) -- Assigning between different json types [\#977](https://github.com/nlohmann/json/issues/977) -- Support serialisation of `unique_ptr<>` and `shared_ptr<>` [\#975](https://github.com/nlohmann/json/issues/975) -- Unexpected end of input \(not same as one before\) [\#974](https://github.com/nlohmann/json/issues/974) -- Segfault on direct initializing json object [\#973](https://github.com/nlohmann/json/issues/973) -- Segmentation fault on G++ when trying to assign json string literal to custom json type. [\#972](https://github.com/nlohmann/json/issues/972) -- os\_defines.h:44:19: error: missing binary operator before token "\(" [\#970](https://github.com/nlohmann/json/issues/970) -- Passing an iteration object by reference to a function [\#967](https://github.com/nlohmann/json/issues/967) -- Json and fmt::lib's format\_arg\(\) [\#964](https://github.com/nlohmann/json/issues/964) - -- Allowing for user-defined string type in lexer/parser [\#1009](https://github.com/nlohmann/json/pull/1009) ([nlohmann](https://github.com/nlohmann)) -- dump to alternative string type, as defined in basic\_json template [\#1006](https://github.com/nlohmann/json/pull/1006) ([agrianius](https://github.com/agrianius)) -- Fix memory leak during parser callback [\#1001](https://github.com/nlohmann/json/pull/1001) ([nlohmann](https://github.com/nlohmann)) -- fixed misprinted condition detected by PVS Studio. [\#992](https://github.com/nlohmann/json/pull/992) ([bogemic](https://github.com/bogemic)) -- Fix/basic json conversion [\#986](https://github.com/nlohmann/json/pull/986) ([theodelrieu](https://github.com/theodelrieu)) -- Make integration section concise [\#981](https://github.com/nlohmann/json/pull/981) ([wla80](https://github.com/wla80)) - -## [v3.1.1](https://github.com/nlohmann/json/releases/tag/v3.1.1) (2018-02-13) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.1.0...v3.1.1) - -- Updation of child object isn't reflected in parent Object [\#968](https://github.com/nlohmann/json/issues/968) -- How to add user defined C++ path to sublime text [\#966](https://github.com/nlohmann/json/issues/966) -- fast number parsing [\#965](https://github.com/nlohmann/json/issues/965) -- With non-unique keys, later stored entries are not taken into account anymore [\#963](https://github.com/nlohmann/json/issues/963) -- Timeout \(OSS-Fuzz 6034\) [\#962](https://github.com/nlohmann/json/issues/962) -- Incorrect parsing of indefinite length CBOR strings. [\#961](https://github.com/nlohmann/json/issues/961) -- Reload a json file at runtime without emptying my std::ifstream [\#959](https://github.com/nlohmann/json/issues/959) -- Split headers should be part of the release [\#956](https://github.com/nlohmann/json/issues/956) -- Coveralls shows no coverage data [\#953](https://github.com/nlohmann/json/issues/953) -- Feature request: Implicit conversion to bool [\#951](https://github.com/nlohmann/json/issues/951) -- converting json to vector of type with templated constructor [\#924](https://github.com/nlohmann/json/issues/924) -- No structured bindings support? [\#901](https://github.com/nlohmann/json/issues/901) -- \[Request\] Macro generating from\_json\(\) and to\_json\(\) [\#895](https://github.com/nlohmann/json/issues/895) -- basic\_json::value throws exception instead of returning default value [\#871](https://github.com/nlohmann/json/issues/871) - -- Fix constraints on from\_json\(CompatibleArrayType\) [\#969](https://github.com/nlohmann/json/pull/969) ([theodelrieu](https://github.com/theodelrieu)) -- Make coveralls watch the include folder [\#957](https://github.com/nlohmann/json/pull/957) ([theodelrieu](https://github.com/theodelrieu)) -- Fix links in README.md [\#955](https://github.com/nlohmann/json/pull/955) ([patrikhuber](https://github.com/patrikhuber)) -- Add a note about installing the library with cget [\#954](https://github.com/nlohmann/json/pull/954) ([pfultz2](https://github.com/pfultz2)) - -## [v3.1.0](https://github.com/nlohmann/json/releases/tag/v3.1.0) (2018-02-01) - -[Full Changelog](https://github.com/nlohmann/json/compare/3.1.0...v3.1.0) - -## [3.1.0](https://github.com/nlohmann/json/releases/tag/3.1.0) (2018-02-01) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.0.1...3.1.0) - -- I have a proposal [\#949](https://github.com/nlohmann/json/issues/949) -- VERSION define\(s\) [\#948](https://github.com/nlohmann/json/issues/948) -- v3.0.1 compile error in icc 16.0.4 [\#947](https://github.com/nlohmann/json/issues/947) -- Use in VS2017 15.5.5 [\#946](https://github.com/nlohmann/json/issues/946) -- Process for reporting Security Bugs? [\#945](https://github.com/nlohmann/json/issues/945) -- Please expose a NLOHMANN\_JSON\_VERSION macro [\#943](https://github.com/nlohmann/json/issues/943) -- Change header include directory to nlohmann/json [\#942](https://github.com/nlohmann/json/issues/942) -- string\_type in binary\_reader [\#941](https://github.com/nlohmann/json/issues/941) -- compile error with clang 5.0 -std=c++1z and no string\_view [\#939](https://github.com/nlohmann/json/issues/939) -- Allow overriding JSON\_THROW to something else than abort\(\) [\#938](https://github.com/nlohmann/json/issues/938) -- Handle invalid string in Json file [\#937](https://github.com/nlohmann/json/issues/937) -- Unused variable 'kMinExp' [\#935](https://github.com/nlohmann/json/issues/935) -- yytext is already defined [\#933](https://github.com/nlohmann/json/issues/933) -- Equality operator fails [\#931](https://github.com/nlohmann/json/issues/931) -- use in visual studio 2015 [\#929](https://github.com/nlohmann/json/issues/929) -- Relative includes of json\_fwd.hpp in detail/meta.hpp. \[Develop branch\] [\#928](https://github.com/nlohmann/json/issues/928) -- GCC 7.x issue [\#926](https://github.com/nlohmann/json/issues/926) -- json\_fwd.hpp not installed [\#923](https://github.com/nlohmann/json/issues/923) -- Use Google Benchmarks [\#921](https://github.com/nlohmann/json/issues/921) -- Move class json\_pointer to separate file [\#920](https://github.com/nlohmann/json/issues/920) -- Unable to locate 'to\_json\(\)' and 'from\_json\(\)' methods in the same namespace [\#917](https://github.com/nlohmann/json/issues/917) -- \[answered\]Read key1 from .value example [\#914](https://github.com/nlohmann/json/issues/914) -- Don't use `define private public` in test files [\#913](https://github.com/nlohmann/json/issues/913) -- value\(\) template argument type deduction [\#912](https://github.com/nlohmann/json/issues/912) -- Installation path is incorrect [\#910](https://github.com/nlohmann/json/issues/910) -- H [\#909](https://github.com/nlohmann/json/issues/909) -- Build failure using clang 5 [\#908](https://github.com/nlohmann/json/issues/908) -- Amalgate [\#907](https://github.com/nlohmann/json/issues/907) -- Update documentation and tests wrt. split headers [\#906](https://github.com/nlohmann/json/issues/906) -- Lib not working on ubuntu 16.04 [\#905](https://github.com/nlohmann/json/issues/905) -- Problem when writing to file. [\#904](https://github.com/nlohmann/json/issues/904) -- C2864 error when compiling with VS2015 and VS 2017 [\#903](https://github.com/nlohmann/json/issues/903) -- \[json.exception.type\_error.304\] cannot use at\(\) with object [\#902](https://github.com/nlohmann/json/issues/902) -- How do I forward nlohmann::json declaration? [\#899](https://github.com/nlohmann/json/issues/899) -- How to effectively store binary data? [\#898](https://github.com/nlohmann/json/issues/898) -- How to get the length of a JSON string without retrieving its std::string? [\#897](https://github.com/nlohmann/json/issues/897) -- Regression Tests Failure using "ctest" [\#887](https://github.com/nlohmann/json/issues/887) -- Discuss: add JSON Merge Patch \(RFC 7396\)? [\#877](https://github.com/nlohmann/json/issues/877) -- Discuss: replace static "iterator\_wrapper" function with "items" member function [\#874](https://github.com/nlohmann/json/issues/874) -- Make optional user-data available in from\_json [\#864](https://github.com/nlohmann/json/issues/864) -- Casting to std::string not working in VS2015 [\#861](https://github.com/nlohmann/json/issues/861) -- Sequential reading of JSON arrays [\#851](https://github.com/nlohmann/json/issues/851) -- Idea: Handle Multimaps Better [\#816](https://github.com/nlohmann/json/issues/816) -- Floating point rounding [\#777](https://github.com/nlohmann/json/issues/777) -- Loss of precision when serializing \ [\#360](https://github.com/nlohmann/json/issues/360) - -- Templatize std::string in binary\_reader \#941 [\#950](https://github.com/nlohmann/json/pull/950) ([kaidokert](https://github.com/kaidokert)) -- fix cmake install directory \(for real this time\) [\#944](https://github.com/nlohmann/json/pull/944) ([theodelrieu](https://github.com/theodelrieu)) -- Allow overriding THROW/CATCH/TRY macros with no-exceptions \#938 [\#940](https://github.com/nlohmann/json/pull/940) ([kaidokert](https://github.com/kaidokert)) -- Removed compiler warning about unused variable 'kMinExp' [\#936](https://github.com/nlohmann/json/pull/936) ([zerodefect](https://github.com/zerodefect)) -- Fix a typo in README.md [\#930](https://github.com/nlohmann/json/pull/930) ([Pipeliner](https://github.com/Pipeliner)) -- Howto installation of json\_fwd.hpp \(fixes \#923\) [\#925](https://github.com/nlohmann/json/pull/925) ([zerodefect](https://github.com/zerodefect)) -- fix sfinae on basic\_json UDT constructor [\#919](https://github.com/nlohmann/json/pull/919) ([theodelrieu](https://github.com/theodelrieu)) -- Floating-point formatting [\#915](https://github.com/nlohmann/json/pull/915) ([abolz](https://github.com/abolz)) -- Fix/cmake install [\#911](https://github.com/nlohmann/json/pull/911) ([theodelrieu](https://github.com/theodelrieu)) -- fix link to the documentation of the emplace function [\#900](https://github.com/nlohmann/json/pull/900) ([Dobiasd](https://github.com/Dobiasd)) -- JSON Merge Patch \(RFC 7396\) [\#876](https://github.com/nlohmann/json/pull/876) ([nlohmann](https://github.com/nlohmann)) -- Refactor/split it [\#700](https://github.com/nlohmann/json/pull/700) ([theodelrieu](https://github.com/theodelrieu)) - -## [v3.0.1](https://github.com/nlohmann/json/releases/tag/v3.0.1) (2017-12-29) - -[Full Changelog](https://github.com/nlohmann/json/compare/3.0.1...v3.0.1) - -## [3.0.1](https://github.com/nlohmann/json/releases/tag/3.0.1) (2017-12-29) - -[Full Changelog](https://github.com/nlohmann/json/compare/v3.0.0...3.0.1) - -- Problem parsing array to global vector [\#896](https://github.com/nlohmann/json/issues/896) -- Invalid RFC6902 copy operation succeeds [\#894](https://github.com/nlohmann/json/issues/894) -- How to rename a key during looping? [\#893](https://github.com/nlohmann/json/issues/893) -- clang++-6.0 \(6.0.0-svn321357-1\) warning [\#892](https://github.com/nlohmann/json/issues/892) -- Make json.hpp aware of the modules TS? [\#891](https://github.com/nlohmann/json/issues/891) -- All enum values not handled in switch cases. \( -Wswitch-enum \) [\#889](https://github.com/nlohmann/json/issues/889) -- JSON Pointer resolve failure resulting in incorrect exception code [\#888](https://github.com/nlohmann/json/issues/888) -- Unexpected nested arrays from std::vector [\#886](https://github.com/nlohmann/json/issues/886) -- erase multiple elements from a json object [\#884](https://github.com/nlohmann/json/issues/884) -- Container function overview in Doxygen is not updated [\#883](https://github.com/nlohmann/json/issues/883) -- How to use this for binary file uploads [\#881](https://github.com/nlohmann/json/issues/881) -- Allow setting JSON\_BuildTests=OFF from parent CMakeLists.txt [\#846](https://github.com/nlohmann/json/issues/846) -- Unit test fails for local-independent str-to-num [\#845](https://github.com/nlohmann/json/issues/845) -- Another idea about type support [\#774](https://github.com/nlohmann/json/issues/774) - -- Includes CTest module/adds BUILD\_TESTING option [\#885](https://github.com/nlohmann/json/pull/885) ([TinyTinni](https://github.com/TinyTinni)) -- Fix MSVC warning C4819 [\#882](https://github.com/nlohmann/json/pull/882) ([erengy](https://github.com/erengy)) -- Merge branch 'develop' into coverity\_scan [\#880](https://github.com/nlohmann/json/pull/880) ([nlohmann](https://github.com/nlohmann)) -- :wrench: Fix up a few more effc++ items [\#858](https://github.com/nlohmann/json/pull/858) ([mattismyname](https://github.com/mattismyname)) - -## [v3.0.0](https://github.com/nlohmann/json/releases/tag/v3.0.0) (2017-12-17) - -[Full Changelog](https://github.com/nlohmann/json/compare/3.0.0...v3.0.0) - -## [3.0.0](https://github.com/nlohmann/json/releases/tag/3.0.0) (2017-12-17) - -[Full Changelog](https://github.com/nlohmann/json/compare/v2.1.1...3.0.0) - -- unicode strings [\#878](https://github.com/nlohmann/json/issues/878) -- Visual Studio 2017 15.5 C++17 std::allocator deprecations [\#872](https://github.com/nlohmann/json/issues/872) -- Typo "excpetion" [\#869](https://github.com/nlohmann/json/issues/869) -- Explicit array example in README.md incorrect [\#867](https://github.com/nlohmann/json/issues/867) -- why don't you release this from Feb. ? [\#865](https://github.com/nlohmann/json/issues/865) -- json::parse throws std::invalid\_argument when processing string generated by json::dump\(\) [\#863](https://github.com/nlohmann/json/issues/863) -- code analysis: potential bug? [\#859](https://github.com/nlohmann/json/issues/859) -- MSVC2017, 15.5 new issues. [\#857](https://github.com/nlohmann/json/issues/857) -- very basic: fetching string value/content without quotes [\#853](https://github.com/nlohmann/json/issues/853) -- Ambiguous function call to get with pointer type and constant json object in VS2015 \(15.4.4\) [\#852](https://github.com/nlohmann/json/issues/852) -- How to put object in the array as a member? [\#850](https://github.com/nlohmann/json/issues/850) -- misclick, please ignore [\#849](https://github.com/nlohmann/json/issues/849) -- Make XML great again. [\#847](https://github.com/nlohmann/json/issues/847) -- Converting to array not working [\#843](https://github.com/nlohmann/json/issues/843) -- Iteration weirdness [\#842](https://github.com/nlohmann/json/issues/842) -- Use reference or pointer as Object value [\#841](https://github.com/nlohmann/json/issues/841) -- Ambiguity in parsing nested maps [\#840](https://github.com/nlohmann/json/issues/840) -- could not find from\_json\(\) method in T's namespace [\#839](https://github.com/nlohmann/json/issues/839) -- Incorrect parse error with binary data in keys? [\#838](https://github.com/nlohmann/json/issues/838) -- using dump\(\) when std::wstring is StringType with VS2017 [\#836](https://github.com/nlohmann/json/issues/836) -- Show the path of the currently parsed value when an error occurs [\#835](https://github.com/nlohmann/json/issues/835) -- Repetitive data type while reading [\#833](https://github.com/nlohmann/json/issues/833) -- Storing multiple types inside map [\#831](https://github.com/nlohmann/json/issues/831) -- Application terminating [\#830](https://github.com/nlohmann/json/issues/830) -- Missing CMake hunter package? [\#828](https://github.com/nlohmann/json/issues/828) -- std::map\ from json object yields C2665: 'std::pair\::pair': none of the 2 overloads could convert all the argument types [\#827](https://github.com/nlohmann/json/issues/827) -- object.dump gives quoted string, want to use .dump\(\) to generate javascripts. [\#826](https://github.com/nlohmann/json/issues/826) -- Assertion failed on \["NoExistKey"\] of an not existing key of const json& [\#825](https://github.com/nlohmann/json/issues/825) -- vs2015 error : static member will remain uninitialized at runtime but use in constant-expressions is supported [\#824](https://github.com/nlohmann/json/issues/824) -- Code Checking Warnings from json.hpp on VS2017 Community [\#821](https://github.com/nlohmann/json/issues/821) -- Missing iostream in try online [\#820](https://github.com/nlohmann/json/issues/820) -- Floating point value loses decimal point during dump [\#818](https://github.com/nlohmann/json/issues/818) -- Conan package for the library [\#817](https://github.com/nlohmann/json/issues/817) -- stream error [\#815](https://github.com/nlohmann/json/issues/815) -- Link error when using find\(\) on the latest commit [\#814](https://github.com/nlohmann/json/issues/814) -- ABI issue with json object between 2 shared libraries [\#813](https://github.com/nlohmann/json/issues/813) -- scan\_string\(\) return token\_type::parse\_error; when parse ansi file [\#812](https://github.com/nlohmann/json/issues/812) -- segfault when using fifo\_map with json [\#810](https://github.com/nlohmann/json/issues/810) -- This shit is shit [\#809](https://github.com/nlohmann/json/issues/809) -- \_finite and \_isnan are no members of "std" [\#808](https://github.com/nlohmann/json/issues/808) -- how to print out the line which causing exception? [\#806](https://github.com/nlohmann/json/issues/806) -- {} uses copy constructor, while = does not [\#805](https://github.com/nlohmann/json/issues/805) -- json.hpp:8955: multiple definition of function that is not defined twice or more. [\#804](https://github.com/nlohmann/json/issues/804) -- \[question\] to\_json for base and derived class [\#803](https://github.com/nlohmann/json/issues/803) -- Misleading error message - unexpected '"' - on incorrect utf-8 symbol [\#802](https://github.com/nlohmann/json/issues/802) -- json data = std::string\_view\("hi"\); doesn't work? [\#801](https://github.com/nlohmann/json/issues/801) -- Thread safety of parse\(\) [\#800](https://github.com/nlohmann/json/issues/800) -- Numbers as strings [\#799](https://github.com/nlohmann/json/issues/799) -- Tests failing on arm [\#797](https://github.com/nlohmann/json/issues/797) -- Using your library \(without modification\) in another library [\#796](https://github.com/nlohmann/json/issues/796) -- Iterating over sub-object [\#794](https://github.com/nlohmann/json/issues/794) -- how to get the json object again from which printed by the method of dump\(\) [\#792](https://github.com/nlohmann/json/issues/792) -- ppa to include source [\#791](https://github.com/nlohmann/json/issues/791) -- Different include paths in macOS and Ubuntu [\#790](https://github.com/nlohmann/json/issues/790) -- Missing break after line 12886 in switch/case [\#789](https://github.com/nlohmann/json/issues/789) -- All unit tests fail? [\#787](https://github.com/nlohmann/json/issues/787) -- More use of move semantics in deserialization [\#786](https://github.com/nlohmann/json/issues/786) -- warning C4706 - Visual Studio 2017 \(/W4\) [\#784](https://github.com/nlohmann/json/issues/784) -- Compile error in clang 5.0 [\#782](https://github.com/nlohmann/json/issues/782) -- Error Installing appium\_lib with Ruby v2.4.2 Due to JSON [\#781](https://github.com/nlohmann/json/issues/781) -- ::get\\(\) fails in new\(er\) release \[MSVC\] [\#780](https://github.com/nlohmann/json/issues/780) -- Type Conversion [\#779](https://github.com/nlohmann/json/issues/779) -- Segfault on nested parsing [\#778](https://github.com/nlohmann/json/issues/778) -- Build warnings: shadowing exception id [\#776](https://github.com/nlohmann/json/issues/776) -- multi-level JSON support. [\#775](https://github.com/nlohmann/json/issues/775) -- SIGABRT on dump\(\) [\#773](https://github.com/nlohmann/json/issues/773) -- \[Question\] Custom StringType template parameter \(possibility for a KeyType template parameter\) [\#772](https://github.com/nlohmann/json/issues/772) -- constexpr ALL the Things! [\#771](https://github.com/nlohmann/json/issues/771) -- error: ‘BasicJsonType’ in namespace ‘::’ does not name a type [\#770](https://github.com/nlohmann/json/issues/770) -- Program calls abort function [\#769](https://github.com/nlohmann/json/issues/769) -- \[Question\] Floating point resolution config during dump\(\) ? [\#768](https://github.com/nlohmann/json/issues/768) -- make check - no test ran [\#767](https://github.com/nlohmann/json/issues/767) -- The library cannot work properly with custom allocator based containers [\#766](https://github.com/nlohmann/json/issues/766) -- Documentation or feature request. [\#763](https://github.com/nlohmann/json/issues/763) -- warnings in msvc about mix/max macro while windows.h is used in the project [\#762](https://github.com/nlohmann/json/issues/762) -- std::signbit ambiguous [\#761](https://github.com/nlohmann/json/issues/761) -- How to use value for std::experimental::optional type? [\#760](https://github.com/nlohmann/json/issues/760) -- Cannot load json file properly [\#759](https://github.com/nlohmann/json/issues/759) -- Compilation error with unordered\_map\< int, int \> [\#758](https://github.com/nlohmann/json/issues/758) -- CBOR string [\#757](https://github.com/nlohmann/json/issues/757) -- Proposal: out\_of\_range should be a subclass of std::out\_of\_range [\#756](https://github.com/nlohmann/json/issues/756) -- Getter is setting the value to null if the key does not exist [\#754](https://github.com/nlohmann/json/issues/754) -- parsing works sometimes and crashes others [\#752](https://github.com/nlohmann/json/issues/752) -- Static\_assert failed "incompatible pointer type" with Xcode [\#751](https://github.com/nlohmann/json/issues/751) -- user-defined literal operator not found [\#750](https://github.com/nlohmann/json/issues/750) -- getting clean string from it.key\(\) [\#748](https://github.com/nlohmann/json/issues/748) -- Best method for exploring and obtaining values of nested json objects when the names are not known beforehand? [\#747](https://github.com/nlohmann/json/issues/747) -- null char at the end of string [\#746](https://github.com/nlohmann/json/issues/746) -- Incorrect sample for operator \>\> in docs [\#745](https://github.com/nlohmann/json/issues/745) -- User-friendly documentation [\#744](https://github.com/nlohmann/json/issues/744) -- Retrieve all values that match a json path [\#743](https://github.com/nlohmann/json/issues/743) -- Compilation issue with gcc 7.2 [\#742](https://github.com/nlohmann/json/issues/742) -- CMake target nlohmann\_json does not have src into its interface includes [\#741](https://github.com/nlohmann/json/issues/741) -- Error when serializing empty json: type must be string, but is object [\#740](https://github.com/nlohmann/json/issues/740) -- Conversion error for std::map\ [\#739](https://github.com/nlohmann/json/issues/739) -- Dumping Json to file as array [\#738](https://github.com/nlohmann/json/issues/738) -- nesting json objects [\#737](https://github.com/nlohmann/json/issues/737) -- where to find general help? [\#736](https://github.com/nlohmann/json/issues/736) -- Compilation Error on Clang 5.0 Upgrade [\#735](https://github.com/nlohmann/json/issues/735) -- Compilation error with std::map\ on vs 2015 [\#734](https://github.com/nlohmann/json/issues/734) -- Benchmarks for Binary formats [\#733](https://github.com/nlohmann/json/issues/733) -- Support \n symbols in json string. [\#731](https://github.com/nlohmann/json/issues/731) -- Project's name is too generic and hard to search for [\#730](https://github.com/nlohmann/json/issues/730) -- Visual Studio 2015 IntelliTrace problems [\#729](https://github.com/nlohmann/json/issues/729) -- How to erase nested objects inside other objects? [\#728](https://github.com/nlohmann/json/issues/728) -- Serialization for CBOR [\#726](https://github.com/nlohmann/json/issues/726) -- Using json Object as value in a map [\#725](https://github.com/nlohmann/json/issues/725) -- std::regex and nlohmann::json value [\#724](https://github.com/nlohmann/json/issues/724) -- Warnings when compiling with VisualStudio 2015 [\#723](https://github.com/nlohmann/json/issues/723) -- Has this lib the unicode \(wstring\) support? [\#722](https://github.com/nlohmann/json/issues/722) -- When will be 3.0 in master? [\#721](https://github.com/nlohmann/json/issues/721) -- Determine the type from error message. [\#720](https://github.com/nlohmann/json/issues/720) -- Compile-Error C2100 \(MS VS2015\) in line 887 json.hpp [\#719](https://github.com/nlohmann/json/issues/719) -- from\_json not working for boost::optional example [\#718](https://github.com/nlohmann/json/issues/718) -- about from\_json and to\_json function [\#717](https://github.com/nlohmann/json/issues/717) -- How to detect parse failure? [\#715](https://github.com/nlohmann/json/issues/715) -- Parse throw std::ios\_base::failure exception when failbit set to true [\#714](https://github.com/nlohmann/json/issues/714) -- Is there a way of format just making a pretty print without changing the key's orders ? [\#713](https://github.com/nlohmann/json/issues/713) -- Serialization of array of not same model items [\#712](https://github.com/nlohmann/json/issues/712) -- pointer to json parse vector [\#711](https://github.com/nlohmann/json/issues/711) -- Gtest SEH Exception [\#709](https://github.com/nlohmann/json/issues/709) -- broken from\_json implementation for pair and tuple [\#707](https://github.com/nlohmann/json/issues/707) -- Unevaluated lambda in assert breaks gcc 7 build [\#705](https://github.com/nlohmann/json/issues/705) -- Issues when adding values to firebase database [\#704](https://github.com/nlohmann/json/issues/704) -- Floating point equality - revisited [\#703](https://github.com/nlohmann/json/issues/703) -- Conversion from valarray\ to json fails to build [\#702](https://github.com/nlohmann/json/issues/702) -- internal compiler error \(gcc7\) [\#701](https://github.com/nlohmann/json/issues/701) -- One build system to rule them all [\#698](https://github.com/nlohmann/json/issues/698) -- Generated nlohmann\_jsonConfig.cmake does not set JSON\_INCLUDE\_DIR [\#695](https://github.com/nlohmann/json/issues/695) -- support the Chinese language in json string [\#694](https://github.com/nlohmann/json/issues/694) -- NaN problem within develop branch [\#693](https://github.com/nlohmann/json/issues/693) -- Please post example of specialization for boost::filesystem [\#692](https://github.com/nlohmann/json/issues/692) -- Impossible to do an array of composite objects [\#691](https://github.com/nlohmann/json/issues/691) -- How to save json to file? [\#690](https://github.com/nlohmann/json/issues/690) -- my simple json parser [\#689](https://github.com/nlohmann/json/issues/689) -- problem with new struct parsing syntax [\#688](https://github.com/nlohmann/json/issues/688) -- Parse error while parse the json string contains UTF 8 encoded document bytes string [\#684](https://github.com/nlohmann/json/issues/684) -- \[question\] how to get a string value by pointer [\#683](https://github.com/nlohmann/json/issues/683) -- create json object from string variable [\#681](https://github.com/nlohmann/json/issues/681) -- adl\_serializer and CRTP [\#680](https://github.com/nlohmann/json/issues/680) -- Is there a way to control the precision of serialized floating point numbers? [\#677](https://github.com/nlohmann/json/issues/677) -- Is there a way to get the path of a value? [\#676](https://github.com/nlohmann/json/issues/676) -- Could the parser locate errors to line? [\#675](https://github.com/nlohmann/json/issues/675) -- There is performance inefficiency found by coverity tool json2.1.1/include/nlohmann/json.hpp [\#673](https://github.com/nlohmann/json/issues/673) -- include problem, when cmake on osx [\#672](https://github.com/nlohmann/json/issues/672) -- Operator= ambiguous in C++1z and GCC 7.1.1 [\#670](https://github.com/nlohmann/json/issues/670) -- should't the cmake install target be to nlohman/json.hpp [\#668](https://github.com/nlohmann/json/issues/668) -- deserialise from `std::vector` [\#667](https://github.com/nlohmann/json/issues/667) -- How to iterate? [\#665](https://github.com/nlohmann/json/issues/665) -- could this json lib work on windows? [\#664](https://github.com/nlohmann/json/issues/664) -- How does from\_json work? [\#662](https://github.com/nlohmann/json/issues/662) -- insert\(or merge\) object should replace same key , not ignore [\#661](https://github.com/nlohmann/json/issues/661) -- Parse method doesn't handle newlines. [\#659](https://github.com/nlohmann/json/issues/659) -- Compilation "note" on GCC 6 ARM [\#658](https://github.com/nlohmann/json/issues/658) -- Adding additional push\_back/operator+= rvalue overloads for JSON object [\#657](https://github.com/nlohmann/json/issues/657) -- dump's parameter "ensure\_ascii" creates too long sequences [\#656](https://github.com/nlohmann/json/issues/656) -- Question: parsing `void *` [\#655](https://github.com/nlohmann/json/issues/655) -- how should I check a string is valid JSON string ? [\#653](https://github.com/nlohmann/json/issues/653) -- Question: thread safety of read only accesses [\#651](https://github.com/nlohmann/json/issues/651) -- Eclipse: Method 'size' could not be resolved [\#649](https://github.com/nlohmann/json/issues/649) -- Update/Add object fields [\#648](https://github.com/nlohmann/json/issues/648) -- No exception raised for Out Of Range input of numbers [\#647](https://github.com/nlohmann/json/issues/647) -- Package Name [\#646](https://github.com/nlohmann/json/issues/646) -- What is the meaning of operator\[\]\(T\* key\) [\#645](https://github.com/nlohmann/json/issues/645) -- Which is the correct way to json objects as parameters to functions? [\#644](https://github.com/nlohmann/json/issues/644) -- Method to get string representations of values [\#642](https://github.com/nlohmann/json/issues/642) -- CBOR serialization of a given JSON value does not serialize [\#641](https://github.com/nlohmann/json/issues/641) -- Are we forced to use "-fexceptions" flag in android ndk project [\#640](https://github.com/nlohmann/json/issues/640) -- Comparison of objects containing floats [\#639](https://github.com/nlohmann/json/issues/639) -- 'localeconv' is not supported by NDK for SDK \<=20 [\#638](https://github.com/nlohmann/json/issues/638) -- \[Question\] cLion integration [\#637](https://github.com/nlohmann/json/issues/637) -- How to construct an iteratable usage in nlohmann json? [\#636](https://github.com/nlohmann/json/issues/636) -- \[Question\] copy assign json-container to vector [\#635](https://github.com/nlohmann/json/issues/635) -- Get size without .dump\(\) [\#634](https://github.com/nlohmann/json/issues/634) -- Segmentation fault when parsing invalid json file [\#633](https://github.com/nlohmann/json/issues/633) -- How to serialize from json to vector\? [\#632](https://github.com/nlohmann/json/issues/632) -- no member named 'thousands\_sep' in 'lconv' [\#631](https://github.com/nlohmann/json/issues/631) -- \[Question\] Any fork for \(the unsupported\) Visual Studio 2012 version? [\#628](https://github.com/nlohmann/json/issues/628) -- Dependency injection in serializer [\#627](https://github.com/nlohmann/json/issues/627) -- from\_json for std::array [\#625](https://github.com/nlohmann/json/issues/625) -- Discussion: How to structure the parsing function families [\#623](https://github.com/nlohmann/json/issues/623) -- Question: How to erase subtree [\#622](https://github.com/nlohmann/json/issues/622) -- Insertion into nested json field [\#621](https://github.com/nlohmann/json/issues/621) -- Question: return static json object from function [\#618](https://github.com/nlohmann/json/issues/618) -- icc16 error [\#617](https://github.com/nlohmann/json/issues/617) -- \[-Wdeprecated-declarations\] in row `j >> ss;` in file `json.hpp:7405:26` and FAILED unit tests with MinGWx64! [\#616](https://github.com/nlohmann/json/issues/616) -- to\_json for pairs, tuples [\#614](https://github.com/nlohmann/json/issues/614) -- Using uninitialized memory 'buf' in line 11173 v2.1.1? [\#613](https://github.com/nlohmann/json/issues/613) -- How to parse multiple same Keys of JSON and save them? [\#612](https://github.com/nlohmann/json/issues/612) -- "Multiple declarations" error when using types defined with `typedef` [\#611](https://github.com/nlohmann/json/issues/611) -- 2.1.1+ breaks compilation of shared\_ptr\ == 0 [\#610](https://github.com/nlohmann/json/issues/610) -- a bug of inheritance ? [\#608](https://github.com/nlohmann/json/issues/608) -- std::map key conversion with to\_json [\#607](https://github.com/nlohmann/json/issues/607) -- json.hpp:6384:62: error: wrong number of template arguments \(1, should be 2\) [\#606](https://github.com/nlohmann/json/issues/606) -- Incremental parsing: Where's the push version? [\#605](https://github.com/nlohmann/json/issues/605) -- Is there a way to validate the structure of a json object ? [\#604](https://github.com/nlohmann/json/issues/604) -- \[Question\] Issue when using Appveyor when compiling library [\#603](https://github.com/nlohmann/json/issues/603) -- BOM not skipped when using json:parse\(iterator\) [\#602](https://github.com/nlohmann/json/issues/602) -- Use of the binary type in CBOR and Message Pack [\#601](https://github.com/nlohmann/json/issues/601) -- Newbie issue: how does one convert a map in Json back to std::map? [\#600](https://github.com/nlohmann/json/issues/600) -- Plugin system [\#599](https://github.com/nlohmann/json/issues/599) -- Using custom types for scalars? [\#596](https://github.com/nlohmann/json/issues/596) -- Issues with the arithmetic in iterator and reverse iterator [\#593](https://github.com/nlohmann/json/issues/593) -- not enough examples [\#592](https://github.com/nlohmann/json/issues/592) -- in-class initialization for type 'const T' is not yet implemented [\#591](https://github.com/nlohmann/json/issues/591) -- compiling with gcc 7 -\> error on bool operator \< [\#590](https://github.com/nlohmann/json/issues/590) -- Parsing from stream leads to an array [\#589](https://github.com/nlohmann/json/issues/589) -- Buggy support for binary string data [\#587](https://github.com/nlohmann/json/issues/587) -- C++17's ambiguous conversion [\#586](https://github.com/nlohmann/json/issues/586) -- How does the messagepack encoding/decoding compare to msgpack-cpp in terms of performance? [\#585](https://github.com/nlohmann/json/issues/585) -- is it possible to check existence of a value deep in hierarchy? [\#584](https://github.com/nlohmann/json/issues/584) -- loading from a stream and exceptions [\#582](https://github.com/nlohmann/json/issues/582) -- Visual Studio seems not to have all min\(\) function versions [\#581](https://github.com/nlohmann/json/issues/581) -- Supporting of the json schema [\#580](https://github.com/nlohmann/json/issues/580) -- Stack-overflow \(OSS-Fuzz 1444\) [\#577](https://github.com/nlohmann/json/issues/577) -- Heap-buffer-overflow \(OSS-Fuzz 1400\) [\#575](https://github.com/nlohmann/json/issues/575) -- JSON escape quotes [\#574](https://github.com/nlohmann/json/issues/574) -- error: static\_assert failed [\#573](https://github.com/nlohmann/json/issues/573) -- Storing floats, and round trip serialisation/deserialisation diffs [\#572](https://github.com/nlohmann/json/issues/572) -- JSON.getLong produces inconsistent results [\#571](https://github.com/nlohmann/json/issues/571) -- Request: Object.at\(\) with default return value [\#570](https://github.com/nlohmann/json/issues/570) -- Internal structure gets corrupted while parsing [\#569](https://github.com/nlohmann/json/issues/569) -- create template \ basic\_json from\_cbor\(Iter begin, Iter end\) [\#568](https://github.com/nlohmann/json/issues/568) -- Conan.io [\#566](https://github.com/nlohmann/json/issues/566) -- contradictory documentation regarding json::find [\#565](https://github.com/nlohmann/json/issues/565) -- Unexpected '\"' in middle of array [\#564](https://github.com/nlohmann/json/issues/564) -- Support parse std::pair to Json object [\#563](https://github.com/nlohmann/json/issues/563) -- json and Microsoft Visual c++ Compiler Nov 2012 CTP [\#562](https://github.com/nlohmann/json/issues/562) -- from\_json declaration order and exceptions [\#561](https://github.com/nlohmann/json/issues/561) -- Tip: Don't upgrade to VS2017 if using json initializer list constructs [\#559](https://github.com/nlohmann/json/issues/559) -- parse error - unexpected end of input [\#558](https://github.com/nlohmann/json/issues/558) -- Cant modify existing numbers inside a json object [\#557](https://github.com/nlohmann/json/issues/557) -- Better support for SAX style serialize and deserialize in new version? [\#554](https://github.com/nlohmann/json/issues/554) -- Cannot convert from json array to std::array [\#553](https://github.com/nlohmann/json/issues/553) -- Do not define an unnamed namespace in a header file \(DCL59-CPP\) [\#552](https://github.com/nlohmann/json/issues/552) -- Parse error on known good json file [\#551](https://github.com/nlohmann/json/issues/551) -- Warning on Intel compiler \(icc 17\) [\#550](https://github.com/nlohmann/json/issues/550) -- multiple versions of 'vsnprintf' [\#549](https://github.com/nlohmann/json/issues/549) -- illegal indirection [\#548](https://github.com/nlohmann/json/issues/548) -- Ambiguous compare operators with clang-5.0 [\#547](https://github.com/nlohmann/json/issues/547) -- Using tsl::ordered\_map [\#546](https://github.com/nlohmann/json/issues/546) -- Compiler support errors are inconvenient [\#544](https://github.com/nlohmann/json/issues/544) -- Duplicate symbols error happens while to\_json/from\_json method implemented inside entity definition header file [\#542](https://github.com/nlohmann/json/issues/542) -- consider adding a bool json::is\_valid\(std::string const&\) non-member function [\#541](https://github.com/nlohmann/json/issues/541) -- Help request [\#539](https://github.com/nlohmann/json/issues/539) -- How to deal with missing keys in `from_json`? [\#538](https://github.com/nlohmann/json/issues/538) -- recursive from\_msgpack implementation will stack overflow [\#537](https://github.com/nlohmann/json/issues/537) -- Exception objects must be nothrow copy constructible \(ERR60-CPP\) [\#531](https://github.com/nlohmann/json/issues/531) -- Support for multiple root elements [\#529](https://github.com/nlohmann/json/issues/529) -- Port has\_shape from dropbox/json11 [\#528](https://github.com/nlohmann/json/issues/528) -- dump\_float: truncation from ptrdiff\_t to long [\#527](https://github.com/nlohmann/json/issues/527) -- Make exception base class visible in basic\_json [\#525](https://github.com/nlohmann/json/issues/525) -- msgpack unit test failures on ppc64 arch [\#524](https://github.com/nlohmann/json/issues/524) -- How about split the implementation out, and only leave the interface? [\#523](https://github.com/nlohmann/json/issues/523) -- VC++2017 not enough actual parameters for macro 'max' [\#522](https://github.com/nlohmann/json/issues/522) -- crash on empty ifstream [\#521](https://github.com/nlohmann/json/issues/521) -- Suggestion: Support tabs for indentation when serializing to stream. [\#520](https://github.com/nlohmann/json/issues/520) -- Abrt in get\_number \(OSS-Fuzz 885\) [\#519](https://github.com/nlohmann/json/issues/519) -- Abrt on unknown address \(OSS-Fuzz 884\) [\#518](https://github.com/nlohmann/json/issues/518) -- Stack-overflow \(OSS-Fuzz 869\) [\#517](https://github.com/nlohmann/json/issues/517) -- Assertion error \(OSS-Fuzz 868\) [\#516](https://github.com/nlohmann/json/issues/516) -- NaN to json and back [\#515](https://github.com/nlohmann/json/issues/515) -- Comparison of NaN [\#514](https://github.com/nlohmann/json/issues/514) -- why it's not possible to serialize c++11 enums directly [\#513](https://github.com/nlohmann/json/issues/513) -- clang compile error: use of overloaded operator '\<=' is ambiguous with \(nlohmann::json{{"a", 5}}\)\["a"\] \<= 10 [\#512](https://github.com/nlohmann/json/issues/512) -- Why not also look inside the type for \(static\) to\_json and from\_json funtions? [\#511](https://github.com/nlohmann/json/issues/511) -- Parser issues [\#509](https://github.com/nlohmann/json/issues/509) -- I may not understand [\#507](https://github.com/nlohmann/json/issues/507) -- VS2017 min / max problem for 2.1.1 [\#506](https://github.com/nlohmann/json/issues/506) -- CBOR/MessagePack is not read until the end [\#505](https://github.com/nlohmann/json/issues/505) -- Assertion error \(OSS-Fuzz 856\) [\#504](https://github.com/nlohmann/json/issues/504) -- Return position in parse error exceptions [\#503](https://github.com/nlohmann/json/issues/503) -- conversion from/to C array is not supported [\#502](https://github.com/nlohmann/json/issues/502) -- error C2338: could not find to\_json\(\) method in T's namespace [\#501](https://github.com/nlohmann/json/issues/501) -- Test suite fails in en\_GB.UTF-8 [\#500](https://github.com/nlohmann/json/issues/500) -- cannot use operator\[\] with number [\#499](https://github.com/nlohmann/json/issues/499) -- consider using \_\_cpp\_exceptions and/or \_\_EXCEPTIONS to disable/enable exception support [\#498](https://github.com/nlohmann/json/issues/498) -- Stack-overflow \(OSS-Fuzz issue 814\) [\#497](https://github.com/nlohmann/json/issues/497) -- Using in Unreal Engine - handling custom types conversion [\#495](https://github.com/nlohmann/json/issues/495) -- Conversion from vector\ to json fails to build [\#494](https://github.com/nlohmann/json/issues/494) -- fill\_line\_buffer incorrectly tests m\_stream for eof but not fail or bad bits [\#493](https://github.com/nlohmann/json/issues/493) -- Compiling with \_GLIBCXX\_DEBUG yields iterator-comparison warnings during tests [\#492](https://github.com/nlohmann/json/issues/492) -- crapy interface [\#491](https://github.com/nlohmann/json/issues/491) -- Fix Visual Studo 2013 builds. [\#490](https://github.com/nlohmann/json/issues/490) -- Failed to compile with -D\_GLIBCXX\_PARALLEL [\#489](https://github.com/nlohmann/json/issues/489) -- Input several field with the same name [\#488](https://github.com/nlohmann/json/issues/488) -- read in .json file yields strange sizes [\#487](https://github.com/nlohmann/json/issues/487) -- json::value\_t can't be a map's key type in VC++ 2015 [\#486](https://github.com/nlohmann/json/issues/486) -- Using fifo\_map [\#485](https://github.com/nlohmann/json/issues/485) -- Cannot get float pointer for value stored as `0` [\#484](https://github.com/nlohmann/json/issues/484) -- byte string support [\#483](https://github.com/nlohmann/json/issues/483) -- https://github.com/nlohmann/json\#execute-unit-tests [\#481](https://github.com/nlohmann/json/issues/481) -- Remove deprecated constructor basic\_json\(std::istream&\) [\#480](https://github.com/nlohmann/json/issues/480) -- writing the binary json file? [\#479](https://github.com/nlohmann/json/issues/479) -- CBOR/MessagePack from uint8\_t \* and size [\#478](https://github.com/nlohmann/json/issues/478) -- Streaming binary representations [\#477](https://github.com/nlohmann/json/issues/477) -- Reuse memory in to\_cbor and to\_msgpack functions [\#476](https://github.com/nlohmann/json/issues/476) -- Error Using JSON Library with arrays C++ [\#475](https://github.com/nlohmann/json/issues/475) -- Moving forward to version 3.0.0 [\#474](https://github.com/nlohmann/json/issues/474) -- Inconsistent behavior in conversion to array type [\#473](https://github.com/nlohmann/json/issues/473) -- Create a \[key:member\_pointer\] map to ease parsing custom types [\#471](https://github.com/nlohmann/json/issues/471) -- MSVC 2015 update 2 [\#469](https://github.com/nlohmann/json/issues/469) -- VS2017 implicit to std::string conversion fix. [\#464](https://github.com/nlohmann/json/issues/464) -- How to make sure a string or string literal is a valid JSON? [\#458](https://github.com/nlohmann/json/issues/458) -- basic\_json templated on a "policy" class [\#456](https://github.com/nlohmann/json/issues/456) -- json::value\(const json\_pointer&, ValueType\) requires exceptions to return the default value. [\#440](https://github.com/nlohmann/json/issues/440) -- is it possible merge two json object [\#428](https://github.com/nlohmann/json/issues/428) -- Is it possible to turn this into a shared library? [\#420](https://github.com/nlohmann/json/issues/420) -- Further thoughts on performance improvements [\#418](https://github.com/nlohmann/json/issues/418) -- nan number stored as null [\#388](https://github.com/nlohmann/json/issues/388) -- Behavior of operator\>\> should more closely resemble that of built-in overloads. [\#367](https://github.com/nlohmann/json/issues/367) -- Request: range-based-for over a json-object to expose .first/.second [\#350](https://github.com/nlohmann/json/issues/350) -- feature wish: JSONPath [\#343](https://github.com/nlohmann/json/issues/343) -- UTF-8/Unicode escape and dump [\#330](https://github.com/nlohmann/json/issues/330) -- Serialized value not always can be parsed. [\#329](https://github.com/nlohmann/json/issues/329) -- Is there a way to forward declare nlohmann::json? [\#314](https://github.com/nlohmann/json/issues/314) -- Exception line [\#301](https://github.com/nlohmann/json/issues/301) -- Do not throw exception when default\_value's type does not match the actual type [\#278](https://github.com/nlohmann/json/issues/278) -- dump\(\) method doesn't work with a custom allocator [\#268](https://github.com/nlohmann/json/issues/268) -- Readme documentation enhancements [\#248](https://github.com/nlohmann/json/issues/248) -- Use user-defined exceptions [\#244](https://github.com/nlohmann/json/issues/244) -- Incorrect C++11 allocator model support [\#161](https://github.com/nlohmann/json/issues/161) - -- :white\_check\_mark: re-added tests for algorithms [\#879](https://github.com/nlohmann/json/pull/879) ([nlohmann](https://github.com/nlohmann)) -- Overworked library toward 3.0.0 release [\#875](https://github.com/nlohmann/json/pull/875) ([nlohmann](https://github.com/nlohmann)) -- :rotating\_light: remove C4996 warnings \#872 [\#873](https://github.com/nlohmann/json/pull/873) ([nlohmann](https://github.com/nlohmann)) -- :boom: throwing an exception in case dump encounters a non-UTF-8 string \#838 [\#870](https://github.com/nlohmann/json/pull/870) ([nlohmann](https://github.com/nlohmann)) -- :memo: fixing documentation \#867 [\#868](https://github.com/nlohmann/json/pull/868) ([nlohmann](https://github.com/nlohmann)) -- iter\_impl template conformance with C++17 [\#860](https://github.com/nlohmann/json/pull/860) ([bogemic](https://github.com/bogemic)) -- Std allocator conformance cpp17 [\#856](https://github.com/nlohmann/json/pull/856) ([bogemic](https://github.com/bogemic)) -- cmake: use BUILD\_INTERFACE/INSTALL\_INTERFACE [\#855](https://github.com/nlohmann/json/pull/855) ([theodelrieu](https://github.com/theodelrieu)) -- to/from\_json: add a MSVC-specific static\_assert to force a stacktrace [\#854](https://github.com/nlohmann/json/pull/854) ([theodelrieu](https://github.com/theodelrieu)) -- Add .natvis for MSVC debug view [\#844](https://github.com/nlohmann/json/pull/844) ([TinyTinni](https://github.com/TinyTinni)) -- Updated hunter package links [\#829](https://github.com/nlohmann/json/pull/829) ([jowr](https://github.com/jowr)) -- Typos README [\#811](https://github.com/nlohmann/json/pull/811) ([Itja](https://github.com/Itja)) -- add forwarding references to json\_ref constructor [\#807](https://github.com/nlohmann/json/pull/807) ([theodelrieu](https://github.com/theodelrieu)) -- Add transparent comparator and perfect forwarding support to find\(\) and count\(\) [\#795](https://github.com/nlohmann/json/pull/795) ([jseward](https://github.com/jseward)) -- Error : 'identifier "size\_t" is undefined' in linux [\#793](https://github.com/nlohmann/json/pull/793) ([sonulohani](https://github.com/sonulohani)) -- Fix Visual Studio 2017 warnings [\#788](https://github.com/nlohmann/json/pull/788) ([jseward](https://github.com/jseward)) -- Fix warning C4706 on Visual Studio 2017 [\#785](https://github.com/nlohmann/json/pull/785) ([jseward](https://github.com/jseward)) -- Set GENERATE\_TAGFILE in Doxyfile [\#783](https://github.com/nlohmann/json/pull/783) ([eld00d](https://github.com/eld00d)) -- using more CMake [\#765](https://github.com/nlohmann/json/pull/765) ([nlohmann](https://github.com/nlohmann)) -- Simplified istream handing \#367 [\#764](https://github.com/nlohmann/json/pull/764) ([pjkundert](https://github.com/pjkundert)) -- Add info for the vcpkg package. [\#753](https://github.com/nlohmann/json/pull/753) ([gregmarr](https://github.com/gregmarr)) -- fix from\_json implementation for pair/tuple [\#708](https://github.com/nlohmann/json/pull/708) ([theodelrieu](https://github.com/theodelrieu)) -- Update json.hpp [\#686](https://github.com/nlohmann/json/pull/686) ([GoWebProd](https://github.com/GoWebProd)) -- Remove duplicate word [\#685](https://github.com/nlohmann/json/pull/685) ([daixtrose](https://github.com/daixtrose)) -- To fix compilation issue for intel OSX compiler [\#682](https://github.com/nlohmann/json/pull/682) ([kbthomp1](https://github.com/kbthomp1)) -- Digraph warning [\#679](https://github.com/nlohmann/json/pull/679) ([traits](https://github.com/traits)) -- massage -\> message [\#678](https://github.com/nlohmann/json/pull/678) ([DmitryKuk](https://github.com/DmitryKuk)) -- Fix "not constraint" grammar in docs [\#674](https://github.com/nlohmann/json/pull/674) ([wincent](https://github.com/wincent)) -- Add documentation for integration with CMake and hunter [\#671](https://github.com/nlohmann/json/pull/671) ([dan-42](https://github.com/dan-42)) -- REFACTOR: rewrite CMakeLists.txt for better inlcude and reuse [\#669](https://github.com/nlohmann/json/pull/669) ([dan-42](https://github.com/dan-42)) -- enable\_testing only if the JSON\_BuildTests is ON [\#666](https://github.com/nlohmann/json/pull/666) ([effolkronium](https://github.com/effolkronium)) -- Support moving from rvalues in std::initializer\_list [\#663](https://github.com/nlohmann/json/pull/663) ([himikof](https://github.com/himikof)) -- add ensure\_ascii parameter to dump. \#330 [\#654](https://github.com/nlohmann/json/pull/654) ([ryanjmulder](https://github.com/ryanjmulder)) -- Rename BuildTests to JSON\_BuildTests [\#652](https://github.com/nlohmann/json/pull/652) ([olegendo](https://github.com/olegendo)) -- Don't include \, use std::make\_shared [\#650](https://github.com/nlohmann/json/pull/650) ([olegendo](https://github.com/olegendo)) -- Refacto/split basic json [\#643](https://github.com/nlohmann/json/pull/643) ([theodelrieu](https://github.com/theodelrieu)) -- fix typo in operator\_\_notequal example [\#630](https://github.com/nlohmann/json/pull/630) ([Chocobo1](https://github.com/Chocobo1)) -- Fix MSVC warning C4819 [\#629](https://github.com/nlohmann/json/pull/629) ([Chocobo1](https://github.com/Chocobo1)) -- \[BugFix\] Add parentheses around std::min [\#626](https://github.com/nlohmann/json/pull/626) ([koemeet](https://github.com/koemeet)) -- add pair/tuple conversions [\#624](https://github.com/nlohmann/json/pull/624) ([theodelrieu](https://github.com/theodelrieu)) -- remove std::pair support [\#615](https://github.com/nlohmann/json/pull/615) ([theodelrieu](https://github.com/theodelrieu)) -- Add pair support, fix CompatibleObject conversions \(fixes \#600\) [\#609](https://github.com/nlohmann/json/pull/609) ([theodelrieu](https://github.com/theodelrieu)) -- \#550 Fix iterator related compiling issues for Intel icc [\#598](https://github.com/nlohmann/json/pull/598) ([HenryRLee](https://github.com/HenryRLee)) -- Issue \#593 Fix the arithmetic operators in the iterator and reverse iterator [\#595](https://github.com/nlohmann/json/pull/595) ([HenryRLee](https://github.com/HenryRLee)) -- fix doxygen error of basic\_json::get\(\) [\#583](https://github.com/nlohmann/json/pull/583) ([zhaohuaxishi](https://github.com/zhaohuaxishi)) -- Fixing assignement for iterator wrapper second, and adding unit test [\#579](https://github.com/nlohmann/json/pull/579) ([Type1J](https://github.com/Type1J)) -- Adding first and second properties to iteration\_proxy\_internal [\#578](https://github.com/nlohmann/json/pull/578) ([Type1J](https://github.com/Type1J)) -- Adding support for Meson. [\#576](https://github.com/nlohmann/json/pull/576) ([Type1J](https://github.com/Type1J)) -- add enum class default conversions [\#545](https://github.com/nlohmann/json/pull/545) ([theodelrieu](https://github.com/theodelrieu)) -- Properly pop diagnostics [\#540](https://github.com/nlohmann/json/pull/540) ([tinloaf](https://github.com/tinloaf)) -- Add Visual Studio 17 image to appveyor build matrix [\#536](https://github.com/nlohmann/json/pull/536) ([vpetrigo](https://github.com/vpetrigo)) -- UTF8 encoding enhancement [\#534](https://github.com/nlohmann/json/pull/534) ([TedLyngmo](https://github.com/TedLyngmo)) -- Fix typo [\#530](https://github.com/nlohmann/json/pull/530) ([berkus](https://github.com/berkus)) -- Make exception base class visible in basic\_json [\#526](https://github.com/nlohmann/json/pull/526) ([ghost](https://github.com/ghost)) -- :art: Namespace `uint8_t` from the C++ stdlib [\#510](https://github.com/nlohmann/json/pull/510) ([alexweej](https://github.com/alexweej)) -- add to\_json method for C arrays [\#508](https://github.com/nlohmann/json/pull/508) ([theodelrieu](https://github.com/theodelrieu)) -- Fix -Weffc++ warnings \(GNU 6.3.1\) [\#496](https://github.com/nlohmann/json/pull/496) ([TedLyngmo](https://github.com/TedLyngmo)) - -## [v2.1.1](https://github.com/nlohmann/json/releases/tag/v2.1.1) (2017-02-25) - -[Full Changelog](https://github.com/nlohmann/json/compare/2.1.1...v2.1.1) - -## [2.1.1](https://github.com/nlohmann/json/releases/tag/2.1.1) (2017-02-25) - -[Full Changelog](https://github.com/nlohmann/json/compare/v2.1.0...2.1.1) - -- warning in the library [\#472](https://github.com/nlohmann/json/issues/472) -- How to create an array of Objects? [\#470](https://github.com/nlohmann/json/issues/470) -- \[Bug?\] Cannot get int pointer, but int64\_t works [\#468](https://github.com/nlohmann/json/issues/468) -- Illegal indirection [\#467](https://github.com/nlohmann/json/issues/467) -- in vs can't find linkageId [\#466](https://github.com/nlohmann/json/issues/466) -- Roundtrip error while parsing "1000000000000000010E5" [\#465](https://github.com/nlohmann/json/issues/465) -- C4996 error and warning with Visual Studio [\#463](https://github.com/nlohmann/json/issues/463) -- Support startIndex for from\_cbor/from\_msgpack [\#462](https://github.com/nlohmann/json/issues/462) -- question: monospace font used in feature slideshow? [\#460](https://github.com/nlohmann/json/issues/460) -- Object.keys\(\) [\#459](https://github.com/nlohmann/json/issues/459) -- Use “, “ as delimiter for json-objects. [\#457](https://github.com/nlohmann/json/issues/457) -- Enum -\> string during serialization and vice versa [\#455](https://github.com/nlohmann/json/issues/455) -- doubles are printed as integers [\#454](https://github.com/nlohmann/json/issues/454) -- Warnings with Visual Studio c++ \(VS2015 Update 3\) [\#453](https://github.com/nlohmann/json/issues/453) -- Heap-buffer-overflow \(OSS-Fuzz issue 585\) [\#452](https://github.com/nlohmann/json/issues/452) -- use of undeclared identifier 'UINT8\_MAX' [\#451](https://github.com/nlohmann/json/issues/451) -- Question on the lifetime managment of objects at the lower levels [\#449](https://github.com/nlohmann/json/issues/449) -- Json should not be constructible with 'json\*' [\#448](https://github.com/nlohmann/json/issues/448) -- Move value\_t to namespace scope [\#447](https://github.com/nlohmann/json/issues/447) -- Typo in README.md [\#446](https://github.com/nlohmann/json/issues/446) -- make check compilation is unneccesarily slow [\#445](https://github.com/nlohmann/json/issues/445) -- Problem in dump\(\) in json.h caused by ss.imbue [\#444](https://github.com/nlohmann/json/issues/444) -- I want to create Windows Application in Visual Studio 2015 c++, and i have a problem [\#443](https://github.com/nlohmann/json/issues/443) -- Implicit conversion issues [\#442](https://github.com/nlohmann/json/issues/442) -- Parsing of floats locale dependent [\#302](https://github.com/nlohmann/json/issues/302) - -- Speedup CI builds using cotire [\#461](https://github.com/nlohmann/json/pull/461) ([tusharpm](https://github.com/tusharpm)) -- TurpentineDistillery feature/locale independent str to num [\#450](https://github.com/nlohmann/json/pull/450) ([nlohmann](https://github.com/nlohmann)) -- README: adjust boost::optional example [\#439](https://github.com/nlohmann/json/pull/439) ([jaredgrubb](https://github.com/jaredgrubb)) -- fix \#414 - comparing to 0 literal [\#415](https://github.com/nlohmann/json/pull/415) ([stanmihai4](https://github.com/stanmihai4)) -- locale-independent num-to-str [\#378](https://github.com/nlohmann/json/pull/378) ([TurpentineDistillery](https://github.com/TurpentineDistillery)) - -## [v2.1.0](https://github.com/nlohmann/json/releases/tag/v2.1.0) (2017-01-28) - -[Full Changelog](https://github.com/nlohmann/json/compare/2.1.0...v2.1.0) - -## [2.1.0](https://github.com/nlohmann/json/releases/tag/2.1.0) (2017-01-28) - -[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.10...2.1.0) - -- Parsing multiple JSON objects from a string or stream [\#438](https://github.com/nlohmann/json/issues/438) -- Use-of-uninitialized-value \(OSS-Fuzz issue 477\) [\#437](https://github.com/nlohmann/json/issues/437) -- add `reserve` function for array to reserve memory before adding json values into it [\#436](https://github.com/nlohmann/json/issues/436) -- Typo in examples page [\#434](https://github.com/nlohmann/json/issues/434) -- avoid malformed json [\#433](https://github.com/nlohmann/json/issues/433) -- How to add json objects to a map? [\#432](https://github.com/nlohmann/json/issues/432) -- create json instance from raw json \(unsigned char\*\) [\#431](https://github.com/nlohmann/json/issues/431) -- Getting std::invalid\_argument: stream error when following example [\#429](https://github.com/nlohmann/json/issues/429) -- Forward declare-only header? [\#427](https://github.com/nlohmann/json/issues/427) -- Implicit conversion from array to object [\#425](https://github.com/nlohmann/json/issues/425) -- error C4996: 'strerror' when reading file [\#422](https://github.com/nlohmann/json/issues/422) -- Get an error - JSON pointer must be empty or begin with '/' [\#421](https://github.com/nlohmann/json/issues/421) -- size parameter for parse\(\) [\#419](https://github.com/nlohmann/json/issues/419) -- json.hpp forcibly defines GCC\_VERSION [\#417](https://github.com/nlohmann/json/issues/417) -- Use-of-uninitialized-value \(OSS-Fuzz issue 377\) [\#416](https://github.com/nlohmann/json/issues/416) -- comparing to 0 literal [\#414](https://github.com/nlohmann/json/issues/414) -- Single char converted to ASCII code instead of string [\#413](https://github.com/nlohmann/json/issues/413) -- How to know if a string was parsed as utf-8? [\#406](https://github.com/nlohmann/json/issues/406) -- Overloaded += to add objects to an array makes no sense? [\#404](https://github.com/nlohmann/json/issues/404) -- Finding a value in an array [\#399](https://github.com/nlohmann/json/issues/399) -- add release information in static function [\#397](https://github.com/nlohmann/json/issues/397) -- Optimize memory usage of json objects in combination with binary serialization [\#373](https://github.com/nlohmann/json/issues/373) -- Conversion operators not considered [\#369](https://github.com/nlohmann/json/issues/369) -- Append ".0" to serialized floating\_point values that are digits-only. [\#362](https://github.com/nlohmann/json/issues/362) -- Add a customization point for user-defined types [\#328](https://github.com/nlohmann/json/issues/328) -- Conformance report for reference [\#307](https://github.com/nlohmann/json/issues/307) -- Document the best way to serialize/deserialize user defined types to json [\#298](https://github.com/nlohmann/json/issues/298) -- Add StringView template typename to basic\_json [\#297](https://github.com/nlohmann/json/issues/297) -- \[Improvement\] Add option to remove exceptions [\#296](https://github.com/nlohmann/json/issues/296) -- Performance in miloyip/nativejson-benchmark [\#202](https://github.com/nlohmann/json/issues/202) - -- conversion from/to user-defined types [\#435](https://github.com/nlohmann/json/pull/435) ([nlohmann](https://github.com/nlohmann)) -- Fix documentation error [\#430](https://github.com/nlohmann/json/pull/430) ([vjon](https://github.com/vjon)) - -## [v2.0.10](https://github.com/nlohmann/json/releases/tag/v2.0.10) (2017-01-02) - -[Full Changelog](https://github.com/nlohmann/json/compare/2.0.10...v2.0.10) - -## [2.0.10](https://github.com/nlohmann/json/releases/tag/2.0.10) (2017-01-02) - -[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.9...2.0.10) - -- Heap-buffer-overflow \(OSS-Fuzz issue 367\) [\#412](https://github.com/nlohmann/json/issues/412) -- Heap-buffer-overflow \(OSS-Fuzz issue 366\) [\#411](https://github.com/nlohmann/json/issues/411) -- Use-of-uninitialized-value \(OSS-Fuzz issue 347\) [\#409](https://github.com/nlohmann/json/issues/409) -- Heap-buffer-overflow \(OSS-Fuzz issue 344\) [\#408](https://github.com/nlohmann/json/issues/408) -- Heap-buffer-overflow \(OSS-Fuzz issue 343\) [\#407](https://github.com/nlohmann/json/issues/407) -- Heap-buffer-overflow \(OSS-Fuzz issue 342\) [\#405](https://github.com/nlohmann/json/issues/405) -- strerror throwing error in compiler VS2015 [\#403](https://github.com/nlohmann/json/issues/403) -- json::parse of std::string being underlined by Visual Studio [\#402](https://github.com/nlohmann/json/issues/402) -- Explicitly getting string without .dump\(\) [\#401](https://github.com/nlohmann/json/issues/401) -- Possible to speed up json::parse? [\#398](https://github.com/nlohmann/json/issues/398) -- the alphabetic order in the code influence console\_output. [\#396](https://github.com/nlohmann/json/issues/396) -- Execute tests with clang sanitizers [\#394](https://github.com/nlohmann/json/issues/394) -- Check if library can be used with ETL [\#361](https://github.com/nlohmann/json/issues/361) - -- Feature/clang sanitize [\#410](https://github.com/nlohmann/json/pull/410) ([Daniel599](https://github.com/Daniel599)) -- Add Doozer build badge [\#400](https://github.com/nlohmann/json/pull/400) ([andoma](https://github.com/andoma)) - -## [v2.0.9](https://github.com/nlohmann/json/releases/tag/v2.0.9) (2016-12-16) - -[Full Changelog](https://github.com/nlohmann/json/compare/2.0.9...v2.0.9) - -## [2.0.9](https://github.com/nlohmann/json/releases/tag/2.0.9) (2016-12-16) - -[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.8...2.0.9) - -- \#pragma GCC diagnostic ignored "-Wdocumentation" [\#393](https://github.com/nlohmann/json/issues/393) -- How to parse this json file and write separate sub object as json files? [\#392](https://github.com/nlohmann/json/issues/392) -- Integer-overflow \(OSS-Fuzz issue 267\) [\#389](https://github.com/nlohmann/json/issues/389) -- Implement indefinite-length types from RFC 7049 [\#387](https://github.com/nlohmann/json/issues/387) -- template parameter "T" is not used in declaring the parameter types of function template [\#386](https://github.com/nlohmann/json/issues/386) -- Serializing json instances containing already serialized string values without escaping [\#385](https://github.com/nlohmann/json/issues/385) -- Add test cases from RFC 7049 [\#384](https://github.com/nlohmann/json/issues/384) -- Add a table of contents to the README file [\#383](https://github.com/nlohmann/json/issues/383) -- Update FAQ section in the guidelines for contributing [\#382](https://github.com/nlohmann/json/issues/382) -- Allow for forward declaring nlohmann::json [\#381](https://github.com/nlohmann/json/issues/381) -- Bug in overflow detection when parsing integers [\#380](https://github.com/nlohmann/json/issues/380) -- A unique name to mention the library? [\#377](https://github.com/nlohmann/json/issues/377) -- Non-unique keys in objects. [\#375](https://github.com/nlohmann/json/issues/375) -- Request: binary serialization/deserialization [\#358](https://github.com/nlohmann/json/issues/358) - -- Replace class iterator and const\_iterator by using a single template class to reduce code. [\#395](https://github.com/nlohmann/json/pull/395) ([Bosswestfalen](https://github.com/Bosswestfalen)) -- Clang: quiet a warning [\#391](https://github.com/nlohmann/json/pull/391) ([jaredgrubb](https://github.com/jaredgrubb)) -- Fix issue \#380: Signed integer overflow check [\#390](https://github.com/nlohmann/json/pull/390) ([qwename](https://github.com/qwename)) - -## [v2.0.8](https://github.com/nlohmann/json/releases/tag/v2.0.8) (2016-12-02) - -[Full Changelog](https://github.com/nlohmann/json/compare/2.0.8...v2.0.8) - -## [2.0.8](https://github.com/nlohmann/json/releases/tag/2.0.8) (2016-12-02) - -[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.7...2.0.8) - -- Reading from file [\#374](https://github.com/nlohmann/json/issues/374) -- Compiler warnings? [\#372](https://github.com/nlohmann/json/issues/372) -- docs: how to release a json object in memory? [\#371](https://github.com/nlohmann/json/issues/371) -- crash in dump [\#370](https://github.com/nlohmann/json/issues/370) -- Coverity issue \(FORWARD\_NULL\) in lexer\(std::istream& s\) [\#368](https://github.com/nlohmann/json/issues/368) -- json::parse on failed stream gets stuck [\#366](https://github.com/nlohmann/json/issues/366) -- Performance improvements [\#365](https://github.com/nlohmann/json/issues/365) -- 'to\_string' is not a member of 'std' [\#364](https://github.com/nlohmann/json/issues/364) -- Crash in dump\(\) from a static object [\#359](https://github.com/nlohmann/json/issues/359) -- json::parse\(...\) vs json j; j.parse\(...\) [\#357](https://github.com/nlohmann/json/issues/357) -- Hi, is there any method to dump json to string with the insert order rather than alphabets [\#356](https://github.com/nlohmann/json/issues/356) -- Provide an example of reading from an json with only a key that has an array of strings. [\#354](https://github.com/nlohmann/json/issues/354) -- Request: access with default value. [\#353](https://github.com/nlohmann/json/issues/353) -- {} and \[\] causes parser error. [\#352](https://github.com/nlohmann/json/issues/352) -- Reading a JSON file into a JSON object [\#351](https://github.com/nlohmann/json/issues/351) -- Request: 'emplace\_back' [\#349](https://github.com/nlohmann/json/issues/349) -- Is it possible to stream data through the json parser without storing everything in memory? [\#347](https://github.com/nlohmann/json/issues/347) -- pure virtual conversion operator [\#346](https://github.com/nlohmann/json/issues/346) -- Floating point precision lost [\#345](https://github.com/nlohmann/json/issues/345) -- unit-conversions SIGSEGV on armv7hl [\#303](https://github.com/nlohmann/json/issues/303) -- Coverity scan fails [\#299](https://github.com/nlohmann/json/issues/299) -- Using QString as string type [\#274](https://github.com/nlohmann/json/issues/274) - -## [v2.0.7](https://github.com/nlohmann/json/releases/tag/v2.0.7) (2016-11-02) - -[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.6...v2.0.7) - -- JSON5 [\#348](https://github.com/nlohmann/json/issues/348) -- Check "Parsing JSON is a Minefield" [\#344](https://github.com/nlohmann/json/issues/344) -- Allow hex numbers [\#342](https://github.com/nlohmann/json/issues/342) -- Convert strings to numbers [\#341](https://github.com/nlohmann/json/issues/341) -- ""-operators ignore the length parameter [\#340](https://github.com/nlohmann/json/issues/340) -- JSON into std::tuple [\#339](https://github.com/nlohmann/json/issues/339) -- JSON into vector [\#335](https://github.com/nlohmann/json/issues/335) -- Installing with Homebrew on Mac Errors \(El Capitan\) [\#331](https://github.com/nlohmann/json/issues/331) -- g++ make check results in error [\#312](https://github.com/nlohmann/json/issues/312) -- Cannot convert from 'json' to 'char' [\#276](https://github.com/nlohmann/json/issues/276) -- Please add a Pretty-Print option for arrays to stay always in one line [\#229](https://github.com/nlohmann/json/issues/229) -- Conversion to STL map\\> gives error [\#220](https://github.com/nlohmann/json/issues/220) -- std::unorderd\_map cannot be used as ObjectType [\#164](https://github.com/nlohmann/json/issues/164) - -- fix minor grammar/style issue in README.md [\#336](https://github.com/nlohmann/json/pull/336) ([seeekr](https://github.com/seeekr)) - -## [v2.0.6](https://github.com/nlohmann/json/releases/tag/v2.0.6) (2016-10-15) - -[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.5...v2.0.6) - -- How to handle json files? [\#333](https://github.com/nlohmann/json/issues/333) -- This file requires compiler and library support .... [\#332](https://github.com/nlohmann/json/issues/332) -- Segmentation fault on saving json to file [\#326](https://github.com/nlohmann/json/issues/326) -- parse error - unexpected \ with 2.0.5 [\#325](https://github.com/nlohmann/json/issues/325) -- Add nested object capability to pointers [\#323](https://github.com/nlohmann/json/issues/323) -- Fix usage examples' comments for std::multiset [\#322](https://github.com/nlohmann/json/issues/322) -- json\_unit runs forever when executed in build directory [\#319](https://github.com/nlohmann/json/issues/319) -- Visual studio 2015 update3 true != TRUE [\#317](https://github.com/nlohmann/json/issues/317) -- releasing single header file in compressed format [\#316](https://github.com/nlohmann/json/issues/316) -- json object from std::ifstream [\#315](https://github.com/nlohmann/json/issues/315) - -- make has\_mapped\_type struct friendly [\#324](https://github.com/nlohmann/json/pull/324) ([vpetrigo](https://github.com/vpetrigo)) -- Fix usage examples' comments for std::multiset [\#321](https://github.com/nlohmann/json/pull/321) ([vasild](https://github.com/vasild)) -- Include dir relocation [\#318](https://github.com/nlohmann/json/pull/318) ([ChristophJud](https://github.com/ChristophJud)) -- trivial documentation fix [\#313](https://github.com/nlohmann/json/pull/313) ([5tefan](https://github.com/5tefan)) - -## [v2.0.5](https://github.com/nlohmann/json/releases/tag/v2.0.5) (2016-09-14) - -[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.4...v2.0.5) - -- \[feature request\]: schema validator and comments [\#311](https://github.com/nlohmann/json/issues/311) -- make json\_benchmarks no longer working in 2.0.4 [\#310](https://github.com/nlohmann/json/issues/310) -- Segmentation fault \(core dumped\) [\#309](https://github.com/nlohmann/json/issues/309) -- No matching member function for call to 'get\_impl' [\#308](https://github.com/nlohmann/json/issues/308) - -## [v2.0.4](https://github.com/nlohmann/json/releases/tag/v2.0.4) (2016-09-11) - -[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.3...v2.0.4) - -- Parsing fails without space at end of file [\#306](https://github.com/nlohmann/json/issues/306) -- json schema validator [\#305](https://github.com/nlohmann/json/issues/305) -- Unused variable warning [\#304](https://github.com/nlohmann/json/issues/304) - -## [v2.0.3](https://github.com/nlohmann/json/releases/tag/v2.0.3) (2016-08-31) - -[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.2...v2.0.3) - -- warning C4706: assignment within conditional expression [\#295](https://github.com/nlohmann/json/issues/295) -- Q: Is it possible to build json tree from already UTF8 encoded values? [\#293](https://github.com/nlohmann/json/issues/293) -- Equality operator results in array when assigned object [\#292](https://github.com/nlohmann/json/issues/292) -- Support for integers not from the range \[-\(2\*\*53\)+1, \(2\*\*53\)-1\] in parser [\#291](https://github.com/nlohmann/json/issues/291) -- Support for iterator-range parsing [\#290](https://github.com/nlohmann/json/issues/290) -- Horribly inconsistent behavior between const/non-const reference in operator \[\] \(\) [\#289](https://github.com/nlohmann/json/issues/289) -- Silently get numbers into smaller types [\#288](https://github.com/nlohmann/json/issues/288) -- Incorrect parsing of large int64\_t numbers [\#287](https://github.com/nlohmann/json/issues/287) -- \[question\]: macro to disable floating point support [\#284](https://github.com/nlohmann/json/issues/284) - -- unit-constructor1.cpp: Fix floating point truncation warning [\#300](https://github.com/nlohmann/json/pull/300) ([t-b](https://github.com/t-b)) - -## [v2.0.2](https://github.com/nlohmann/json/releases/tag/v2.0.2) (2016-07-31) - -[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.1...v2.0.2) - -- can function dump\(\) return string in the order I push in the json object ? [\#286](https://github.com/nlohmann/json/issues/286) -- Error on the Mac: Undefined symbols for architecture x86\_64 [\#285](https://github.com/nlohmann/json/issues/285) -- value\(\) does not work with \_json\_pointer types [\#283](https://github.com/nlohmann/json/issues/283) -- Build error for std::int64 [\#282](https://github.com/nlohmann/json/issues/282) -- strings can't be accessed after dump\(\)-\>parse\(\) - type is lost [\#281](https://github.com/nlohmann/json/issues/281) -- Easy serialization of classes [\#280](https://github.com/nlohmann/json/issues/280) -- recursive data structures [\#277](https://github.com/nlohmann/json/issues/277) -- hexify\(\) function emits conversion warning [\#270](https://github.com/nlohmann/json/issues/270) - -- let the makefile choose the correct sed [\#279](https://github.com/nlohmann/json/pull/279) ([murinicanor](https://github.com/murinicanor)) -- Update hexify to use array lookup instead of ternary \(\#270\) [\#275](https://github.com/nlohmann/json/pull/275) ([dtoma](https://github.com/dtoma)) - -## [v2.0.1](https://github.com/nlohmann/json/releases/tag/v2.0.1) (2016-06-28) - -[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.0...v2.0.1) - -- Compilation error. [\#273](https://github.com/nlohmann/json/issues/273) -- dump\(\) performance degradation in v2 [\#272](https://github.com/nlohmann/json/issues/272) - -- fixed a tiny typo [\#271](https://github.com/nlohmann/json/pull/271) ([feroldi](https://github.com/feroldi)) - -## [v2.0.0](https://github.com/nlohmann/json/releases/tag/v2.0.0) (2016-06-23) - -[Full Changelog](https://github.com/nlohmann/json/compare/v1.1.0...v2.0.0) - -- json::diff generates incorrect patch when removing multiple array elements. [\#269](https://github.com/nlohmann/json/issues/269) -- Docs - What does Json\[key\] return? [\#267](https://github.com/nlohmann/json/issues/267) -- Compiler Errors With JSON.hpp [\#265](https://github.com/nlohmann/json/issues/265) -- Ambiguous push\_back and operator+= overloads [\#263](https://github.com/nlohmann/json/issues/263) -- Preseving order of items in json [\#262](https://github.com/nlohmann/json/issues/262) -- '\' char problem in strings [\#261](https://github.com/nlohmann/json/issues/261) -- VS2015 compile fail [\#260](https://github.com/nlohmann/json/issues/260) -- -Wconversion warning [\#259](https://github.com/nlohmann/json/issues/259) -- Maybe a bug [\#258](https://github.com/nlohmann/json/issues/258) -- Few tests failed on Visual C++ 2015 [\#257](https://github.com/nlohmann/json/issues/257) -- Access keys when iteration with new for loop C++11 [\#256](https://github.com/nlohmann/json/issues/256) -- multiline text values [\#255](https://github.com/nlohmann/json/issues/255) -- Error when using json in g++ [\#254](https://github.com/nlohmann/json/issues/254) -- is the release 2.0? [\#253](https://github.com/nlohmann/json/issues/253) -- concatenate objects [\#252](https://github.com/nlohmann/json/issues/252) -- Encoding [\#251](https://github.com/nlohmann/json/issues/251) -- Unable to build example for constructing json object with stringstreams [\#250](https://github.com/nlohmann/json/issues/250) -- Hexadecimal support [\#249](https://github.com/nlohmann/json/issues/249) -- Update long-term goals [\#246](https://github.com/nlohmann/json/issues/246) -- Contribution To This Json Project [\#245](https://github.com/nlohmann/json/issues/245) -- Trouble using parser with initial dictionary [\#243](https://github.com/nlohmann/json/issues/243) -- Unit test fails when doing a CMake out-of-tree build [\#241](https://github.com/nlohmann/json/issues/241) -- -Wconversion warnings [\#239](https://github.com/nlohmann/json/issues/239) -- Additional integration options [\#237](https://github.com/nlohmann/json/issues/237) -- .get\\(\) works for non spaced string but returns as array for spaced/longer strings [\#236](https://github.com/nlohmann/json/issues/236) -- ambiguous overload for 'push\_back' and 'operator+=' [\#235](https://github.com/nlohmann/json/issues/235) -- Can't use basic\_json::iterator as a base iterator for std::move\_iterator [\#233](https://github.com/nlohmann/json/issues/233) -- json object's creation can freezes execution [\#231](https://github.com/nlohmann/json/issues/231) -- Incorrect dumping of parsed numbers with exponents, but without decimal places [\#230](https://github.com/nlohmann/json/issues/230) -- double values are serialized with commas as decimal points [\#228](https://github.com/nlohmann/json/issues/228) -- Move semantics with std::initializer\_list [\#225](https://github.com/nlohmann/json/issues/225) -- replace emplace [\#224](https://github.com/nlohmann/json/issues/224) -- abort during getline in yyfill [\#223](https://github.com/nlohmann/json/issues/223) -- free\(\): invalid pointer error in GCC 5.2.1 [\#221](https://github.com/nlohmann/json/issues/221) -- Error compile Android NDK error: 'strtof' is not a member of 'std' [\#219](https://github.com/nlohmann/json/issues/219) -- Wrong link in the README.md [\#217](https://github.com/nlohmann/json/issues/217) -- Wide character strings not supported [\#216](https://github.com/nlohmann/json/issues/216) -- Memory allocations using range-based for loops [\#214](https://github.com/nlohmann/json/issues/214) -- would you like to support gcc 4.8.1? [\#211](https://github.com/nlohmann/json/issues/211) -- Reading concatenated json's from an istream [\#210](https://github.com/nlohmann/json/issues/210) -- Conflicting typedef of ssize\_t on Windows 32 bit when using Boost.Python [\#204](https://github.com/nlohmann/json/issues/204) -- Inconsistency between operator\[\] and push\_back [\#203](https://github.com/nlohmann/json/issues/203) -- Small bugs in json.hpp \(get\_number\) and unit.cpp \(non-standard integer type test\) [\#199](https://github.com/nlohmann/json/issues/199) -- GCC/clang floating point parsing bug in strtod\(\) [\#195](https://github.com/nlohmann/json/issues/195) -- What is within scope? [\#192](https://github.com/nlohmann/json/issues/192) -- Bugs in miloyip/nativejson-benchmark: roundtrips [\#187](https://github.com/nlohmann/json/issues/187) -- Floating point exceptions [\#181](https://github.com/nlohmann/json/issues/181) -- Integer conversion to unsigned [\#178](https://github.com/nlohmann/json/issues/178) -- map string string fails to compile [\#176](https://github.com/nlohmann/json/issues/176) -- In basic\_json::basic\_json\(const CompatibleArrayType& val\), the requirement of CompatibleArrayType is not strict enough. [\#174](https://github.com/nlohmann/json/issues/174) -- Provide a FAQ [\#163](https://github.com/nlohmann/json/issues/163) -- Implicit assignment to std::string fails [\#144](https://github.com/nlohmann/json/issues/144) - -- Fix Issue \#265 [\#266](https://github.com/nlohmann/json/pull/266) ([06needhamt](https://github.com/06needhamt)) -- Define CMake/CTest tests [\#247](https://github.com/nlohmann/json/pull/247) ([robertmrk](https://github.com/robertmrk)) -- Out of tree builds and a few other miscellaneous CMake cleanups. [\#242](https://github.com/nlohmann/json/pull/242) ([ChrisKitching](https://github.com/ChrisKitching)) -- Implement additional integration options [\#238](https://github.com/nlohmann/json/pull/238) ([robertmrk](https://github.com/robertmrk)) -- make serialization locale-independent [\#232](https://github.com/nlohmann/json/pull/232) ([nlohmann](https://github.com/nlohmann)) -- fixes \#223 by updating README.md [\#227](https://github.com/nlohmann/json/pull/227) ([kevin--](https://github.com/kevin--)) -- Use namespace std for int64\_t and uint64\_t [\#226](https://github.com/nlohmann/json/pull/226) ([lv-zheng](https://github.com/lv-zheng)) -- Added missing cerrno header to fix ERANGE compile error on android [\#222](https://github.com/nlohmann/json/pull/222) ([Teemperor](https://github.com/Teemperor)) -- Corrected readme [\#218](https://github.com/nlohmann/json/pull/218) ([Annihil](https://github.com/Annihil)) -- Create PULL\_REQUEST\_TEMPLATE.md [\#213](https://github.com/nlohmann/json/pull/213) ([whackashoe](https://github.com/whackashoe)) -- fixed noexcept; added constexpr [\#208](https://github.com/nlohmann/json/pull/208) ([nlohmann](https://github.com/nlohmann)) -- Add support for afl-fuzz testing [\#207](https://github.com/nlohmann/json/pull/207) ([mykter](https://github.com/mykter)) -- replaced ssize\_t occurrences with auto \(addresses \#204\) [\#205](https://github.com/nlohmann/json/pull/205) ([nlohmann](https://github.com/nlohmann)) -- Fixed issue \#199 - Small bugs in json.hpp \(get\_number\) and unit.cpp \(non-standard integer type test\) [\#200](https://github.com/nlohmann/json/pull/200) ([twelsby](https://github.com/twelsby)) -- Fix broken link [\#197](https://github.com/nlohmann/json/pull/197) ([vog](https://github.com/vog)) -- Issue \#195 - update Travis to Trusty due to gcc/clang strtod\(\) bug [\#196](https://github.com/nlohmann/json/pull/196) ([twelsby](https://github.com/twelsby)) -- Issue \#178 - Extending support to full uint64\_t/int64\_t range and unsigned type \(updated\) [\#193](https://github.com/nlohmann/json/pull/193) ([twelsby](https://github.com/twelsby)) - -## [v1.1.0](https://github.com/nlohmann/json/releases/tag/v1.1.0) (2016-01-24) - -[Full Changelog](https://github.com/nlohmann/json/compare/v1.0.0...v1.1.0) - -- Small error in pull \#185 [\#194](https://github.com/nlohmann/json/issues/194) -- Bugs in miloyip/nativejson-benchmark: floating-point parsing [\#186](https://github.com/nlohmann/json/issues/186) -- Floating point equality [\#185](https://github.com/nlohmann/json/issues/185) -- Unused variables in catch [\#180](https://github.com/nlohmann/json/issues/180) -- Typo in documentation [\#179](https://github.com/nlohmann/json/issues/179) -- JSON performance benchmark comparision [\#177](https://github.com/nlohmann/json/issues/177) -- Since re2c is often ignored in pull requests, it may make sense to make a contributing.md file [\#175](https://github.com/nlohmann/json/issues/175) -- Question about exceptions [\#173](https://github.com/nlohmann/json/issues/173) -- Android? [\#172](https://github.com/nlohmann/json/issues/172) -- Cannot index by key of type static constexpr const char\* [\#171](https://github.com/nlohmann/json/issues/171) -- Add assertions [\#168](https://github.com/nlohmann/json/issues/168) -- MSVC 2015 build fails when attempting to compare object\_t [\#167](https://github.com/nlohmann/json/issues/167) -- Member detector is not portable [\#166](https://github.com/nlohmann/json/issues/166) -- Unnecessary const\_cast [\#162](https://github.com/nlohmann/json/issues/162) -- Question about get\_ref\(\) [\#128](https://github.com/nlohmann/json/issues/128) -- range based for loop for objects [\#83](https://github.com/nlohmann/json/issues/83) -- Consider submitting this to the Boost Library Incubator [\#66](https://github.com/nlohmann/json/issues/66) - -- Fixed Issue \#186 - add strto\(f|d|ld\) overload wrappers, "-0.0" special case and FP trailing zero [\#191](https://github.com/nlohmann/json/pull/191) ([twelsby](https://github.com/twelsby)) -- Issue \#185 - remove approx\(\) and use \#pragma to kill warnings [\#190](https://github.com/nlohmann/json/pull/190) ([twelsby](https://github.com/twelsby)) -- Fixed Issue \#171 - added two extra template overloads of operator\[\] for T\* arguments [\#189](https://github.com/nlohmann/json/pull/189) ([twelsby](https://github.com/twelsby)) -- Fixed issue \#167 - removed operator ValueType\(\) condition for VS2015 [\#188](https://github.com/nlohmann/json/pull/188) ([twelsby](https://github.com/twelsby)) -- Implementation of get\_ref\(\) [\#184](https://github.com/nlohmann/json/pull/184) ([dariomt](https://github.com/dariomt)) -- Fixed some typos in CONTRIBUTING.md [\#182](https://github.com/nlohmann/json/pull/182) ([nibroc](https://github.com/nibroc)) - -## [v1.0.0](https://github.com/nlohmann/json/releases/tag/v1.0.0) (2015-12-27) - -[Full Changelog](https://github.com/nlohmann/json/compare/v1.0.0-rc1...v1.0.0) - -- add key name to exception [\#160](https://github.com/nlohmann/json/issues/160) -- Getting member discarding qualifyer [\#159](https://github.com/nlohmann/json/issues/159) -- basic\_json::iterator::value\(\) output includes quotes while basic\_json::iterator::key\(\) doesn't [\#158](https://github.com/nlohmann/json/issues/158) -- Indexing `const basic_json<>` with `const basic_string` [\#157](https://github.com/nlohmann/json/issues/157) -- token\_type\_name\(token\_type t\): not all control paths return a value [\#156](https://github.com/nlohmann/json/issues/156) -- prevent json.hpp from emitting compiler warnings [\#154](https://github.com/nlohmann/json/issues/154) -- json::parse\(string\) does not check utf8 bom [\#152](https://github.com/nlohmann/json/issues/152) -- unsigned 64bit values output as signed [\#151](https://github.com/nlohmann/json/issues/151) -- Wish feature: json5 [\#150](https://github.com/nlohmann/json/issues/150) -- Unable to compile on MSVC 2015 with SDL checking enabled: This function or variable may be unsafe. [\#149](https://github.com/nlohmann/json/issues/149) -- "Json Object" type does not keep object order [\#148](https://github.com/nlohmann/json/issues/148) -- dump\(\) convert strings encoded by utf-8 to shift-jis on windows 10. [\#147](https://github.com/nlohmann/json/issues/147) -- Unable to get field names in a json object [\#145](https://github.com/nlohmann/json/issues/145) -- Question: Is the use of incomplete type correct? [\#138](https://github.com/nlohmann/json/issues/138) -- json.hpp:5746:32: error: 'to\_string' is not a member of 'std' [\#136](https://github.com/nlohmann/json/issues/136) -- Bug in basic\_json::operator\[\] const overload [\#135](https://github.com/nlohmann/json/issues/135) -- wrong enable\_if for const pointer \(instead of pointer-to-const\) [\#134](https://github.com/nlohmann/json/issues/134) -- overload of at\(\) with default value [\#133](https://github.com/nlohmann/json/issues/133) -- Splitting source [\#132](https://github.com/nlohmann/json/issues/132) -- Question about get\_ptr\(\) [\#127](https://github.com/nlohmann/json/issues/127) -- Visual Studio 14 Debug assertion failed [\#125](https://github.com/nlohmann/json/issues/125) -- Memory leak in face of exceptions [\#118](https://github.com/nlohmann/json/issues/118) -- Find and Count for arrays [\#117](https://github.com/nlohmann/json/issues/117) -- dynamically constructing an arbitrarily nested object [\#114](https://github.com/nlohmann/json/issues/114) -- Returning any data type [\#113](https://github.com/nlohmann/json/issues/113) -- Compile error with g++ 4.9.3 cygwin 64-bit [\#112](https://github.com/nlohmann/json/issues/112) -- insert json array issue with gcc4.8.2 [\#110](https://github.com/nlohmann/json/issues/110) -- error: unterminated raw string [\#109](https://github.com/nlohmann/json/issues/109) -- vector\ copy constructor really weird [\#108](https://github.com/nlohmann/json/issues/108) -- \[clang-3.6.2\] string/sstream with number to json issue [\#107](https://github.com/nlohmann/json/issues/107) -- object field accessors [\#103](https://github.com/nlohmann/json/issues/103) -- v8pp and json [\#95](https://github.com/nlohmann/json/issues/95) -- Wishlist [\#65](https://github.com/nlohmann/json/issues/65) -- Windows/Visual Studio \(through 2013\) is unsupported [\#62](https://github.com/nlohmann/json/issues/62) - -- Replace sprintf with hex function, this fixes \#149 [\#153](https://github.com/nlohmann/json/pull/153) ([whackashoe](https://github.com/whackashoe)) -- Fix character skipping after a surrogate pair [\#146](https://github.com/nlohmann/json/pull/146) ([robertmrk](https://github.com/robertmrk)) -- Detect correctly pointer-to-const [\#137](https://github.com/nlohmann/json/pull/137) ([dariomt](https://github.com/dariomt)) -- disabled "CopyAssignable" test for MSVC in Debug mode, see \#125 [\#131](https://github.com/nlohmann/json/pull/131) ([dariomt](https://github.com/dariomt)) -- removed stream operator for iterator, resolution for \#125 [\#130](https://github.com/nlohmann/json/pull/130) ([dariomt](https://github.com/dariomt)) -- fixed typos in comments for examples [\#129](https://github.com/nlohmann/json/pull/129) ([dariomt](https://github.com/dariomt)) -- Remove superfluous inefficiency [\#126](https://github.com/nlohmann/json/pull/126) ([d-frey](https://github.com/d-frey)) -- remove invalid parameter '-stdlib=libc++' in CMakeLists.txt [\#124](https://github.com/nlohmann/json/pull/124) ([emvivre](https://github.com/emvivre)) -- exception-safe object creation, fixes \#118 [\#122](https://github.com/nlohmann/json/pull/122) ([d-frey](https://github.com/d-frey)) -- Fix small oversight. [\#121](https://github.com/nlohmann/json/pull/121) ([ColinH](https://github.com/ColinH)) -- Overload parse\(\) to accept an rvalue reference [\#120](https://github.com/nlohmann/json/pull/120) ([silverweed](https://github.com/silverweed)) -- Use the right variable name in doc string [\#115](https://github.com/nlohmann/json/pull/115) ([whoshuu](https://github.com/whoshuu)) - -## [v1.0.0-rc1](https://github.com/nlohmann/json/releases/tag/v1.0.0-rc1) (2015-07-26) - -[Full Changelog](https://github.com/nlohmann/json/compare/4502e7e51c0569419c26e75fbdd5748170603e54...v1.0.0-rc1) - -- Finish documenting the public interface in Doxygen [\#102](https://github.com/nlohmann/json/issues/102) -- Binary string causes numbers to be dumped as hex [\#101](https://github.com/nlohmann/json/issues/101) -- failed to iterator json object with reverse\_iterator [\#100](https://github.com/nlohmann/json/issues/100) -- 'noexcept' : unknown override specifier [\#99](https://github.com/nlohmann/json/issues/99) -- json float parsing problem [\#98](https://github.com/nlohmann/json/issues/98) -- Adjust wording to JSON RFC [\#97](https://github.com/nlohmann/json/issues/97) -- static analysis warnings [\#94](https://github.com/nlohmann/json/issues/94) -- reverse\_iterator operator inheritance problem [\#93](https://github.com/nlohmann/json/issues/93) -- init error [\#92](https://github.com/nlohmann/json/issues/92) -- access by \(const\) reference [\#91](https://github.com/nlohmann/json/issues/91) -- is\_integer and is\_float tests [\#90](https://github.com/nlohmann/json/issues/90) -- Nonstandard integer type [\#89](https://github.com/nlohmann/json/issues/89) -- static library build [\#84](https://github.com/nlohmann/json/issues/84) -- lexer::get\_number return NAN [\#82](https://github.com/nlohmann/json/issues/82) -- MinGW have no std::to\_string [\#80](https://github.com/nlohmann/json/issues/80) -- Incorrect behaviour of basic\_json::count method [\#78](https://github.com/nlohmann/json/issues/78) -- Invoking is\_array\(\) function creates "null" value [\#77](https://github.com/nlohmann/json/issues/77) -- dump\(\) / parse\(\) not idempotent [\#76](https://github.com/nlohmann/json/issues/76) -- Handle infinity and NaN cases [\#70](https://github.com/nlohmann/json/issues/70) -- errors in g++-4.8.1 [\#68](https://github.com/nlohmann/json/issues/68) -- Keys when iterating over objects [\#67](https://github.com/nlohmann/json/issues/67) -- Compilation results in tons of warnings [\#64](https://github.com/nlohmann/json/issues/64) -- Complete brief documentation [\#61](https://github.com/nlohmann/json/issues/61) -- Double quotation mark is not parsed correctly [\#60](https://github.com/nlohmann/json/issues/60) -- Get coverage back to 100% [\#58](https://github.com/nlohmann/json/issues/58) -- erase elements using iterators [\#57](https://github.com/nlohmann/json/issues/57) -- Removing item from array [\#56](https://github.com/nlohmann/json/issues/56) -- Serialize/Deserialize like PHP? [\#55](https://github.com/nlohmann/json/issues/55) -- Numbers as keys [\#54](https://github.com/nlohmann/json/issues/54) -- Why are elements alphabetized on key while iterating? [\#53](https://github.com/nlohmann/json/issues/53) -- Document erase, count, and iterators key and value [\#52](https://github.com/nlohmann/json/issues/52) -- Do not use std::to\_string [\#51](https://github.com/nlohmann/json/issues/51) -- Supported compilers [\#50](https://github.com/nlohmann/json/issues/50) -- Confused about iterating through json objects [\#49](https://github.com/nlohmann/json/issues/49) -- Use non-member begin/end [\#48](https://github.com/nlohmann/json/issues/48) -- Erase key [\#47](https://github.com/nlohmann/json/issues/47) -- Key iterator [\#46](https://github.com/nlohmann/json/issues/46) -- Add count member function [\#45](https://github.com/nlohmann/json/issues/45) -- Problem getting vector \(array\) of strings [\#44](https://github.com/nlohmann/json/issues/44) -- Compilation error due to assuming that private=public [\#43](https://github.com/nlohmann/json/issues/43) -- Use of deprecated implicit copy constructor [\#42](https://github.com/nlohmann/json/issues/42) -- Printing attribute names [\#39](https://github.com/nlohmann/json/issues/39) -- dumping a small number\_float just outputs 0.000000 [\#37](https://github.com/nlohmann/json/issues/37) -- find is error [\#32](https://github.com/nlohmann/json/issues/32) -- Avoid using spaces when encoding without pretty print [\#31](https://github.com/nlohmann/json/issues/31) -- Cannot encode long numbers [\#30](https://github.com/nlohmann/json/issues/30) -- segmentation fault when iterating over empty arrays/objects [\#28](https://github.com/nlohmann/json/issues/28) -- Creating an empty array [\#27](https://github.com/nlohmann/json/issues/27) -- Custom allocator support [\#25](https://github.com/nlohmann/json/issues/25) -- make the type of the used string container customizable [\#20](https://github.com/nlohmann/json/issues/20) -- Improper parsing of JSON string "\\" [\#17](https://github.com/nlohmann/json/issues/17) -- create a header-only version [\#16](https://github.com/nlohmann/json/issues/16) -- Don't return "const values" [\#15](https://github.com/nlohmann/json/issues/15) -- Add to\_string overload for indentation [\#13](https://github.com/nlohmann/json/issues/13) -- string parser does not recognize uncompliant strings [\#12](https://github.com/nlohmann/json/issues/12) -- possible double-free in find function [\#11](https://github.com/nlohmann/json/issues/11) -- UTF-8 encoding/deconding/testing [\#10](https://github.com/nlohmann/json/issues/10) -- move code into namespace [\#9](https://github.com/nlohmann/json/issues/9) -- free functions for explicit objects and arrays in initializer lists [\#8](https://github.com/nlohmann/json/issues/8) -- unique\_ptr for ownership [\#7](https://github.com/nlohmann/json/issues/7) -- Add unit tests [\#4](https://github.com/nlohmann/json/issues/4) -- Drop C++98 support [\#3](https://github.com/nlohmann/json/issues/3) -- Test case coverage [\#2](https://github.com/nlohmann/json/issues/2) -- Runtime error in Travis job [\#1](https://github.com/nlohmann/json/issues/1) - -- Keyword 'inline' is useless when member functions are defined in headers [\#87](https://github.com/nlohmann/json/pull/87) ([ahamez](https://github.com/ahamez)) -- Remove useless typename [\#86](https://github.com/nlohmann/json/pull/86) ([ahamez](https://github.com/ahamez)) -- Avoid warning with Xcode's clang [\#85](https://github.com/nlohmann/json/pull/85) ([ahamez](https://github.com/ahamez)) -- Fix typos [\#73](https://github.com/nlohmann/json/pull/73) ([aqnouch](https://github.com/aqnouch)) -- Replace `default_callback` function with `nullptr` and check for null… [\#72](https://github.com/nlohmann/json/pull/72) ([aburgh](https://github.com/aburgh)) -- support enum [\#71](https://github.com/nlohmann/json/pull/71) ([likebeta](https://github.com/likebeta)) -- Fix performance regression introduced with the parsing callback feature. [\#69](https://github.com/nlohmann/json/pull/69) ([aburgh](https://github.com/aburgh)) -- Improve the implementations of the comparission-operators [\#63](https://github.com/nlohmann/json/pull/63) ([Florianjw](https://github.com/Florianjw)) -- Fix compilation of json\_unit with GCC 5 [\#59](https://github.com/nlohmann/json/pull/59) ([dkopecek](https://github.com/dkopecek)) -- Parse streams incrementally. [\#40](https://github.com/nlohmann/json/pull/40) ([aburgh](https://github.com/aburgh)) -- Feature/small float serialization [\#38](https://github.com/nlohmann/json/pull/38) ([jrandall](https://github.com/jrandall)) -- template version with re2c scanner [\#36](https://github.com/nlohmann/json/pull/36) ([nlohmann](https://github.com/nlohmann)) -- more descriptive documentation in example [\#33](https://github.com/nlohmann/json/pull/33) ([luxe](https://github.com/luxe)) -- Fix string conversion under Clang [\#26](https://github.com/nlohmann/json/pull/26) ([wancw](https://github.com/wancw)) -- Fixed dumping of strings [\#24](https://github.com/nlohmann/json/pull/24) ([Teemperor](https://github.com/Teemperor)) -- Added a remark to the readme that coverage is GCC only for now [\#23](https://github.com/nlohmann/json/pull/23) ([Teemperor](https://github.com/Teemperor)) -- Unicode escaping [\#22](https://github.com/nlohmann/json/pull/22) ([Teemperor](https://github.com/Teemperor)) -- Implemented the JSON spec for string parsing for everything but the \uXXXX escaping [\#21](https://github.com/nlohmann/json/pull/21) ([Teemperor](https://github.com/Teemperor)) -- add the std iterator typedefs to iterator and const\_iterator [\#19](https://github.com/nlohmann/json/pull/19) ([kirkshoop](https://github.com/kirkshoop)) -- Fixed escaped quotes [\#18](https://github.com/nlohmann/json/pull/18) ([Teemperor](https://github.com/Teemperor)) -- Fix double delete on std::bad\_alloc exception [\#14](https://github.com/nlohmann/json/pull/14) ([elliotgoodrich](https://github.com/elliotgoodrich)) -- Added CMake and lcov [\#6](https://github.com/nlohmann/json/pull/6) ([Teemperor](https://github.com/Teemperor)) -- Version 2.0 [\#5](https://github.com/nlohmann/json/pull/5) ([nlohmann](https://github.com/nlohmann)) - - - -\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* diff --git a/LICENSE.MIT b/LICENSE.MIT deleted file mode 100644 index 1c1f7a690d..0000000000 --- a/LICENSE.MIT +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2013-2022 Niels Lohmann - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/LICENSES/Apache-2.0.txt b/LICENSES/Apache-2.0.txt deleted file mode 100644 index 137069b823..0000000000 --- a/LICENSES/Apache-2.0.txt +++ /dev/null @@ -1,73 +0,0 @@ -Apache License -Version 2.0, January 2004 -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. - -"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: - - (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. - - You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - -To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/LICENSES/BSD-3-Clause.txt b/LICENSES/BSD-3-Clause.txt deleted file mode 100644 index ea890afbc7..0000000000 --- a/LICENSES/BSD-3-Clause.txt +++ /dev/null @@ -1,11 +0,0 @@ -Copyright (c) . - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/LICENSES/GPL-3.0-only.txt b/LICENSES/GPL-3.0-only.txt deleted file mode 100644 index d41c0bd98f..0000000000 --- a/LICENSES/GPL-3.0-only.txt +++ /dev/null @@ -1,232 +0,0 @@ -GNU GENERAL PUBLIC LICENSE -Version 3, 29 June 2007 - -Copyright © 2007 Free Software Foundation, Inc. - -Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - -Preamble - -The GNU General Public License is a free, copyleft license for software and other kinds of works. - -The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. - -When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. - -To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. - -For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. - -Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. - -For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. - -Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. - -Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. - -The precise terms and conditions for copying, distribution and modification follow. - -TERMS AND CONDITIONS - -0. Definitions. - -“This License” refers to version 3 of the GNU General Public License. - -“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. - -“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations. - -To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work. - -A “covered work” means either the unmodified Program or a work based on the Program. - -To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. - -To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. - -An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. - -1. Source Code. -The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work. - -A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. - -The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. - -The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. - -The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. - -The Corresponding Source for a work in source code form is that same work. - -2. Basic Permissions. -All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. - -You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. - -Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. - -3. Protecting Users' Legal Rights From Anti-Circumvention Law. -No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. - -When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. - -4. Conveying Verbatim Copies. -You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. - -You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. - -5. Conveying Modified Source Versions. -You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”. - - c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. - -A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. - -6. Conveying Non-Source Forms. -You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: - - a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. - - d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. - -A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. - -A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. - -“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. - -If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). - -The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. - -Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. - -7. Additional Terms. -“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. - -When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. - -Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or authors of the material; or - - e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. - -All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. - -If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. - -Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. - -8. Termination. -You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). - -However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. - -Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. - -Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. - -9. Acceptance Not Required for Having Copies. -You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. - -10. Automatic Licensing of Downstream Recipients. -Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. - -An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. - -You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. - -11. Patents. -A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”. - -A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. - -Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. - -In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. - -If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. - -If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. - -A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. - -Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. - -12. No Surrender of Others' Freedom. -If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. - -13. Use with the GNU Affero General Public License. -Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. - -14. Revised Versions of this License. -The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. - -If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. - -Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. - -15. Disclaimer of Warranty. -THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -16. Limitation of Liability. -IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -17. Interpretation of Sections 15 and 16. -If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. - -END OF TERMS AND CONDITIONS - -How to Apply These Terms to Your New Programs - -If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. - -To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - -If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”. - -You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . - -The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt deleted file mode 100644 index 2071b23b0e..0000000000 --- a/LICENSES/MIT.txt +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Makefile b/Makefile deleted file mode 100644 index 6eff8663ec..0000000000 --- a/Makefile +++ /dev/null @@ -1,284 +0,0 @@ -.PHONY: pretty clean ChangeLog.md release - -########################################################################## -# configuration -########################################################################## - -# find GNU sed to use `-i` parameter -SED:=$(shell command -v gsed || which sed) - - -########################################################################## -# source files -########################################################################## - -# the list of sources in the include folder -SRCS=$(shell find include -type f | sort) - -# the list of sources in the tests folder -TESTS_SRCS=$(shell find tests -type f \( -name '*.hpp' -o -name '*.cpp' -o -name '*.cu' \) -not -path 'tests/thirdparty/*' -not -path 'tests/abi/include/nlohmann/*' | sort) - -# the single headers (amalgamated from the source files) -AMALGAMATED_FILE=single_include/nlohmann/json.hpp -AMALGAMATED_FWD_FILE=single_include/nlohmann/json_fwd.hpp - - -########################################################################## -# documentation of the Makefile's targets -########################################################################## - -# main target -all: - @echo "amalgamate - amalgamate files single_include/nlohmann/json{,_fwd}.hpp from the include/nlohmann sources" - @echo "ChangeLog.md - generate ChangeLog file" - @echo "check-amalgamation - check whether sources have been amalgamated" - @echo "clean - remove built files" - @echo "doctest - compile example files and check their output" - @echo "fuzz_testing - prepare fuzz testing of the JSON parser" - @echo "fuzz_testing_bson - prepare fuzz testing of the BSON parser" - @echo "fuzz_testing_cbor - prepare fuzz testing of the CBOR parser" - @echo "fuzz_testing_msgpack - prepare fuzz testing of the MessagePack parser" - @echo "fuzz_testing_ubjson - prepare fuzz testing of the UBJSON parser" - @echo "pretty - beautify code with Artistic Style" - @echo "run_benchmarks - build and run benchmarks" - - -########################################################################## -# documentation tests -########################################################################## - -# compile example files and check output -doctest: - $(MAKE) check_output -C docs - - -########################################################################## -# benchmarks -########################################################################## - -run_benchmarks: - rm -fr cmake-build-benchmarks - mkdir cmake-build-benchmarks - cd cmake-build-benchmarks ; cmake ../tests/benchmarks -GNinja -DCMAKE_BUILD_TYPE=Release - cd cmake-build-benchmarks ; ninja - cd cmake-build-benchmarks ; ./json_benchmarks - - -########################################################################## -# fuzzing -########################################################################## - -# the overall fuzz testing target -fuzz_testing: - rm -fr fuzz-testing - mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out - $(MAKE) parse_afl_fuzzer -C tests CXX=afl-clang++ - mv tests/parse_afl_fuzzer fuzz-testing/fuzzer - find tests/data/json_tests -size -5k -name *json | xargs -I{} cp "{}" fuzz-testing/testcases - @echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer" - -fuzz_testing_bson: - rm -fr fuzz-testing - mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out - $(MAKE) parse_bson_fuzzer -C tests CXX=afl-clang++ - mv tests/parse_bson_fuzzer fuzz-testing/fuzzer - find tests/data -size -5k -name *.bson | xargs -I{} cp "{}" fuzz-testing/testcases - @echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer" - -fuzz_testing_cbor: - rm -fr fuzz-testing - mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out - $(MAKE) parse_cbor_fuzzer -C tests CXX=afl-clang++ - mv tests/parse_cbor_fuzzer fuzz-testing/fuzzer - find tests/data -size -5k -name *.cbor | xargs -I{} cp "{}" fuzz-testing/testcases - @echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer" - -fuzz_testing_msgpack: - rm -fr fuzz-testing - mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out - $(MAKE) parse_msgpack_fuzzer -C tests CXX=afl-clang++ - mv tests/parse_msgpack_fuzzer fuzz-testing/fuzzer - find tests/data -size -5k -name *.msgpack | xargs -I{} cp "{}" fuzz-testing/testcases - @echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer" - -fuzz_testing_ubjson: - rm -fr fuzz-testing - mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out - $(MAKE) parse_ubjson_fuzzer -C tests CXX=afl-clang++ - mv tests/parse_ubjson_fuzzer fuzz-testing/fuzzer - find tests/data -size -5k -name *.ubjson | xargs -I{} cp "{}" fuzz-testing/testcases - @echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer" - -fuzzing-start: - afl-fuzz -S fuzzer1 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null & - afl-fuzz -S fuzzer2 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null & - afl-fuzz -S fuzzer3 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null & - afl-fuzz -S fuzzer4 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null & - afl-fuzz -S fuzzer5 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null & - afl-fuzz -S fuzzer6 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null & - afl-fuzz -S fuzzer7 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null & - afl-fuzz -M fuzzer0 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer - -fuzzing-stop: - -killall fuzzer - -killall afl-fuzz - - -########################################################################## -# Static analysis -########################################################################## - -# call PVS-Studio Analyzer -pvs_studio: - rm -fr cmake-build-pvs-studio - mkdir cmake-build-pvs-studio - cd cmake-build-pvs-studio ; cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DJSON_MultipleHeaders=ON - cd cmake-build-pvs-studio ; pvs-studio-analyzer analyze -j 10 - cd cmake-build-pvs-studio ; plog-converter -a'GA:1,2;64:1;CS' -t fullhtml PVS-Studio.log -o pvs - open cmake-build-pvs-studio/pvs/index.html - - -########################################################################## -# Code format and source amalgamation -########################################################################## - -# call the Artistic Style pretty printer on all source files -pretty: - 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) - $(MAKE) pretty - -# call the amalgamation tool for json.hpp -$(AMALGAMATED_FILE): $(SRCS) - tools/amalgamate/amalgamate.py -c tools/amalgamate/config_json.json -s . --verbose=yes - -# call the amalgamation tool for json_fwd.hpp -$(AMALGAMATED_FWD_FILE): $(SRCS) - tools/amalgamate/amalgamate.py -c tools/amalgamate/config_json_fwd.json -s . --verbose=yes - -# check if file single_include/nlohmann/json.hpp has been amalgamated from the nlohmann sources -# Note: this target is called by Travis -check-amalgamation: - @mv $(AMALGAMATED_FILE) $(AMALGAMATED_FILE)~ - @mv $(AMALGAMATED_FWD_FILE) $(AMALGAMATED_FWD_FILE)~ - @$(MAKE) amalgamate - @diff $(AMALGAMATED_FILE) $(AMALGAMATED_FILE)~ || (echo "===================================================================\n Amalgamation required! Please read the contribution guidelines\n in file .github/CONTRIBUTING.md.\n===================================================================" ; mv $(AMALGAMATED_FILE)~ $(AMALGAMATED_FILE) ; false) - @diff $(AMALGAMATED_FWD_FILE) $(AMALGAMATED_FWD_FILE)~ || (echo "===================================================================\n Amalgamation required! Please read the contribution guidelines\n in file .github/CONTRIBUTING.md.\n===================================================================" ; mv $(AMALGAMATED_FWD_FILE)~ $(AMALGAMATED_FWD_FILE) ; false) - @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 -########################################################################## - -# Create a ChangeLog based on the git log using the GitHub Changelog Generator -# (). - -# variable to control the diffs between the last released version and the current repository state -NEXT_VERSION ?= "unreleased" - -ChangeLog.md: - github_changelog_generator -o ChangeLog.md --user nlohmann --project json --simple-list --release-url https://github.com/nlohmann/json/releases/tag/%s --future-release $(NEXT_VERSION) - $(SED) -i 's|https://github.com/nlohmann/json/releases/tag/HEAD|https://github.com/nlohmann/json/tree/HEAD|' ChangeLog.md - $(SED) -i '2i All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).' ChangeLog.md - - -########################################################################## -# Release files -########################################################################## - -# Create a tar.gz archive that contains sufficient files to be used as CMake project (e.g., using FetchContent). The -# archive is created according to the advices of . -json.tar.xz: - mkdir json - rsync -R $(shell find LICENSE.MIT nlohmann_json.natvis CMakeLists.txt cmake/*.in include single_include -type f) json - gtar --sort=name --mtime="@$(shell git log -1 --pretty=%ct)" --owner=0 --group=0 --numeric-owner --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime --create --file - json | xz --compress -9e --threads=2 - > json.tar.xz - rm -fr json - -# We use `-X` to make the resulting ZIP file reproducible, see -# . -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 - -# Create the files for a release and add signatures and hashes. -release: include.zip json.tar.xz - rm -fr release_files - mkdir release_files - gpg --armor --detach-sig include.zip - gpg --armor --detach-sig $(AMALGAMATED_FILE) - gpg --armor --detach-sig $(AMALGAMATED_FWD_FILE) - gpg --armor --detach-sig json.tar.xz - cp $(AMALGAMATED_FILE) release_files - cp $(AMALGAMATED_FWD_FILE) release_files - mv $(AMALGAMATED_FILE).asc $(AMALGAMATED_FWD_FILE).asc json.tar.xz json.tar.xz.asc include.zip include.zip.asc release_files - cd release_files ; shasum -a 256 json.hpp include.zip json.tar.xz > hashes.txt - - -########################################################################## -# Maintenance -########################################################################## - -# clean up -clean: - rm -fr fuzz fuzz-testing *.dSYM tests/*.dSYM - rm -fr benchmarks/files/numbers/*.json - rm -fr cmake-build-benchmarks fuzz-testing cmake-build-pvs-studio release_files - $(MAKE) clean -Cdocs - - -########################################################################## -# Thirdparty code -########################################################################## - -update_hedley: - rm -f include/nlohmann/thirdparty/hedley/hedley.hpp include/nlohmann/thirdparty/hedley/hedley_undef.hpp - curl https://raw.githubusercontent.com/nemequ/hedley/master/hedley.h -o include/nlohmann/thirdparty/hedley/hedley.hpp - $(SED) -i 's/HEDLEY_/JSON_HEDLEY_/g' include/nlohmann/thirdparty/hedley/hedley.hpp - grep "[[:blank:]]*#[[:blank:]]*undef" include/nlohmann/thirdparty/hedley/hedley.hpp | grep -v "__" | sort | uniq | $(SED) 's/ //g' | $(SED) 's/undef/undef /g' > include/nlohmann/thirdparty/hedley/hedley_undef.hpp - $(SED) -i '1s/^/#pragma once\n\n/' include/nlohmann/thirdparty/hedley/hedley.hpp - $(SED) -i '1s/^/#pragma once\n\n/' include/nlohmann/thirdparty/hedley/hedley_undef.hpp - $(MAKE) amalgamate - -########################################################################## -# serve_header.py -########################################################################## - -serve_header: - ./tools/serve_header/serve_header.py --make $(MAKE) - -########################################################################## -# REUSE -########################################################################## - -reuse: - pipx run reuse addheader --recursive single_include include -tjson --license MIT --copyright "Niels Lohmann " --year "2013-2022" - pipx run reuse addheader $(TESTS_SRCS) --style=c -tjson_support --license MIT --copyright "Niels Lohmann " --year "2013-2022" - pipx run reuse lint diff --git a/README.md b/README.md index 43aacf4d55..657cd75e78 100644 --- a/README.md +++ b/README.md @@ -1,1859 +1,102 @@ -[![JSON for Modern C++](docs/json.gif)](https://github.com/nlohmann/json/releases) +## Purpose -[![Build Status](https://ci.appveyor.com/api/projects/status/1acb366xfyg3qybk/branch/develop?svg=true)](https://ci.appveyor.com/project/nlohmann/json) -[![Ubuntu](https://github.com/nlohmann/json/workflows/Ubuntu/badge.svg)](https://github.com/nlohmann/json/actions?query=workflow%3AUbuntu) -[![macOS](https://github.com/nlohmann/json/workflows/macOS/badge.svg)](https://github.com/nlohmann/json/actions?query=workflow%3AmacOS) -[![Windows](https://github.com/nlohmann/json/workflows/Windows/badge.svg)](https://github.com/nlohmann/json/actions?query=workflow%3AWindows) -[![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&utm_medium=referral&utm_content=nlohmann/json&utm_campaign=Badge_Grade) -[![Cirrus CI](https://api.cirrus-ci.com/github/nlohmann/json.svg)](https://cirrus-ci.com/github/nlohmann/json) -[![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) -[![Average time to resolve an issue](https://isitmaintained.com/badge/resolution/nlohmann/json.svg)](https://isitmaintained.com/project/nlohmann/json "Average time to resolve an issue") -[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/289/badge)](https://bestpractices.coreinfrastructure.org/projects/289) -[![GitHub Sponsors](https://img.shields.io/badge/GitHub-Sponsors-ff69b4)](https://github.com/sponsors/nlohmann) -[![REUSE status](https://api.reuse.software/badge/github.com/nlohmann/json)](https://api.reuse.software/info/github.com/nlohmann/json) -[![Discord](https://img.shields.io/discord/1003743314341793913)](https://discord.gg/6mrGXKvX7y) +Suppose that your application has a complex configuration and: + * that configuration is represented as a set of JSON files + * the files are supposed to be edited by the end-users + * the application on its own provides/dumps only a "default" set of files +somehow annotating the dumped JSON makes much more sense than maintaining a separate documentation +for the allowed values and expected keys, which will get out of date on the nearest occasion. -- [Design goals](#design-goals) -- [Sponsors](#sponsors) -- [Support](#support) ([documentation](https://json.nlohmann.me), [FAQ](https://json.nlohmann.me/home/faq/), [discussions](https://github.com/nlohmann/json/discussions), [API](https://json.nlohmann.me/api/basic_json/), [bug issues](https://github.com/nlohmann/json/issues)) -- [Examples](#examples) - - [Read JSON from a file](#read-json-from-a-file) - - [Creating `json` objects from JSON literals](#creating-json-objects-from-json-literals) - - [JSON as first-class data type](#json-as-first-class-data-type) - - [Serialization / Deserialization](#serialization--deserialization) - - [STL-like access](#stl-like-access) - - [Conversion from STL containers](#conversion-from-stl-containers) - - [JSON Pointer and JSON Patch](#json-pointer-and-json-patch) - - [JSON Merge Patch](#json-merge-patch) - - [Implicit conversions](#implicit-conversions) - - [Conversions to/from arbitrary types](#arbitrary-types-conversions) - - [Specializing enum conversion](#specializing-enum-conversion) - - [Binary formats (BSON, CBOR, MessagePack, UBJSON, and BJData)](#binary-formats-bson-cbor-messagepack-ubjson-and-bjdata) -- [Supported compilers](#supported-compilers) -- [Integration](#integration) - - [CMake](#cmake) - - [Package Managers](#package-managers) - - [Pkg-config](#pkg-config) -- [License](#license) -- [Contact](#contact) -- [Thanks](#thanks) -- [Used third-party tools](#used-third-party-tools) -- [Projects using JSON for Modern C++](#projects-using-json-for-modern-c) -- [Notes](#notes) -- [Execute unit tests](#execute-unit-tests) +As per the [original JSON's RFC](https://datatracker.ietf.org/doc/html/rfc8259) comments are not allowed in JSON. But, knowing that the world +is not ideal, [nlohmann's JSON library](https://github.com/nlohmann/json) does support parsing JSON files with so-called "comments", encoded as follows: -## Design goals - -There are myriads of [JSON](https://json.org) libraries out there, and each may even have its reason to exist. Our class had these design goals: - -- **Intuitive syntax**. In languages such as Python, JSON feels like a first class data type. We used all the operator magic of modern C++ to achieve the same feeling in your code. Check out the [examples below](#examples) and you'll know what I mean. - -- **Trivial integration**. Our whole code consists of a single header file [`json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp). That's it. No library, no subproject, no dependencies, no complex build system. The class is written in vanilla C++11. All in all, everything should require no adjustment of your compiler flags or project settings. - -- **Serious testing**. Our code is heavily [unit-tested](https://github.com/nlohmann/json/tree/develop/tests/src) and covers [100%](https://coveralls.io/r/nlohmann/json) of the code, including all exceptional behavior. Furthermore, we checked with [Valgrind](https://valgrind.org) and the [Clang Sanitizers](https://clang.llvm.org/docs/index.html) that there are no memory leaks. [Google OSS-Fuzz](https://github.com/google/oss-fuzz/tree/master/projects/json) additionally runs fuzz tests against all parsers 24/7, effectively executing billions of tests so far. To maintain high quality, the project is following the [Core Infrastructure Initiative (CII) best practices](https://bestpractices.coreinfrastructure.org/projects/289). - -Other aspects were not so important to us: - -- **Memory efficiency**. Each JSON object has an overhead of one pointer (the maximal size of a union) and one enumeration element (1 byte). The default generalization uses the following C++ data types: `std::string` for strings, `int64_t`, `uint64_t` or `double` for numbers, `std::map` for objects, `std::vector` for arrays, and `bool` for Booleans. However, you can template the generalized class `basic_json` to your needs. - -- **Speed**. There are certainly [faster JSON libraries](https://github.com/miloyip/nativejson-benchmark#parsing-time) out there. However, if your goal is to speed up your development by adding JSON support with a single header, then this library is the way to go. If you know how to use a `std::vector` or `std::map`, you are already set. - -See the [contribution guidelines](https://github.com/nlohmann/json/blob/master/.github/CONTRIBUTING.md#please-dont) for more information. - - -## Sponsors - -You can sponsor this library at [GitHub Sponsors](https://github.com/sponsors/nlohmann). - -### :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) - -### :label: Named Sponsors - -- [Michael Hartmann](https://github.com/reFX-Mike) -- [Stefan Hagen](https://github.com/sthagen) -- [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! - -## Support - -:question: If you have a **question**, please check if it is already answered in the [**FAQ**](https://json.nlohmann.me/home/faq/) or the [**Q&A**](https://github.com/nlohmann/json/discussions/categories/q-a) section. If not, please [**ask a new question**](https://github.com/nlohmann/json/discussions/new) there. - -:books: If you want to **learn more** about how to use the library, check out the rest of the [**README**](#examples), have a look at [**code examples**](https://github.com/nlohmann/json/tree/develop/docs/examples), or browse through the [**help pages**](https://json.nlohmann.me). - -:construction: If you want to understand the **API** better, check out the [**API Reference**](https://json.nlohmann.me/api/basic_json/). - -:bug: If you found a **bug**, please check the [**FAQ**](https://json.nlohmann.me/home/faq/) if it is a known issue or the result of a design decision. Please also have a look at the [**issue list**](https://github.com/nlohmann/json/issues) before you [**create a new issue**](https://github.com/nlohmann/json/issues/new/choose). Please provide as much information as possible to help us understand and reproduce your issue. - -There is also a [**docset**](https://github.com/Kapeli/Dash-User-Contributions/tree/master/docsets/JSON_for_Modern_C%2B%2B) for the documentation browsers [Dash](https://kapeli.com/dash), [Velocity](https://velocity.silverlakesoftware.com), and [Zeal](https://zealdocs.org) that contains the full [documentation](https://json.nlohmann.me) as offline resource. - -## Examples - -Here are some examples to give you an idea how to use the class. - -Beside the examples below, you may want to: - -→ Check the [documentation](https://json.nlohmann.me/)\ -→ Browse the [standalone example files](https://github.com/nlohmann/json/tree/develop/docs/examples) - -Every API function (documented in the [API Documentation](https://json.nlohmann.me/api/basic_json/)) has a corresponding standalone example file. For example, the [`emplace()`](https://json.nlohmann.me/api/basic_json/emplace/) function has a matching [emplace.cpp](https://github.com/nlohmann/json/blob/develop/docs/examples/emplace.cpp) example file. - -### Read JSON from a file - -The `json` class provides an API for manipulating a JSON value. To create a `json` object by reading a JSON file: - -```cpp -#include -#include -using json = nlohmann::json; - -// ... - -std::ifstream f("example.json"); -json data = json::parse(f); -``` - -### Creating `json` objects from JSON literals - -Assume you want to create hard-code this literal JSON value in a file, as a `json` object: - -```json -{ - "pi": 3.141, - "happy": true -} -``` - -There are various options: - -```cpp -// Using (raw) string literals and json::parse -json ex1 = json::parse(R"( - { - "pi": 3.141, - "happy": true - } -)"); - -// Using user-defined (raw) string literals -using namespace nlohmann::literals; -json ex2 = R"( - { - "pi": 3.141, - "happy": true - } -)"_json; - -// Using initializer lists -json ex3 = { - {"happy", true}, - {"pi", 3.141}, -}; ``` - -### JSON as first-class data type - -Here are some examples to give you an idea how to use the class. - -Assume you want to create the JSON object - -```json { - "pi": 3.141, - "happy": true, - "name": "Niels", - "nothing": null, - "answer": { - "everything": 42 - }, - "list": [1, 0, 2], - "object": { - "currency": "USD", - "value": 42.99 - } -} -``` - -With this library, you could write: - -```cpp -// create an empty structure (null) -json j; - -// add a number that is stored as double (note the implicit conversion of j to an object) -j["pi"] = 3.141; - -// add a Boolean that is stored as bool -j["happy"] = true; - -// add a string that is stored as std::string -j["name"] = "Niels"; - -// add another null object by passing nullptr -j["nothing"] = nullptr; - -// add an object inside the object -j["answer"]["everything"] = 42; - -// add an array that is stored as std::vector (using an initializer list) -j["list"] = { 1, 0, 2 }; - -// add another object (using an initializer list of pairs) -j["object"] = { {"currency", "USD"}, {"value", 42.99} }; - -// instead, you could also write (which looks very similar to the JSON above) -json j2 = { - {"pi", 3.141}, - {"happy", true}, - {"name", "Niels"}, - {"nothing", nullptr}, - {"answer", { - {"everything", 42} - }}, - {"list", {1, 0, 2}}, - {"object", { - {"currency", "USD"}, - {"value", 42.99} - }} -}; -``` - -Note that in all these cases, you never need to "tell" the compiler which JSON value type you want to use. If you want to be explicit or express some edge cases, the functions [`json::array()`](https://json.nlohmann.me/api/basic_json/array/) and [`json::object()`](https://json.nlohmann.me/api/basic_json/object/) will help: - -```cpp -// a way to express the empty array [] -json empty_array_explicit = json::array(); - -// ways to express the empty object {} -json empty_object_implicit = json({}); -json empty_object_explicit = json::object(); - -// a way to express an _array_ of key/value pairs [["currency", "USD"], ["value", 42.99]] -json array_not_object = json::array({ {"currency", "USD"}, {"value", 42.99} }); -``` - -### Serialization / Deserialization - -#### To/from strings - -You can create a JSON value (deserialization) by appending `_json` to a string literal: - -```cpp -// create object from string literal -json j = "{ \"happy\": true, \"pi\": 3.141 }"_json; - -// or even nicer with a raw string literal -auto j2 = R"( - { - "happy": true, - "pi": 3.141 - } -)"_json; -``` - -Note that without appending the `_json` suffix, the passed string literal is not parsed, but just used as JSON string -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;` -(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/): - -```cpp -// parse explicitly -auto j3 = json::parse(R"({"happy": true, "pi": 3.141})"); -``` - -You can also get a string representation of a JSON value (serialize): - -```cpp -// explicit conversion to string -std::string s = j.dump(); // {"happy":true,"pi":3.141} - -// serialization with pretty printing -// pass in the amount of spaces to indent -std::cout << j.dump(4) << std::endl; -// { -// "happy": true, -// "pi": 3.141 -// } -``` - -Note the difference between serialization and assignment: - -```cpp -// store a string in a JSON value -json j_string = "this is a string"; - -// retrieve the string value -auto cpp_string = j_string.template get(); -// retrieve the string value (alternative when a variable already exists) -std::string cpp_string2; -j_string.get_to(cpp_string2); - -// retrieve the serialized value (explicit JSON serialization) -std::string serialized_string = j_string.dump(); - -// output of original string -std::cout << cpp_string << " == " << cpp_string2 << " == " << j_string.template get() << '\n'; -// output of serialized value -std::cout << j_string << " == " << serialized_string << std::endl; -``` - -[`.dump()`](https://json.nlohmann.me/api/basic_json/dump/) returns the originally stored string value. - -Note the library only supports UTF-8. When you store strings with different encodings in the library, calling [`dump()`](https://json.nlohmann.me/api/basic_json/dump/) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers. - -#### To/from streams (e.g. files, string streams) - -You can also use streams to serialize and deserialize: - -```cpp -// deserialize from standard input -json j; -std::cin >> j; - -// serialize to standard output -std::cout << j; - -// the setw manipulator was overloaded to set the indentation for pretty printing -std::cout << std::setw(4) << j << std::endl; -``` - -These operators work for any subclasses of `std::istream` or `std::ostream`. Here is the same example with files: - -```cpp -// read a JSON file -std::ifstream i("file.json"); -json j; -i >> j; - -// write prettified JSON to another file -std::ofstream o("pretty.json"); -o << std::setw(4) << j << std::endl; -``` - -Please note that setting the exception bit for `failbit` is inappropriate for this use case. It will result in program termination due to the `noexcept` specifier in use. - -#### Read from iterator range - -You can also parse JSON from an iterator range; that is, from any container accessible by iterators whose `value_type` is an integral type of 1, 2 or 4 bytes, which will be interpreted as UTF-8, UTF-16 and UTF-32 respectively. For instance, a `std::vector`, or a `std::list`: - -```cpp -std::vector v = {'t', 'r', 'u', 'e'}; -json j = json::parse(v.begin(), v.end()); -``` - -You may leave the iterators for the range [begin, end): - -```cpp -std::vector v = {'t', 'r', 'u', 'e'}; -json j = json::parse(v); -``` - -#### Custom data source - -Since the parse function accepts arbitrary iterator ranges, you can provide your own data sources by implementing the `LegacyInputIterator` concept. - -```cpp -struct MyContainer { - void advance(); - const char& get_current(); -}; - -struct MyIterator { - using difference_type = std::ptrdiff_t; - using value_type = char; - using pointer = const char*; - using reference = const char&; - using iterator_category = std::input_iterator_tag; - - MyIterator& operator++() { - MyContainer.advance(); - return *this; - } - - bool operator!=(const MyIterator& rhs) const { - return rhs.target != target; - } - - reference operator*() const { - return target.get_current(); - } - - MyContainer* target = nullptr; -}; - -MyIterator begin(MyContainer& tgt) { - return MyIterator{&tgt}; -} - -MyIterator end(const MyContainer&) { - return {}; -} - -void foo() { - MyContainer c; - json j = json::parse(c); -} -``` - -#### SAX interface - -The library uses a SAX-like interface with the following functions: - -```cpp -// called when null is parsed -bool null(); - -// called when a boolean is parsed; value is passed -bool boolean(bool val); - -// called when a signed or unsigned integer number is parsed; value is passed -bool number_integer(number_integer_t val); -bool number_unsigned(number_unsigned_t val); - -// called when a floating-point number is parsed; value and original string is passed -bool number_float(number_float_t val, const string_t& s); - -// called when a string is parsed; value is passed and can be safely moved away -bool string(string_t& val); -// called when a binary value is parsed; value is passed and can be safely moved away -bool binary(binary_t& val); - -// called when an object or array begins or ends, resp. The number of elements is passed (or -1 if not known) -bool start_object(std::size_t elements); -bool end_object(); -bool start_array(std::size_t elements); -bool end_array(); -// called when an object key is parsed; value is passed and can be safely moved away -bool key(string_t& val); - -// called when a parse error occurs; byte position, the last token, and an exception is passed -bool parse_error(std::size_t position, const std::string& last_token, const detail::exception& ex); -``` - -The return value of each function determines whether parsing should proceed. - -To implement your own SAX handler, proceed as follows: - -1. Implement the SAX interface in a class. You can use class `nlohmann::json_sax` as base class, but you can also use any class where the functions described above are implemented and public. -2. Create an object of your SAX interface class, e.g. `my_sax`. -3. Call `bool json::sax_parse(input, &my_sax)`; where the first parameter can be any input like a string or an input stream and the second parameter is a pointer to your SAX interface. - -Note the `sax_parse` function only returns a `bool` indicating the result of the last executed SAX event. It does not return a `json` value - it is up to you to decide what to do with the SAX events. Furthermore, no exceptions are thrown in case of a parse error - it is up to you what to do with the exception object passed to your `parse_error` implementation. Internally, the SAX interface is used for the DOM parser (class `json_sax_dom_parser`) as well as the acceptor (`json_sax_acceptor`), see file [`json_sax.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/input/json_sax.hpp). - -### STL-like access - -We designed the JSON class to behave just like an STL container. In fact, it satisfies the [**ReversibleContainer**](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer) requirement. - -```cpp -// create an array using push_back -json j; -j.push_back("foo"); -j.push_back(1); -j.push_back(true); - -// also use emplace_back -j.emplace_back(1.78); - -// iterate the array -for (json::iterator it = j.begin(); it != j.end(); ++it) { - std::cout << *it << '\n'; -} - -// range-based for -for (auto& element : j) { - std::cout << element << '\n'; -} - -// getter/setter -const auto tmp = j[0].template get(); -j[1] = 42; -bool foo = j.at(2); - -// comparison -j == R"(["foo", 1, true, 1.78])"_json; // true - -// other stuff -j.size(); // 4 entries -j.empty(); // false -j.type(); // json::value_t::array -j.clear(); // the array is empty again - -// convenience type checkers -j.is_null(); -j.is_boolean(); -j.is_number(); -j.is_object(); -j.is_array(); -j.is_string(); - -// create an object -json o; -o["foo"] = 23; -o["bar"] = false; -o["baz"] = 3.141; - -// also use emplace -o.emplace("weather", "sunny"); - -// special iterator member functions for objects -for (json::iterator it = o.begin(); it != o.end(); ++it) { - std::cout << it.key() << " : " << it.value() << "\n"; -} - -// the same code as range for -for (auto& el : o.items()) { - std::cout << el.key() << " : " << el.value() << "\n"; -} - -// even easier with structured bindings (C++17) -for (auto& [key, value] : o.items()) { - std::cout << key << " : " << value << "\n"; -} - -// find an entry -if (o.contains("foo")) { - // there is an entry with key "foo" + /* this is a comment */ + "property_1": 5 } - -// or via find and an iterator -if (o.find("foo") != o.end()) { - // there is an entry with key "foo" -} - -// or simpler using count() -int foo_present = o.count("foo"); // 1 -int fob_present = o.count("fob"); // 0 - -// delete an entry -o.erase("foo"); ``` +A specific overload of the `parse` method has to be called, as per [this](https://json.nlohmann.me/features/comments/) part of the reference: -### Conversion from STL containers - -Any sequence container (`std::array`, `std::vector`, `std::deque`, `std::forward_list`, `std::list`) whose values can be used to construct JSON values (e.g., integers, floating point numbers, Booleans, string types, or again STL containers described in this section) can be used to create a JSON array. The same holds for similar associative containers (`std::set`, `std::multiset`, `std::unordered_set`, `std::unordered_multiset`), but in these cases the order of the elements of the array depends on how the elements are ordered in the respective STL container. - -```cpp -std::vector c_vector {1, 2, 3, 4}; -json j_vec(c_vector); -// [1, 2, 3, 4] - -std::deque c_deque {1.2, 2.3, 3.4, 5.6}; -json j_deque(c_deque); -// [1.2, 2.3, 3.4, 5.6] - -std::list c_list {true, true, false, true}; -json j_list(c_list); -// [true, true, false, true] - -std::forward_list c_flist {12345678909876, 23456789098765, 34567890987654, 45678909876543}; -json j_flist(c_flist); -// [12345678909876, 23456789098765, 34567890987654, 45678909876543] - -std::array c_array {{1, 2, 3, 4}}; -json j_array(c_array); -// [1, 2, 3, 4] - -std::set c_set {"one", "two", "three", "four", "one"}; -json j_set(c_set); // only one entry for "one" is used -// ["four", "one", "three", "two"] - -std::unordered_set c_uset {"one", "two", "three", "four", "one"}; -json j_uset(c_uset); // only one entry for "one" is used -// maybe ["two", "three", "four", "one"] - -std::multiset c_mset {"one", "two", "one", "four"}; -json j_mset(c_mset); // both entries for "one" are used -// maybe ["one", "two", "one", "four"] - -std::unordered_multiset c_umset {"one", "two", "one", "four"}; -json j_umset(c_umset); // both entries for "one" are used -// maybe ["one", "two", "one", "four"] -``` - -Likewise, any associative key-value containers (`std::map`, `std::multimap`, `std::unordered_map`, `std::unordered_multimap`) whose keys can construct an `std::string` and whose values can be used to construct JSON values (see examples above) can be used to create a JSON object. Note that in case of multimaps only one key is used in the JSON object and the value depends on the internal order of the STL container. - -```cpp -std::map c_map { {"one", 1}, {"two", 2}, {"three", 3} }; -json j_map(c_map); -// {"one": 1, "three": 3, "two": 2 } - -std::unordered_map c_umap { {"one", 1.2}, {"two", 2.3}, {"three", 3.4} }; -json j_umap(c_umap); -// {"one": 1.2, "two": 2.3, "three": 3.4} - -std::multimap c_mmap { {"one", true}, {"two", true}, {"three", false}, {"three", true} }; -json j_mmap(c_mmap); // only one entry for key "three" is used -// maybe {"one": true, "two": true, "three": true} - -std::unordered_multimap c_ummap { {"one", true}, {"two", true}, {"three", false}, {"three", true} }; -json j_ummap(c_ummap); // only one entry for key "three" is used -// maybe {"one": true, "two": true, "three": true} -``` - -### JSON Pointer and JSON Patch - -The library supports **JSON Pointer** ([RFC 6901](https://tools.ietf.org/html/rfc6901)) as alternative means to address structured values. On top of this, **JSON Patch** ([RFC 6902](https://tools.ietf.org/html/rfc6902)) allows describing differences between two JSON values - effectively allowing patch and diff operations known from Unix. - -```cpp -// a JSON value -json j_original = R"({ - "baz": ["one", "two", "three"], - "foo": "bar" -})"_json; - -// access members with a JSON pointer (RFC 6901) -j_original["/baz/1"_json_pointer]; -// "two" - -// a JSON patch (RFC 6902) -json j_patch = R"([ - { "op": "replace", "path": "/baz", "value": "boo" }, - { "op": "add", "path": "/hello", "value": ["world"] }, - { "op": "remove", "path": "/foo"} -])"_json; - -// apply the patch -json j_result = j_original.patch(j_patch); -// { -// "baz": "boo", -// "hello": ["world"] -// } - -// calculate a JSON patch from two JSON values -json::diff(j_result, j_original); -// [ -// { "op":" replace", "path": "/baz", "value": ["one", "two", "three"] }, -// { "op": "remove","path": "/hello" }, -// { "op": "add", "path": "/foo", "value": "bar" } -// ] -``` - -### JSON Merge Patch - -The library supports **JSON Merge Patch** ([RFC 7386](https://tools.ietf.org/html/rfc7386)) as a patch format. Instead of using JSON Pointer (see above) to specify values to be manipulated, it describes the changes using a syntax that closely mimics the document being modified. - -```cpp -// a JSON value -json j_document = R"({ - "a": "b", - "c": { - "d": "e", - "f": "g" - } -})"_json; - -// a patch -json j_patch = R"({ - "a":"z", - "c": { - "f": null - } -})"_json; - -// apply the patch -j_document.merge_patch(j_patch); -// { -// "a": "z", -// "c": { -// "d": "e" -// } -// } -``` - -### Implicit conversions - -Supported types can be implicitly converted to JSON values. - -It is recommended to **NOT USE** implicit conversions **FROM** a JSON value. -You can find more details about this recommendation [here](https://www.github.com/nlohmann/json/issues/958). -You can switch off implicit conversions by defining `JSON_USE_IMPLICIT_CONVERSIONS` to `0` before including the `json.hpp` header. When using CMake, you can also achieve this by setting the option `JSON_ImplicitConversions` to `OFF`. - -```cpp -// strings -std::string s1 = "Hello, world!"; -json js = s1; -auto s2 = js.template get(); -// NOT RECOMMENDED -std::string s3 = js; -std::string s4; -s4 = js; - -// Booleans -bool b1 = true; -json jb = b1; -auto b2 = jb.template get(); -// NOT RECOMMENDED -bool b3 = jb; -bool b4; -b4 = jb; - -// numbers -int i = 42; -json jn = i; -auto f = jn.template get(); -// NOT RECOMMENDED -double f2 = jb; -double f3; -f3 = jb; - -// etc. -``` - -Note that `char` types are not automatically converted to JSON strings, but to integer numbers. A conversion to a string must be specified explicitly: - -```cpp -char ch = 'A'; // ASCII value 65 -json j_default = ch; // stores integer number 65 -json j_string = std::string(1, ch); // stores string "A" -``` - -### Arbitrary types conversions - -Every type can be serialized in JSON, not just STL containers and scalar types. Usually, you would do something along those lines: - -```cpp -namespace ns { - // a simple struct to model a person - struct person { - std::string name; - std::string address; - int age; - }; -} - -ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; - -// convert to JSON: copy each value into the JSON object -json j; -j["name"] = p.name; -j["address"] = p.address; -j["age"] = p.age; - -// ... - -// convert from JSON: copy each value from the JSON object -ns::person p { - j["name"].template get(), - j["address"].template get(), - j["age"].template get() -}; -``` - -It works, but that's quite a lot of boilerplate... Fortunately, there's a better way: - -```cpp -// create a person -ns::person p {"Ned Flanders", "744 Evergreen Terrace", 60}; - -// conversion: person -> json -json j = p; - -std::cout << j << std::endl; -// {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} - -// conversion: json -> person -auto p2 = j.template get(); - -// that's it -assert(p == p2); ``` - -#### Basic usage - -To make this work with one of your types, you only need to provide two functions: - -```cpp -using json = nlohmann::json; - -namespace ns { - void to_json(json& j, const person& p) { - j = json{{"name", p.name}, {"address", p.address}, {"age", p.age}}; - } - - void from_json(const json& j, person& p) { - j.at("name").get_to(p.name); - j.at("address").get_to(p.address); - j.at("age").get_to(p.age); - } -} // namespace ns +json j = json::parse(s, + /* callback */ nullptr, + /* allow exceptions */ true, + /* ignore_comments */ true); ``` -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()` 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` **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. +(so, more specifically, the library allows ignoring them) -#### Simplify your life with macros +However, the library does not allow for annotating (adding the comments) when serializing your custom classes or structures. Best you could +possibly do is post-process the dumped string or file through raw string processing, which is error-prone and problematic. -If you just want to serialize/deserialize some structs, the `to_json`/`from_json` functions can be a lot of boilerplate. - -There are two macros to make your life easier as long as you (1) want to use a JSON object as serialization and (2) want to use the member variable names as object keys in that object: - -- `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(name, member1, member2, ...)` is to be defined inside the namespace of the class/struct to create code for. -- `NLOHMANN_DEFINE_TYPE_INTRUSIVE(name, member1, member2, ...)` is to be defined inside the class/struct to create code for. This macro can also access private members. - -In both macros, the first parameter is the name of the class/struct, and all remaining parameters name the members. - -##### Examples - -The `to_json`/`from_json` functions for the `person` struct above can be created with: - -```cpp -namespace ns { - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(person, name, address, age) -} -``` +This fork of the [nlohmann's JSON library](https://github.com/nlohmann/json) adds a possibility to add annotations (known at compile-time) to your classes and structures. I'll try to keep the fork up to date with the original repository, potentially "shadowing" the releases in the future as well[^1]. -Here is an example with private members, where `NLOHMANN_DEFINE_TYPE_INTRUSIVE` is needed: +## How to use -```cpp -namespace ns { - class address { - private: - std::string street; - int housenumber; - int postcode; +Currently, the extension applies exclusively[^2] to [`NLOHMANN_DEFINE_TYPE_INTRUSIVE` macro](https://github.com/nlohmann/json#simplify-your-life-with-macros): - public: - NLOHMANN_DEFINE_TYPE_INTRUSIVE(address, street, housenumber, postcode) - }; -} ``` +class ExampleClass { +private: + int property1{1}; + double property2{2.5}; + std::string property3{"test"}; + std::map property4{{"x", 1}, {"y", 2}}; + std::vector property5{1.5, 5.4, 3.2}; +public: + ExampleClass() = default; -#### How do I convert third-party types? - -This requires a bit more advanced technique. But first, let's see how this conversion mechanism works: - -The library uses **JSON Serializers** to convert types to json. -The default serializer for `nlohmann::json` is `nlohmann::adl_serializer` (ADL means [Argument-Dependent Lookup](https://en.cppreference.com/w/cpp/language/adl)). - -It is implemented like this (simplified): - -```cpp -template -struct adl_serializer { - static void to_json(json& j, const T& value) { - // calls the "to_json" method in T's namespace - } - - static void from_json(const json& j, T& value) { - // same thing, but with the "from_json" method - } + NLOHMANN_DEFINE_TYPE_INTRUSIVE_ANNOTATED(ExampleClass, property1, "comment两两", + property2, "multiline\ncomment2", + property3, "comment3", + property4, "comment4", + property5, "comment5"); }; ``` -This serializer works fine when you have control over the type's namespace. However, what about `boost::optional` or `std::filesystem::path` (C++17)? Hijacking the `boost` namespace is pretty bad, and it's illegal to add something other than template specializations to `std`... +Dumping is as simple as that: -To solve this, you need to add a specialization of `adl_serializer` to the `nlohmann` namespace, here's an example: - -```cpp -// partial specialization (full specialization works too) -namespace nlohmann { - template - struct adl_serializer> { - static void to_json(json& j, const boost::optional& opt) { - if (opt == boost::none) { - j = nullptr; - } else { - j = *opt; // this will call adl_serializer::to_json which will - // find the free function to_json in T's namespace! - } - } - - static void from_json(const json& j, boost::optional& opt) { - if (j.is_null()) { - opt = boost::none; - } else { - opt = j.template get(); // same as above, but with - // adl_serializer::from_json - } - } - }; -} ``` +int main() { + ExampleClass ec; + std::ofstream example_file; + example_file.open("example_1.json"); -#### How can I use `get()` for non-default constructible/non-copyable types? - -There is a way, if your type is [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible). You will need to specialize the `adl_serializer` as well, but with a special `from_json` overload: - -```cpp -struct move_only_type { - move_only_type() = delete; - move_only_type(int ii): i(ii) {} - move_only_type(const move_only_type&) = delete; - move_only_type(move_only_type&&) = default; - - int i; -}; - -namespace nlohmann { - template <> - struct adl_serializer { - // 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()}; - } + nlohmann::json j = ec; + example_file << j.dump_annotated(4) << std::endl; + // instead of the original: + // example_file << j.dump(4) << std::endl; - // Here's the catch! You must provide a to_json method! Otherwise, you - // will not be able to convert move_only_type to json, since you fully - // specialized adl_serializer on that type - static void to_json(json& j, move_only_type t) { - j = t.i; - } - }; + return 0; } ``` -#### Can I write my own serializer? (Advanced use) - -Yes. You might want to take a look at [`unit-udt.cpp`](https://github.com/nlohmann/json/blob/develop/tests/src/unit-udt.cpp) in the test suite, to see a few examples. - -If you write your own serializer, you'll need to do a few things: - -- use a different `basic_json` alias than `nlohmann::json` (the last template parameter of `basic_json` is the `JSONSerializer`) -- use your `basic_json` alias (or a template parameter) in all your `to_json`/`from_json` methods -- use `nlohmann::to_json` and `nlohmann::from_json` when you need ADL +This is then going to produce a JSON file like this: -Here is an example, without simplifications, that only accepts types with a size <= 32, and uses ADL. - -```cpp -// You should use void as a second template argument -// if you don't need compile-time checks on T -template::type> -struct less_than_32_serializer { - template - static void to_json(BasicJsonType& j, T value) { - // we want to use ADL, and call the correct to_json overload - using nlohmann::to_json; // this method is called by adl_serializer, - // this is where the magic happens - to_json(j, value); - } - - template - static void from_json(const BasicJsonType& j, T& value) { - // same thing here - using nlohmann::from_json; - from_json(j, value); - } -}; ``` - -Be **very** careful when reimplementing your serializer, you can stack overflow if you don't pay attention: - -```cpp -template -struct bad_serializer { - template - static void to_json(BasicJsonType& j, const T& value) { - // this calls BasicJsonType::json_serializer::to_json(j, value); - // if BasicJsonType::json_serializer == bad_serializer ... oops! - j = value; - } - - template - static void to_json(const BasicJsonType& j, T& value) { - // this calls BasicJsonType::json_serializer::from_json(j, value); - // if BasicJsonType::json_serializer == bad_serializer ... oops! - value = j.template get(); // oops! - } -}; -``` - -### Specializing enum conversion - -By default, enum values are serialized to JSON as integers. In some cases this could result in undesired behavior. If an enum is modified or re-ordered after data has been serialized to JSON, the later de-serialized JSON data may be undefined or a different enum value than was originally intended. - -It is possible to more precisely specify how a given enum is mapped to and from JSON as shown below: - -```cpp -// example enum type declaration -enum TaskState { - TS_STOPPED, - TS_RUNNING, - TS_COMPLETED, - TS_INVALID=-1, -}; - -// map TaskState values to JSON as strings -NLOHMANN_JSON_SERIALIZE_ENUM( TaskState, { - {TS_INVALID, nullptr}, - {TS_STOPPED, "stopped"}, - {TS_RUNNING, "running"}, - {TS_COMPLETED, "completed"}, -}) -``` - -The `NLOHMANN_JSON_SERIALIZE_ENUM()` macro declares a set of `to_json()` / `from_json()` functions for type `TaskState` while avoiding repetition and boilerplate serialization code. - -**Usage:** - -```cpp -// enum to JSON as string -json j = TS_STOPPED; -assert(j == "stopped"); - -// json string to enum -json j3 = "running"; -assert(j3.template get() == TS_RUNNING); - -// undefined json value to enum (where the first map entry above is the default) -json jPi = 3.14; -assert(jPi.template get() == TS_INVALID ); -``` - -Just as in [Arbitrary Type Conversions](#arbitrary-types-conversions) above, -- `NLOHMANN_JSON_SERIALIZE_ENUM()` MUST be declared in your enum type's namespace (which can be the global namespace), or the library will not be able to locate it, and it will default to integer serialization. -- It MUST be available (e.g., proper headers must be included) everywhere you use the conversions. - -Other Important points: -- When using `template get()`, 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) - -Though JSON is a ubiquitous data format, it is not a very compact format suitable for data exchange, for instance over a network. Hence, the library supports [BSON](https://bsonspec.org) (Binary JSON), [CBOR](https://cbor.io) (Concise Binary Object Representation), [MessagePack](https://msgpack.org), [UBJSON](https://ubjson.org) (Universal Binary JSON Specification) and [BJData](https://neurojson.org/bjdata) (Binary JData) to efficiently encode JSON values to byte vectors and to decode such vectors. - -```cpp -// create a JSON value -json j = R"({"compact": true, "schema": 0})"_json; - -// serialize to BSON -std::vector v_bson = json::to_bson(j); - -// 0x1B, 0x00, 0x00, 0x00, 0x08, 0x63, 0x6F, 0x6D, 0x70, 0x61, 0x63, 0x74, 0x00, 0x01, 0x10, 0x73, 0x63, 0x68, 0x65, 0x6D, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - -// roundtrip -json j_from_bson = json::from_bson(v_bson); - -// serialize to CBOR -std::vector v_cbor = json::to_cbor(j); - -// 0xA2, 0x67, 0x63, 0x6F, 0x6D, 0x70, 0x61, 0x63, 0x74, 0xF5, 0x66, 0x73, 0x63, 0x68, 0x65, 0x6D, 0x61, 0x00 - -// roundtrip -json j_from_cbor = json::from_cbor(v_cbor); - -// serialize to MessagePack -std::vector v_msgpack = json::to_msgpack(j); - -// 0x82, 0xA7, 0x63, 0x6F, 0x6D, 0x70, 0x61, 0x63, 0x74, 0xC3, 0xA6, 0x73, 0x63, 0x68, 0x65, 0x6D, 0x61, 0x00 - -// roundtrip -json j_from_msgpack = json::from_msgpack(v_msgpack); - -// serialize to UBJSON -std::vector v_ubjson = json::to_ubjson(j); - -// 0x7B, 0x69, 0x07, 0x63, 0x6F, 0x6D, 0x70, 0x61, 0x63, 0x74, 0x54, 0x69, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6D, 0x61, 0x69, 0x00, 0x7D - -// roundtrip -json j_from_ubjson = json::from_ubjson(v_ubjson); -``` - -The library also supports binary types from BSON, CBOR (byte strings), and MessagePack (bin, ext, fixext). They are stored by default as `std::vector` to be processed outside the library. - -```cpp -// CBOR byte string with payload 0xCAFE -std::vector v = {0x42, 0xCA, 0xFE}; - -// read value -json j = json::from_cbor(v); - -// the JSON value has type binary -j.is_binary(); // true - -// get reference to stored binary value -auto& binary = j.get_binary(); - -// the binary value has no subtype (CBOR has no binary subtypes) -binary.has_subtype(); // false - -// access std::vector member functions -binary.size(); // 2 -binary[0]; // 0xCA -binary[1]; // 0xFE - -// set subtype to 0x10 -binary.set_subtype(0x10); - -// serialize to MessagePack -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: - -- GCC 4.8 - 12.0 (and possibly later) -- Clang 3.4 - 15.0 (and possibly later) -- Apple Clang 9.1 - 13.1 (and possibly later) -- Intel C++ Compiler 17.0.2 (and possibly later) -- Nvidia CUDA Compiler 11.0.221 (and possibly later) -- Microsoft Visual C++ 2015 / Build Tools 14.0.25123.0 (and possibly later) -- Microsoft Visual C++ 2017 / Build Tools 15.5.180.51428 (and possibly later) -- Microsoft Visual C++ 2019 / Build Tools 16.3.1+1def00d3d (and possibly later) -- Microsoft Visual C++ 2022 / Build Tools 19.30.30709.0 (and possibly later) - -I would be happy to learn about other compilers/versions. - -Please note: - -- GCC 4.8 has a bug [57824](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57824)): multiline raw strings cannot be the arguments to macros. Don't use multiline raw strings directly in macros with this compiler. -- Android defaults to using very old compilers and C++ libraries. To fix this, add the following to your `Application.mk`. This will switch to the LLVM C++ library, the Clang compiler, and enable C++11 and other features disabled by default. - - ``` - APP_STL := c++_shared - NDK_TOOLCHAIN_VERSION := clang3.6 - APP_CPPFLAGS += -frtti -fexceptions - ``` - - The code compiles successfully with [Android NDK](https://developer.android.com/ndk/index.html?hl=ml), Revision 9 - 11 (and possibly later) and [CrystaX's Android NDK](https://www.crystax.net/en/android/ndk) version 10. - -- For GCC running on MinGW or Android SDK, the error `'to_string' is not a member of 'std'` (or similarly, for `strtod` or `strtof`) may occur. Note this is not an issue with the code, but rather with the compiler itself. On Android, see above to build with a newer environment. For MinGW, please refer to [this site](https://tehsausage.com/mingw-to-string) and [this discussion](https://github.com/nlohmann/json/issues/136) for information on how to fix this bug. For Android NDK using `APP_STL := gnustl_static`, please refer to [this discussion](https://github.com/nlohmann/json/issues/219). - -- 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): - -| 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 | -| 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 | -| 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 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 | -| 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 | -| Visual Studio 15 2017 MSVC 19.16.27035.0 (Build Engine version 15.9.21+g9802d43bc3 for .NET Framework) | Windows-10.0.14393 | AppVeyor | -| Visual Studio 16 2019 MSVC 19.28.29912.0 (Build Engine version 16.9.0+57a23d249 for .NET Framework) | Windows-10.0.17763 | GitHub Actions | -| Visual Studio 16 2019 MSVC 19.28.29912.0 (Build Engine version 16.9.0+57a23d249 for .NET Framework) | Windows-10.0.17763 | AppVeyor | -| Visual Studio 17 2022 MSVC 19.30.30709.0 (Build Engine version 17.0.31804.368 for .NET Framework) | Windows-10.0.20348 | GitHub Actions | - - -## Integration - -[`json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp) is the single required file in `single_include/nlohmann` or [released here](https://github.com/nlohmann/json/releases). You need to add - -```cpp -#include - -// for convenience -using json = nlohmann::json; -``` - -to the files you want to process JSON and set the necessary switches to enable C++11 (e.g., `-std=c++11` for GCC and Clang). - -You can further use file [`include/nlohmann/json_fwd.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/json_fwd.hpp) for forward-declarations. The installation of json_fwd.hpp (as part of cmake's install step), can be achieved by setting `-DJSON_MultipleHeaders=ON`. - -### CMake - -You can also use the `nlohmann_json::nlohmann_json` interface target in CMake. This target populates the appropriate usage requirements for `INTERFACE_INCLUDE_DIRECTORIES` to point to the appropriate include directories and `INTERFACE_COMPILE_FEATURES` for the necessary C++11 flags. - -#### External - -To use this library from a CMake project, you can locate it directly with `find_package()` and use the namespaced imported target from the generated package configuration: - -```cmake -# CMakeLists.txt -find_package(nlohmann_json 3.2.0 REQUIRED) -... -add_library(foo ...) -... -target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json) -``` - -The package configuration file, `nlohmann_jsonConfig.cmake`, can be used either from an install tree or directly out of the build tree. - -#### Embedded - -To embed the library directly into an existing CMake project, place the entire source tree in a subdirectory and call `add_subdirectory()` in your `CMakeLists.txt` file: - -```cmake -# Typically you don't care so much for a third party library's tests to be -# run from your own project's code. -set(JSON_BuildTests OFF CACHE INTERNAL "") - -# If you only include this third party in PRIVATE source files, you do not -# need to install it when your main project gets installed. -# set(JSON_Install OFF CACHE INTERNAL "") - -# Don't use include(nlohmann_json/CMakeLists.txt) since that carries with it -# unintended consequences that will break the build. It's generally -# discouraged (although not necessarily well documented as such) to use -# include(...) for pulling in other CMake projects anyways. -add_subdirectory(nlohmann_json) -... -add_library(foo ...) -... -target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json) -``` - -##### Embedded (FetchContent) - -Since CMake v3.11, -[FetchContent](https://cmake.org/cmake/help/v3.11/module/FetchContent.html) can -be used to automatically download a release as a dependency at configure time. - -Example: -```cmake -include(FetchContent) - -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) -``` - -**Note**: It is recommended to use the URL approach described above which is supported as of version 3.10.0. See - for more information. - -#### Supporting Both - -To allow your project to support either an externally supplied or an embedded JSON library, you can use a pattern akin to the following: - -``` cmake -# Top level CMakeLists.txt -project(FOO) -... -option(FOO_USE_EXTERNAL_JSON "Use an external JSON library" OFF) -... -add_subdirectory(thirdparty) -... -add_library(foo ...) -... -# Note that the namespaced target will always be available regardless of the -# import method -target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json) -``` -```cmake -# thirdparty/CMakeLists.txt -... -if(FOO_USE_EXTERNAL_JSON) - find_package(nlohmann_json 3.2.0 REQUIRED) -else() - set(JSON_BuildTests OFF CACHE INTERNAL "") - add_subdirectory(nlohmann_json) -endif() -... -``` - -`thirdparty/nlohmann_json` is then a complete copy of this source tree. - -### Package Managers - -:beer: If you are using OS X and [Homebrew](https://brew.sh), just type `brew install nlohmann-json` and you're set. If you want the bleeding edge rather than the latest release, use `brew install nlohmann-json --HEAD`. See [nlohmann-json](https://formulae.brew.sh/formula/nlohmann-json) for more information. - -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`. - -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. - -If you are using [Spack](https://www.spack.io/) to manage your dependencies, you can use the [`nlohmann-json` package](https://spack.readthedocs.io/en/latest/package_list.html#nlohmann-json). Please see the [spack project](https://github.com/spack/spack) for any issues regarding the packaging. - -If you are using [hunter](https://github.com/cpp-pm/hunter) on your project for external dependencies, then you can use the [nlohmann_json package](https://hunter.readthedocs.io/en/latest/packages/pkg/nlohmann_json.html). Please see the hunter project for any issues regarding the packaging. - -If you are using [Buckaroo](https://buckaroo.pm), you can install this library's module with `buckaroo add github.com/buckaroo-pm/nlohmann-json`. Please file issues [here](https://github.com/buckaroo-pm/nlohmann-json). There is a demo repo [here](https://github.com/njlr/buckaroo-nholmann-json-example). - -If you are using [vcpkg](https://github.com/Microsoft/vcpkg/) on your project for external dependencies, then you can install the [nlohmann-json package](https://github.com/Microsoft/vcpkg/tree/master/ports/nlohmann-json) with `vcpkg install nlohmann-json` and follow the then displayed descriptions. Please see the vcpkg project for any issues regarding the packaging. - -If you are using [cget](https://cget.readthedocs.io/en/latest/), you can install the latest development version with `cget install nlohmann/json`. A specific version can be installed with `cget install nlohmann/json@v3.1.0`. Also, the multiple header version can be installed by adding the `-DJSON_MultipleHeaders=ON` flag (i.e., `cget install nlohmann/json -DJSON_MultipleHeaders=ON`). - -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 [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). - -If you are using [MSYS2](https://www.msys2.org/), you can use the [mingw-w64-nlohmann-json](https://packages.msys2.org/base/mingw-w64-nlohmann-json) package, just type `pacman -S mingw-w64-i686-nlohmann-json` or `pacman -S mingw-w64-x86_64-nlohmann-json` for installation. Please file issues [here](https://github.com/msys2/MINGW-packages/issues/new?title=%5Bnlohmann-json%5D) if you experience problems with the packages. - -If you are using [MacPorts](https://ports.macports.org), execute `sudo port install nlohmann-json` to install the [nlohmann-json](https://ports.macports.org/port/nlohmann-json/) package. - -If you are using [`build2`](https://build2.org), you can use the [`nlohmann-json`](https://cppget.org/nlohmann-json) package from the public repository https://cppget.org or directly from the [package's sources repository](https://github.com/build2-packaging/nlohmann-json). In your project's `manifest` file, just add `depends: nlohmann-json` (probably with some [version constraints](https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml#guide-add-remove-deps)). If you are not familiar with using dependencies in `build2`, [please read this introduction](https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml). -Please file issues [here](https://github.com/build2-packaging/nlohmann-json) if you experience problems with the packages. - -If you are using [`wsjcpp`](https://wsjcpp.org), you can use the command `wsjcpp install "https://github.com/nlohmann/json:develop"` to get the latest version. Note you can change the branch ":develop" to an existing tag or another branch. - -If you are using [`CPM.cmake`](https://github.com/TheLartians/CPM.cmake), you can check this [`example`](https://github.com/TheLartians/CPM.cmake/tree/master/examples/json). After [adding CPM script](https://github.com/TheLartians/CPM.cmake#adding-cpm) to your project, implement the following snippet to your CMake: - -```cmake -CPMAddPackage( - NAME nlohmann_json - GITHUB_REPOSITORY nlohmann/json - VERSION 3.9.1) -``` - -### Pkg-config - -If you are using bare Makefiles, you can use `pkg-config` to generate the include flags that point to where the library is installed: - -```sh -pkg-config nlohmann_json --cflags -``` - -Users of the Meson build system will also be able to use a system-wide library, which will be found by `pkg-config`: - -```meson -json = dependency('nlohmann_json', required: true) -``` - - -## License - - - -The class is licensed under the [MIT License](https://opensource.org/licenses/MIT): - -Copyright © 2013-2022 [Niels Lohmann](https://nlohmann.me) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -* * * - -The class contains the UTF-8 Decoder from Bjoern Hoehrmann which is licensed under the [MIT License](https://opensource.org/licenses/MIT) (see above). Copyright © 2008-2009 [Björn Hoehrmann](https://bjoern.hoehrmann.de/) - -The class contains a slightly modified version of the Grisu2 algorithm from Florian Loitsch which is licensed under the [MIT License](https://opensource.org/licenses/MIT) (see above). Copyright © 2009 [Florian Loitsch](https://florian.loitsch.com/) - -The class contains a copy of [Hedley](https://nemequ.github.io/hedley/) from Evan Nemerson which is licensed as [CC0-1.0](https://creativecommons.org/publicdomain/zero/1.0/). - -The class contains parts of [Google Abseil](https://github.com/abseil/abseil-cpp) which is licensed under the [Apache 2.0 License](https://opensource.org/licenses/Apache-2.0). - -## Contact - -If you have questions regarding the library, I would like to invite you to [open an issue at GitHub](https://github.com/nlohmann/json/issues/new/choose). Please describe your request, problem, or question as detailed as possible, and also mention the version of the library you are using as well as the version of your compiler and operating system. Opening an issue at GitHub allows other users and contributors to this library to collaborate. For instance, I have little experience with MSVC, and most issues in this regard have been solved by a growing community. If you have a look at the [closed issues](https://github.com/nlohmann/json/issues?q=is%3Aissue+is%3Aclosed), you will see that we react quite timely in most cases. - -Only if your request would contain confidential information, please [send me an email](mailto:mail@nlohmann.me). For encrypted messages, please use [this key](https://keybase.io/nlohmann/pgp_keys.asc). - -## Security - -[Commits by Niels Lohmann](https://github.com/nlohmann/json/commits) and [releases](https://github.com/nlohmann/json/releases) are signed with this [PGP Key](https://keybase.io/nlohmann/pgp_keys.asc?fingerprint=797167ae41c0a6d9232e48457f3cea63ae251b69). - -## Thanks - -I deeply appreciate the help of the following people. - - - -1. [Teemperor](https://github.com/Teemperor) implemented CMake support and lcov integration, realized escape and Unicode handling in the string parser, and fixed the JSON serialization. -2. [elliotgoodrich](https://github.com/elliotgoodrich) fixed an issue with double deletion in the iterator classes. -3. [kirkshoop](https://github.com/kirkshoop) made the iterators of the class composable to other libraries. -4. [wancw](https://github.com/wanwc) fixed a bug that hindered the class to compile with Clang. -5. Tomas Åblad found a bug in the iterator implementation. -6. [Joshua C. Randall](https://github.com/jrandall) fixed a bug in the floating-point serialization. -7. [Aaron Burghardt](https://github.com/aburgh) implemented code to parse streams incrementally. Furthermore, he greatly improved the parser class by allowing the definition of a filter function to discard undesired elements while parsing. -8. [Daniel Kopeček](https://github.com/dkopecek) fixed a bug in the compilation with GCC 5.0. -9. [Florian Weber](https://github.com/Florianjw) fixed a bug in and improved the performance of the comparison operators. -10. [Eric Cornelius](https://github.com/EricMCornelius) pointed out a bug in the handling with NaN and infinity values. He also improved the performance of the string escaping. -11. [易思龙](https://github.com/likebeta) implemented a conversion from anonymous enums. -12. [kepkin](https://github.com/kepkin) patiently pushed forward the support for Microsoft Visual studio. -13. [gregmarr](https://github.com/gregmarr) simplified the implementation of reverse iterators and helped with numerous hints and improvements. In particular, he pushed forward the implementation of user-defined types. -14. [Caio Luppi](https://github.com/caiovlp) fixed a bug in the Unicode handling. -15. [dariomt](https://github.com/dariomt) fixed some typos in the examples. -16. [Daniel Frey](https://github.com/d-frey) cleaned up some pointers and implemented exception-safe memory allocation. -17. [Colin Hirsch](https://github.com/ColinH) took care of a small namespace issue. -18. [Huu Nguyen](https://github.com/whoshuu) correct a variable name in the documentation. -19. [Silverweed](https://github.com/silverweed) overloaded `parse()` to accept an rvalue reference. -20. [dariomt](https://github.com/dariomt) fixed a subtlety in MSVC type support and implemented the `get_ref()` function to get a reference to stored values. -21. [ZahlGraf](https://github.com/ZahlGraf) added a workaround that allows compilation using Android NDK. -22. [whackashoe](https://github.com/whackashoe) replaced a function that was marked as unsafe by Visual Studio. -23. [406345](https://github.com/406345) fixed two small warnings. -24. [Glen Fernandes](https://github.com/glenfe) noted a potential portability problem in the `has_mapped_type` function. -25. [Corbin Hughes](https://github.com/nibroc) fixed some typos in the contribution guidelines. -26. [twelsby](https://github.com/twelsby) fixed the array subscript operator, an issue that failed the MSVC build, and floating-point parsing/dumping. He further added support for unsigned integer numbers and implemented better roundtrip support for parsed numbers. -27. [Volker Diels-Grabsch](https://github.com/vog) fixed a link in the README file. -28. [msm-](https://github.com/msm-) added support for American Fuzzy Lop. -29. [Annihil](https://github.com/Annihil) fixed an example in the README file. -30. [Themercee](https://github.com/Themercee) noted a wrong URL in the README file. -31. [Lv Zheng](https://github.com/lv-zheng) fixed a namespace issue with `int64_t` and `uint64_t`. -32. [abc100m](https://github.com/abc100m) analyzed the issues with GCC 4.8 and proposed a [partial solution](https://github.com/nlohmann/json/pull/212). -33. [zewt](https://github.com/zewt) added useful notes to the README file about Android. -34. [Róbert Márki](https://github.com/robertmrk) added a fix to use move iterators and improved the integration via CMake. -35. [Chris Kitching](https://github.com/ChrisKitching) cleaned up the CMake files. -36. [Tom Needham](https://github.com/06needhamt) fixed a subtle bug with MSVC 2015 which was also proposed by [Michael K.](https://github.com/Epidal). -37. [Mário Feroldi](https://github.com/thelostt) fixed a small typo. -38. [duncanwerner](https://github.com/duncanwerner) found a really embarrassing performance regression in the 2.0.0 release. -39. [Damien](https://github.com/dtoma) fixed one of the last conversion warnings. -40. [Thomas Braun](https://github.com/t-b) fixed a warning in a test case and adjusted MSVC calls in the CI. -41. [Théo DELRIEU](https://github.com/theodelrieu) patiently and constructively oversaw the long way toward [iterator-range parsing](https://github.com/nlohmann/json/issues/290). He also implemented the magic behind the serialization/deserialization of user-defined types and split the single header file into smaller chunks. -42. [Stefan](https://github.com/5tefan) fixed a minor issue in the documentation. -43. [Vasil Dimov](https://github.com/vasild) fixed the documentation regarding conversions from `std::multiset`. -44. [ChristophJud](https://github.com/ChristophJud) overworked the CMake files to ease project inclusion. -45. [Vladimir Petrigo](https://github.com/vpetrigo) made a SFINAE hack more readable and added Visual Studio 17 to the build matrix. -46. [Denis Andrejew](https://github.com/seeekr) fixed a grammar issue in the README file. -47. [Pierre-Antoine Lacaze](https://github.com/palacaze) found a subtle bug in the `dump()` function. -48. [TurpentineDistillery](https://github.com/TurpentineDistillery) pointed to [`std::locale::classic()`](https://en.cppreference.com/w/cpp/locale/locale/classic) to avoid too much locale joggling, found some nice performance improvements in the parser, improved the benchmarking code, and realized locale-independent number parsing and printing. -49. [cgzones](https://github.com/cgzones) had an idea how to fix the Coverity scan. -50. [Jared Grubb](https://github.com/jaredgrubb) silenced a nasty documentation warning. -51. [Yixin Zhang](https://github.com/qwename) fixed an integer overflow check. -52. [Bosswestfalen](https://github.com/Bosswestfalen) merged two iterator classes into a smaller one. -53. [Daniel599](https://github.com/Daniel599) helped to get Travis execute the tests with Clang's sanitizers. -54. [Jonathan Lee](https://github.com/vjon) fixed an example in the README file. -55. [gnzlbg](https://github.com/gnzlbg) supported the implementation of user-defined types. -56. [Alexej Harm](https://github.com/qis) helped to get the user-defined types working with Visual Studio. -57. [Jared Grubb](https://github.com/jaredgrubb) supported the implementation of user-defined types. -58. [EnricoBilla](https://github.com/EnricoBilla) noted a typo in an example. -59. [Martin Hořeňovský](https://github.com/horenmar) found a way for a 2x speedup for the compilation time of the test suite. -60. [ukhegg](https://github.com/ukhegg) found proposed an improvement for the examples section. -61. [rswanson-ihi](https://github.com/rswanson-ihi) noted a typo in the README. -62. [Mihai Stan](https://github.com/stanmihai4) fixed a bug in the comparison with `nullptr`s. -63. [Tushar Maheshwari](https://github.com/tusharpm) added [cotire](https://github.com/sakra/cotire) support to speed up the compilation. -64. [TedLyngmo](https://github.com/TedLyngmo) noted a typo in the README, removed unnecessary bit arithmetic, and fixed some `-Weffc++` warnings. -65. [Krzysztof Woś](https://github.com/krzysztofwos) made exceptions more visible. -66. [ftillier](https://github.com/ftillier) fixed a compiler warning. -67. [tinloaf](https://github.com/tinloaf) made sure all pushed warnings are properly popped. -68. [Fytch](https://github.com/Fytch) found a bug in the documentation. -69. [Jay Sistar](https://github.com/Type1J) implemented a Meson build description. -70. [Henry Lee](https://github.com/HenryRLee) fixed a warning in ICC and improved the iterator implementation. -71. [Vincent Thiery](https://github.com/vthiery) maintains a package for the Conan package manager. -72. [Steffen](https://github.com/koemeet) fixed a potential issue with MSVC and `std::min`. -73. [Mike Tzou](https://github.com/Chocobo1) fixed some typos. -74. [amrcode](https://github.com/amrcode) noted a misleading documentation about comparison of floats. -75. [Oleg Endo](https://github.com/olegendo) reduced the memory consumption by replacing `` with ``. -76. [dan-42](https://github.com/dan-42) cleaned up the CMake files to simplify including/reusing of the library. -77. [Nikita Ofitserov](https://github.com/himikof) allowed for moving values from initializer lists. -78. [Greg Hurrell](https://github.com/wincent) fixed a typo. -79. [Dmitry Kukovinets](https://github.com/DmitryKuk) fixed a typo. -80. [kbthomp1](https://github.com/kbthomp1) fixed an issue related to the Intel OSX compiler. -81. [Markus Werle](https://github.com/daixtrose) fixed a typo. -82. [WebProdPP](https://github.com/WebProdPP) fixed a subtle error in a precondition check. -83. [Alex](https://github.com/leha-bot) noted an error in a code sample. -84. [Tom de Geus](https://github.com/tdegeus) reported some warnings with ICC and helped to fix them. -85. [Perry Kundert](https://github.com/pjkundert) simplified reading from input streams. -86. [Sonu Lohani](https://github.com/sonulohani) fixed a small compilation error. -87. [Jamie Seward](https://github.com/jseward) fixed all MSVC warnings. -88. [Nate Vargas](https://github.com/eld00d) added a Doxygen tag file. -89. [pvleuven](https://github.com/pvleuven) helped to fix a warning in ICC. -90. [Pavel](https://github.com/crea7or) helped to fix some warnings in MSVC. -91. [Jamie Seward](https://github.com/jseward) avoided unnecessary string copies in `find()` and `count()`. -92. [Mitja](https://github.com/Itja) fixed some typos. -93. [Jorrit Wronski](https://github.com/jowr) updated the Hunter package links. -94. [Matthias Möller](https://github.com/TinyTinni) added a `.natvis` for the MSVC debug view. -95. [bogemic](https://github.com/bogemic) fixed some C++17 deprecation warnings. -96. [Eren Okka](https://github.com/erengy) fixed some MSVC warnings. -97. [abolz](https://github.com/abolz) integrated the Grisu2 algorithm for proper floating-point formatting, allowing more roundtrip checks to succeed. -98. [Vadim Evard](https://github.com/Pipeliner) fixed a Markdown issue in the README. -99. [zerodefect](https://github.com/zerodefect) fixed a compiler warning. -100. [Kert](https://github.com/kaidokert) allowed to template the string type in the serialization and added the possibility to override the exceptional behavior. -101. [mark-99](https://github.com/mark-99) helped fixing an ICC error. -102. [Patrik Huber](https://github.com/patrikhuber) fixed links in the README file. -103. [johnfb](https://github.com/johnfb) found a bug in the implementation of CBOR's indefinite length strings. -104. [Paul Fultz II](https://github.com/pfultz2) added a note on the cget package manager. -105. [Wilson Lin](https://github.com/wla80) made the integration section of the README more concise. -106. [RalfBielig](https://github.com/ralfbielig) detected and fixed a memory leak in the parser callback. -107. [agrianius](https://github.com/agrianius) allowed to dump JSON to an alternative string type. -108. [Kevin Tonon](https://github.com/ktonon) overworked the C++11 compiler checks in CMake. -109. [Axel Huebl](https://github.com/ax3l) simplified a CMake check and added support for the [Spack package manager](https://spack.io). -110. [Carlos O'Ryan](https://github.com/coryan) fixed a typo. -111. [James Upjohn](https://github.com/jammehcow) fixed a version number in the compilers section. -112. [Chuck Atkins](https://github.com/chuckatkins) adjusted the CMake files to the CMake packaging guidelines and provided documentation for the CMake integration. -113. [Jan Schöppach](https://github.com/dns13) fixed a typo. -114. [martin-mfg](https://github.com/martin-mfg) fixed a typo. -115. [Matthias Möller](https://github.com/TinyTinni) removed the dependency from `std::stringstream`. -116. [agrianius](https://github.com/agrianius) added code to use alternative string implementations. -117. [Daniel599](https://github.com/Daniel599) allowed to use more algorithms with the `items()` function. -118. [Julius Rakow](https://github.com/jrakow) fixed the Meson include directory and fixed the links to [cppreference.com](cppreference.com). -119. [Sonu Lohani](https://github.com/sonulohani) fixed the compilation with MSVC 2015 in debug mode. -120. [grembo](https://github.com/grembo) fixed the test suite and re-enabled several test cases. -121. [Hyeon Kim](https://github.com/simnalamburt) introduced the macro `JSON_INTERNAL_CATCH` to control the exception handling inside the library. -122. [thyu](https://github.com/thyu) fixed a compiler warning. -123. [David Guthrie](https://github.com/LEgregius) fixed a subtle compilation error with Clang 3.4.2. -124. [Dennis Fischer](https://github.com/dennisfischer) allowed to call `find_package` without installing the library. -125. [Hyeon Kim](https://github.com/simnalamburt) fixed an issue with a double macro definition. -126. [Ben Berman](https://github.com/rivertam) made some error messages more understandable. -127. [zakalibit](https://github.com/zakalibit) fixed a compilation problem with the Intel C++ compiler. -128. [mandreyel](https://github.com/mandreyel) fixed a compilation problem. -129. [Kostiantyn Ponomarenko](https://github.com/koponomarenko) added version and license information to the Meson build file. -130. [Henry Schreiner](https://github.com/henryiii) added support for GCC 4.8. -131. [knilch](https://github.com/knilch0r) made sure the test suite does not stall when run in the wrong directory. -132. [Antonio Borondo](https://github.com/antonioborondo) fixed an MSVC 2017 warning. -133. [Dan Gendreau](https://github.com/dgendreau) implemented the `NLOHMANN_JSON_SERIALIZE_ENUM` macro to quickly define an enum/JSON mapping. -134. [efp](https://github.com/efp) added line and column information to parse errors. -135. [julian-becker](https://github.com/julian-becker) added BSON support. -136. [Pratik Chowdhury](https://github.com/pratikpc) added support for structured bindings. -137. [David Avedissian](https://github.com/davedissian) added support for Clang 5.0.1 (PS4 version). -138. [Jonathan Dumaresq](https://github.com/dumarjo) implemented an input adapter to read from `FILE*`. -139. [kjpus](https://github.com/kjpus) fixed a link in the documentation. -140. [Manvendra Singh](https://github.com/manu-chroma) fixed a typo in the documentation. -141. [ziggurat29](https://github.com/ziggurat29) fixed an MSVC warning. -142. [Sylvain Corlay](https://github.com/SylvainCorlay) added code to avoid an issue with MSVC. -143. [mefyl](https://github.com/mefyl) fixed a bug when JSON was parsed from an input stream. -144. [Millian Poquet](https://github.com/mpoquet) allowed to install the library via Meson. -145. [Michael Behrns-Miller](https://github.com/moodboom) found an issue with a missing namespace. -146. [Nasztanovics Ferenc](https://github.com/naszta) fixed a compilation issue with libc 2.12. -147. [Andreas Schwab](https://github.com/andreas-schwab) fixed the endian conversion. -148. [Mark-Dunning](https://github.com/Mark-Dunning) fixed a warning in MSVC. -149. [Gareth Sylvester-Bradley](https://github.com/garethsb-sony) added `operator/` for JSON Pointers. -150. [John-Mark](https://github.com/johnmarkwayve) noted a missing header. -151. [Vitaly Zaitsev](https://github.com/xvitaly) fixed compilation with GCC 9.0. -152. [Laurent Stacul](https://github.com/stac47) fixed compilation with GCC 9.0. -153. [Ivor Wanders](https://github.com/iwanders) helped to reduce the CMake requirement to version 3.1. -154. [njlr](https://github.com/njlr) updated the Buckaroo instructions. -155. [Lion](https://github.com/lieff) fixed a compilation issue with GCC 7 on CentOS. -156. [Isaac Nickaein](https://github.com/nickaein) improved the integer serialization performance and implemented the `contains()` function. -157. [past-due](https://github.com/past-due) suppressed an unfixable warning. -158. [Elvis Oric](https://github.com/elvisoric) improved Meson support. -159. [Matěj Plch](https://github.com/Afforix) fixed an example in the README. -160. [Mark Beckwith](https://github.com/wythe) fixed a typo. -161. [scinart](https://github.com/scinart) fixed bug in the serializer. -162. [Patrick Boettcher](https://github.com/pboettch) implemented `push_back()` and `pop_back()` for JSON Pointers. -163. [Bruno Oliveira](https://github.com/nicoddemus) added support for Conda. -164. [Michele Caini](https://github.com/skypjack) fixed links in the README. -165. [Hani](https://github.com/hnkb) documented how to install the library with NuGet. -166. [Mark Beckwith](https://github.com/wythe) fixed a typo. -167. [yann-morin-1998](https://github.com/yann-morin-1998) helped to reduce the CMake requirement to version 3.1. -168. [Konstantin Podsvirov](https://github.com/podsvirov) maintains a package for the MSYS2 software distro. -169. [remyabel](https://github.com/remyabel) added GNUInstallDirs to the CMake files. -170. [Taylor Howard](https://github.com/taylorhoward92) fixed a unit test. -171. [Gabe Ron](https://github.com/Macr0Nerd) implemented the `to_string` method. -172. [Watal M. Iwasaki](https://github.com/heavywatal) fixed a Clang warning. -173. [Viktor Kirilov](https://github.com/onqtam) switched the unit tests from [Catch](https://github.com/philsquared/Catch) to [doctest](https://github.com/onqtam/doctest) -174. [Juncheng E](https://github.com/ejcjason) fixed a typo. -175. [tete17](https://github.com/tete17) fixed a bug in the `contains` function. -176. [Xav83](https://github.com/Xav83) fixed some cppcheck warnings. -177. [0xflotus](https://github.com/0xflotus) fixed some typos. -178. [Christian Deneke](https://github.com/chris0x44) added a const version of `json_pointer::back`. -179. [Julien Hamaide](https://github.com/crazyjul) made the `items()` function work with custom string types. -180. [Evan Nemerson](https://github.com/nemequ) updated fixed a bug in Hedley and updated this library accordingly. -181. [Florian Pigorsch](https://github.com/flopp) fixed a lot of typos. -182. [Camille Bégué](https://github.com/cbegue) fixed an issue in the conversion from `std::pair` and `std::tuple` to `json`. -183. [Anthony VH](https://github.com/AnthonyVH) fixed a compile error in an enum deserialization. -184. [Yuriy Vountesmery](https://github.com/ua-code-dragon) noted a subtle bug in a preprocessor check. -185. [Chen](https://github.com/dota17) fixed numerous issues in the library. -186. [Antony Kellermann](https://github.com/aokellermann) added a CI step for GCC 10.1. -187. [Alex](https://github.com/gistrec) fixed an MSVC warning. -188. [Rainer](https://github.com/rvjr) proposed an improvement in the floating-point serialization in CBOR. -189. [Francois Chabot](https://github.com/FrancoisChabot) made performance improvements in the input adapters. -190. [Arthur Sonzogni](https://github.com/ArthurSonzogni) documented how the library can be included via `FetchContent`. -191. [Rimas Misevičius](https://github.com/rmisev) fixed an error message. -192. [Alexander Myasnikov](https://github.com/alexandermyasnikov) fixed some examples and a link in the README. -193. [Hubert Chathi](https://github.com/uhoreg) made CMake's version config file architecture-independent. -194. [OmnipotentEntity](https://github.com/OmnipotentEntity) implemented the binary values for CBOR, MessagePack, BSON, and UBJSON. -195. [ArtemSarmini](https://github.com/ArtemSarmini) fixed a compilation issue with GCC 10 and fixed a leak. -196. [Evgenii Sopov](https://github.com/sea-kg) integrated the library to the wsjcpp package manager. -197. [Sergey Linev](https://github.com/linev) fixed a compiler warning. -198. [Miguel Magalhães](https://github.com/magamig) fixed the year in the copyright. -199. [Gareth Sylvester-Bradley](https://github.com/garethsb-sony) fixed a compilation issue with MSVC. -200. [Alexander “weej” Jones](https://github.com/alex-weej) fixed an example in the README. -201. [Antoine Cœur](https://github.com/Coeur) fixed some typos in the documentation. -202. [jothepro](https://github.com/jothepro) updated links to the Hunter package. -203. [Dave Lee](https://github.com/kastiglione) fixed link in the README. -204. [Joël Lamotte](https://github.com/Klaim) added instruction for using Build2's package manager. -205. [Paul Jurczak](https://github.com/pauljurczak) fixed an example in the README. -206. [Sonu Lohani](https://github.com/sonulohani) fixed a warning. -207. [Carlos Gomes Martinho](https://github.com/gocarlos) updated the Conan package source. -208. [Konstantin Podsvirov](https://github.com/podsvirov) fixed the MSYS2 package documentation. -209. [Tridacnid](https://github.com/Tridacnid) improved the CMake tests. -210. [Michael](https://github.com/MBalszun) fixed MSVC warnings. -211. [Quentin Barbarat](https://github.com/quentin-dev) fixed an example in the documentation. -212. [XyFreak](https://github.com/XyFreak) fixed a compiler warning. -213. [TotalCaesar659](https://github.com/TotalCaesar659) fixed links in the README. -214. [Tanuj Garg](https://github.com/tanuj208) improved the fuzzer coverage for UBSAN input. -215. [AODQ](https://github.com/AODQ) fixed a compiler warning. -216. [jwittbrodt](https://github.com/jwittbrodt) made `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE` inline. -217. [pfeatherstone](https://github.com/pfeatherstone) improved the upper bound of arguments of the `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`/`NLOHMANN_DEFINE_TYPE_INTRUSIVE` macros. -218. [Jan Procházka](https://github.com/jprochazk) fixed a bug in the CBOR parser for binary and string values. -219. [T0b1-iOS](https://github.com/T0b1-iOS) fixed a bug in the new hash implementation. -220. [Matthew Bauer](https://github.com/matthewbauer) adjusted the CBOR writer to create tags for binary subtypes. -221. [gatopeich](https://github.com/gatopeich) implemented an ordered map container for `nlohmann::ordered_json`. -222. [Érico Nogueira Rolim](https://github.com/ericonr) added support for pkg-config. -223. [KonanM](https://github.com/KonanM) proposed an implementation for the `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`/`NLOHMANN_DEFINE_TYPE_INTRUSIVE` macros. -224. [Guillaume Racicot](https://github.com/gracicot) implemented `string_view` support and allowed C++20 support. -225. [Alex Reinking](https://github.com/alexreinking) improved CMake support for `FetchContent`. -226. [Hannes Domani](https://github.com/ssbssa) provided a GDB pretty printer. -227. Lars Wirzenius reviewed the README file. -228. [Jun Jie](https://github.com/ongjunjie) fixed a compiler path in the CMake scripts. -229. [Ronak Buch](https://github.com/rbuch) fixed typos in the documentation. -230. [Alexander Karzhenkov](https://github.com/karzhenkov) fixed a move constructor and the Travis builds. -231. [Leonardo Lima](https://github.com/leozz37) added CPM.Cmake support. -232. [Joseph Blackman](https://github.com/jbzdarkid) fixed a warning. -233. [Yaroslav](https://github.com/YarikTH) updated doctest and implemented unit tests. -234. [Martin Stump](https://github.com/globberwops) fixed a bug in the CMake files. -235. [Jaakko Moisio](https://github.com/jasujm) fixed a bug in the input adapters. -236. [bl-ue](https://github.com/bl-ue) fixed some Markdown issues in the README file. -237. [William A. Wieselquist](https://github.com/wawiesel) fixed an example from the README. -238. [abbaswasim](https://github.com/abbaswasim) fixed an example from the README. -239. [Remy Jette](https://github.com/remyjette) fixed a warning. -240. [Fraser](https://github.com/frasermarlow) fixed the documentation. -241. [Ben Beasley](https://github.com/musicinmybrain) updated doctest. -242. [Doron Behar](https://github.com/doronbehar) fixed pkg-config.pc. -243. [raduteo](https://github.com/raduteo) fixed a warning. -244. [David Pfahler](https://github.com/theShmoo) added the possibility to compile the library without I/O support. -245. [Morten Fyhn Amundsen](https://github.com/mortenfyhn) fixed a typo. -246. [jpl-mac](https://github.com/jpl-mac) allowed to treat the library as a system header in CMake. -247. [Jason Dsouza](https://github.com/jasmcaus) fixed the indentation of the CMake file. -248. [offa](https://github.com/offa) added a link to Conan Center to the documentation. -249. [TotalCaesar659](https://github.com/TotalCaesar659) updated the links in the documentation to use HTTPS. -250. [Rafail Giavrimis](https://github.com/grafail) fixed the Google Benchmark default branch. -251. [Louis Dionne](https://github.com/ldionne) fixed a conversion operator. -252. [justanotheranonymoususer](https://github.com/justanotheranonymoususer) made the examples in the README more consistent. -253. [Finkman](https://github.com/Finkman) suppressed some `-Wfloat-equal` warnings. -254. [Ferry Huberts](https://github.com/fhuberts) fixed `-Wswitch-enum` warnings. -255. [Arseniy Terekhin](https://github.com/senyai) made the GDB pretty-printer robust against unset variable names. -256. [Amir Masoud Abdol](https://github.com/amirmasoudabdol) updated the Homebrew command as nlohmann/json is now in homebrew-core. -257. [Hallot](https://github.com/Hallot) fixed some `-Wextra-semi-stmt warnings`. -258. [Giovanni Cerretani](https://github.com/gcerretani) fixed `-Wunused` warnings on `JSON_DIAGNOSTICS`. -259. [Bogdan Popescu](https://github.com/Kapeli) hosts the [docset](https://github.com/Kapeli/Dash-User-Contributions/tree/master/docsets/JSON_for_Modern_C%2B%2B) for offline documentation viewers. -260. [Carl Smedstad](https://github.com/carlsmedstad) fixed an assertion error when using `JSON_DIAGNOSTICS`. -261. [miikka75](https://github.com/miikka75) provided an important fix to compile C++17 code with Clang 9. -262. [Maarten Becker](https://github.com/kernie) fixed a warning for shadowed variables. -263. [Cristi Vîjdea](https://github.com/axnsan12) fixed typos in the `operator[]` documentation. -264. [Alex Beregszaszi](https://github.com/axic) fixed spelling mistakes in comments. -265. [Dirk Stolle](https://github.com/striezel) fixed typos in documentation. -266. [Daniel Albuschat](https://github.com/daniel-kun) corrected the parameter name in the `parse` documentation. -267. [Prince Mendiratta](https://github.com/Prince-Mendiratta) fixed a link to the FAQ. -268. [Florian Albrechtskirchinger](https://github.com/falbrechtskirchinger) implemented `std::string_view` support for object keys and made dozens of other improvements. -269. [Qianqian Fang](https://github.com/fangq) implemented the Binary JData (BJData) format. -270. [pketelsen](https://github.com/pketelsen) added macros `NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT` and `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT`. -271. [DarkZeros](https://github.com/DarkZeros) adjusted to code to not clash with Arduino defines. -272. [flagarde](https://github.com/flagarde) fixed the output of `meta()` for MSVC. -273. [Giovanni Cerretani](https://github.com/gcerretani) fixed a check for `std::filesystem`. -274. [Dimitris Apostolou](https://github.com/rex4539) fixed a typo. -275. [Ferry Huberts](https://github.com/fhuberts) fixed a typo. -276. [Michael Nosthoff](https://github.com/heinemml) fixed a typo. -277. [JungHoon Lee](https://github.com/jhnlee) fixed a typo. -278. [Faruk D.](https://github.com/fdiblen) fixed the CITATION.CFF file. -279. [Andrea Cocito](https://github.com/puffetto) added a clarification on macro usage to the documentation. -280. [Krzysiek Karbowiak](https://github.com/kkarbowiak) refactored the tests to use `CHECK_THROWS_WITH_AS`. -281. [Chaoqi Zhang](https://github.com/prncoprs) fixed a typo. -282. [ivanovmp](https://github.com/ivanovmp) fixed a whitespace error. -283. [KsaNL](https://github.com/KsaNL) fixed a build error when including ``. -284. [Andrea Pappacoda](https://github.com/Tachi107) moved `.pc` and `.cmake` files to `share` directory. -285. [Wolf Vollprecht](https://github.com/wolfv) added the `patch_inplace` function. -286. [Jake Zimmerman](https://github.com/jez) highlighted common usage patterns in the README file. -287. [NN](https://github.com/NN---) added the Visual Studio output directory to `.gitignore`. -288. [Romain Reignier](https://github.com/romainreignier) improved the performance the vector output adapter. -289. [Mike](https://github.com/Mike-Leo-Smith) fixed the `std::iterator_traits`. -290. [Richard Hozák](https://github.com/zxey) added macro `JSON_NO_ENUM` to disable default enum conversions. -291. [vakokako](https://github.com/vakokako) fixed tests when compiling with C++20. -292. [Alexander “weej” Jones](https://github.com/alexweej) fixed an example in the README. -293. [Eli Schwartz](https://github.com/eli-schwartz) added more files to the `include.zip` archive. -294. [Kevin Lu](https://github.com/kevinlul) fixed a compilation issue when typedefs with certain names were present. -295. [Trevor Hickey](https://github.com/luxe) improved the description of an example. -296. [Jef LeCompte](https://github.com/jef) updated the year in the README file. -297. [Alexandre Hamez](https://github.com/ahamez) fixed a warning. -298. [Maninderpal Badhan](https://github.com/mbadhan) fixed a typo. -299. [kevin--](https://github.com/kevin--) added a note to an example in the README file. -300. [I](https://github.com/wx257osn2) fixed a typo. -301. [Gregorio Litenstein](https://github.com/Lord-Kamina) fixed the Clang detection. -302. [Andreas Smas](https://github.com/andoma) added a Doozer badge. -303. [WanCW](https://github.com/wancw) fixed the string conversion with Clang. -304. [zhaohuaxishi](https://github.com/zhaohuaxishi) fixed a Doxygen error. -305. [emvivre](https://github.com/emvivre) removed an invalid parameter from CMake. -306. [Tobias Hermann](https://github.com/Dobiasd) fixed a link in the README file. -307. [Michael](https://github.com/traits) fixed a warning. -308. [Ryan Mulder](https://github.com/ryanjmulder) added `ensure_ascii` to the `dump` function. -309. [Muri Nicanor](https://github.com/murinicanor) fixed the `sed` discovery in the Makefile. -310. [David Avedissian](https://github.com/dgavedissian) implemented SFINAE-friendly `iterator_traits`. -311. [AQNOUCH Mohammed](https://github.com/aqnouch) fixed a typo in the README. -312. [Gareth Sylvester-Bradley](https://github.com/garethsb) added `operator/=` and `operator/` to construct JSON pointers. -313. [Michael Macnair](https://github.com/mykter) added support for afl-fuzz testing. -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. - -Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I forgot someone. - - -## Used third-party tools - -The library itself consists of a single header file licensed under the MIT license. However, it is built, tested, documented, and whatnot using a lot of third-party tools and services. Thanks a lot! - -- [**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 -- [**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) -- [**Coverity Scan**](https://scan.coverity.com) for [static analysis](https://scan.coverity.com/projects/nlohmann-json) -- [**cppcheck**](http://cppcheck.sourceforge.net) for static analysis -- [**doctest**](https://github.com/onqtam/doctest) for the unit tests -- [**git-update-ghpages**](https://github.com/rstacruz/git-update-ghpages) to upload the documentation to gh-pages -- [**GitHub Changelog Generator**](https://github.com/skywinder/github-changelog-generator) to generate the [ChangeLog](https://github.com/nlohmann/json/blob/develop/ChangeLog.md) -- [**Google Benchmark**](https://github.com/google/benchmark) to implement the benchmarks -- [**Hedley**](https://nemequ.github.io/hedley/) to avoid re-inventing several compiler-agnostic feature macros -- [**lcov**](http://ltp.sourceforge.net/coverage/lcov.php) to process coverage information and create an HTML view -- [**libFuzzer**](https://llvm.org/docs/LibFuzzer.html) to implement fuzz testing for OSS-Fuzz -- [**Material for MkDocs**](https://squidfunk.github.io/mkdocs-material/) for the style of the documentation site -- [**MkDocs**](https://www.mkdocs.org) for the documentation site -- [**OSS-Fuzz**](https://github.com/google/oss-fuzz) for continuous fuzz testing of the library ([project repository](https://github.com/google/oss-fuzz/tree/master/projects/json)) -- [**Probot**](https://probot.github.io) for automating maintainer tasks such as closing stale issues, requesting missing information, or detecting toxic comments. -- [**Valgrind**](https://valgrind.org) to check for correct memory management - - -## Projects using JSON for Modern C++ - -The library is currently used in Apple macOS Sierra-Monterey and iOS 10-15. I am not sure what they are using the library for, but I am happy that it runs on so many devices. - - -## Notes - -### Character encoding - -The library supports **Unicode input** as follows: - -- Only **UTF-8** encoded input is supported which is the default encoding for JSON according to [RFC 8259](https://tools.ietf.org/html/rfc8259.html#section-8.1). -- `std::u16string` and `std::u32string` can be parsed, assuming UTF-16 and UTF-32 encoding, respectively. These encodings are not supported when reading from files or other input containers. -- Other encodings such as Latin-1 or ISO 8859-1 are **not** supported and will yield parse or serialization errors. -- [Unicode noncharacters](https://www.unicode.org/faq/private_use.html#nonchar1) will not be replaced by the library. -- Invalid surrogates (e.g., incomplete pairs such as `\uDEAD`) will yield parse errors. -- The strings stored in the library are UTF-8 encoded. When using the default string type (`std::string`), note that its length/size functions return the number of stored bytes rather than the number of characters or glyphs. -- When you store strings with different encodings in the library, calling [`dump()`](https://json.nlohmann.me/api/basic_json/dump/) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers. -- To store wide strings (e.g., `std::wstring`), you need to convert them to a UTF-8 encoded `std::string` before, see [an example](https://json.nlohmann.me/home/faq/#wide-string-handling). - -### Comments in JSON - -This library does not support comments by default. It does so for three reasons: - -1. Comments are not part of the [JSON specification](https://tools.ietf.org/html/rfc8259). You may argue that `//` or `/* */` are allowed in JavaScript, but JSON is not JavaScript. -2. This was not an oversight: Douglas Crockford [wrote on this](https://plus.google.com/118095276221607585885/posts/RK8qyGVaGSr) in May 2012: - - > I removed comments from JSON because I saw people were using them to hold parsing directives, a practice which would have destroyed interoperability. I know that the lack of comments makes some people sad, but it shouldn't. - - > Suppose you are using JSON to keep configuration files, which you would like to annotate. Go ahead and insert all the comments you like. Then pipe it through JSMin before handing it to your JSON parser. - -3. It is dangerous for interoperability if some libraries would add comment support while others don't. Please check [The Harmful Consequences of the Robustness Principle](https://tools.ietf.org/html/draft-iab-protocol-maintenance-01) on this. - -However, you can pass set parameter `ignore_comments` to true in the `parse` function to ignore `//` or `/* */` comments. Comments will then be treated as whitespace. - -### Order of object keys - -By default, the library does not preserve the **insertion order of object elements**. This is standards-compliant, as the [JSON standard](https://tools.ietf.org/html/rfc8259.html) defines objects as "an unordered collection of zero or more name/value pairs". - -If you do want to preserve the insertion order, you can try the type [`nlohmann::ordered_json`](https://github.com/nlohmann/json/issues/2179). Alternatively, you can use a more sophisticated ordered map like [`tsl::ordered_map`](https://github.com/Tessil/ordered-map) ([integration](https://github.com/nlohmann/json/issues/546#issuecomment-304447518)) or [`nlohmann::fifo_map`](https://github.com/nlohmann/fifo_map) ([integration](https://github.com/nlohmann/json/issues/485#issuecomment-333652309)). - -### Memory Release - -We checked with Valgrind and the Address Sanitizer (ASAN) that there are no memory leaks. - -If you find that a parsing program with this library does not release memory, please consider the following case, and it may be unrelated to this library. - -**Your program is compiled with glibc.** There is a tunable threshold that glibc uses to decide whether to actually return memory to the system or whether to cache it for later reuse. If in your program you make lots of small allocations and those small allocations are not a contiguous block and are presumably below the threshold, then they will not get returned to the OS. -Here is a related issue [#1924](https://github.com/nlohmann/json/issues/1924). - -### Further notes - -- The code contains numerous debug **assertions** which can be switched off by defining the preprocessor macro `NDEBUG`, see the [documentation of `assert`](https://en.cppreference.com/w/cpp/error/assert). In particular, note [`operator[]`](https://json.nlohmann.me/api/basic_json/operator%5B%5D/) implements **unchecked access** for const objects: If the given key is not present, the behavior is undefined (think of a dereferenced null pointer) and yields an [assertion failure](https://github.com/nlohmann/json/issues/289) if assertions are switched on. If you are not sure whether an element in an object exists, use checked access with the [`at()` function](https://json.nlohmann.me/api/basic_json/at/). Furthermore, you can define `JSON_ASSERT(x)` to replace calls to `assert(x)`. -- As the exact number type is not defined in the [JSON specification](https://tools.ietf.org/html/rfc8259.html), this library tries to choose the best fitting C++ number type automatically. As a result, the type `double` may be used to store numbers which may yield [**floating-point exceptions**](https://github.com/nlohmann/json/issues/181) in certain rare situations if floating-point exceptions have been unmasked in the calling code. These exceptions are not caused by the library and need to be fixed in the calling code, such as by re-masking the exceptions prior to calling library functions. -- The code can be compiled without C++ **runtime type identification** features; that is, you can use the `-fno-rtti` compiler flag. -- **Exceptions** are used widely within the library. They can, however, be switched off with either using the compiler flag `-fno-exceptions` or by defining the symbol `JSON_NOEXCEPTION`. In this case, exceptions are replaced by `abort()` calls. You can further control this behavior by defining `JSON_THROW_USER` (overriding `throw`), `JSON_TRY_USER` (overriding `try`), and `JSON_CATCH_USER` (overriding `catch`). Note that `JSON_THROW_USER` should leave the current scope (e.g., by throwing or aborting), as continuing after it may yield undefined behavior. Note the explanatory [`what()`](https://en.cppreference.com/w/cpp/error/exception/what) string of exceptions is not available for MSVC if exceptions are disabled, see [#2824](https://github.com/nlohmann/json/discussions/2824). - -## Execute unit tests - -To compile and run the tests, you need to execute - -```sh -$ mkdir build -$ cd build -$ cmake .. -DJSON_BuildTests=On -$ cmake --build . -$ ctest --output-on-failure -``` - -Note that during the `ctest` stage, several JSON test files are downloaded from an [external repository](https://github.com/nlohmann/json_test_data). If policies forbid downloading artifacts during testing, you can download the files yourself and pass the directory with the test files via `-DJSON_TestDataDirectory=path` to CMake. Then, no Internet connectivity is required. See [issue #2189](https://github.com/nlohmann/json/issues/2189) for more information. - -If the test suite is not found, several test suites will fail like this: - -``` -=============================================================================== -json/tests/src/make_test_data_available.hpp:21: -TEST CASE: check test suite is downloaded - -json/tests/src/make_test_data_available.hpp:23: FATAL ERROR: REQUIRE( utils::check_testsuite_downloaded() ) is NOT correct! - values: REQUIRE( false ) - logged: Test data not found in 'json/cmake-build-debug/json_test_data'. - Please execute target 'download_test_data' before running this test suite. - See for more information. - -=============================================================================== -``` - -In case you have downloaded the library rather than checked out the code via Git, test `cmake_fetch_content_configure` will fail. Please execute `ctest -LE git_required` to skip these tests. See [issue #2189](https://github.com/nlohmann/json/issues/2189) for more information. - -Some tests change the installed files and hence make the whole process not reproducible. Please execute `ctest -LE not_reproducible` to skip these tests. See [issue #2324](https://github.com/nlohmann/json/issues/2324) for more information. - -Note you need to call `cmake -LE "not_reproducible|git_required"` to exclude both labels. See [issue #2596](https://github.com/nlohmann/json/issues/2596) for more information. - -As Intel compilers use unsafe floating point optimization by default, the unit tests may fail. Use flag [`/fp:precise`](https://software.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/floating-point-options/fp-model-fp.html) then. + /* comment两两 */ + "property1": 1, + /* multiline */ + /* comment2 */ + "property2": 2.5, + /* comment3 */ + "property3": "test", + /* comment4 */ + "property4": { + "x": 1, + "y": 2 + }, + /* comment5 */ + "property5": [ + 1.5, + 5.4, + 3.2 + ] +} +``` + +[^1]: Tried creating a pull request in the original repository, but I doubt it's ever going to be considered. +[^2]: If you look closely at the new macro, it's relatively easy to figure out how to actually *avoid* using the macro, but I need to document that to make it officially supported. diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel deleted file mode 100644 index 2b2ae9dba7..0000000000 --- a/WORKSPACE.bazel +++ /dev/null @@ -1 +0,0 @@ -workspace(name = "nlohmann_json") diff --git a/annotation-support.patch b/annotation-support.patch new file mode 100644 index 0000000000..8b171e5232 --- /dev/null +++ b/annotation-support.patch @@ -0,0 +1,520 @@ +diff --git a/include/nlohmann/detail/macro_scope_annotated.hpp b/include/nlohmann/detail/macro_scope_annotated.hpp +new file mode 100644 +index 00000000..6aca7839 +--- /dev/null ++++ b/include/nlohmann/detail/macro_scope_annotated.hpp +@@ -0,0 +1,80 @@ ++#include ++ ++#define ANNOTATED_JSON_NOT_ALLOWED static_assert(false, "Annotated macro requires even number of arguments where each property is accompanied by a string comment.") ++ ++#define NLOHMANN_JSON_ANNOTATED_TO(v1, w1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; ++ ++#define NLOHMANN_JSON_ANNOTATED_EXPAND( x ) x ++#define NLOHMANN_JSON_ANNOTATED_GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26,_27,_28,_29,_30,_31,_32,NAME,...) NAME ++#define NLOHMANN_JSON_ANNOTATED_PASTE(...) NLOHMANN_JSON_ANNOTATED_EXPAND(NLOHMANN_JSON_ANNOTATED_GET_MACRO(__VA_ARGS__, \ ++ ANNOTATED_JSON_NOT_ALLOWED, NLOHMANN_JSON_ANNOTATED_PASTE30, \ ++ ANNOTATED_JSON_NOT_ALLOWED, NLOHMANN_JSON_ANNOTATED_PASTE28, \ ++ ANNOTATED_JSON_NOT_ALLOWED, NLOHMANN_JSON_ANNOTATED_PASTE26, \ ++ ANNOTATED_JSON_NOT_ALLOWED, NLOHMANN_JSON_ANNOTATED_PASTE24, \ ++ ANNOTATED_JSON_NOT_ALLOWED, NLOHMANN_JSON_ANNOTATED_PASTE22, \ ++ ANNOTATED_JSON_NOT_ALLOWED, NLOHMANN_JSON_ANNOTATED_PASTE20, \ ++ ANNOTATED_JSON_NOT_ALLOWED, NLOHMANN_JSON_ANNOTATED_PASTE18, \ ++ ANNOTATED_JSON_NOT_ALLOWED, NLOHMANN_JSON_ANNOTATED_PASTE16, \ ++ ANNOTATED_JSON_NOT_ALLOWED, NLOHMANN_JSON_ANNOTATED_PASTE14, \ ++ ANNOTATED_JSON_NOT_ALLOWED, NLOHMANN_JSON_ANNOTATED_PASTE12, \ ++ ANNOTATED_JSON_NOT_ALLOWED, NLOHMANN_JSON_ANNOTATED_PASTE10, \ ++ ANNOTATED_JSON_NOT_ALLOWED, NLOHMANN_JSON_ANNOTATED_PASTE8, \ ++ ANNOTATED_JSON_NOT_ALLOWED, NLOHMANN_JSON_ANNOTATED_PASTE6, \ ++ ANNOTATED_JSON_NOT_ALLOWED, NLOHMANN_JSON_ANNOTATED_PASTE4, \ ++ ANNOTATED_JSON_NOT_ALLOWED, NLOHMANN_JSON_ANNOTATED_PASTE2, \ ++ ANNOTATED_JSON_NOT_ALLOWED, ANNOTATED_JSON_NOT_ALLOWED, \ ++ ANNOTATED_JSON_NOT_ALLOWED)(__VA_ARGS__)) ++#define NLOHMANN_JSON_ANNOTATED_PASTE2(func, v1, w1) func(v1, w1) ++#define NLOHMANN_JSON_ANNOTATED_PASTE4(func, v1, w1, v2, w2) NLOHMANN_JSON_ANNOTATED_PASTE2(func, v1, w1) NLOHMANN_JSON_ANNOTATED_PASTE2(func, v2, w2) ++#define NLOHMANN_JSON_ANNOTATED_PASTE6(func, v1, w1, v2, w2, v3, w3) NLOHMANN_JSON_ANNOTATED_PASTE2(func, v1, w1) NLOHMANN_JSON_ANNOTATED_PASTE4(func, v2, w2, v3, w3) ++#define NLOHMANN_JSON_ANNOTATED_PASTE8(func, v1, w1, v2, w2, v3, w3, v4, w4) NLOHMANN_JSON_ANNOTATED_PASTE2(func, v1, w1) NLOHMANN_JSON_ANNOTATED_PASTE6(func, v2, w2, v3, w3, v4, w4) ++#define NLOHMANN_JSON_ANNOTATED_PASTE10(func, v1, w1, v2, w2, v3, w3, v4, w4, v5, w5) NLOHMANN_JSON_ANNOTATED_PASTE2(func, v1, w1) NLOHMANN_JSON_ANNOTATED_PASTE8(func, v2, w2, v3, w3, v4, w4, v5, w5) ++#define NLOHMANN_JSON_ANNOTATED_PASTE12(func, v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6) NLOHMANN_JSON_ANNOTATED_PASTE2(func, v1, w1) NLOHMANN_JSON_ANNOTATED_PASTE10(func, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6) ++#define NLOHMANN_JSON_ANNOTATED_PASTE14(func, v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7) NLOHMANN_JSON_ANNOTATED_PASTE2(func, v1, w1) NLOHMANN_JSON_ANNOTATED_PASTE12(func, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7) ++#define NLOHMANN_JSON_ANNOTATED_PASTE16(func, v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8) NLOHMANN_JSON_ANNOTATED_PASTE2(func, v1, w1) NLOHMANN_JSON_ANNOTATED_PASTE14(func, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8) ++#define NLOHMANN_JSON_ANNOTATED_PASTE18(func, v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9) NLOHMANN_JSON_ANNOTATED_PASTE2(func, v1, w1) NLOHMANN_JSON_ANNOTATED_PASTE16(func, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9) ++#define NLOHMANN_JSON_ANNOTATED_PASTE20(func, v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10) NLOHMANN_JSON_ANNOTATED_PASTE2(func, v1, w1) NLOHMANN_JSON_ANNOTATED_PASTE18(func, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10) ++#define NLOHMANN_JSON_ANNOTATED_PASTE22(func, v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10, v11, w11) NLOHMANN_JSON_ANNOTATED_PASTE2(func, v1, w1) NLOHMANN_JSON_ANNOTATED_PASTE20(func, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10, v11, w11) ++#define NLOHMANN_JSON_ANNOTATED_PASTE24(func, v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10, v11, w11, v12, w12) NLOHMANN_JSON_ANNOTATED_PASTE2(func, v1, w1) NLOHMANN_JSON_ANNOTATED_PASTE22(func, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10, v11, w11, v12, w12) ++#define NLOHMANN_JSON_ANNOTATED_PASTE26(func, v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10, v11, w11, v12, w12, v13, w13) NLOHMANN_JSON_ANNOTATED_PASTE2(func, v1, w1) NLOHMANN_JSON_ANNOTATED_PASTE24(func, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10, v11, w11, v12, w12, v13, w13) ++#define NLOHMANN_JSON_ANNOTATED_PASTE28(func, v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10, v11, w11, v12, w12, v13, w13, v14, w14) NLOHMANN_JSON_ANNOTATED_PASTE2(func, v1, w1) NLOHMANN_JSON_ANNOTATED_PASTE26(func, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10, v11, w11, v12, w12, v13, w13, v14, w14) ++#define NLOHMANN_JSON_ANNOTATED_PASTE30(func, v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10, v11, w11, v12, w12, v13, w13, v14, w14, v15, w15) NLOHMANN_JSON_ANNOTATED_PASTE2(func, v1, w1) NLOHMANN_JSON_ANNOTATED_PASTE28(func, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10, v11, w11, v12, w12, v13, w13, v14, w14, v15, w15) ++ ++ ++#define TERNARY_EXPAND1(v1, w1) (property == #v1 ? w1 : "") ++#define TERNARY_EXPAND2(v1, w1, v2, w2) (property == #v2 ? w2 : TERNARY_EXPAND1(v1, w1)) ++#define TERNARY_EXPAND3(v1, w1, v2, w2, v3, w3) (property == #v3 ? w3 : TERNARY_EXPAND2(v1, w1, v2, w2)) ++#define TERNARY_EXPAND4(v1, w1, v2, w2, v3, w3, v4, w4) (property == #v4 ? w4 : TERNARY_EXPAND3(v1, w1, v2, w2, v3, w3)) ++#define TERNARY_EXPAND5(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5) (property == #v5 ? w5 : TERNARY_EXPAND4(v1, w1, v2, w2, v3, w3, v4, w4)) ++#define TERNARY_EXPAND6(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6) (property == #v6 ? w6 : TERNARY_EXPAND5(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5)) ++#define TERNARY_EXPAND7(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7) (property == #v7 ? w7 : TERNARY_EXPAND6(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6)) ++#define TERNARY_EXPAND8(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8) (property == #v8 ? w8 : TERNARY_EXPAND7(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7)) ++#define TERNARY_EXPAND9(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9) (property == #v9 ? w9 : TERNARY_EXPAND8(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8)) ++#define TERNARY_EXPAND10(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10) (property == #v10 ? w10 : TERNARY_EXPAND9(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9)) ++#define TERNARY_EXPAND11(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10, v11, w11) (property == #v11 ? w11 : TERNARY_EXPAND10(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10)) ++#define TERNARY_EXPAND12(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10, v11, w11, v12, w12) (property == #v12 ? w12 : TERNARY_EXPAND11(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10, v11, w11)) ++#define TERNARY_EXPAND13(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10, v11, w11, v12, w12, v13, w13) (property == #v13 ? w13 : TERNARY_EXPAND12(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10, v11, w11, v12, w12)) ++#define TERNARY_EXPAND14(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10, v11, w11, v12, w12, v13, w13, v14, w14) (property == #v14 ? w14 : TERNARY_EXPAND13(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10, v11, w11, v12, w12, v13, w13)) ++#define TERNARY_EXPAND15(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10, v11, w11, v12, w12, v13, w13, v14, w14, v15, w15) (property == #v15 ? w15 : TERNARY_EXPAND14(v1, w1, v2, w2, v3, w3, v4, w4, v5, w5, v6, w6, v7, w7, v8, w8, v9, w9, v10, w10, v11, w11, v12, w12, v13, w13, v14, w14)) ++ ++#define GET_TERNARY_EXPAND_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26,_27,_28,_29,_30,NAME,...) NAME ++#define TERNARY_EXPAND(...) GET_TERNARY_EXPAND_MACRO(__VA_ARGS__, \ ++ TERNARY_EXPAND15, ANNOTATED_JSON_NOT_ALLOWED, \ ++ TERNARY_EXPAND14, ANNOTATED_JSON_NOT_ALLOWED, \ ++ TERNARY_EXPAND13, ANNOTATED_JSON_NOT_ALLOWED, \ ++ TERNARY_EXPAND12, ANNOTATED_JSON_NOT_ALLOWED, \ ++ TERNARY_EXPAND11, ANNOTATED_JSON_NOT_ALLOWED, \ ++ TERNARY_EXPAND10, ANNOTATED_JSON_NOT_ALLOWED, \ ++ TERNARY_EXPAND9, ANNOTATED_JSON_NOT_ALLOWED, \ ++ TERNARY_EXPAND8, ANNOTATED_JSON_NOT_ALLOWED, \ ++ TERNARY_EXPAND7, ANNOTATED_JSON_NOT_ALLOWED, \ ++ TERNARY_EXPAND6, ANNOTATED_JSON_NOT_ALLOWED, \ ++ TERNARY_EXPAND5, ANNOTATED_JSON_NOT_ALLOWED, \ ++ TERNARY_EXPAND4, ANNOTATED_JSON_NOT_ALLOWED, \ ++ TERNARY_EXPAND3, ANNOTATED_JSON_NOT_ALLOWED, \ ++ TERNARY_EXPAND2, ANNOTATED_JSON_NOT_ALLOWED, \ ++ TERNARY_EXPAND1, ANNOTATED_JSON_NOT_ALLOWED)(__VA_ARGS__) ++ ++#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ANNOTATED(Type, ...) \ ++ friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_ANNOTATED_EXPAND(NLOHMANN_JSON_ANNOTATED_PASTE(NLOHMANN_JSON_ANNOTATED_TO, __VA_ARGS__)) } \ ++ static std::string get_annotation(const std::string& property) { return TERNARY_EXPAND(__VA_ARGS__); } +\ No newline at end of file +diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp +index f17b89c6..1cad019d 100644 +--- a/include/nlohmann/detail/output/serializer.hpp ++++ b/include/nlohmann/detail/output/serializer.hpp +@@ -21,6 +21,7 @@ + #include // setfill, setw + #include // is_same + #include // move ++#include + + #include + #include +@@ -31,6 +32,7 @@ + #include + #include + ++ + NLOHMANN_JSON_NAMESPACE_BEGIN + namespace detail + { +@@ -373,6 +375,197 @@ class serializer + } + } + ++ template ++ void dump_annotated(const BasicJsonType& val, ++ const bool ensure_ascii, ++ const unsigned int indent_step, ++ const unsigned int current_indent = 0) { ++ switch (val.m_data.m_type) ++ { ++ case value_t::object: ++ { ++ if (val.m_data.m_value.object->empty()) ++ { ++ o->write_characters("{}", 2); ++ return; ++ } ++ ++ o->write_characters("{\n", 2); ++ ++ // variable to hold indentation for recursive calls ++ const auto new_indent = current_indent + indent_step; ++ if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) ++ { ++ indent_string.resize(indent_string.size() * 2, ' '); ++ } ++ ++ // first n-1 elements ++ auto i = val.m_data.m_value.object->cbegin(); ++ for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i) ++ { ++ write_annotation_if_available(i->first, indent_string, new_indent, ensure_ascii); ++ o->write_characters(indent_string.c_str(), new_indent); ++ o->write_character('\"'); ++ dump_escaped(i->first, ensure_ascii); ++ o->write_characters("\": ", 3); ++ dump(i->second, true, ensure_ascii, indent_step, new_indent); ++ o->write_characters(",\n", 2); ++ } ++ ++ // last element ++ JSON_ASSERT(i != val.m_data.m_value.object->cend()); ++ JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend()); ++ write_annotation_if_available(i->first, indent_string, new_indent, ensure_ascii); ++ o->write_characters(indent_string.c_str(), new_indent); ++ o->write_character('\"'); ++ dump_escaped(i->first, ensure_ascii); ++ o->write_characters("\": ", 3); ++ dump(i->second, true, ensure_ascii, indent_step, new_indent); ++ ++ o->write_character('\n'); ++ o->write_characters(indent_string.c_str(), current_indent); ++ o->write_character('}'); ++ ++ return; ++ } ++ ++ case value_t::array: ++ { ++ if (val.m_data.m_value.array->empty()) ++ { ++ o->write_characters("[]", 2); ++ return; ++ } ++ ++ o->write_characters("[\n", 2); ++ ++ // variable to hold indentation for recursive calls ++ const auto new_indent = current_indent + indent_step; ++ if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) ++ { ++ indent_string.resize(indent_string.size() * 2, ' '); ++ } ++ ++ // first n-1 elements ++ for (auto i = val.m_data.m_value.array->cbegin(); ++ i != val.m_data.m_value.array->cend() - 1; ++i) ++ { ++ o->write_characters(indent_string.c_str(), new_indent); ++ dump(*i, true, ensure_ascii, indent_step, new_indent); ++ o->write_characters(",\n", 2); ++ } ++ ++ // last element ++ JSON_ASSERT(!val.m_data.m_value.array->empty()); ++ o->write_characters(indent_string.c_str(), new_indent); ++ dump(val.m_data.m_value.array->back(), true, ensure_ascii, indent_step, new_indent); ++ ++ o->write_character('\n'); ++ o->write_characters(indent_string.c_str(), current_indent); ++ o->write_character(']'); ++ ++ return; ++ } ++ ++ case value_t::string: ++ { ++ o->write_character('\"'); ++ dump_escaped(*val.m_data.m_value.string, ensure_ascii); ++ o->write_character('\"'); ++ return; ++ } ++ ++ case value_t::binary: ++ { ++ o->write_characters("{\n", 2); ++ ++ // variable to hold indentation for recursive calls ++ const auto new_indent = current_indent + indent_step; ++ if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) ++ { ++ indent_string.resize(indent_string.size() * 2, ' '); ++ } ++ ++ o->write_characters(indent_string.c_str(), new_indent); ++ ++ o->write_characters("\"bytes\": [", 10); ++ ++ if (!val.m_data.m_value.binary->empty()) ++ { ++ for (auto i = val.m_data.m_value.binary->cbegin(); ++ i != val.m_data.m_value.binary->cend() - 1; ++i) ++ { ++ dump_integer(*i); ++ o->write_characters(", ", 2); ++ } ++ dump_integer(val.m_data.m_value.binary->back()); ++ } ++ ++ o->write_characters("],\n", 3); ++ o->write_characters(indent_string.c_str(), new_indent); ++ ++ o->write_characters("\"subtype\": ", 11); ++ if (val.m_data.m_value.binary->has_subtype()) ++ { ++ dump_integer(val.m_data.m_value.binary->subtype()); ++ } ++ else ++ { ++ o->write_characters("null", 4); ++ } ++ o->write_character('\n'); ++ o->write_characters(indent_string.c_str(), current_indent); ++ o->write_character('}'); ++ return; ++ } ++ ++ case value_t::boolean: ++ { ++ if (val.m_data.m_value.boolean) ++ { ++ o->write_characters("true", 4); ++ } ++ else ++ { ++ o->write_characters("false", 5); ++ } ++ return; ++ } ++ ++ case value_t::number_integer: ++ { ++ dump_integer(val.m_data.m_value.number_integer); ++ return; ++ } ++ ++ case value_t::number_unsigned: ++ { ++ dump_integer(val.m_data.m_value.number_unsigned); ++ return; ++ } ++ ++ case value_t::number_float: ++ { ++ dump_float(val.m_data.m_value.number_float); ++ return; ++ } ++ ++ case value_t::discarded: ++ { ++ o->write_characters("", 11); ++ return; ++ } ++ ++ case value_t::null: ++ { ++ o->write_characters("null", 4); ++ return; ++ } ++ ++ default: // LCOV_EXCL_LINE ++ JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE ++ } ++ } + JSON_PRIVATE_UNLESS_TESTED: + /*! + @brief dump escaped string +@@ -958,6 +1151,23 @@ class serializer + return static_cast(-(x + 1)) + 1; + } + ++ template ++ void write_annotation_if_available(const std::string& property, const std::string& indent_string, unsigned int new_indent, bool ensure_ascii) ++ { ++ const auto annotation = UnderlyingType::get_annotation(property); ++ if(annotation != "") { ++ std::stringstream ss{annotation}; ++ for (std::string line; std::getline(ss, line, '\n');) ++ { ++ o->write_characters(indent_string.c_str(), new_indent); ++ o->write_characters("/* ", 3); ++ dump_escaped(line, ensure_ascii); ++ o->write_characters(" */", 3); ++ o->write_characters("\n", 1); ++ } ++ } ++ } ++ + private: + /// the output of the serializer + output_adapter_t o = nullptr; +diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp +index a3c0af1e..c06a4be4 100644 +--- a/include/nlohmann/json.hpp ++++ b/include/nlohmann/json.hpp +@@ -60,6 +60,7 @@ + #include + #include + #include ++#include + + #if defined(JSON_HAS_CPP_17) + #include +@@ -1289,6 +1290,21 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec + return result; + } + ++ template ++ string_t dump_annotated(const int indent = 4, ++ const char indent_char = ' ', ++ const bool ensure_ascii = false, ++ const error_handler_t error_handler = error_handler_t::strict) const ++ { ++ string_t result; ++ serializer s(detail::output_adapter(result), indent_char, error_handler); ++ ++ JSON_ASSERT(indent >= 0); ++ s.template dump_annotated(*this, ensure_ascii, static_cast(indent)); ++ ++ return result; ++ } ++ + /// @brief return the type of the JSON value (explicit) + /// @sa https://json.nlohmann.me/api/basic_json/type/ + constexpr value_t type() const noexcept +diff --git a/tests/src/unit-annotations.cpp b/tests/src/unit-annotations.cpp +new file mode 100644 +index 00000000..df9b4f45 +--- /dev/null ++++ b/tests/src/unit-annotations.cpp +@@ -0,0 +1,150 @@ ++#include "doctest_compatibility.h" ++ ++#include ++using nlohmann::json; ++ ++namespace { ++ class ExampleClass { ++private: ++ int property1{1}; ++ double property2{2.5}; ++ std::string property3{"test"}; ++ std::map property4{{"x", 1}, {"y", 2}}; ++ std::vector property5{1.5, 5.4, 3.2}; ++public: ++ ExampleClass() = default; ++ ++ NLOHMANN_DEFINE_TYPE_INTRUSIVE_ANNOTATED(ExampleClass, property1, "comment1", ++ property2, "comment2", ++ property3, "comment3", ++ property4, "comment4", ++ property5, "comment5"); ++}; ++ ++class AnotherExampleClass { ++private: ++ int property1{11}; ++ double property2{25.5}; ++public: ++ AnotherExampleClass() = default; ++ ++ NLOHMANN_DEFINE_TYPE_INTRUSIVE_ANNOTATED(AnotherExampleClass, property1, "comment11", ++ property2, "comment22"); ++}; ++ ++class MultiLineAnnotationExampleClass { ++private: ++ int property1{11}; ++ std::string property2{"test"}; ++public: ++ MultiLineAnnotationExampleClass() = default; ++ ++ NLOHMANN_DEFINE_TYPE_INTRUSIVE_ANNOTATED(MultiLineAnnotationExampleClass, property1, "multiline\ncomment11", ++ property2, "multiline\ncomment22"); ++}; ++ ++class ExampleClassUTF8 { ++private: ++ double property3{1.1}; ++ std::vector property5{1.5, 5.4, 3.2}; ++public: ++ ExampleClassUTF8() = default; ++ ++ NLOHMANN_DEFINE_TYPE_INTRUSIVE_ANNOTATED(ExampleClassUTF8, property3, "comment三", ++ property5, "comment五"); ++}; ++} ++ ++TEST_CASE("annotation") ++{ ++ SECTION("canonical") ++ { ++ ExampleClass ex; ++ nlohmann::json j = ex; ++ const auto ex_actual_json = j.dump_annotated(4); ++ const auto expected_json = "{\n" ++ " /* comment1 */\n" ++ " \"property1\": 1,\n" ++ " /* comment2 */\n" ++ " \"property2\": 2.5,\n" ++ " /* comment3 */\n" ++ " \"property3\": \"test\",\n" ++ " /* comment4 */\n" ++ " \"property4\": {\n" ++ " \"x\": 1,\n" ++ " \"y\": 2\n" ++ " },\n" ++ " /* comment5 */\n" ++ " \"property5\": [\n" ++ " 1.5,\n" ++ " 5.4,\n" ++ " 3.2\n" ++ " ]\n" ++ "}"; ++ CHECK(ex_actual_json == expected_json); ++ } ++ SECTION("macro_does_not_pollute_global_scope") ++ { ++ ExampleClass ex; ++ AnotherExampleClass another_ex; ++ nlohmann::json j1 = ex; ++ nlohmann::json j2 = another_ex; ++ const auto another_ex_actual_json = j2.dump_annotated(4); ++ const auto expected_json = "{\n" ++ " /* comment11 */\n" ++ " \"property1\": 11,\n" ++ " /* comment22 */\n" ++ " \"property2\": 25.5\n" ++ "}"; ++ CHECK(another_ex_actual_json == expected_json); ++ } ++ SECTION("multi_line_annotation") ++ { ++ MultiLineAnnotationExampleClass ex; ++ nlohmann::json j = ex; ++ const auto ex_actual_json = j.dump_annotated(4); ++ const auto expected_json = "{\n" ++ " /* multiline */\n" ++ " /* comment11 */\n" ++ " \"property1\": 11,\n" ++ " /* multiline */\n" ++ " /* comment22 */\n" ++ " \"property2\": \"test\"\n" ++ "}"; ++ CHECK(ex_actual_json == expected_json); ++ } ++ SECTION("utf8_comment_ascii_not_ensured") ++ { ++ ExampleClassUTF8 ex; ++ nlohmann::json j = ex; ++ const auto ex_actual_json = j.dump_annotated(4); ++ const auto expected_json = "{\n" ++ " /* comment三 */\n" ++ " \"property3\": 1.1,\n" ++ " /* comment五 */\n" ++ " \"property5\": [\n" ++ " 1.5,\n" ++ " 5.4,\n" ++ " 3.2\n" ++ " ]\n" ++ "}"; ++ CHECK(ex_actual_json == expected_json); ++ } ++ SECTION("utf8_comment_ensure_ascii") ++ { ++ ExampleClassUTF8 ex; ++ nlohmann::json j = ex; ++ const auto ex_actual_json = j.dump_annotated(4, ' ', true); ++ const auto expected_json = "{\n" ++ " /* comment\\u4e09 */\n" ++ " \"property3\": 1.1,\n" ++ " /* comment\\u4e94 */\n" ++ " \"property5\": [\n" ++ " 1.5,\n" ++ " 5.4,\n" ++ " 3.2\n" ++ " ]\n" ++ "}"; ++ CHECK(ex_actual_json == expected_json); ++ } ++} +\ No newline at end of file diff --git a/cmake/ci.cmake b/cmake/ci.cmake deleted file mode 100644 index bbb2d4cb95..0000000000 --- a/cmake/ci.cmake +++ /dev/null @@ -1,983 +0,0 @@ -# number of parallel jobs for CTest -set(N 10) - -############################################################################### -# Needed tools. -############################################################################### - -include(FindPython3) -find_package(Python3 COMPONENTS Interpreter) - -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++ clang++-17 clang++-16 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_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) -execute_process(COMMAND ${CLANG_TIDY_TOOL} --version OUTPUT_VARIABLE CLANG_TIDY_TOOL_VERSION ERROR_VARIABLE CLANG_TIDY_TOOL_VERSION) -string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CLANG_TIDY_TOOL_VERSION "${CLANG_TIDY_TOOL_VERSION}") -message(STATUS "🔖 Clang-Tidy ${CLANG_TIDY_TOOL_VERSION} (${CLANG_TIDY_TOOL})") - -message(STATUS "🔖 CMake ${CMAKE_VERSION} (${CMAKE_COMMAND})") - -find_program(CPPCHECK_TOOL NAMES cppcheck) -execute_process(COMMAND ${CPPCHECK_TOOL} --version OUTPUT_VARIABLE CPPCHECK_TOOL_VERSION ERROR_VARIABLE CPPCHECK_TOOL_VERSION) -string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CPPCHECK_TOOL_VERSION "${CPPCHECK_TOOL_VERSION}") -message(STATUS "🔖 Cppcheck ${CPPCHECK_TOOL_VERSION} (${CPPCHECK_TOOL})") - -find_program(GCC_TOOL NAMES g++-latest g++-HEAD g++-13 g++-12 g++-11 g++-10) -execute_process(COMMAND ${GCC_TOOL} --version OUTPUT_VARIABLE GCC_TOOL_VERSION ERROR_VARIABLE GCC_TOOL_VERSION) -string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" GCC_TOOL_VERSION "${GCC_TOOL_VERSION}") -message(STATUS "🔖 GCC ${GCC_TOOL_VERSION} (${GCC_TOOL})") - -find_program(GCOV_TOOL NAMES gcov-HEAD gcov-11 gcov-10 gcov) -execute_process(COMMAND ${GCOV_TOOL} --version OUTPUT_VARIABLE GCOV_TOOL_VERSION ERROR_VARIABLE GCOV_TOOL_VERSION) -string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" GCOV_TOOL_VERSION "${GCOV_TOOL_VERSION}") -message(STATUS "🔖 GCOV ${GCOV_TOOL_VERSION} (${GCOV_TOOL})") - -find_program(GIT_TOOL NAMES git) -execute_process(COMMAND ${GIT_TOOL} --version OUTPUT_VARIABLE GIT_TOOL_VERSION ERROR_VARIABLE GIT_TOOL_VERSION) -string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" GIT_TOOL_VERSION "${GIT_TOOL_VERSION}") -message(STATUS "🔖 Git ${GIT_TOOL_VERSION} (${GIT_TOOL})") - -find_program(IWYU_TOOL NAMES include-what-you-use iwyu) -execute_process(COMMAND ${IWYU_TOOL} --version OUTPUT_VARIABLE IWYU_TOOL_VERSION ERROR_VARIABLE IWYU_TOOL_VERSION) -string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" IWYU_TOOL_VERSION "${IWYU_TOOL_VERSION}") -message(STATUS "🔖 include-what-you-use ${IWYU_TOOL_VERSION} (${IWYU_TOOL})") - -find_program(INFER_TOOL NAMES infer) -execute_process(COMMAND ${INFER_TOOL} --version OUTPUT_VARIABLE INFER_TOOL_VERSION ERROR_VARIABLE INFER_TOOL_VERSION) -string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" INFER_TOOL_VERSION "${INFER_TOOL_VERSION}") -message(STATUS "🔖 Infer ${INFER_TOOL_VERSION} (${INFER_TOOL})") - -find_program(LCOV_TOOL NAMES lcov) -execute_process(COMMAND ${LCOV_TOOL} --version OUTPUT_VARIABLE LCOV_TOOL_VERSION ERROR_VARIABLE LCOV_TOOL_VERSION) -string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" LCOV_TOOL_VERSION "${LCOV_TOOL_VERSION}") -message(STATUS "🔖 LCOV ${LCOV_TOOL_VERSION} (${LCOV_TOOL})") - -find_program(NINJA_TOOL NAMES ninja) -execute_process(COMMAND ${NINJA_TOOL} --version OUTPUT_VARIABLE NINJA_TOOL_VERSION ERROR_VARIABLE NINJA_TOOL_VERSION) -string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" NINJA_TOOL_VERSION "${NINJA_TOOL_VERSION}") -message(STATUS "🔖 Ninja ${NINJA_TOOL_VERSION} (${NINJA_TOOL})") - -find_program(OCLINT_TOOL NAMES oclint-json-compilation-database) -find_program(OCLINT_VERSION_TOOL NAMES oclint) -execute_process(COMMAND ${OCLINT_VERSION_TOOL} --version OUTPUT_VARIABLE OCLINT_TOOL_VERSION ERROR_VARIABLE OCLINT_TOOL_VERSION) -string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" OCLINT_TOOL_VERSION "${OCLINT_TOOL_VERSION}") -message(STATUS "🔖 OCLint ${OCLINT_TOOL_VERSION} (${OCLINT_TOOL})") - -find_program(VALGRIND_TOOL NAMES valgrind) -execute_process(COMMAND ${VALGRIND_TOOL} --version OUTPUT_VARIABLE VALGRIND_TOOL_VERSION ERROR_VARIABLE VALGRIND_TOOL_VERSION) -string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" VALGRIND_TOOL_VERSION "${VALGRIND_TOOL_VERSION}") -message(STATUS "🔖 Valgrind ${VALGRIND_TOOL_VERSION} (${VALGRIND_TOOL})") - -find_program(GENHTML_TOOL NAMES genhtml) -find_program(PLOG_CONVERTER_TOOL NAMES plog-converter) -find_program(PVS_STUDIO_ANALYZER_TOOL NAMES pvs-studio-analyzer) -find_program(SCAN_BUILD_TOOL NAMES scan-build-15 scan-build-14 scan-build-13 scan-build-12 scan-build-11 scan-build) - -# the individual source files -file(GLOB_RECURSE SRC_FILES ${PROJECT_SOURCE_DIR}/include/nlohmann/*.hpp) - -############################################################################### -# Thorough check with recent compilers -############################################################################### - -# Ignored Clang warnings: -# -Wno-c++98-compat The library targets C++11. -# -Wno-c++98-compat-pedantic The library targets C++11. -# -Wno-deprecated-declarations The library contains annotations for deprecated functions. -# -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. - -set(CLANG_CXXFLAGS - -Werror - -Weverything - -Wno-c++98-compat - -Wno-c++98-compat-pedantic - -Wno-deprecated-declarations - -Wno-extra-semi-stmt - -Wno-padded - -Wno-covered-switch-default - -Wno-unsafe-buffer-usage - -Wno-weak-vtables - -Wno-reserved-identifier -) - -# Warning flags determined for GCC 13.0 (experimental) with https://github.com/nlohmann/gcc_flags: -# Ignored GCC warnings: -# -Wno-abi-tag We do not care about ABI tags. -# -Wno-aggregate-return The library uses aggregate returns. -# -Wno-long-long The library uses the long long type to interface with system functions. -# -Wno-namespaces The library uses namespaces. -# -Wno-padded We do not care about padding warnings. -# -Wno-system-headers We do not care about warnings in system headers. -# -Wno-templates The library uses templates. - -set(GCC_CXXFLAGS - -pedantic - -Werror - --all-warnings - --extra-warnings - -W - -WNSObject-attribute - -Wno-abi-tag - -Waddress - -Waddress-of-packed-member - -Wno-aggregate-return - -Waggressive-loop-optimizations - -Waligned-new=all - -Wall - -Walloc-zero - -Walloca - -Wanalyzer-double-fclose - -Wanalyzer-double-free - -Wanalyzer-exposure-through-output-file - -Wanalyzer-file-leak - -Wanalyzer-free-of-non-heap - -Wanalyzer-malloc-leak - -Wanalyzer-mismatching-deallocation - -Wanalyzer-null-argument - -Wanalyzer-null-dereference - -Wanalyzer-possible-null-argument - -Wanalyzer-possible-null-dereference - -Wanalyzer-shift-count-negative - -Wanalyzer-shift-count-overflow - -Wanalyzer-stale-setjmp-buffer - -Wanalyzer-tainted-allocation-size - -Wanalyzer-tainted-array-index - -Wanalyzer-tainted-divisor - -Wanalyzer-tainted-offset - -Wanalyzer-tainted-size - -Wanalyzer-too-complex - -Wanalyzer-unsafe-call-within-signal-handler - -Wanalyzer-use-after-free - -Wanalyzer-use-of-pointer-in-stale-stack-frame - -Wanalyzer-use-of-uninitialized-value - -Wanalyzer-va-arg-type-mismatch - -Wanalyzer-va-list-exhausted - -Wanalyzer-va-list-leak - -Wanalyzer-va-list-use-after-va-end - -Wanalyzer-write-to-const - -Wanalyzer-write-to-string-literal - -Warith-conversion - -Warray-bounds=2 - -Warray-compare - -Warray-parameter=2 - -Wattribute-alias=2 - -Wattribute-warning - -Wattributes - -Wbool-compare - -Wbool-operation - -Wbuiltin-declaration-mismatch - -Wbuiltin-macro-redefined - -Wc++0x-compat - -Wc++11-compat - -Wc++11-extensions - -Wc++14-compat - -Wc++14-extensions - -Wc++17-compat - -Wc++17-extensions - -Wc++1z-compat - -Wc++20-compat - -Wc++20-extensions - -Wc++23-extensions - -Wc++2a-compat - -Wcannot-profile - -Wcast-align - -Wcast-align=strict - -Wcast-function-type - -Wcast-qual - -Wcatch-value=3 - -Wchar-subscripts - -Wclass-conversion - -Wclass-memaccess - -Wclobbered - -Wcomma-subscript - -Wcomment - -Wcomments - -Wconditionally-supported - -Wconversion - -Wconversion-null - -Wcoverage-invalid-line-number - -Wcoverage-mismatch - -Wcpp - -Wctad-maybe-unsupported - -Wctor-dtor-privacy - -Wdangling-else - -Wdangling-pointer=2 - -Wdate-time - -Wdelete-incomplete - -Wdelete-non-virtual-dtor - -Wdeprecated - -Wdeprecated-copy - -Wdeprecated-copy-dtor - -Wdeprecated-declarations - -Wdeprecated-enum-enum-conversion - -Wdeprecated-enum-float-conversion - -Wdisabled-optimization - -Wdiv-by-zero - -Wdouble-promotion - -Wduplicated-branches - -Wduplicated-cond - -Weffc++ - -Wempty-body - -Wendif-labels - -Wenum-compare - -Wenum-conversion - -Wexceptions - -Wexpansion-to-defined - -Wextra - -Wextra-semi - -Wfloat-conversion - -Wfloat-equal - -Wformat-diag - -Wformat-overflow=2 - -Wformat-signedness - -Wformat-truncation=2 - -Wformat=2 - -Wframe-address - -Wfree-nonheap-object - -Whsa - -Wif-not-aligned - -Wignored-attributes - -Wignored-qualifiers - -Wimplicit-fallthrough=5 - -Winaccessible-base - -Winfinite-recursion - -Winherited-variadic-ctor - -Winit-list-lifetime - -Winit-self - -Winline - -Wint-in-bool-context - -Wint-to-pointer-cast - -Winterference-size - -Winvalid-imported-macros - -Winvalid-memory-model - -Winvalid-offsetof - -Winvalid-pch - -Wliteral-suffix - -Wlogical-not-parentheses - -Wlogical-op - -Wno-long-long - -Wlto-type-mismatch - -Wmain - -Wmaybe-uninitialized - -Wmemset-elt-size - -Wmemset-transposed-args - -Wmisleading-indentation - -Wmismatched-dealloc - -Wmismatched-new-delete - -Wmismatched-tags - -Wmissing-attributes - -Wmissing-braces - -Wmissing-declarations - -Wmissing-field-initializers - -Wmissing-include-dirs - -Wmissing-profile - -Wmissing-requires - -Wmissing-template-keyword - -Wmultichar - -Wmultiple-inheritance - -Wmultistatement-macros - -Wno-namespaces - -Wnarrowing - -Wnoexcept - -Wnoexcept-type - -Wnon-template-friend - -Wnon-virtual-dtor - -Wnonnull - -Wnonnull-compare - -Wnormalized=nfkc - -Wnull-dereference - -Wodr - -Wold-style-cast - -Wopenacc-parallelism - -Wopenmp-simd - -Woverflow - -Woverlength-strings - -Woverloaded-virtual - -Wpacked - -Wpacked-bitfield-compat - -Wpacked-not-aligned - -Wno-padded - -Wparentheses - -Wpedantic - -Wpessimizing-move - -Wplacement-new=2 - -Wpmf-conversions - -Wpointer-arith - -Wpointer-compare - -Wpragmas - -Wprio-ctor-dtor - -Wpsabi - -Wrange-loop-construct - -Wredundant-decls - -Wredundant-move - -Wredundant-tags - -Wregister - -Wreorder - -Wrestrict - -Wreturn-local-addr - -Wreturn-type - -Wscalar-storage-order - -Wsequence-point - -Wshadow=compatible-local - -Wshadow=global - -Wshadow=local - -Wshift-count-negative - -Wshift-count-overflow - -Wshift-negative-value - -Wshift-overflow=2 - -Wsign-compare - -Wsign-conversion - -Wsign-promo - -Wsized-deallocation - -Wsizeof-array-argument - -Wsizeof-array-div - -Wsizeof-pointer-div - -Wsizeof-pointer-memaccess - -Wstack-protector - -Wstrict-aliasing=3 - -Wstrict-null-sentinel - -Wno-strict-overflow - -Wstring-compare - -Wstringop-overflow=4 - -Wstringop-overread - -Wstringop-truncation - -Wsubobject-linkage - -Wsuggest-attribute=cold - -Wsuggest-attribute=const - -Wsuggest-attribute=format - -Wsuggest-attribute=malloc - -Wsuggest-attribute=noreturn - -Wsuggest-attribute=pure - -Wsuggest-final-methods - -Wsuggest-final-types - -Wsuggest-override - -Wswitch - -Wswitch-bool - -Wswitch-default - -Wswitch-enum - -Wswitch-outside-range - -Wswitch-unreachable - -Wsync-nand - -Wsynth - -Wno-system-headers - -Wtautological-compare - -Wno-templates - -Wterminate - -Wtrampolines - -Wtrigraphs - -Wtrivial-auto-var-init - -Wtsan - -Wtype-limits - -Wundef - -Wuninitialized - -Wunknown-pragmas - -Wunreachable-code - -Wunsafe-loop-optimizations - -Wunused - -Wunused-but-set-parameter - -Wunused-but-set-variable - -Wunused-const-variable=2 - -Wunused-function - -Wunused-label - -Wunused-local-typedefs - -Wunused-macros - -Wunused-parameter - -Wunused-result - -Wunused-value - -Wunused-variable - -Wuse-after-free=3 - -Wuseless-cast - -Wvarargs - -Wvariadic-macros - -Wvector-operation-performance - -Wvexing-parse - -Wvirtual-inheritance - -Wvirtual-move-assign - -Wvla - -Wvla-parameter - -Wvolatile - -Wvolatile-register-var - -Wwrite-strings - -Wzero-as-null-pointer-constant - -Wzero-length-bounds -) - -add_custom_target(ci_test_gcc - COMMAND CXX=${GCC_TOOL} CXXFLAGS="${GCC_CXXFLAGS}" ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja - -DJSON_BuildTests=ON - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_gcc - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_gcc - COMMAND cd ${PROJECT_BINARY_DIR}/build_gcc && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure - COMMENT "Compile and test with GCC using maximal warning flags" -) - -add_custom_target(ci_test_clang - COMMAND CXX=${CLANG_TOOL} CXXFLAGS="${CLANG_CXXFLAGS}" ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja - -DJSON_BuildTests=ON - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_clang - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_clang - COMMAND cd ${PROJECT_BINARY_DIR}/build_clang && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure - COMMENT "Compile and test with Clang using maximal warning flags" -) - -############################################################################### -# Different C++ Standards. -############################################################################### - -foreach(CXX_STANDARD 11 14 17 20 23) - add_custom_target(ci_test_gcc_cxx${CXX_STANDARD} - COMMAND CXX=${GCC_TOOL} CXXFLAGS="${GCC_CXXFLAGS}" ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja - -DJSON_BuildTests=ON -DJSON_FastTests=ON - -DJSON_TestStandards=${CXX_STANDARD} - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_gcc_cxx${CXX_STANDARD} - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_gcc_cxx${CXX_STANDARD} - COMMAND cd ${PROJECT_BINARY_DIR}/build_gcc_cxx${CXX_STANDARD} && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure - COMMENT "Compile and test with GCC for C++${CXX_STANDARD}" - ) - - add_custom_target(ci_test_clang_cxx${CXX_STANDARD} - COMMAND CXX=${CLANG_TOOL} CXXFLAGS="${CLANG_CXXFLAGS}" ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja - -DJSON_BuildTests=ON -DJSON_FastTests=ON - -DJSON_TestStandards=${CXX_STANDARD} - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_clang_cxx${CXX_STANDARD} - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_clang_cxx${CXX_STANDARD} - COMMAND cd ${PROJECT_BINARY_DIR}/build_clang_cxx${CXX_STANDARD} && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure - COMMENT "Compile and test with Clang for C++${CXX_STANDARD}" - ) -endforeach() - -############################################################################### -# Disable exceptions. -############################################################################### - -add_custom_target(ci_test_noexceptions - COMMAND ${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 - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_noexceptions - COMMAND cd ${PROJECT_BINARY_DIR}/build_noexceptions && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure - COMMENT "Compile and test with exceptions switched off" -) - -############################################################################### -# Disable implicit conversions. -############################################################################### - -add_custom_target(ci_test_noimplicitconversions - COMMAND ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja - -DJSON_BuildTests=ON -DJSON_ImplicitConversions=OFF - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_noimplicitconversions - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_noimplicitconversions - COMMAND cd ${PROJECT_BINARY_DIR}/build_noimplicitconversions && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure - COMMENT "Compile and test with implicit conversions switched off" -) - -############################################################################### -# Enable improved diagnostics. -############################################################################### - -add_custom_target(ci_test_diagnostics - COMMAND ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja - -DJSON_BuildTests=ON -DJSON_Diagnostics=ON - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_diagnostics - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_diagnostics - COMMAND cd ${PROJECT_BINARY_DIR}/build_diagnostics && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure - COMMENT "Compile and test with improved diagnostics enabled" -) - -############################################################################### -# Enable legacy discarded value comparison. -############################################################################### - -add_custom_target(ci_test_legacycomparison - COMMAND ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja - -DJSON_BuildTests=ON -DJSON_LegacyDiscardedValueComparison=ON - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_legacycomparison - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_legacycomparison - COMMAND cd ${PROJECT_BINARY_DIR}/build_legacycomparison && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure - COMMENT "Compile and test with legacy discarded value comparison enabled" -) - -############################################################################### -# Disable global UDLs. -############################################################################### - -add_custom_target(ci_test_noglobaludls - COMMAND ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja - -DJSON_BuildTests=ON -DJSON_FastTests=ON -DJSON_GlobalUDLs=OFF - -DCMAKE_CXX_FLAGS=-DJSON_TEST_NO_GLOBAL_UDLS - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_noglobaludls - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_noglobaludls - COMMAND cd ${PROJECT_BINARY_DIR}/build_noglobaludls && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure - COMMENT "Compile and test with global UDLs disabled" -) - -############################################################################### -# Coverage. -############################################################################### - -add_custom_target(ci_test_coverage - COMMAND CXX=g++ ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_CXX_FLAGS="--coverage;-fprofile-arcs;-ftest-coverage" - -DJSON_BuildTests=ON - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_coverage - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_coverage - COMMAND cd ${PROJECT_BINARY_DIR}/build_coverage && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure - - COMMAND CXX=g++ ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_CXX_FLAGS="-m32;--coverage;-fprofile-arcs;-ftest-coverage" - -DJSON_BuildTests=ON -DJSON_32bitTest=ONLY - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_coverage32 - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_coverage32 - COMMAND cd ${PROJECT_BINARY_DIR}/build_coverage32 && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure - - COMMAND ${LCOV_TOOL} --directory . --capture --output-file json.info --rc lcov_branch_coverage=1 - COMMAND ${LCOV_TOOL} -e json.info ${SRC_FILES} --output-file json.info.filtered --rc lcov_branch_coverage=1 - COMMAND ${CMAKE_SOURCE_DIR}/tests/thirdparty/imapdl/filterbr.py json.info.filtered > json.info.filtered.noexcept - COMMAND genhtml --title "JSON for Modern C++" --legend --demangle-cpp --output-directory html --show-details --branch-coverage json.info.filtered.noexcept - - COMMENT "Compile and test with coverage" -) - -############################################################################### -# Sanitizers. -############################################################################### - -set(CLANG_CXX_FLAGS_SANITIZER "-g -O1 -fsanitize=address -fsanitize=undefined -fsanitize=integer -fsanitize=nullability -fno-omit-frame-pointer -fno-sanitize-recover=all -fno-sanitize=unsigned-integer-overflow -fno-sanitize=unsigned-shift-base") - -add_custom_target(ci_test_clang_sanitizer - COMMAND CXX=${CLANG_TOOL} CXXFLAGS=${CLANG_CXX_FLAGS_SANITIZER} ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja - -DJSON_BuildTests=ON - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_clang_sanitizer - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_clang_sanitizer - COMMAND cd ${PROJECT_BINARY_DIR}/build_clang_sanitizer && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure - COMMENT "Compile and test with sanitizers" -) - -############################################################################### -# 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 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" -) - -############################################################################### -# Build and test using the amalgamated header -############################################################################### - -add_custom_target(ci_test_single_header - COMMAND CXX=${GCC_TOOL} CXXFLAGS="${GCC_CXXFLAGS}" ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja - -DJSON_BuildTests=ON -DJSON_MultipleHeaders=OFF -DJSON_FastTests=ON - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_single_header - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_single_header - COMMAND cd ${PROJECT_BINARY_DIR}/build_single_header && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure - COMMENT "Compile and test single-header version" -) - -############################################################################### -# Valgrind. -############################################################################### - -add_custom_target(ci_test_valgrind - COMMAND CXX=${GCC_TOOL} ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja - -DJSON_BuildTests=ON -DJSON_Valgrind=ON - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_valgrind - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_valgrind - COMMAND cd ${PROJECT_BINARY_DIR}/build_valgrind && ${CMAKE_CTEST_COMMAND} -L valgrind --parallel ${N} --output-on-failure - COMMENT "Compile and test with Valgrind" -) - -############################################################################### -# Check code with Clang Static Analyzer. -############################################################################### - -set(CLANG_ANALYZER_CHECKS "fuchsia.HandleChecker,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,optin.cplusplus.UninitializedObject,optin.cplusplus.VirtualCall,optin.mpi.MPI-Checker,optin.osx.OSObjectCStyleCast,optin.osx.cocoa.localizability.EmptyLocalizationContextChecker,optin.osx.cocoa.localizability.NonLocalizedStringChecker,optin.performance.GCDAntipattern,optin.performance.Padding,optin.portability.UnixAPI,security.FloatLoopCounter,security.insecureAPI.DeprecatedOrUnsafeBufferHandling,security.insecureAPI.bcmp,security.insecureAPI.bcopy,security.insecureAPI.bzero,security.insecureAPI.rand,security.insecureAPI.strcpy,valist.CopyToSelf,valist.Uninitialized,valist.Unterminated,webkit.NoUncountedMemberChecker,webkit.RefCntblBaseVirtualDtor,core.CallAndMessage,core.DivideZero,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.VLASize,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.UndefReturn,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.PlacementNew,cplusplus.PureVirtualCall,deadcode.DeadStores,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,osx.API,osx.MIG,osx.NumberObjectConversion,osx.OSObjectRetainCount,osx.ObjCProperty,osx.SecKeychainAPI,osx.cocoa.AtSync,osx.cocoa.AutoreleaseWrite,osx.cocoa.ClassRelease,osx.cocoa.Dealloc,osx.cocoa.IncompatibleMethodTypes,osx.cocoa.Loops,osx.cocoa.MissingSuperCall,osx.cocoa.NSAutoreleasePool,osx.cocoa.NSError,osx.cocoa.NilArg,osx.cocoa.NonNilReturnValue,osx.cocoa.ObjCGenerics,osx.cocoa.RetainCount,osx.cocoa.RunLoopAutoreleaseLeak,osx.cocoa.SelfInit,osx.cocoa.SuperDealloc,osx.cocoa.UnusedIvars,osx.cocoa.VariadicMethodTypes,osx.coreFoundation.CFError,osx.coreFoundation.CFNumber,osx.coreFoundation.CFRetainRelease,osx.coreFoundation.containers.OutOfBounds,osx.coreFoundation.containers.PointerSizedValues,security.insecureAPI.UncheckedReturn,security.insecureAPI.decodeValueOfObjCType,security.insecureAPI.getpw,security.insecureAPI.gets,security.insecureAPI.mkstemp,security.insecureAPI.mktemp,security.insecureAPI.vfork,unix.API,unix.Malloc,unix.MallocSizeof,unix.MismatchedDeallocator,unix.Vfork,unix.cstring.BadSizeArg,unix.cstring.NullArg") - -add_custom_target(ci_clang_analyze - COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja - -DJSON_BuildTests=ON - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_clang_analyze - COMMAND cd ${PROJECT_BINARY_DIR}/build_clang_analyze && ${SCAN_BUILD_TOOL} -enable-checker ${CLANG_ANALYZER_CHECKS} --use-c++=${CLANG_TOOL} -analyze-headers -o ${PROJECT_BINARY_DIR}/report ninja - COMMENT "Check code with Clang Analyzer" -) - -############################################################################### -# Check code with Cppcheck. -############################################################################### - -add_custom_target(ci_cppcheck - COMMAND ${CPPCHECK_TOOL} --enable=warning --suppress=missingReturn --inline-suppr --inconclusive --force --std=c++11 ${PROJECT_SOURCE_DIR}/single_include/nlohmann/json.hpp --error-exitcode=1 - COMMENT "Check code with Cppcheck" -) - -############################################################################### -# Check code with cpplint. -############################################################################### - -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} - COMMENT "Check code with cpplint" - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} -) - -############################################################################### -# Check code with OCLint. -############################################################################### - -file(COPY ${PROJECT_SOURCE_DIR}/single_include/nlohmann/json.hpp DESTINATION ${PROJECT_BINARY_DIR}/src_single) -file(RENAME ${PROJECT_BINARY_DIR}/src_single/json.hpp ${PROJECT_BINARY_DIR}/src_single/all.cpp) -file(APPEND "${PROJECT_BINARY_DIR}/src_single/all.cpp" "\n\nint main()\n{}\n") - -add_executable(single_all ${PROJECT_BINARY_DIR}/src_single/all.cpp) -target_compile_features(single_all PRIVATE cxx_std_11) - -add_custom_target(ci_oclint - COMMAND ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug - -DCMAKE_EXPORT_COMPILE_COMMANDS=ON - -DJSON_BuildTests=OFF -DJSON_CI=ON - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_oclint - COMMAND ${OCLINT_TOOL} -i ${PROJECT_BINARY_DIR}/build_oclint/src_single/all.cpp -p ${PROJECT_BINARY_DIR}/build_oclint -- - -report-type html -enable-global-analysis --max-priority-1=0 --max-priority-2=1000 --max-priority-3=2000 - --disable-rule=MultipleUnaryOperator - --disable-rule=DoubleNegative - --disable-rule=ShortVariableName - --disable-rule=GotoStatement - --disable-rule=LongLine - -o ${PROJECT_BINARY_DIR}/build_oclint/oclint_report.html - COMMENT "Check code with OCLint" -) - -############################################################################### -# Check code with Clang-Tidy. -############################################################################### - -add_custom_target(ci_clang_tidy - COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja - -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_CLANG_TIDY=${CLANG_TIDY_TOOL} - -DJSON_BuildTests=ON - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_clang_tidy - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_clang_tidy - COMMENT "Check code with Clang-Tidy" -) - -############################################################################### -# Check code with PVS-Studio Analyzer . -############################################################################### - -add_custom_target(ci_pvs_studio - COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug - -DCMAKE_EXPORT_COMPILE_COMMANDS=ON - -DJSON_BuildTests=ON - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_pvs_studio - COMMAND cd ${PROJECT_BINARY_DIR}/build_pvs_studio && ${PVS_STUDIO_ANALYZER_TOOL} analyze -j 10 - COMMAND cd ${PROJECT_BINARY_DIR}/build_pvs_studio && ${PLOG_CONVERTER_TOOL} -a'GA:1,2;64:1;CS' -t fullhtml PVS-Studio.log -o pvs - COMMENT "Check code with PVS Studio" -) - -############################################################################### -# Check code with Infer static analyzer. -############################################################################### - -add_custom_target(ci_infer - COMMAND mkdir -p ${PROJECT_BINARY_DIR}/build_infer - COMMAND cd ${PROJECT_BINARY_DIR}/build_infer && ${INFER_TOOL} compile -- ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${PROJECT_SOURCE_DIR} -DJSON_BuildTests=ON - COMMAND cd ${PROJECT_BINARY_DIR}/build_infer && ${INFER_TOOL} run -- make - COMMENT "Check code with Infer" -) - -############################################################################### -# Run test suite with previously downloaded test data. -############################################################################### - -add_custom_target(ci_offline_testdata - COMMAND mkdir -p ${PROJECT_BINARY_DIR}/build_offline_testdata/test_data - COMMAND cd ${PROJECT_BINARY_DIR}/build_offline_testdata/test_data && ${GIT_TOOL} clone -c advice.detachedHead=false --branch v3.1.0 https://github.com/nlohmann/json_test_data.git --quiet --depth 1 - COMMAND ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja - -DJSON_BuildTests=ON -DJSON_FastTests=ON -DJSON_TestDataDirectory=${PROJECT_BINARY_DIR}/build_offline_testdata/test_data/json_test_data - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_offline_testdata - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_offline_testdata - COMMAND cd ${PROJECT_BINARY_DIR}/build_offline_testdata && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure - COMMENT "Check code with previously downloaded test data" -) - -############################################################################### -# Run test suite when project was not checked out from Git -############################################################################### - -add_custom_target(ci_non_git_tests - COMMAND git config --global --add safe.directory ${PROJECT_SOURCE_DIR} - COMMAND mkdir -p ${PROJECT_BINARY_DIR}/build_non_git_tests/sources - COMMAND cd ${PROJECT_SOURCE_DIR} && for FILE in `${GIT_TOOL} ls-tree --name-only HEAD`\; do cp -r $$FILE ${PROJECT_BINARY_DIR}/build_non_git_tests/sources \; done - COMMAND ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja - -DJSON_BuildTests=ON -DJSON_FastTests=ON - -S${PROJECT_BINARY_DIR}/build_non_git_tests/sources -B${PROJECT_BINARY_DIR}/build_non_git_tests - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_non_git_tests - COMMAND cd ${PROJECT_BINARY_DIR}/build_non_git_tests && ${CMAKE_CTEST_COMMAND} --parallel ${N} -LE git_required --output-on-failure - COMMENT "Check code when project was not checked out from Git" -) - -############################################################################### -# Run test suite and exclude tests that change installed files -############################################################################### - -add_custom_target(ci_reproducible_tests - COMMAND ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja - -DJSON_BuildTests=ON -DJSON_FastTests=ON - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_reproducible_tests - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_reproducible_tests - COMMAND cd ${PROJECT_BINARY_DIR}/build_reproducible_tests && ${CMAKE_CTEST_COMMAND} --parallel ${N} -LE not_reproducible --output-on-failure - COMMENT "Check code and exclude tests that change installed files" -) - -############################################################################### -# Check if every header in the include folder includes sufficient headers to -# be compiled individually. -############################################################################### - -set(iwyu_path_and_options ${IWYU_TOOL} -Xiwyu --max_line_length=300) - -foreach(SRC_FILE ${SRC_FILES}) - # get relative path of the header file - file(RELATIVE_PATH RELATIVE_SRC_FILE "${PROJECT_SOURCE_DIR}/include/nlohmann" "${SRC_FILE}") - # replace slashes and strip suffix - string(REPLACE "/" "_" RELATIVE_SRC_FILE "${RELATIVE_SRC_FILE}") - string(REPLACE ".hpp" "" RELATIVE_SRC_FILE "${RELATIVE_SRC_FILE}") - # create code file - file(WRITE "${PROJECT_BINARY_DIR}/src_single/${RELATIVE_SRC_FILE}.cpp" "#include \"${SRC_FILE}\" // IWYU pragma: keep\n\nint main()\n{}\n") - # create executable - add_executable(single_${RELATIVE_SRC_FILE} EXCLUDE_FROM_ALL ${PROJECT_BINARY_DIR}/src_single/${RELATIVE_SRC_FILE}.cpp) - target_include_directories(single_${RELATIVE_SRC_FILE} PRIVATE ${PROJECT_SOURCE_DIR}/include) - target_compile_features(single_${RELATIVE_SRC_FILE} PRIVATE cxx_std_11) - set_property(TARGET single_${RELATIVE_SRC_FILE} PROPERTY CXX_INCLUDE_WHAT_YOU_USE "${iwyu_path_and_options}") - # remember binary for ci_single_binaries target - list(APPEND single_binaries single_${RELATIVE_SRC_FILE}) -endforeach() - -add_custom_target(ci_single_binaries - DEPENDS ${single_binaries} - COMMENT "Check if headers are self-contained" -) - -############################################################################### -# Benchmarks -############################################################################### - -add_custom_target(ci_benchmarks - COMMAND ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Release -GNinja - -S${PROJECT_SOURCE_DIR}/benchmarks -B${PROJECT_BINARY_DIR}/build_benchmarks - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_benchmarks --target json_benchmarks - COMMAND cd ${PROJECT_BINARY_DIR}/build_benchmarks && ./json_benchmarks - COMMENT "Run benchmarks" -) - -############################################################################### -# CMake flags -############################################################################### - -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}" - ) - set(${var} ${${var}} PARENT_SCOPE) -endfunction() - -ci_get_cmake(3.1.0 CMAKE_3_1_0_BINARY) -ci_get_cmake(3.13.0 CMAKE_3_13_0_BINARY) - -set(JSON_CMAKE_FLAGS_3_1_0 JSON_Diagnostics JSON_GlobalUDLs JSON_ImplicitConversions JSON_DisableEnumSerialization - JSON_LegacyDiscardedValueComparison JSON_Install JSON_MultipleHeaders JSON_SystemInclude JSON_Valgrind) -set(JSON_CMAKE_FLAGS_3_13_0 JSON_BuildTests) - -function(ci_add_cmake_flags_targets flag min_version) - string(TOLOWER "ci_cmake_flag_${flag}" flag_target) - string(REPLACE . _ min_version_var ${min_version}) - set(cmake_binary ${CMAKE_${min_version_var}_BINARY}) - add_custom_target(${flag_target} - COMMENT "Check CMake flag ${flag} (CMake ${CMAKE_VERSION})" - COMMAND ${CMAKE_COMMAND} - -Werror=dev - -D${flag}=ON - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_${flag_target} - ) - add_custom_target(${flag_target}_${min_version_var} - COMMENT "Check CMake flag ${JSON_CMAKE_FLAG} (CMake ${min_version})" - COMMAND mkdir -pv ${PROJECT_BINARY_DIR}/build_${flag_target}_${min_version_var} - COMMAND cd ${PROJECT_BINARY_DIR}/build_${flag_target}_${min_version_var} - && ${cmake_binary} -Werror=dev ${PROJECT_SOURCE_DIR} -D${flag}=ON - DEPENDS ${cmake_binary} - ) - list(APPEND JSON_CMAKE_FLAG_TARGETS ${JSON_CMAKE_FLAG_TARGET} ${flag_target}_${min_version_var}) - list(APPEND JSON_CMAKE_FLAG_BUILD_DIRS ${PROJECT_BINARY_DIR}/build_${flag_target} ${PROJECT_BINARY_DIR}/build_${flag_target}_${min_version_var}) - set(JSON_CMAKE_FLAG_TARGETS ${JSON_CMAKE_FLAG_TARGETS} PARENT_SCOPE) - set(JSON_CMAKE_FLAG_BUILD_DIRS ${JSON_CMAKE_FLAG_BUILD_DIRS} PARENT_SCOPE) -endfunction() - -foreach(JSON_CMAKE_FLAG ${JSON_CMAKE_FLAGS_3_1_0}) - ci_add_cmake_flags_targets(${JSON_CMAKE_FLAG} 3.1.0) -endforeach() - -foreach(JSON_CMAKE_FLAG ${JSON_CMAKE_FLAGS_3_13_0}) - ci_add_cmake_flags_targets(${JSON_CMAKE_FLAG} 3.13.0) -endforeach() - -add_custom_target(ci_cmake_flags - DEPENDS ${JSON_CMAKE_FLAG_TARGETS} - COMMENT "Check 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) - find_program(COMPILER_TOOL NAMES ${COMPILER}) - if (COMPILER_TOOL) - unset(ADDITIONAL_FLAGS) - - add_custom_target(ci_test_compiler_${COMPILER} - COMMAND CXX=${COMPILER} ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja - -DJSON_BuildTests=ON -DJSON_FastTests=ON - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_compiler_${COMPILER} - ${ADDITIONAL_FLAGS} - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_compiler_${COMPILER} - COMMAND cd ${PROJECT_BINARY_DIR}/build_compiler_${COMPILER} && ${CMAKE_CTEST_COMMAND} --parallel ${N} --exclude-regex "test-unicode" --output-on-failure - COMMENT "Compile and test with ${COMPILER}" - ) - endif() - 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 -############################################################################### - -add_custom_target(ci_cuda_example - COMMAND ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja - -DCMAKE_CUDA_HOST_COMPILER=g++-8 - -S${PROJECT_SOURCE_DIR}/tests/cuda_example -B${PROJECT_BINARY_DIR}/build_cuda_example - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_cuda_example -) - -############################################################################### -# Intel C++ Compiler -############################################################################### - -add_custom_target(ci_icpc - COMMAND ${CMAKE_COMMAND} - -DCMAKE_BUILD_TYPE=Debug -GNinja - -DCMAKE_C_COMPILER=icc -DCMAKE_CXX_COMPILER=icpc - -DJSON_BuildTests=ON -DJSON_FastTests=ON - -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_icpc - COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_icpc - COMMAND cd ${PROJECT_BINARY_DIR}/build_icpc && ${CMAKE_CTEST_COMMAND} --parallel ${N} --exclude-regex "test-unicode" --output-on-failure - COMMENT "Compile and test with ICPC" -) - -############################################################################### -# test documentation -############################################################################### - -add_custom_target(ci_test_examples - COMMAND make CXX="${GCC_TOOL}" check_output_portable -j8 - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/docs - COMMENT "Check that all examples compile and create the desired output" -) - -add_custom_target(ci_test_api_documentation - COMMAND ${Python3_EXECUTABLE} scripts/check_structure.py - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/docs/mkdocs - COMMENT "Lint the API documentation" -) - -############################################################################### -# Clean up all generated files. -############################################################################### - -add_custom_target(ci_clean - COMMAND rm -fr ${PROJECT_BINARY_DIR}/build_* cmake-3.1.0-Darwin64 ${JSON_CMAKE_FLAG_BUILD_DIRS} ${single_binaries} - COMMENT "Clean generated directories" -) diff --git a/cmake/config.cmake.in b/cmake/config.cmake.in deleted file mode 100644 index 9a17a7d7b2..0000000000 --- a/cmake/config.cmake.in +++ /dev/null @@ -1,15 +0,0 @@ -include(FindPackageHandleStandardArgs) -set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG ${CMAKE_CURRENT_LIST_FILE}) -find_package_handle_standard_args(@PROJECT_NAME@ CONFIG_MODE) - -if(NOT TARGET @PROJECT_NAME@::@NLOHMANN_JSON_TARGET_NAME@) - include("${CMAKE_CURRENT_LIST_DIR}/@NLOHMANN_JSON_TARGETS_EXPORT_NAME@.cmake") - if((NOT TARGET @NLOHMANN_JSON_TARGET_NAME@) AND - (NOT @PROJECT_NAME@_FIND_VERSION OR - @PROJECT_NAME@_FIND_VERSION VERSION_LESS 3.2.0)) - add_library(@NLOHMANN_JSON_TARGET_NAME@ INTERFACE IMPORTED) - set_target_properties(@NLOHMANN_JSON_TARGET_NAME@ PROPERTIES - INTERFACE_LINK_LIBRARIES @PROJECT_NAME@::@NLOHMANN_JSON_TARGET_NAME@ - ) - endif() -endif() diff --git a/cmake/download_test_data.cmake b/cmake/download_test_data.cmake deleted file mode 100644 index 1bb998dae6..0000000000 --- a/cmake/download_test_data.cmake +++ /dev/null @@ -1,56 +0,0 @@ -set(JSON_TEST_DATA_URL https://github.com/nlohmann/json_test_data) -set(JSON_TEST_DATA_VERSION 3.1.0) - -# if variable is set, use test data from given directory rather than downloading them -if(JSON_TestDataDirectory) - message(STATUS "Using test data in ${JSON_TestDataDirectory}.") - add_custom_target(download_test_data) - file(WRITE ${CMAKE_BINARY_DIR}/include/test_data.hpp "#define TEST_DATA_DIRECTORY \"${JSON_TestDataDirectory}\"\n") -else() - find_package(Git) - # target to download test data - add_custom_target(download_test_data - COMMAND test -d json_test_data || ${GIT_EXECUTABLE} clone -c advice.detachedHead=false --branch v${JSON_TEST_DATA_VERSION} ${JSON_TEST_DATA_URL}.git --quiet --depth 1 - COMMENT "Downloading test data from ${JSON_TEST_DATA_URL} (v${JSON_TEST_DATA_VERSION})" - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - # create a header with the path to the downloaded test data - file(WRITE ${CMAKE_BINARY_DIR}/include/test_data.hpp "#define TEST_DATA_DIRECTORY \"${CMAKE_BINARY_DIR}/json_test_data\"\n") -endif() - -# determine the operating system (for debug and support purposes) -find_program(UNAME_COMMAND uname) -find_program(VER_COMMAND ver) -find_program(LSB_RELEASE_COMMAND lsb_release) -find_program(SW_VERS_COMMAND sw_vers) -set(OS_VERSION_STRINGS "${CMAKE_SYSTEM}") -if (VER_COMMAND) - execute_process(COMMAND ${VER_COMMAND} OUTPUT_VARIABLE VER_COMMAND_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE) - set(OS_VERSION_STRINGS "${OS_VERSION_STRINGS}; ${VER_COMMAND_RESULT}") -endif() -if (SW_VERS_COMMAND) - execute_process(COMMAND ${SW_VERS_COMMAND} OUTPUT_VARIABLE SW_VERS_COMMAND_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) - string(REGEX REPLACE "[ ]*\n" "; " SW_VERS_COMMAND_RESULT "${SW_VERS_COMMAND_RESULT}") - set(OS_VERSION_STRINGS "${OS_VERSION_STRINGS}; ${SW_VERS_COMMAND_RESULT}") -endif() -if (LSB_RELEASE_COMMAND) - execute_process(COMMAND ${LSB_RELEASE_COMMAND} -a OUTPUT_VARIABLE LSB_RELEASE_COMMAND_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) - string(REGEX REPLACE "[ ]*\n" "; " LSB_RELEASE_COMMAND_RESULT "${LSB_RELEASE_COMMAND_RESULT}") - set(OS_VERSION_STRINGS "${OS_VERSION_STRINGS}; ${LSB_RELEASE_COMMAND_RESULT}") -endif() -if (UNAME_COMMAND) - execute_process(COMMAND ${UNAME_COMMAND} -a OUTPUT_VARIABLE UNAME_COMMAND_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) - set(OS_VERSION_STRINGS "${OS_VERSION_STRINGS}; ${UNAME_COMMAND_RESULT}") -endif() - -message(STATUS "Operating system: ${OS_VERSION_STRINGS}") - -# determine the compiler (for debug and support purposes) -if (MSVC) - execute_process(COMMAND ${CMAKE_CXX_COMPILER} OUTPUT_VARIABLE CXX_VERSION_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_VARIABLE CXX_VERSION_RESULT ERROR_STRIP_TRAILING_WHITESPACE) - set(CXX_VERSION_RESULT "${CXX_VERSION_RESULT}; MSVC_VERSION=${MSVC_VERSION}; MSVC_TOOLSET_VERSION=${MSVC_TOOLSET_VERSION}") -else() - execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE CXX_VERSION_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE) -endif() -string(REGEX REPLACE "[ ]*\n" "; " CXX_VERSION_RESULT "${CXX_VERSION_RESULT}") -message(STATUS "Compiler: ${CXX_VERSION_RESULT}") diff --git a/cmake/nlohmann_jsonConfigVersion.cmake.in b/cmake/nlohmann_jsonConfigVersion.cmake.in deleted file mode 100644 index 1091085973..0000000000 --- a/cmake/nlohmann_jsonConfigVersion.cmake.in +++ /dev/null @@ -1,20 +0,0 @@ -# This is essentially cmake's BasicConfigVersion-SameMajorVersion.cmake.in but -# without the 32/64-bit check. Since json is a header-only library, it doesn't -# matter if it was built on a different platform than what it is used on (see -# https://github.com/nlohmann/json/issues/1697). -set(PACKAGE_VERSION "@PROJECT_VERSION@") - -if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) - set(PACKAGE_VERSION_COMPATIBLE FALSE) -else() - - if(PACKAGE_FIND_VERSION_MAJOR STREQUAL "@PROJECT_VERSION_MAJOR@") - set(PACKAGE_VERSION_COMPATIBLE TRUE) - else() - set(PACKAGE_VERSION_COMPATIBLE FALSE) - endif() - - if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) - set(PACKAGE_VERSION_EXACT TRUE) - endif() -endif() diff --git a/cmake/pkg-config.pc.in b/cmake/pkg-config.pc.in deleted file mode 100644 index d36317f09a..0000000000 --- a/cmake/pkg-config.pc.in +++ /dev/null @@ -1,4 +0,0 @@ -Name: ${PROJECT_NAME} -Description: JSON for Modern C++ -Version: ${PROJECT_VERSION} -Cflags: -I${CMAKE_INSTALL_FULL_INCLUDEDIR} diff --git a/cmake/scripts/gen_bazel_build_file.cmake b/cmake/scripts/gen_bazel_build_file.cmake deleted file mode 100644 index e754d387d9..0000000000 --- a/cmake/scripts/gen_bazel_build_file.cmake +++ /dev/null @@ -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, -) -]=]) diff --git a/cmake/test.cmake b/cmake/test.cmake deleted file mode 100644 index 7105b97c33..0000000000 --- a/cmake/test.cmake +++ /dev/null @@ -1,273 +0,0 @@ -set(_json_test_cmake_list_file ${CMAKE_CURRENT_LIST_FILE}) - -############################################################################# -# download test data -############################################################################# - -include(download_test_data) - -# test fixture to download test data -add_test(NAME "download_test_data" COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} - --target download_test_data -) -set_tests_properties(download_test_data PROPERTIES FIXTURES_SETUP TEST_DATA) - -if(JSON_Valgrind) - find_program(CMAKE_MEMORYCHECK_COMMAND valgrind) - message(STATUS "Executing test suite with Valgrind (${CMAKE_MEMORYCHECK_COMMAND})") - set(memcheck_command "${CMAKE_MEMORYCHECK_COMMAND} ${CMAKE_MEMORYCHECK_COMMAND_OPTIONS} --error-exitcode=1 --leak-check=full") - separate_arguments(memcheck_command) -endif() - -############################################################################# -# detect standard support -############################################################################# - -# C++11 is the minimum required -set(compiler_supports_cpp_11 TRUE) - -foreach(feature ${CMAKE_CXX_COMPILE_FEATURES}) - if (${feature} STREQUAL cxx_std_14) - set(compiler_supports_cpp_14 TRUE) - elseif (${feature} STREQUAL cxx_std_17) - set(compiler_supports_cpp_17 TRUE) - elseif (${feature} STREQUAL cxx_std_20) - set(compiler_supports_cpp_20 TRUE) - elseif (${feature} STREQUAL cxx_std_23) - set(compiler_supports_cpp_23 TRUE) - endif() -endforeach() - -############################################################################# -# test functions -############################################################################# - -############################################################################# -# json_test_set_test_options( -# all| -# [CXX_STANDARDS all|...] -# [COMPILE_DEFINITIONS ...] -# [COMPILE_FEATURES ...] -# [COMPILE_OPTIONS ...] -# [LINK_LIBRARIES ...] -# [LINK_OPTIONS ...] -# [TEST_PROPERTIES ...]) -# -# Supply test- and standard-specific build settings and/or test properties. -# Specify multiple tests using a list e.g., "test-foo;test-bar". -# -# Must be called BEFORE the test is created. -############################################################################# - -function(json_test_set_test_options tests) - cmake_parse_arguments(args "" "" - "CXX_STANDARDS;COMPILE_DEFINITIONS;COMPILE_FEATURES;COMPILE_OPTIONS;LINK_LIBRARIES;LINK_OPTIONS;TEST_PROPERTIES" - ${ARGN}) - - if(NOT args_CXX_STANDARDS) - set(args_CXX_STANDARDS "all") - endif() - - foreach(test ${tests}) - if("${test}" STREQUAL "all") - set(test "") - endif() - - foreach(cxx_standard ${args_CXX_STANDARDS}) - if("${cxx_standard}" STREQUAL "all") - if("${test}" STREQUAL "") - message(FATAL_ERROR "Not supported. Change defaults in: ${_json_test_cmake_list_file}") - endif() - set(test_interface _json_test_interface_${test}) - else() - set(test_interface _json_test_interface_${test}_cpp_${cxx_standard}) - endif() - - if(NOT TARGET ${test_interface}) - add_library(${test_interface} INTERFACE) - endif() - - target_compile_definitions(${test_interface} INTERFACE ${args_COMPILE_DEFINITIONS}) - target_compile_features(${test_interface} INTERFACE ${args_COMPILE_FEATURES}) - target_compile_options(${test_interface} INTERFACE ${args_COMPILE_OPTIONS}) - target_link_libraries (${test_interface} INTERFACE ${args_LINK_LIBRARIES}) - target_link_options(${test_interface} INTERFACE ${args_LINK_OPTIONS}) - #set_target_properties(${test_interface} PROPERTIES JSON_TEST_PROPERTIES "${args_TEST_PROPERTIES}") - set_property(DIRECTORY PROPERTY - ${test_interface}_TEST_PROPERTIES "${args_TEST_PROPERTIES}" - ) - endforeach() - endforeach() -endfunction() - -# for internal use by _json_test_add_test() -function(_json_test_apply_test_properties test_target properties_target) - #get_target_property(test_properties ${properties_target} JSON_TEST_PROPERTIES) - get_property(test_properties DIRECTORY PROPERTY ${properties_target}_TEST_PROPERTIES) - if(test_properties) - set_tests_properties(${test_target} PROPERTIES ${test_properties}) - endif() -endfunction() - -# for internal use by json_test_add_test_for() -function(_json_test_add_test test_name file main cxx_standard) - set(test_target ${test_name}_cpp${cxx_standard}) - - if(TARGET ${test_target}) - message(FATAL_ERROR "Target ${test_target} has already been added.") - endif() - - add_executable(${test_target} ${file}) - target_link_libraries(${test_target} PRIVATE ${main}) - - # set and require C++ standard - set_target_properties(${test_target} PROPERTIES - CXX_STANDARD ${cxx_standard} - CXX_STANDARD_REQUIRED ON - ) - - # apply standard-specific build settings - if(TARGET _json_test_interface__cpp_${cxx_standard}) - target_link_libraries(${test_target} PRIVATE _json_test_interface__cpp_${cxx_standard}) - endif() - - # apply test-specific build settings - if(TARGET _json_test_interface_${test_name}) - target_link_libraries(${test_target} PRIVATE _json_test_interface_${test_name}) - endif() - - # apply test- and standard-specific build settings - if(TARGET _json_test_interface_${test_name}_cpp_${cxx_standard}) - target_link_libraries(${test_target} PRIVATE - _json_test_interface_${test_name}_cpp_${cxx_standard} - ) - endif() - - if (JSON_FastTests) - add_test(NAME ${test_target} - COMMAND ${test_target} ${DOCTEST_TEST_FILTER} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - ) - else() - add_test(NAME ${test_target} - COMMAND ${test_target} ${DOCTEST_TEST_FILTER} --no-skip - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - ) - endif() - set_tests_properties(${test_target} PROPERTIES LABELS "all" FIXTURES_REQUIRED TEST_DATA) - - # apply standard-specific test properties - if(TARGET _json_test_interface__cpp_${cxx_standard}) - _json_test_apply_test_properties(${test_target} _json_test_interface__cpp_${cxx_standard}) - endif() - - # apply test-specific test properties - if(TARGET _json_test_interface_${test_name}) - _json_test_apply_test_properties(${test_target} _json_test_interface_${test_name}) - endif() - - # apply test- and standard-specific test properties - if(TARGET _json_test_interface_${test_name}_cpp_${cxx_standard}) - _json_test_apply_test_properties(${test_target} - _json_test_interface_${test_name}_cpp_${cxx_standard} - ) - endif() - - if(JSON_Valgrind) - add_test(NAME ${test_target}_valgrind - COMMAND ${memcheck_command} $ ${DOCTEST_TEST_FILTER} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - ) - set_tests_properties(${test_target}_valgrind PROPERTIES - LABELS "valgrind" FIXTURES_REQUIRED TEST_DATA - ) - endif() -endfunction() - -############################################################################# -# json_test_add_test_for( -# -# [NAME ] -# MAIN
-# [CXX_STANDARDS ...] [FORCE]) -# -# Given a unit-foo.cpp, produces -# -# test-foo_cpp -# -# if C++ standard is supported by the compiler and the -# source file contains JSON_HAS_CPP_. -# Use NAME to override the filename-derived test name. -# Use FORCE to create the test regardless of the file containing -# JSON_HAS_CPP_. -# Test targets are linked against
. -# CXX_STANDARDS defaults to "11". -############################################################################# - -function(json_test_add_test_for file) - cmake_parse_arguments(args "FORCE" "MAIN;NAME" "CXX_STANDARDS" ${ARGN}) - - if("${args_MAIN}" STREQUAL "") - message(FATAL_ERROR "Required argument MAIN
missing.") - endif() - - if("${args_NAME}" STREQUAL "") - get_filename_component(file_basename ${file} NAME_WE) - string(REGEX REPLACE "unit-([^$]+)" "test-\\1" test_name ${file_basename}) - else() - set(test_name ${args_NAME}) - if(NOT test_name MATCHES "test-[^$]+") - message(FATAL_ERROR "Test name must start with 'test-'.") - endif() - endif() - - if("${args_CXX_STANDARDS}" STREQUAL "") - set(args_CXX_STANDARDS 11) - endif() - - file(READ ${file} file_content) - foreach(cxx_standard ${args_CXX_STANDARDS}) - if(NOT compiler_supports_cpp_${cxx_standard}) - continue() - endif() - - # add unconditionally if C++11 (default) or forced - if(NOT ("${cxx_standard}" STREQUAL 11 OR args_FORCE)) - string(FIND "${file_content}" JSON_HAS_CPP_${cxx_standard} has_cpp_found) - if(${has_cpp_found} EQUAL -1) - continue() - endif() - endif() - - _json_test_add_test(${test_name} ${file} ${args_MAIN} ${cxx_standard}) - endforeach() -endfunction() - -############################################################################# -# json_test_should_build_32bit_test( -# ) -# -# Check if the 32bit unit test should be built based on the value of -# and store the result in the variables and -# . -############################################################################# - -function(json_test_should_build_32bit_test build_32bit_var build_32bit_only_var input) - set(${build_32bit_only_var} OFF PARENT_SCOPE) - string(TOUPPER "${input}" ${build_32bit_var}) - if("${${build_32bit_var}}" STREQUAL AUTO) - # 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) - message(STATUS "Auto-enabling 32bit unit test.") - set(${build_32bit_var} ON) - else() - set(${build_32bit_var} OFF) - endif() - elseif("${${build_32bit_var}}" STREQUAL ONLY) - set(${build_32bit_only_var} ON PARENT_SCOPE) - endif() - - set(${build_32bit_var} "${${build_32bit_var}}" PARENT_SCOPE) -endfunction() diff --git a/docs/Makefile b/docs/Makefile deleted file mode 100644 index 35c30daefb..0000000000 --- a/docs/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -SRCDIR = ../single_include - -all: create_output - -########################################################################## -# example files -########################################################################## - -# where are the example cpp files -EXAMPLES = $(wildcard examples/*.cpp) - -cxx_standard = $(lastword c++11 $(filter c++%, $(subst ., ,$1))) - -# create output from a stand-alone example file -%.output: %.cpp - @echo "standard $(call cxx_standard $(<:.cpp=))" - $(MAKE) $(<:.cpp=) \ - CPPFLAGS="-I $(SRCDIR) -DJSON_USE_GLOBAL_UDLS=0" \ - CXXFLAGS="-std=$(call cxx_standard,$(<:.cpp=)) -Wno-deprecated-declarations" - ./$(<:.cpp=) > $@ - rm $(<:.cpp=) - -# compare created output with current output of the example files -%.test: %.cpp - $(MAKE) $(<:.cpp=) \ - CPPFLAGS="-I $(SRCDIR) -DJSON_USE_GLOBAL_UDLS=0" \ - CXXFLAGS="-std=$(call cxx_standard,$(<:.cpp=)) -Wno-deprecated-declarations" - ./$(<:.cpp=) > $@ - diff $@ $(<:.cpp=.output) - rm $(<:.cpp=) $@ - -# create output from all stand-alone example files -create_output: $(EXAMPLES:.cpp=.output) - -# check output of all stand-alone example files -check_output: $(EXAMPLES:.cpp=.test) - -# check output of all stand-alone example files (exclude files with platform-dependent output.) -# This target is used in the CI (ci_test_documentation). -check_output_portable: $(filter-out examples/meta.test examples/max_size.test examples/std_hash.test examples/basic_json__CompatibleType.test,$(EXAMPLES:.cpp=.test)) - -clean: - rm -fr $(EXAMPLES:.cpp=) - $(MAKE) clean -C docset - $(MAKE) clean -C mkdocs diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index b39d54e055..0000000000 --- a/docs/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# Documentation - -## Generate documentation - -Note on documentation: The source files contain links to the online documentation at https://json.nlohmann.me. This URL -contains the most recent documentation and should also be applicable to previous versions; documentation for deprecated -functions is not removed, but marked deprecated. - -If you want to see the documentation for a specific tag or commit hash, you can generate it as follows (here for tag -`v3.10.2`): - -```shell -git clone https://github.com/nlohmann/json.git -cd json -git checkout v3.10.2 -make install_venv serve -C docs/mkdocs -``` - -Open URL in your browser. Replace from any URL from the source code `https://json.nlohmann.me` -with `http://127.0.0.1:8000` to see the documentation for your tag or commit hash. diff --git a/docs/avatars.png b/docs/avatars.png deleted file mode 100644 index 0a25221872..0000000000 Binary files a/docs/avatars.png and /dev/null differ diff --git a/docs/docset/Info.plist b/docs/docset/Info.plist deleted file mode 100644 index 772ec08afa..0000000000 --- a/docs/docset/Info.plist +++ /dev/null @@ -1,20 +0,0 @@ - - - - - CFBundleIdentifier - nlohmann_json - CFBundleName - JSON for Modern C++ - DocSetPlatformFamily - json - isDashDocset - - dashIndexFilePath - index.html - DashDocSetFallbackURL - https://nlohmann.github.io/json/ - isJavaScriptEnabled - - - diff --git a/docs/docset/Makefile b/docs/docset/Makefile deleted file mode 100644 index eb1cfd38c0..0000000000 --- a/docs/docset/Makefile +++ /dev/null @@ -1,87 +0,0 @@ -SHELL=/usr/bin/env bash -SED ?= $(shell which gsed 2>/dev/null || which sed) - -MKDOCS_PAGES=$(shell cd ../mkdocs/docs/ && find * -type f -name '*.md' | sort) - -.PHONY: all -all: JSON_for_Modern_C++.tgz - -docSet.dsidx: docSet.sql - # generate index - sqlite3 docSet.dsidx > "$$(ls JSON_for_Modern_C++.docset/Contents/Resources/Documents/assets/stylesheets/main.*.min.css)" - # fix spacing - echo -e "\n\ndiv.md-sidebar div.md-sidebar--secondary, div.md-main__inner { top: 0; margin-top: 0 }" >> "$$(ls JSON_for_Modern_C++.docset/Contents/Resources/Documents/assets/stylesheets/main.*.min.css)" - # remove "JSON for Modern C++" from page titles (fallback) - find JSON_for_Modern_C++.docset/Contents/Resources/Documents -type f -exec $(SED) -i 's| - JSON for Modern C++||' {} + - # replace page titles with name from index, if available - for page in $(MKDOCS_PAGES); do \ - case "$$page" in \ - */index.md) path=$${page/\/index.md/} ;; \ - *) path=$${page/.md/} ;; \ - esac; \ - title=$$(sqlite3 docSet.dsidx "SELECT name FROM searchIndex WHERE path='$$path/index.html'" | tr '\n' ',' | $(SED) -e 's/,/, /g' -e 's/, $$/\n/'); \ - if [ "x$$title" != "x" ]; then \ - $(SED) -i "s%.*%$$title%" "JSON_for_Modern_C++.docset/Contents/Resources/Documents/$$path/index.html"; \ - fi \ - done - # clean up - rm JSON_for_Modern_C++.docset/Contents/Resources/Documents/sitemap.* - # copy index - cp docSet.dsidx JSON_for_Modern_C++.docset/Contents/Resources/ - -JSON_for_Modern_C++.tgz: JSON_for_Modern_C++.docset - tar --exclude='.DS_Store' -cvzf JSON_for_Modern_C++.tgz JSON_for_Modern_C++.docset - -# install docset for Zeal documentation browser (https://zealdocs.org/) -.PHONY: install_docset_zeal -install_docset_zeal: JSON_for_Modern_C++.docset - docset_root=$${XDG_DATA_HOME:-$$HOME/.local/share}/Zeal/Zeal/docsets; \ - rm -rf $$docset_root/JSON_for_Modern_C++.docset; \ - mkdir -p $$docset_root; \ - cp -r JSON_for_Modern_C++.docset $$docset_root/ - -# list mkdocs pages missing from the docset index -.PHONY: list_missing_pages -list_missing_pages: docSet.dsidx - @for page in $(MKDOCS_PAGES); do \ - case "$$page" in \ - */index.md) path=$${page/\/index.md/} ;; \ - *) path=$${page/.md/} ;; \ - esac; \ - if [ "x$$page" != "xindex.md" -a "x$$(sqlite3 docSet.dsidx "SELECT COUNT(*) FROM searchIndex WHERE path='$$path/index.html'")" = "x0" ]; then \ - echo $$page; \ - fi \ - done - -# list paths in the docset index without a corresponding mkdocs page -.PHONY: list_removed_paths -list_removed_paths: docSet.dsidx - @for path in $$(sqlite3 docSet.dsidx "SELECT path FROM searchIndex"); do \ - page=$${path/\/index.html/.md}; \ - page_index=$${path/index.html/index.md}; \ - page_found=0; \ - for p in $(MKDOCS_PAGES); do \ - if [ "x$$p" = "x$$page" -o "x$$p" = "x$$page_index" ]; then \ - page_found=1; \ - fi \ - done; \ - if [ "x$$page_found" = "x0" ]; then \ - echo $$path; \ - fi \ - done - -.PHONY: clean -clean: - rm -f docSet.dsidx - rm -fr JSON_for_Modern_C++.docset JSON_for_Modern_C++.tgz diff --git a/docs/docset/README.md b/docs/docset/README.md deleted file mode 100644 index 79a778eb8f..0000000000 --- a/docs/docset/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# docset - -The folder contains the required files to create a [docset](https://kapeli.com/docsets) which can be used in -documentation browsers like [Dash](https://kapeli.com/dash), [Velocity](https://velocity.silverlakesoftware.com), or -[Zeal](https://zealdocs.org). - -The docset can be created with - -```sh -make nlohmann_json.docset -``` - -The generated folder `nlohmann_json.docset` can then be opened in the documentation browser. - -A recent version is also part of the [Dash user contributions](https://github.com/Kapeli/Dash-User-Contributions/tree/master/docsets/JSON_for_Modern_C%2B%2B). - -## Licenses - -The [JSON logo](https://commons.wikimedia.org/wiki/File:JSON_vector_logo.svg) is public domain. diff --git a/docs/docset/docSet.sql b/docs/docset/docSet.sql deleted file mode 100644 index ea6b4f2855..0000000000 --- a/docs/docset/docSet.sql +++ /dev/null @@ -1,234 +0,0 @@ -DROP TABLE IF EXISTS searchIndex; -CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT); -CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path); - --- API -INSERT INTO searchIndex(name, type, path) VALUES ('adl_serializer', 'Class', 'api/adl_serializer/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('adl_serializer::from_json', 'Function', 'api/adl_serializer/from_json/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('adl_serializer::to_json', 'Function', 'api/adl_serializer/to_json/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('byte_container_with_subtype', 'Class', 'api/byte_container_with_subtype/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('byte_container_with_subtype::byte_container_with_subtype', 'Constructor', 'api/byte_container_with_subtype/byte_container_with_subtype/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('byte_container_with_subtype::clear_subtype', 'Method', 'api/byte_container_with_subtype/clear_subtype/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('byte_container_with_subtype::has_subtype', 'Method', 'api/byte_container_with_subtype/has_subtype/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('byte_container_with_subtype::set_subtype', 'Method', 'api/byte_container_with_subtype/set_subtype/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('byte_container_with_subtype::subtype', 'Method', 'api/byte_container_with_subtype/subtype/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json', 'Class', 'api/basic_json/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::accept', 'Function', 'api/basic_json/accept/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::array', 'Function', 'api/basic_json/array/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::array_t', 'Type', 'api/basic_json/array_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::at', 'Method', 'api/basic_json/at/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::back', 'Method', 'api/basic_json/back/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::basic_json', 'Constructor', 'api/basic_json/basic_json/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::begin', 'Method', 'api/basic_json/begin/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::binary', 'Function', 'api/basic_json/binary/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::binary_t', 'Type', 'api/basic_json/binary_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::boolean_t', 'Type', 'api/basic_json/boolean_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::cbegin', 'Method', 'api/basic_json/cbegin/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::cbor_tag_handler_t', 'Enum', 'api/basic_json/cbor_tag_handler_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::cend', 'Method', 'api/basic_json/cend/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::clear', 'Method', 'api/basic_json/clear/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::contains', 'Method', 'api/basic_json/contains/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::count', 'Method', 'api/basic_json/count/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::crbegin', 'Method', 'api/basic_json/crbegin/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::crend', 'Method', 'api/basic_json/crend/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::default_object_comparator_t', 'Type', 'api/basic_json/default_object_comparator_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::diff', 'Function', 'api/basic_json/diff/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::dump', 'Method', 'api/basic_json/dump/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::emplace', 'Method', 'api/basic_json/emplace/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::emplace_back', 'Method', 'api/basic_json/emplace_back/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::empty', 'Method', 'api/basic_json/empty/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::end', 'Method', 'api/basic_json/end/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::erase', 'Method', 'api/basic_json/erase/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::error_handler_t', 'Enum', 'api/basic_json/error_handler_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::exception', 'Class', 'api/basic_json/exception/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::find', 'Method', 'api/basic_json/find/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::flatten', 'Method', 'api/basic_json/flatten/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::from_bjdata', 'Function', 'api/basic_json/from_bjdata/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::from_bson', 'Function', 'api/basic_json/from_bson/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::from_cbor', 'Function', 'api/basic_json/from_cbor/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::from_msgpack', 'Function', 'api/basic_json/from_msgpack/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::from_ubjson', 'Function', 'api/basic_json/from_ubjson/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::front', 'Method', 'api/basic_json/front/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::get', 'Method', 'api/basic_json/get/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::get_allocator', 'Function', 'api/basic_json/get_allocator/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::get_binary', 'Method', 'api/basic_json/get_binary/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::get_ptr', 'Method', 'api/basic_json/get_ptr/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::get_ref', 'Method', 'api/basic_json/get_ref/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::get_to', 'Method', 'api/basic_json/get_to/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::input_format_t', 'Enum', 'api/basic_json/input_format_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::insert', 'Method', 'api/basic_json/insert/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::invalid_iterator', 'Class', 'api/basic_json/invalid_iterator/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_array', 'Method', 'api/basic_json/is_array/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_binary', 'Method', 'api/basic_json/is_binary/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_boolean', 'Method', 'api/basic_json/is_boolean/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_discarded', 'Method', 'api/basic_json/is_discarded/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_null', 'Method', 'api/basic_json/is_null/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_number', 'Method', 'api/basic_json/is_number/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_number_float', 'Method', 'api/basic_json/is_number_float/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_number_integer', 'Method', 'api/basic_json/is_number_integer/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_number_unsigned', 'Method', 'api/basic_json/is_number_unsigned/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_object', 'Method', 'api/basic_json/is_object/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_primitive', 'Method', 'api/basic_json/is_primitive/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_string', 'Method', 'api/basic_json/is_string/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::is_structured', 'Method', 'api/basic_json/is_structured/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::items', 'Method', 'api/basic_json/items/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::json_serializer', 'Class', 'api/basic_json/json_serializer/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::max_size', 'Method', 'api/basic_json/max_size/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::merge_patch', 'Method', 'api/basic_json/merge_patch/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::meta', 'Function', 'api/basic_json/meta/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::number_float_t', 'Type', 'api/basic_json/number_float_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::number_integer_t', 'Type', 'api/basic_json/number_integer_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::number_unsigned_t', 'Type', 'api/basic_json/number_unsigned_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::object', 'Function', 'api/basic_json/object/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::object_comparator_t', 'Type', 'api/basic_json/object_comparator_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::object_t', 'Type', 'api/basic_json/object_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator ValueType', 'Operator', 'api/basic_json/operator_ValueType/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator value_t', 'Operator', 'api/basic_json/operator_value_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator[]', 'Operator', 'api/basic_json/operator[]/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator=', 'Operator', 'api/basic_json/operator=/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator+=', 'Operator', 'api/basic_json/operator+=/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator==', 'Operator', 'api/basic_json/operator_eq/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator!=', 'Operator', 'api/basic_json/operator_ne/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator<', 'Operator', 'api/basic_json/operator_lt/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator<=', 'Operator', 'api/basic_json/operator_le/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator>', 'Operator', 'api/basic_json/operator_gt/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator>=', 'Operator', 'api/basic_json/operator_ge/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::operator<=>', 'Operator', 'api/basic_json/operator_spaceship/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::out_of_range', 'Class', 'api/basic_json/out_of_range/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::other_error', 'Class', 'api/basic_json/other_error/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::parse', 'Function', 'api/basic_json/parse/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::parse_error', 'Class', 'api/basic_json/parse_error/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::parse_event_t', 'Enum', 'api/basic_json/parse_event_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::parser_callback_t', 'Type', 'api/basic_json/parser_callback_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::patch', 'Method', 'api/basic_json/patch/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::patch_inplace', 'Method', 'api/basic_json/patch_inplace/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::push_back', 'Method', 'api/basic_json/push_back/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::rbegin', 'Method', 'api/basic_json/rbegin/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::rend', 'Method', 'api/basic_json/rend/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::sax_parse', 'Function', 'api/basic_json/sax_parse/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::size', 'Method', 'api/basic_json/size/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::string_t', 'Type', 'api/basic_json/string_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::swap', 'Method', 'api/basic_json/swap/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::type', 'Method', 'api/basic_json/type/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::type_error', 'Class', 'api/basic_json/type_error/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::type_name', 'Method', 'api/basic_json/type_name/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::unflatten', 'Method', 'api/basic_json/unflatten/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::update', 'Method', 'api/basic_json/update/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::to_bjdata', 'Function', 'api/basic_json/to_bjdata/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::to_bson', 'Function', 'api/basic_json/to_bson/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::to_cbor', 'Function', 'api/basic_json/to_cbor/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::to_msgpack', 'Function', 'api/basic_json/to_msgpack/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::to_string', 'Method', 'api/basic_json/to_string/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::to_ubjson', 'Function', 'api/basic_json/to_ubjson/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::value', 'Method', 'api/basic_json/value/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::value_t', 'Enum', 'api/basic_json/value_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('basic_json::~basic_json', 'Method', 'api/basic_json/~basic_json/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json', 'Class', 'api/json/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer', 'Class', 'api/json_pointer/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::back', 'Method', 'api/json_pointer/back/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::empty', 'Method', 'api/json_pointer/empty/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::json_pointer', 'Constructor', 'api/json_pointer/json_pointer/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::operator==', 'Operator', 'api/json_pointer/operator_eq/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::operator!=', 'Operator', 'api/json_pointer/operator_ne/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::operator/', 'Operator', 'api/json_pointer/operator_slash/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::operator/=', 'Operator', 'api/json_pointer/operator_slasheq/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::operator string_t', 'Operator', 'api/json_pointer/operator_string_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::parent_pointer', 'Method', 'api/json_pointer/parent_pointer/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::pop_back', 'Method', 'api/json_pointer/pop_back/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::push_back', 'Method', 'api/json_pointer/push_back/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::string_t', 'Type', 'api/json_pointer/string_t/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer::to_string', 'Method', 'api/json_pointer/to_string/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_sax', 'Class', 'api/json_sax/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::binary', 'Method', 'api/json_sax/binary/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::boolean', 'Method', 'api/json_sax/boolean/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::end_array', 'Method', 'api/json_sax/end_array/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::end_object', 'Method', 'api/json_sax/end_object/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::key', 'Method', 'api/json_sax/key/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::null', 'Method', 'api/json_sax/null/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::number_float', 'Method', 'api/json_sax/number_float/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::number_integer', 'Method', 'api/json_sax/number_integer/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::number_unsigned', 'Method', 'api/json_sax/number_unsigned/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::parse_error', 'Method', 'api/json_sax/parse_error/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::start_array', 'Method', 'api/json_sax/start_array/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::start_object', 'Method', 'api/json_sax/start_object/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('json_sax::string', 'Method', 'api/json_sax/string/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('operator""_json', 'Literal', 'api/operator_literal_json/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('operator""_json_pointer', 'Literal', 'api/operator_literal_json_pointer/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('operator<<', 'Operator', 'api/operator_ltlt/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('operator>>', 'Operator', 'api/operator_gtgt/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('ordered_json', 'Class', 'api/ordered_json/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('ordered_map', 'Class', 'api/ordered_map/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('std::hash', 'Class', 'api/basic_json/std_hash/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('std::swap', 'Function', 'api/basic_json/std_swap/index.html'); - --- Features -INSERT INTO searchIndex(name, type, path) VALUES ('Arbitrary Type Conversions', 'Guide', 'features/arbitrary_types/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Binary Formats', 'Guide', 'features/binary_formats/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Binary Formats: BJData', 'Guide', 'features/binary_formats/bjdata/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Binary Formats: BSON', 'Guide', 'features/binary_formats/bson/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Binary Formats: CBOR', 'Guide', 'features/binary_formats/cbor/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Binary Formats: MessagePack', 'Guide', 'features/binary_formats/messagepack/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Binary Formats: UBJSON', 'Guide', 'features/binary_formats/ubjson/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Binary Values', 'Guide', 'features/binary_values/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Comments', 'Guide', 'features/comments/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Element Access', 'Guide', 'features/element_access/index.html'); -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'); -INSERT INTO searchIndex(name, type, path) VALUES ('Integration: Pkg-config', 'Guide', 'integration/pkg-config/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Iterators', 'Guide', 'features/iterators/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON Merge Patch', 'Guide', 'features/merge_patch/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON Patch and Diff', 'Guide', 'features/json_patch/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON Pointer', 'Guide', 'features/json_pointer/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('nlohmann Namespace', 'Guide', 'features/namespace/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Types', 'Guide', 'features/types/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Types: Number Handling', 'Guide', 'features/types/number_handling/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Object Order', 'Guide', 'features/object_order/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Parsing', 'Guide', 'features/parsing/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Parsing: JSON Lines', 'Guide', 'features/parsing/json_lines/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Parsing: Parser Callbacks', 'Guide', 'features/parsing/parser_callbacks/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Parsing: Parsing and Exceptions', 'Guide', 'features/parsing/parse_exceptions/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Parsing: SAX Interface', 'Guide', 'features/parsing/sax_interface/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Runtime Assertions', 'Guide', 'features/assertions/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Specializing enum conversion', 'Guide', 'features/enum_conversion/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Supported Macros', 'Guide', 'features/macros/index.html'); - --- Macros -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_ASSERT', 'Macro', 'api/macros/json_assert/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_CATCH_USER', 'Macro', 'api/macros/json_throw_user/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_DIAGNOSTICS', 'Macro', 'api/macros/json_diagnostics/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_DISABLE_ENUM_SERIALIZATION', 'Macro', 'api/macros/json_disable_enum_serialization/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_HAS_CPP_11', 'Macro', 'api/macros/json_has_cpp_11/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_HAS_CPP_14', 'Macro', 'api/macros/json_has_cpp_11/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_HAS_CPP_17', 'Macro', 'api/macros/json_has_cpp_11/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_HAS_CPP_20', 'Macro', 'api/macros/json_has_cpp_11/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_HAS_EXPERIMENTAL_FILESYSTEM', 'Macro', 'api/macros/json_has_filesystem/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_HAS_FILESYSTEM', 'Macro', 'api/macros/json_has_filesystem/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_HAS_RANGES', 'Macro', 'api/macros/json_has_ranges/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_HAS_THREE_WAY_COMPARISON', 'Macro', 'api/macros/json_has_three_way_comparison/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_NOEXCEPTION', 'Macro', 'api/macros/json_noexception/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_NO_IO', 'Macro', 'api/macros/json_no_io/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_SKIP_LIBRARY_VERSION_CHECK', 'Macro', 'api/macros/json_skip_library_version_check/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_SKIP_UNSUPPORTED_COMPILER_CHECK', 'Macro', 'api/macros/json_skip_unsupported_compiler_check/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_THROW_USER', 'Macro', 'api/macros/json_throw_user/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_TRY_USER', 'Macro', 'api/macros/json_throw_user/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_USE_GLOBAL_UDLS', 'Macro', 'api/macros/json_use_global_udls/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_USE_IMPLICIT_CONVERSIONS', 'Macro', 'api/macros/json_use_implicit_conversions/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON', 'Macro', 'api/macros/json_use_legacy_discarded_value_comparison/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('Macros', 'Macro', 'api/macros/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_DEFINE_TYPE_INTRUSIVE', 'Macro', 'api/macros/nlohmann_define_type_intrusive/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT', 'Macro', 'api/macros/nlohmann_define_type_intrusive/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE', 'Macro', 'api/macros/nlohmann_define_type_non_intrusive/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT', 'Macro', 'api/macros/nlohmann_define_type_non_intrusive/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_NAMESPACE', 'Macro', 'api/macros/nlohmann_json_namespace/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_NAMESPACE_BEGIN', 'Macro', 'api/macros/nlohmann_json_namespace_begin/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_NAMESPACE_END', 'Macro', 'api/macros/nlohmann_json_namespace_begin/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_NAMESPACE_NO_VERSION', 'Macro', 'api/macros/nlohmann_json_namespace_no_version/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_SERIALIZE_ENUM', 'Macro', 'api/macros/nlohmann_json_serialize_enum/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_VERSION_MAJOR', 'Macro', 'api/macros/nlohmann_json_version_major/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_VERSION_MINOR', 'Macro', 'api/macros/nlohmann_json_version_major/index.html'); -INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_VERSION_PATCH', 'Macro', 'api/macros/nlohmann_json_version_major/index.html'); diff --git a/docs/docset/docset.json b/docs/docset/docset.json deleted file mode 100644 index a11ceadfa8..0000000000 --- a/docs/docset/docset.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "JSON for Modern C++", - "version": "3.11.2", - "archive": "JSON_for_Modern_C++.tgz", - "author": { - "name": "Niels Lohmann", - "link": "https://twitter.com/nlohmann" - }, - "aliases": ["nlohmann/json"] -} diff --git a/docs/docset/icon.png b/docs/docset/icon.png deleted file mode 100644 index 7197d0a754..0000000000 Binary files a/docs/docset/icon.png and /dev/null differ diff --git a/docs/docset/icon@2x.png b/docs/docset/icon@2x.png deleted file mode 100644 index 5f2fac87aa..0000000000 Binary files a/docs/docset/icon@2x.png and /dev/null differ diff --git a/docs/examples/README.cpp b/docs/examples/README.cpp deleted file mode 100644 index 2d641e5878..0000000000 --- a/docs/examples/README.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON object - json j = - { - {"pi", 3.141}, - {"happy", true}, - {"name", "Niels"}, - {"nothing", nullptr}, - { - "answer", { - {"everything", 42} - } - }, - {"list", {1, 0, 2}}, - { - "object", { - {"currency", "USD"}, - {"value", 42.99} - } - } - }; - - // add new values - j["new"]["key"]["value"] = {"another", "list"}; - - // count elements - auto s = j.size(); - j["size"] = s; - - // pretty print with indent of 4 spaces - std::cout << std::setw(4) << j << '\n'; -} diff --git a/docs/examples/README.output b/docs/examples/README.output deleted file mode 100644 index 31188d45ef..0000000000 --- a/docs/examples/README.output +++ /dev/null @@ -1,27 +0,0 @@ -{ - "answer": { - "everything": 42 - }, - "happy": true, - "list": [ - 1, - 0, - 2 - ], - "name": "Niels", - "new": { - "key": { - "value": [ - "another", - "list" - ] - } - }, - "nothing": null, - "object": { - "currency": "USD", - "value": 42.99 - }, - "pi": 3.141, - "size": 8 -} diff --git a/docs/examples/accept__string.cpp b/docs/examples/accept__string.cpp deleted file mode 100644 index 8eb3d9b75f..0000000000 --- a/docs/examples/accept__string.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // a valid JSON text - auto valid_text = R"( - { - "numbers": [1, 2, 3] - } - )"; - - // an invalid JSON text - auto invalid_text = R"( - { - "strings": ["extra", "comma", ] - } - )"; - - std::cout << std::boolalpha - << json::accept(valid_text) << ' ' - << json::accept(invalid_text) << '\n'; -} diff --git a/docs/examples/accept__string.output b/docs/examples/accept__string.output deleted file mode 100644 index 836a5934c8..0000000000 --- a/docs/examples/accept__string.output +++ /dev/null @@ -1 +0,0 @@ -true false diff --git a/docs/examples/array.cpp b/docs/examples/array.cpp deleted file mode 100644 index 139b5ef10e..0000000000 --- a/docs/examples/array.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON arrays - json j_no_init_list = json::array(); - json j_empty_init_list = json::array({}); - json j_nonempty_init_list = json::array({1, 2, 3, 4}); - json j_list_of_pairs = json::array({ {"one", 1}, {"two", 2} }); - - // serialize the JSON arrays - std::cout << j_no_init_list << '\n'; - std::cout << j_empty_init_list << '\n'; - std::cout << j_nonempty_init_list << '\n'; - std::cout << j_list_of_pairs << '\n'; -} diff --git a/docs/examples/array.output b/docs/examples/array.output deleted file mode 100644 index 4e75a1b678..0000000000 --- a/docs/examples/array.output +++ /dev/null @@ -1,4 +0,0 @@ -[] -[] -[1,2,3,4] -[["one",1],["two",2]] diff --git a/docs/examples/array_t.cpp b/docs/examples/array_t.cpp deleted file mode 100644 index 0964857b70..0000000000 --- a/docs/examples/array_t.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - std::cout << std::boolalpha << std::is_same, json::array_t>::value << std::endl; -} diff --git a/docs/examples/array_t.output b/docs/examples/array_t.output deleted file mode 100644 index 27ba77ddaf..0000000000 --- a/docs/examples/array_t.output +++ /dev/null @@ -1 +0,0 @@ -true diff --git a/docs/examples/at__json_pointer.cpp b/docs/examples/at__json_pointer.cpp deleted file mode 100644 index 26dfd8edda..0000000000 --- a/docs/examples/at__json_pointer.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -int main() -{ - // create a JSON value - json j = - { - {"number", 1}, {"string", "foo"}, {"array", {1, 2}} - }; - - // read-only access - - // output element with JSON pointer "/number" - std::cout << j.at("/number"_json_pointer) << '\n'; - // output element with JSON pointer "/string" - std::cout << j.at("/string"_json_pointer) << '\n'; - // output element with JSON pointer "/array" - std::cout << j.at("/array"_json_pointer) << '\n'; - // output element with JSON pointer "/array/1" - std::cout << j.at("/array/1"_json_pointer) << '\n'; - - // writing access - - // change the string - j.at("/string"_json_pointer) = "bar"; - // output the changed string - std::cout << j["string"] << '\n'; - - // change an array element - j.at("/array/1"_json_pointer) = 21; - // output the changed array - std::cout << j["array"] << '\n'; - - - // out_of_range.106 - try - { - // try to use an array index with leading '0' - json::reference ref = j.at("/array/01"_json_pointer); - } - catch (json::parse_error& e) - { - std::cout << e.what() << '\n'; - } - - // out_of_range.109 - try - { - // try to use an array index that is not a number - json::reference ref = j.at("/array/one"_json_pointer); - } - catch (json::parse_error& e) - { - std::cout << e.what() << '\n'; - } - - // out_of_range.401 - try - { - // try to use an invalid array index - json::reference ref = j.at("/array/4"_json_pointer); - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } - - // out_of_range.402 - try - { - // try to use the array index '-' - json::reference ref = j.at("/array/-"_json_pointer); - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } - - // out_of_range.403 - try - { - // try to use a JSON pointer to a nonexistent object key - json::const_reference ref = j.at("/foo"_json_pointer); - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } - - // out_of_range.404 - try - { - // try to use a JSON pointer that cannot be resolved - json::reference ref = j.at("/number/foo"_json_pointer); - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } -} diff --git a/docs/examples/at__json_pointer.output b/docs/examples/at__json_pointer.output deleted file mode 100644 index 1d29893e49..0000000000 --- a/docs/examples/at__json_pointer.output +++ /dev/null @@ -1,12 +0,0 @@ -1 -"foo" -[1,2] -2 -"bar" -[1,21] -[json.exception.parse_error.106] parse error: array index '01' must not begin with '0' -[json.exception.parse_error.109] parse error: array index 'one' is not a number -[json.exception.out_of_range.401] array index 4 is out of range -[json.exception.out_of_range.402] array index '-' (2) is out of range -[json.exception.out_of_range.403] key 'foo' not found -[json.exception.out_of_range.404] unresolved reference token 'foo' diff --git a/docs/examples/at__json_pointer_const.cpp b/docs/examples/at__json_pointer_const.cpp deleted file mode 100644 index f049bd8d9e..0000000000 --- a/docs/examples/at__json_pointer_const.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -int main() -{ - // create a JSON value - const json j = - { - {"number", 1}, {"string", "foo"}, {"array", {1, 2}} - }; - - // read-only access - - // output element with JSON pointer "/number" - std::cout << j.at("/number"_json_pointer) << '\n'; - // output element with JSON pointer "/string" - std::cout << j.at("/string"_json_pointer) << '\n'; - // output element with JSON pointer "/array" - std::cout << j.at("/array"_json_pointer) << '\n'; - // output element with JSON pointer "/array/1" - std::cout << j.at("/array/1"_json_pointer) << '\n'; - - // out_of_range.109 - try - { - // try to use an array index that is not a number - json::const_reference ref = j.at("/array/one"_json_pointer); - } - catch (json::parse_error& e) - { - std::cout << e.what() << '\n'; - } - - // out_of_range.401 - try - { - // try to use an invalid array index - json::const_reference ref = j.at("/array/4"_json_pointer); - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } - - // out_of_range.402 - try - { - // try to use the array index '-' - json::const_reference ref = j.at("/array/-"_json_pointer); - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } - - // out_of_range.403 - try - { - // try to use a JSON pointer to a nonexistent object key - json::const_reference ref = j.at("/foo"_json_pointer); - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } - - // out_of_range.404 - try - { - // try to use a JSON pointer that cannot be resolved - json::const_reference ref = j.at("/number/foo"_json_pointer); - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } -} diff --git a/docs/examples/at__json_pointer_const.output b/docs/examples/at__json_pointer_const.output deleted file mode 100644 index aaf8f18712..0000000000 --- a/docs/examples/at__json_pointer_const.output +++ /dev/null @@ -1,9 +0,0 @@ -1 -"foo" -[1,2] -2 -[json.exception.parse_error.109] parse error: array index 'one' is not a number -[json.exception.out_of_range.401] array index 4 is out of range -[json.exception.out_of_range.402] array index '-' (2) is out of range -[json.exception.out_of_range.403] key 'foo' not found -[json.exception.out_of_range.404] unresolved reference token 'foo' diff --git a/docs/examples/at__keytype.c++17.cpp b/docs/examples/at__keytype.c++17.cpp deleted file mode 100644 index 3491cb9f77..0000000000 --- a/docs/examples/at__keytype.c++17.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include -#include - -using namespace std::string_view_literals; -using json = nlohmann::json; - -int main() -{ - // create JSON object - json object = - { - {"the good", "il buono"}, - {"the bad", "il cattivo"}, - {"the ugly", "il brutto"} - }; - - // output element with key "the ugly" using string_view - std::cout << object.at("the ugly"sv) << '\n'; - - // change element with key "the bad" using string_view - object.at("the bad"sv) = "il cattivo"; - - // output changed array - std::cout << object << '\n'; - - - // exception type_error.304 - try - { - // use at() with string_view on a non-object type - json str = "I am a string"; - str.at("the good"sv) = "Another string"; - } - catch (json::type_error& e) - { - std::cout << e.what() << '\n'; - } - - // exception out_of_range.401 - try - { - // try to write at a nonexisting key using string_view - object.at("the fast"sv) = "il rapido"; - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } -} diff --git a/docs/examples/at__keytype.c++17.output b/docs/examples/at__keytype.c++17.output deleted file mode 100644 index b544b7299c..0000000000 --- a/docs/examples/at__keytype.c++17.output +++ /dev/null @@ -1,4 +0,0 @@ -"il brutto" -{"the bad":"il cattivo","the good":"il buono","the ugly":"il brutto"} -[json.exception.type_error.304] cannot use at() with string -[json.exception.out_of_range.403] key 'the fast' not found diff --git a/docs/examples/at__keytype_const.c++17.cpp b/docs/examples/at__keytype_const.c++17.cpp deleted file mode 100644 index ec93c70590..0000000000 --- a/docs/examples/at__keytype_const.c++17.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -#include - -using namespace std::string_view_literals; -using json = nlohmann::json; - -int main() -{ - // create JSON object - const json object = - { - {"the good", "il buono"}, - {"the bad", "il cattivo"}, - {"the ugly", "il brutto"} - }; - - // output element with key "the ugly" using string_view - std::cout << object.at("the ugly"sv) << '\n'; - - - // exception type_error.304 - try - { - // use at() with string_view on a non-object type - const json str = "I am a string"; - std::cout << str.at("the good"sv) << '\n'; - } - catch (json::type_error& e) - { - std::cout << e.what() << '\n'; - } - - // exception out_of_range.401 - try - { - // try to read from a nonexisting key using string_view - std::cout << object.at("the fast"sv) << '\n'; - } - catch (json::out_of_range) - { - std::cout << "out of range" << '\n'; - } -} diff --git a/docs/examples/at__keytype_const.c++17.output b/docs/examples/at__keytype_const.c++17.output deleted file mode 100644 index 40ca3f09f3..0000000000 --- a/docs/examples/at__keytype_const.c++17.output +++ /dev/null @@ -1,3 +0,0 @@ -"il brutto" -[json.exception.type_error.304] cannot use at() with string -out of range diff --git a/docs/examples/at__object_t_key_type.cpp b/docs/examples/at__object_t_key_type.cpp deleted file mode 100644 index 202f8a2eed..0000000000 --- a/docs/examples/at__object_t_key_type.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON object - json object = - { - {"the good", "il buono"}, - {"the bad", "il cattivo"}, - {"the ugly", "il brutto"} - }; - - // output element with key "the ugly" - std::cout << object.at("the ugly") << '\n'; - - // change element with key "the bad" - object.at("the bad") = "il cattivo"; - - // output changed array - std::cout << object << '\n'; - - - // exception type_error.304 - try - { - // use at() on a non-object type - json str = "I am a string"; - str.at("the good") = "Another string"; - } - catch (json::type_error& e) - { - std::cout << e.what() << '\n'; - } - - // exception out_of_range.401 - try - { - // try to write at a nonexisting key - object.at("the fast") = "il rapido"; - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } -} diff --git a/docs/examples/at__object_t_key_type.output b/docs/examples/at__object_t_key_type.output deleted file mode 100644 index b544b7299c..0000000000 --- a/docs/examples/at__object_t_key_type.output +++ /dev/null @@ -1,4 +0,0 @@ -"il brutto" -{"the bad":"il cattivo","the good":"il buono","the ugly":"il brutto"} -[json.exception.type_error.304] cannot use at() with string -[json.exception.out_of_range.403] key 'the fast' not found diff --git a/docs/examples/at__object_t_key_type_const.cpp b/docs/examples/at__object_t_key_type_const.cpp deleted file mode 100644 index e5244f3f7f..0000000000 --- a/docs/examples/at__object_t_key_type_const.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON object - const json object = - { - {"the good", "il buono"}, - {"the bad", "il cattivo"}, - {"the ugly", "il brutto"} - }; - - // output element with key "the ugly" - std::cout << object.at("the ugly") << '\n'; - - - // exception type_error.304 - try - { - // use at() on a non-object type - const json str = "I am a string"; - std::cout << str.at("the good") << '\n'; - } - catch (json::type_error& e) - { - std::cout << e.what() << '\n'; - } - - // exception out_of_range.401 - try - { - // try to read from a nonexisting key - std::cout << object.at("the fast") << '\n'; - } - catch (json::out_of_range) - { - std::cout << "out of range" << '\n'; - } -} diff --git a/docs/examples/at__object_t_key_type_const.output b/docs/examples/at__object_t_key_type_const.output deleted file mode 100644 index 40ca3f09f3..0000000000 --- a/docs/examples/at__object_t_key_type_const.output +++ /dev/null @@ -1,3 +0,0 @@ -"il brutto" -[json.exception.type_error.304] cannot use at() with string -out of range diff --git a/docs/examples/at__size_type.cpp b/docs/examples/at__size_type.cpp deleted file mode 100644 index 65baeddcf4..0000000000 --- a/docs/examples/at__size_type.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON array - json array = {"first", "2nd", "third", "fourth"}; - - // output element at index 2 (third element) - std::cout << array.at(2) << '\n'; - - // change element at index 1 (second element) to "second" - array.at(1) = "second"; - - // output changed array - std::cout << array << '\n'; - - - // exception type_error.304 - try - { - // use at() on a non-array type - json str = "I am a string"; - str.at(0) = "Another string"; - } - catch (json::type_error& e) - { - std::cout << e.what() << '\n'; - } - - // exception out_of_range.401 - try - { - // try to write beyond the array limit - array.at(5) = "sixth"; - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } -} diff --git a/docs/examples/at__size_type.output b/docs/examples/at__size_type.output deleted file mode 100644 index 54026436f5..0000000000 --- a/docs/examples/at__size_type.output +++ /dev/null @@ -1,4 +0,0 @@ -"third" -["first","second","third","fourth"] -[json.exception.type_error.304] cannot use at() with string -[json.exception.out_of_range.401] array index 5 is out of range diff --git a/docs/examples/at__size_type_const.cpp b/docs/examples/at__size_type_const.cpp deleted file mode 100644 index faa4cffdd1..0000000000 --- a/docs/examples/at__size_type_const.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON array - const json array = {"first", "2nd", "third", "fourth"}; - - // output element at index 2 (third element) - std::cout << array.at(2) << '\n'; - - - // exception type_error.304 - try - { - // use at() on a non-array type - const json str = "I am a string"; - std::cout << str.at(0) << '\n'; - } - catch (json::type_error& e) - { - std::cout << e.what() << '\n'; - } - - // exception out_of_range.401 - try - { - // try to read beyond the array limit - std::cout << array.at(5) << '\n'; - } - catch (json::out_of_range& e) - { - std::cout << e.what() << '\n'; - } -} diff --git a/docs/examples/at__size_type_const.output b/docs/examples/at__size_type_const.output deleted file mode 100644 index 8135a27a50..0000000000 --- a/docs/examples/at__size_type_const.output +++ /dev/null @@ -1,3 +0,0 @@ -"third" -[json.exception.type_error.304] cannot use at() with string -[json.exception.out_of_range.401] array index 5 is out of range diff --git a/docs/examples/back.cpp b/docs/examples/back.cpp deleted file mode 100644 index 1439a8218c..0000000000 --- a/docs/examples/back.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_boolean = true; - json j_number_integer = 17; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_object_empty(json::value_t::object); - json j_array = {1, 2, 4, 8, 16}; - json j_array_empty(json::value_t::array); - json j_string = "Hello, world"; - - // call back() - std::cout << j_boolean.back() << '\n'; - std::cout << j_number_integer.back() << '\n'; - std::cout << j_number_float.back() << '\n'; - std::cout << j_object.back() << '\n'; - //std::cout << j_object_empty.back() << '\n'; // undefined behavior - std::cout << j_array.back() << '\n'; - //std::cout << j_array_empty.back() << '\n'; // undefined behavior - std::cout << j_string.back() << '\n'; - - // back() called on a null value - try - { - json j_null; - j_null.back(); - } - catch (json::invalid_iterator& e) - { - std::cout << e.what() << '\n'; - } -} diff --git a/docs/examples/back.output b/docs/examples/back.output deleted file mode 100644 index 2990dbf0e8..0000000000 --- a/docs/examples/back.output +++ /dev/null @@ -1,7 +0,0 @@ -true -17 -23.42 -2 -16 -"Hello, world" -[json.exception.invalid_iterator.214] cannot get value diff --git a/docs/examples/basic_json__CompatibleType.cpp b/docs/examples/basic_json__CompatibleType.cpp deleted file mode 100644 index e2f01aa63f..0000000000 --- a/docs/examples/basic_json__CompatibleType.cpp +++ /dev/null @@ -1,218 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // ============ - // object types - // ============ - - // create an object from an object_t value - json::object_t object_value = { {"one", 1}, {"two", 2} }; - json j_object_t(object_value); - - // create an object from std::map - std::map c_map - { - {"one", 1}, {"two", 2}, {"three", 3} - }; - json j_map(c_map); - - // create an object from std::unordered_map - std::unordered_map c_umap - { - {"one", 1.2}, {"two", 2.3}, {"three", 3.4} - }; - json j_umap(c_umap); - - // create an object from std::multimap - std::multimap c_mmap - { - {"one", true}, {"two", true}, {"three", false}, {"three", true} - }; - json j_mmap(c_mmap); // only one entry for key "three" is used - - // create an object from std::unordered_multimap - std::unordered_multimap c_ummap - { - {"one", true}, {"two", true}, {"three", false}, {"three", true} - }; - json j_ummap(c_ummap); // only one entry for key "three" is used - - // serialize the JSON objects - std::cout << j_object_t << '\n'; - std::cout << j_map << '\n'; - std::cout << j_umap << '\n'; - std::cout << j_mmap << '\n'; - std::cout << j_ummap << "\n\n"; - - - // =========== - // array types - // =========== - - // create an array from an array_t value - json::array_t array_value = {"one", "two", 3, 4.5, false}; - json j_array_t(array_value); - - // create an array from std::vector - std::vector c_vector {1, 2, 3, 4}; - json j_vec(c_vector); - - // create an array from std::valarray - std::valarray c_valarray {10, 9, 8, 7}; - json j_valarray(c_valarray); - - // create an array from std::deque - std::deque c_deque {1.2, 2.3, 3.4, 5.6}; - json j_deque(c_deque); - - // create an array from std::list - std::list c_list {true, true, false, true}; - json j_list(c_list); - - // create an array from std::forward_list - std::forward_list c_flist {12345678909876, 23456789098765, 34567890987654, 45678909876543}; - json j_flist(c_flist); - - // create an array from std::array - std::array c_array {{1, 2, 3, 4}}; - json j_array(c_array); - - // create an array from std::set - std::set c_set {"one", "two", "three", "four", "one"}; - json j_set(c_set); // only one entry for "one" is used - - // create an array from std::unordered_set - std::unordered_set c_uset {"one", "two", "three", "four", "one"}; - json j_uset(c_uset); // only one entry for "one" is used - - // create an array from std::multiset - std::multiset c_mset {"one", "two", "one", "four"}; - json j_mset(c_mset); // both entries for "one" are used - - // create an array from std::unordered_multiset - std::unordered_multiset c_umset {"one", "two", "one", "four"}; - json j_umset(c_umset); // both entries for "one" are used - - // serialize the JSON arrays - std::cout << j_array_t << '\n'; - std::cout << j_vec << '\n'; - std::cout << j_valarray << '\n'; - std::cout << j_deque << '\n'; - std::cout << j_list << '\n'; - std::cout << j_flist << '\n'; - std::cout << j_array << '\n'; - std::cout << j_set << '\n'; - std::cout << j_uset << '\n'; - std::cout << j_mset << '\n'; - std::cout << j_umset << "\n\n"; - - - // ============ - // string types - // ============ - - // create string from a string_t value - json::string_t string_value = "The quick brown fox jumps over the lazy dog."; - json j_string_t(string_value); - - // create a JSON string directly from a string literal - json j_string_literal("The quick brown fox jumps over the lazy dog."); - - // create string from std::string - std::string s_stdstring = "The quick brown fox jumps over the lazy dog."; - json j_stdstring(s_stdstring); - - // serialize the JSON strings - std::cout << j_string_t << '\n'; - std::cout << j_string_literal << '\n'; - std::cout << j_stdstring << "\n\n"; - - - // ============ - // number types - // ============ - - // create a JSON number from number_integer_t - json::number_integer_t value_integer_t = -42; - json j_integer_t(value_integer_t); - - // create a JSON number from number_unsigned_t - json::number_integer_t value_unsigned_t = 17; - json j_unsigned_t(value_unsigned_t); - - // create a JSON number from an anonymous enum - enum { enum_value = 17 }; - json j_enum(enum_value); - - // create values of different integer types - short n_short = 42; - int n_int = -23; - long n_long = 1024; - int_least32_t n_int_least32_t = -17; - uint8_t n_uint8_t = 8; - - // create (integer) JSON numbers - json j_short(n_short); - json j_int(n_int); - json j_long(n_long); - json j_int_least32_t(n_int_least32_t); - json j_uint8_t(n_uint8_t); - - // create values of different floating-point types - json::number_float_t v_ok = 3.141592653589793; - json::number_float_t v_nan = NAN; - json::number_float_t v_infinity = INFINITY; - - // create values of different floating-point types - float n_float = 42.23; - float n_float_nan = 1.0f / 0.0f; - double n_double = 23.42; - - // create (floating point) JSON numbers - json j_ok(v_ok); - json j_nan(v_nan); - json j_infinity(v_infinity); - json j_float(n_float); - json j_float_nan(n_float_nan); - json j_double(n_double); - - // serialize the JSON numbers - std::cout << j_integer_t << '\n'; - std::cout << j_unsigned_t << '\n'; - std::cout << j_enum << '\n'; - std::cout << j_short << '\n'; - std::cout << j_int << '\n'; - std::cout << j_long << '\n'; - std::cout << j_int_least32_t << '\n'; - std::cout << j_uint8_t << '\n'; - std::cout << j_ok << '\n'; - std::cout << j_nan << '\n'; - std::cout << j_infinity << '\n'; - std::cout << j_float << '\n'; - std::cout << j_float_nan << '\n'; - std::cout << j_double << "\n\n"; - - - // ============= - // boolean types - // ============= - - // create boolean values - json j_truth = true; - json j_falsity = false; - - // serialize the JSON booleans - std::cout << j_truth << '\n'; - std::cout << j_falsity << '\n'; -} diff --git a/docs/examples/basic_json__CompatibleType.output b/docs/examples/basic_json__CompatibleType.output deleted file mode 100644 index 2337e81fb0..0000000000 --- a/docs/examples/basic_json__CompatibleType.output +++ /dev/null @@ -1,39 +0,0 @@ -{"one":1,"two":2} -{"one":1,"three":3,"two":2} -{"one":1.2,"three":3.4,"two":2.3} -{"one":true,"three":false,"two":true} -{"one":true,"three":false,"two":true} - -["one","two",3,4.5,false] -[1,2,3,4] -[10,9,8,7] -[1.2,2.3,3.4,5.6] -[true,true,false,true] -[12345678909876,23456789098765,34567890987654,45678909876543] -[1,2,3,4] -["four","one","three","two"] -["four","three","two","one"] -["four","one","one","two"] -["four","two","one","one"] - -"The quick brown fox jumps over the lazy dog." -"The quick brown fox jumps over the lazy dog." -"The quick brown fox jumps over the lazy dog." - --42 -17 -17 -42 --23 -1024 --17 -8 -3.141592653589793 -null -null -42.22999954223633 -null -23.42 - -true -false diff --git a/docs/examples/basic_json__InputIt_InputIt.cpp b/docs/examples/basic_json__InputIt_InputIt.cpp deleted file mode 100644 index ed5aff9a83..0000000000 --- a/docs/examples/basic_json__InputIt_InputIt.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_array = {"alpha", "bravo", "charly", "delta", "easy"}; - json j_number = 42; - json j_object = {{"one", "eins"}, {"two", "zwei"}}; - - // create copies using iterators - json j_array_range(j_array.begin() + 1, j_array.end() - 2); - json j_number_range(j_number.begin(), j_number.end()); - json j_object_range(j_object.begin(), j_object.find("two")); - - // serialize the values - std::cout << j_array_range << '\n'; - std::cout << j_number_range << '\n'; - std::cout << j_object_range << '\n'; - - // example for an exception - try - { - json j_invalid(j_number.begin() + 1, j_number.end()); - } - catch (json::invalid_iterator& e) - { - std::cout << e.what() << '\n'; - } -} diff --git a/docs/examples/basic_json__InputIt_InputIt.output b/docs/examples/basic_json__InputIt_InputIt.output deleted file mode 100644 index bfb017785e..0000000000 --- a/docs/examples/basic_json__InputIt_InputIt.output +++ /dev/null @@ -1,4 +0,0 @@ -["bravo","charly"] -42 -{"one":"eins"} -[json.exception.invalid_iterator.204] iterators out of range diff --git a/docs/examples/basic_json__basic_json.cpp b/docs/examples/basic_json__basic_json.cpp deleted file mode 100644 index 17136f4377..0000000000 --- a/docs/examples/basic_json__basic_json.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON array - json j1 = {"one", "two", 3, 4.5, false}; - - // create a copy - json j2(j1); - - // serialize the JSON array - std::cout << j1 << " = " << j2 << '\n'; - std::cout << std::boolalpha << (j1 == j2) << '\n'; -} diff --git a/docs/examples/basic_json__basic_json.output b/docs/examples/basic_json__basic_json.output deleted file mode 100644 index ee93a41ca8..0000000000 --- a/docs/examples/basic_json__basic_json.output +++ /dev/null @@ -1,2 +0,0 @@ -["one","two",3,4.5,false] = ["one","two",3,4.5,false] -true diff --git a/docs/examples/basic_json__copyassignment.cpp b/docs/examples/basic_json__copyassignment.cpp deleted file mode 100644 index 2d86574000..0000000000 --- a/docs/examples/basic_json__copyassignment.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json a = 23; - json b = 42; - - // copy-assign a to b - b = a; - - // serialize the JSON arrays - std::cout << a << '\n'; - std::cout << b << '\n'; -} diff --git a/docs/examples/basic_json__copyassignment.output b/docs/examples/basic_json__copyassignment.output deleted file mode 100644 index c1eee21050..0000000000 --- a/docs/examples/basic_json__copyassignment.output +++ /dev/null @@ -1,2 +0,0 @@ -23 -23 diff --git a/docs/examples/basic_json__list_init_t.cpp b/docs/examples/basic_json__list_init_t.cpp deleted file mode 100644 index 78611e1a3e..0000000000 --- a/docs/examples/basic_json__list_init_t.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_empty_init_list = json({}); - json j_object = { {"one", 1}, {"two", 2} }; - json j_array = {1, 2, 3, 4}; - json j_nested_object = { {"one", {1}}, {"two", {1, 2}} }; - json j_nested_array = { {{1}, "one"}, {{1, 2}, "two"} }; - - // serialize the JSON value - std::cout << j_empty_init_list << '\n'; - std::cout << j_object << '\n'; - std::cout << j_array << '\n'; - std::cout << j_nested_object << '\n'; - std::cout << j_nested_array << '\n'; -} diff --git a/docs/examples/basic_json__list_init_t.output b/docs/examples/basic_json__list_init_t.output deleted file mode 100644 index d38f5b842c..0000000000 --- a/docs/examples/basic_json__list_init_t.output +++ /dev/null @@ -1,5 +0,0 @@ -{} -{"one":1,"two":2} -[1,2,3,4] -{"one":[1],"two":[1,2]} -[[[1],"one"],[[1,2],"two"]] diff --git a/docs/examples/basic_json__moveconstructor.cpp b/docs/examples/basic_json__moveconstructor.cpp deleted file mode 100644 index 48b68f61ed..0000000000 --- a/docs/examples/basic_json__moveconstructor.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON value - json a = 23; - - // move contents of a to b - json b(std::move(a)); - - // serialize the JSON arrays - std::cout << a << '\n'; - std::cout << b << '\n'; -} diff --git a/docs/examples/basic_json__moveconstructor.output b/docs/examples/basic_json__moveconstructor.output deleted file mode 100644 index 911b5b1ac2..0000000000 --- a/docs/examples/basic_json__moveconstructor.output +++ /dev/null @@ -1,2 +0,0 @@ -null -23 diff --git a/docs/examples/basic_json__nullptr_t.cpp b/docs/examples/basic_json__nullptr_t.cpp deleted file mode 100644 index 7a4366650a..0000000000 --- a/docs/examples/basic_json__nullptr_t.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // implicitly create a JSON null value - json j1; - - // explicitly create a JSON null value - json j2(nullptr); - - // serialize the JSON null value - std::cout << j1 << '\n' << j2 << '\n'; -} diff --git a/docs/examples/basic_json__nullptr_t.output b/docs/examples/basic_json__nullptr_t.output deleted file mode 100644 index c1e4b6c175..0000000000 --- a/docs/examples/basic_json__nullptr_t.output +++ /dev/null @@ -1,2 +0,0 @@ -null -null diff --git a/docs/examples/basic_json__size_type_basic_json.cpp b/docs/examples/basic_json__size_type_basic_json.cpp deleted file mode 100644 index 9ec7677273..0000000000 --- a/docs/examples/basic_json__size_type_basic_json.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create an array by creating copies of a JSON value - json value = "Hello"; - json array_0 = json(0, value); - json array_1 = json(1, value); - json array_5 = json(5, value); - - // serialize the JSON arrays - std::cout << array_0 << '\n'; - std::cout << array_1 << '\n'; - std::cout << array_5 << '\n'; -} diff --git a/docs/examples/basic_json__size_type_basic_json.output b/docs/examples/basic_json__size_type_basic_json.output deleted file mode 100644 index f4c59b3485..0000000000 --- a/docs/examples/basic_json__size_type_basic_json.output +++ /dev/null @@ -1,3 +0,0 @@ -[] -["Hello"] -["Hello","Hello","Hello","Hello","Hello"] diff --git a/docs/examples/basic_json__value_t.cpp b/docs/examples/basic_json__value_t.cpp deleted file mode 100644 index c306731ac2..0000000000 --- a/docs/examples/basic_json__value_t.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create the different JSON values with default values - json j_null(json::value_t::null); - json j_boolean(json::value_t::boolean); - json j_number_integer(json::value_t::number_integer); - json j_number_float(json::value_t::number_float); - json j_object(json::value_t::object); - json j_array(json::value_t::array); - json j_string(json::value_t::string); - - // serialize the JSON values - std::cout << j_null << '\n'; - std::cout << j_boolean << '\n'; - std::cout << j_number_integer << '\n'; - std::cout << j_number_float << '\n'; - std::cout << j_object << '\n'; - std::cout << j_array << '\n'; - std::cout << j_string << '\n'; -} diff --git a/docs/examples/basic_json__value_t.output b/docs/examples/basic_json__value_t.output deleted file mode 100644 index ea542caebb..0000000000 --- a/docs/examples/basic_json__value_t.output +++ /dev/null @@ -1,7 +0,0 @@ -null -false -0 -0.0 -{} -[] -"" diff --git a/docs/examples/begin.cpp b/docs/examples/begin.cpp deleted file mode 100644 index 654835b025..0000000000 --- a/docs/examples/begin.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create an array value - json array = {1, 2, 3, 4, 5}; - - // get an iterator to the first element - json::iterator it = array.begin(); - - // serialize the element that the iterator points to - std::cout << *it << '\n'; -} diff --git a/docs/examples/begin.output b/docs/examples/begin.output deleted file mode 100644 index d00491fd7e..0000000000 --- a/docs/examples/begin.output +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/docs/examples/binary.cpp b/docs/examples/binary.cpp deleted file mode 100644 index 617ce60960..0000000000 --- a/docs/examples/binary.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a binary vector - std::vector vec = {0xCA, 0xFE, 0xBA, 0xBE}; - - // create a binary JSON value with subtype 42 - json j = json::binary(vec, 42); - - // output type and subtype - std::cout << "type: " << j.type_name() << ", subtype: " << j.get_binary().subtype() << std::endl; -} diff --git a/docs/examples/binary.output b/docs/examples/binary.output deleted file mode 100644 index 74b05d23fe..0000000000 --- a/docs/examples/binary.output +++ /dev/null @@ -1 +0,0 @@ -type: binary, subtype: 42 diff --git a/docs/examples/binary_t.cpp b/docs/examples/binary_t.cpp deleted file mode 100644 index bfaee5ca86..0000000000 --- a/docs/examples/binary_t.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - std::cout << std::boolalpha << std::is_same>, json::binary_t>::value << std::endl; -} diff --git a/docs/examples/binary_t.output b/docs/examples/binary_t.output deleted file mode 100644 index 27ba77ddaf..0000000000 --- a/docs/examples/binary_t.output +++ /dev/null @@ -1 +0,0 @@ -true diff --git a/docs/examples/boolean_t.cpp b/docs/examples/boolean_t.cpp deleted file mode 100644 index 75b8c99f91..0000000000 --- a/docs/examples/boolean_t.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - std::cout << std::boolalpha << std::is_same::value << std::endl; -} diff --git a/docs/examples/boolean_t.output b/docs/examples/boolean_t.output deleted file mode 100644 index 27ba77ddaf..0000000000 --- a/docs/examples/boolean_t.output +++ /dev/null @@ -1 +0,0 @@ -true diff --git a/docs/examples/byte_container_with_subtype__byte_container_with_subtype.cpp b/docs/examples/byte_container_with_subtype__byte_container_with_subtype.cpp deleted file mode 100644 index 1c10be5c26..0000000000 --- a/docs/examples/byte_container_with_subtype__byte_container_with_subtype.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -// define a byte container based on std::vector -using byte_container_with_subtype = nlohmann::byte_container_with_subtype>; - -using json = nlohmann::json; - -int main() -{ - // (1) create empty container - auto c1 = byte_container_with_subtype(); - - std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}}; - - // (2) create container - auto c2 = byte_container_with_subtype(bytes); - - // (3) create container with subtype - auto c3 = byte_container_with_subtype(bytes, 42); - - std::cout << json(c1) << "\n" << json(c2) << "\n" << json(c3) << std::endl; -} diff --git a/docs/examples/byte_container_with_subtype__byte_container_with_subtype.output b/docs/examples/byte_container_with_subtype__byte_container_with_subtype.output deleted file mode 100644 index 67ac1b2ef1..0000000000 --- a/docs/examples/byte_container_with_subtype__byte_container_with_subtype.output +++ /dev/null @@ -1,3 +0,0 @@ -{"bytes":[],"subtype":null} -{"bytes":[202,254,186,190],"subtype":null} -{"bytes":[202,254,186,190],"subtype":42} diff --git a/docs/examples/byte_container_with_subtype__clear_subtype.cpp b/docs/examples/byte_container_with_subtype__clear_subtype.cpp deleted file mode 100644 index f9ce6842bb..0000000000 --- a/docs/examples/byte_container_with_subtype__clear_subtype.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -// define a byte container based on std::vector -using byte_container_with_subtype = nlohmann::byte_container_with_subtype>; - -using json = nlohmann::json; - -int main() -{ - std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}}; - - // create container with subtype - auto c1 = byte_container_with_subtype(bytes, 42); - - std::cout << "before calling clear_subtype(): " << json(c1) << '\n'; - - c1.clear_subtype(); - - std::cout << "after calling clear_subtype(): " << json(c1) << '\n'; -} diff --git a/docs/examples/byte_container_with_subtype__clear_subtype.output b/docs/examples/byte_container_with_subtype__clear_subtype.output deleted file mode 100644 index 9d8212946d..0000000000 --- a/docs/examples/byte_container_with_subtype__clear_subtype.output +++ /dev/null @@ -1,2 +0,0 @@ -before calling clear_subtype(): {"bytes":[202,254,186,190],"subtype":42} -after calling clear_subtype(): {"bytes":[202,254,186,190],"subtype":null} diff --git a/docs/examples/byte_container_with_subtype__has_subtype.cpp b/docs/examples/byte_container_with_subtype__has_subtype.cpp deleted file mode 100644 index 61c21eaae6..0000000000 --- a/docs/examples/byte_container_with_subtype__has_subtype.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -// define a byte container based on std::vector -using byte_container_with_subtype = nlohmann::byte_container_with_subtype>; - -int main() -{ - std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}}; - - // create container - auto c1 = byte_container_with_subtype(bytes); - - // create container with subtype - auto c2 = byte_container_with_subtype(bytes, 42); - - std::cout << std::boolalpha << "c1.has_subtype() = " << c1.has_subtype() - << "\nc2.has_subtype() = " << c2.has_subtype() << std::endl; -} diff --git a/docs/examples/byte_container_with_subtype__has_subtype.output b/docs/examples/byte_container_with_subtype__has_subtype.output deleted file mode 100644 index f4aade2a1e..0000000000 --- a/docs/examples/byte_container_with_subtype__has_subtype.output +++ /dev/null @@ -1,2 +0,0 @@ -c1.has_subtype() = false -c2.has_subtype() = true diff --git a/docs/examples/byte_container_with_subtype__set_subtype.cpp b/docs/examples/byte_container_with_subtype__set_subtype.cpp deleted file mode 100644 index b2694c54d5..0000000000 --- a/docs/examples/byte_container_with_subtype__set_subtype.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -// define a byte container based on std::vector -using byte_container_with_subtype = nlohmann::byte_container_with_subtype>; - -using json = nlohmann::json; - -int main() -{ - std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}}; - - // create container without subtype - auto c = byte_container_with_subtype(bytes); - - std::cout << "before calling set_subtype(42): " << json(c) << '\n'; - - // set the subtype - c.set_subtype(42); - - std::cout << "after calling set_subtype(42): " << json(c) << '\n'; -} diff --git a/docs/examples/byte_container_with_subtype__set_subtype.output b/docs/examples/byte_container_with_subtype__set_subtype.output deleted file mode 100644 index 648b3ef24f..0000000000 --- a/docs/examples/byte_container_with_subtype__set_subtype.output +++ /dev/null @@ -1,2 +0,0 @@ -before calling set_subtype(42): {"bytes":[202,254,186,190],"subtype":null} -after calling set_subtype(42): {"bytes":[202,254,186,190],"subtype":42} diff --git a/docs/examples/byte_container_with_subtype__subtype.cpp b/docs/examples/byte_container_with_subtype__subtype.cpp deleted file mode 100644 index cd230ade1e..0000000000 --- a/docs/examples/byte_container_with_subtype__subtype.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -// define a byte container based on std::vector -using byte_container_with_subtype = nlohmann::byte_container_with_subtype>; - -int main() -{ - std::vector bytes = {{0xca, 0xfe, 0xba, 0xbe}}; - - // create container - auto c1 = byte_container_with_subtype(bytes); - - // create container with subtype - auto c2 = byte_container_with_subtype(bytes, 42); - - std::cout << "c1.subtype() = " << c1.subtype() - << "\nc2.subtype() = " << c2.subtype() << std::endl; - - // in case no subtype is set, return special value - assert(c1.subtype() == static_cast(-1)); -} diff --git a/docs/examples/byte_container_with_subtype__subtype.output b/docs/examples/byte_container_with_subtype__subtype.output deleted file mode 100644 index 47955277b2..0000000000 --- a/docs/examples/byte_container_with_subtype__subtype.output +++ /dev/null @@ -1,2 +0,0 @@ -c1.subtype() = 18446744073709551615 -c2.subtype() = 42 diff --git a/docs/examples/cbegin.cpp b/docs/examples/cbegin.cpp deleted file mode 100644 index bed2b37255..0000000000 --- a/docs/examples/cbegin.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create an array value - const json array = {1, 2, 3, 4, 5}; - - // get an iterator to the first element - json::const_iterator it = array.cbegin(); - - // serialize the element that the iterator points to - std::cout << *it << '\n'; -} diff --git a/docs/examples/cbegin.output b/docs/examples/cbegin.output deleted file mode 100644 index d00491fd7e..0000000000 --- a/docs/examples/cbegin.output +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/docs/examples/cbor_tag_handler_t.cpp b/docs/examples/cbor_tag_handler_t.cpp deleted file mode 100644 index 79052c7a0d..0000000000 --- a/docs/examples/cbor_tag_handler_t.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // tagged byte string - std::vector vec = {{0xd8, 0x42, 0x44, 0xcA, 0xfe, 0xba, 0xbe}}; - - // cbor_tag_handler_t::error throws - try - { - auto b_throw_on_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::error); - } - catch (json::parse_error& e) - { - std::cout << e.what() << std::endl; - } - - // cbor_tag_handler_t::ignore ignores the tag - auto b_ignore_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::ignore); - std::cout << b_ignore_tag << std::endl; - - // cbor_tag_handler_t::store stores the tag as binary subtype - auto b_store_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::store); - std::cout << b_store_tag << std::endl; -} diff --git a/docs/examples/cbor_tag_handler_t.output b/docs/examples/cbor_tag_handler_t.output deleted file mode 100644 index 18920b137a..0000000000 --- a/docs/examples/cbor_tag_handler_t.output +++ /dev/null @@ -1,3 +0,0 @@ -[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing CBOR value: invalid byte: 0xD8 -{"bytes":[202,254,186,190],"subtype":null} -{"bytes":[202,254,186,190],"subtype":66} diff --git a/docs/examples/cend.cpp b/docs/examples/cend.cpp deleted file mode 100644 index 3050f50013..0000000000 --- a/docs/examples/cend.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create an array value - json array = {1, 2, 3, 4, 5}; - - // get an iterator to one past the last element - json::const_iterator it = array.cend(); - - // decrement the iterator to point to the last element - --it; - - // serialize the element that the iterator points to - std::cout << *it << '\n'; -} diff --git a/docs/examples/cend.output b/docs/examples/cend.output deleted file mode 100644 index 7ed6ff82de..0000000000 --- a/docs/examples/cend.output +++ /dev/null @@ -1 +0,0 @@ -5 diff --git a/docs/examples/clear.cpp b/docs/examples/clear.cpp deleted file mode 100644 index f081e7eda8..0000000000 --- a/docs/examples/clear.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = 17; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - - // call clear() - j_null.clear(); - j_boolean.clear(); - j_number_integer.clear(); - j_number_float.clear(); - j_object.clear(); - j_array.clear(); - j_string.clear(); - - // serialize the cleared values() - std::cout << j_null << '\n'; - std::cout << j_boolean << '\n'; - std::cout << j_number_integer << '\n'; - std::cout << j_number_float << '\n'; - std::cout << j_object << '\n'; - std::cout << j_array << '\n'; - std::cout << j_string << '\n'; -} diff --git a/docs/examples/clear.output b/docs/examples/clear.output deleted file mode 100644 index ea542caebb..0000000000 --- a/docs/examples/clear.output +++ /dev/null @@ -1,7 +0,0 @@ -null -false -0 -0.0 -{} -[] -"" diff --git a/docs/examples/contains__json_pointer.cpp b/docs/examples/contains__json_pointer.cpp deleted file mode 100644 index f9de546b5d..0000000000 --- a/docs/examples/contains__json_pointer.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -int main() -{ - // create a JSON value - json j = - { - {"number", 1}, {"string", "foo"}, {"array", {1, 2}} - }; - - std::cout << std::boolalpha - << j.contains("/number"_json_pointer) << '\n' - << j.contains("/string"_json_pointer) << '\n' - << j.contains("/array"_json_pointer) << '\n' - << j.contains("/array/1"_json_pointer) << '\n' - << j.contains("/array/-"_json_pointer) << '\n' - << j.contains("/array/4"_json_pointer) << '\n' - << j.contains("/baz"_json_pointer) << std::endl; - - try - { - // try to use an array index with leading '0' - j.contains("/array/01"_json_pointer); - } - catch (json::parse_error& e) - { - std::cout << e.what() << '\n'; - } - - try - { - // try to use an array index that is not a number - j.contains("/array/one"_json_pointer); - } - catch (json::parse_error& e) - { - std::cout << e.what() << '\n'; - } -} diff --git a/docs/examples/contains__json_pointer.output b/docs/examples/contains__json_pointer.output deleted file mode 100644 index dd1eb38c19..0000000000 --- a/docs/examples/contains__json_pointer.output +++ /dev/null @@ -1,7 +0,0 @@ -true -true -true -true -false -false -false diff --git a/docs/examples/contains__keytype.c++17.cpp b/docs/examples/contains__keytype.c++17.cpp deleted file mode 100644 index 43b62fab10..0000000000 --- a/docs/examples/contains__keytype.c++17.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include -#include - -using namespace std::string_view_literals; -using json = nlohmann::json; -using namespace nlohmann::literals; - -int main() -{ - // create some JSON values - json j_object = R"( {"key": "value"} )"_json; - json j_array = R"( [1, 2, 3] )"_json; - - // call contains - std::cout << std::boolalpha << - "j_object contains 'key': " << j_object.contains("key"sv) << '\n' << - "j_object contains 'another': " << j_object.contains("another"sv) << '\n' << - "j_array contains 'key': " << j_array.contains("key"sv) << std::endl; -} diff --git a/docs/examples/contains__keytype.c++17.output b/docs/examples/contains__keytype.c++17.output deleted file mode 100644 index 14ad177b14..0000000000 --- a/docs/examples/contains__keytype.c++17.output +++ /dev/null @@ -1,3 +0,0 @@ -j_object contains 'key': true -j_object contains 'another': false -j_array contains 'key': false diff --git a/docs/examples/contains__object_t_key_type.cpp b/docs/examples/contains__object_t_key_type.cpp deleted file mode 100644 index a8bc8143df..0000000000 --- a/docs/examples/contains__object_t_key_type.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -int main() -{ - // create some JSON values - json j_object = R"( {"key": "value"} )"_json; - json j_array = R"( [1, 2, 3] )"_json; - - // call contains - std::cout << std::boolalpha << - "j_object contains 'key': " << j_object.contains("key") << '\n' << - "j_object contains 'another': " << j_object.contains("another") << '\n' << - "j_array contains 'key': " << j_array.contains("key") << std::endl; -} diff --git a/docs/examples/contains__object_t_key_type.output b/docs/examples/contains__object_t_key_type.output deleted file mode 100644 index 14ad177b14..0000000000 --- a/docs/examples/contains__object_t_key_type.output +++ /dev/null @@ -1,3 +0,0 @@ -j_object contains 'key': true -j_object contains 'another': false -j_array contains 'key': false diff --git a/docs/examples/count__keytype.c++17.cpp b/docs/examples/count__keytype.c++17.cpp deleted file mode 100644 index ec6de06076..0000000000 --- a/docs/examples/count__keytype.c++17.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include -#include - -using namespace std::string_view_literals; -using json = nlohmann::json; - -int main() -{ - // create a JSON object - json j_object = {{"one", 1}, {"two", 2}}; - - // call count() - auto count_two = j_object.count("two"sv); - auto count_three = j_object.count("three"sv); - - // print values - std::cout << "number of elements with key \"two\": " << count_two << '\n'; - std::cout << "number of elements with key \"three\": " << count_three << '\n'; -} diff --git a/docs/examples/count__keytype.c++17.output b/docs/examples/count__keytype.c++17.output deleted file mode 100644 index d816fcb24d..0000000000 --- a/docs/examples/count__keytype.c++17.output +++ /dev/null @@ -1,2 +0,0 @@ -number of elements with key "two": 1 -number of elements with key "three": 0 diff --git a/docs/examples/count__object_t_key_type.cpp b/docs/examples/count__object_t_key_type.cpp deleted file mode 100644 index a8d54b9d10..0000000000 --- a/docs/examples/count__object_t_key_type.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON object - json j_object = {{"one", 1}, {"two", 2}}; - - // call count() - auto count_two = j_object.count("two"); - auto count_three = j_object.count("three"); - - // print values - std::cout << "number of elements with key \"two\": " << count_two << '\n'; - std::cout << "number of elements with key \"three\": " << count_three << '\n'; -} diff --git a/docs/examples/count__object_t_key_type.output b/docs/examples/count__object_t_key_type.output deleted file mode 100644 index d816fcb24d..0000000000 --- a/docs/examples/count__object_t_key_type.output +++ /dev/null @@ -1,2 +0,0 @@ -number of elements with key "two": 1 -number of elements with key "three": 0 diff --git a/docs/examples/crbegin.cpp b/docs/examples/crbegin.cpp deleted file mode 100644 index dc3209cf87..0000000000 --- a/docs/examples/crbegin.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create an array value - json array = {1, 2, 3, 4, 5}; - - // get an iterator to the reverse-beginning - json::const_reverse_iterator it = array.crbegin(); - - // serialize the element that the iterator points to - std::cout << *it << '\n'; -} diff --git a/docs/examples/crbegin.output b/docs/examples/crbegin.output deleted file mode 100644 index 7ed6ff82de..0000000000 --- a/docs/examples/crbegin.output +++ /dev/null @@ -1 +0,0 @@ -5 diff --git a/docs/examples/crend.cpp b/docs/examples/crend.cpp deleted file mode 100644 index dff2609316..0000000000 --- a/docs/examples/crend.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create an array value - json array = {1, 2, 3, 4, 5}; - - // get an iterator to the reverse-end - json::const_reverse_iterator it = array.crend(); - - // increment the iterator to point to the first element - --it; - - // serialize the element that the iterator points to - std::cout << *it << '\n'; -} diff --git a/docs/examples/crend.output b/docs/examples/crend.output deleted file mode 100644 index d00491fd7e..0000000000 --- a/docs/examples/crend.output +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/docs/examples/default_object_comparator_t.cpp b/docs/examples/default_object_comparator_t.cpp deleted file mode 100644 index 9f200fe6b5..0000000000 --- a/docs/examples/default_object_comparator_t.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - std::cout << std::boolalpha - << "one < two : " << json::default_object_comparator_t{}("one", "two") << "\n" - << "three < four : " << json::default_object_comparator_t{}("three", "four") << std::endl; -} diff --git a/docs/examples/default_object_comparator_t.output b/docs/examples/default_object_comparator_t.output deleted file mode 100644 index b1daf3b967..0000000000 --- a/docs/examples/default_object_comparator_t.output +++ /dev/null @@ -1,2 +0,0 @@ -one < two : true -three < four : false diff --git a/docs/examples/diagnostics_extended.cpp b/docs/examples/diagnostics_extended.cpp deleted file mode 100644 index f4c43f05e6..0000000000 --- a/docs/examples/diagnostics_extended.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include - -# define JSON_DIAGNOSTICS 1 -#include - -using json = nlohmann::json; - -int main() -{ - json j; - j["address"]["street"] = "Fake Street"; - j["address"]["housenumber"] = "12"; - - try - { - int housenumber = j["address"]["housenumber"]; - } - catch (json::exception& e) - { - std::cout << e.what() << '\n'; - } -} diff --git a/docs/examples/diagnostics_extended.output b/docs/examples/diagnostics_extended.output deleted file mode 100644 index f142927a17..0000000000 --- a/docs/examples/diagnostics_extended.output +++ /dev/null @@ -1 +0,0 @@ -[json.exception.type_error.302] (/address/housenumber) type must be number, but is string diff --git a/docs/examples/diagnostics_standard.cpp b/docs/examples/diagnostics_standard.cpp deleted file mode 100644 index 575c409eb6..0000000000 --- a/docs/examples/diagnostics_standard.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - json j; - j["address"]["street"] = "Fake Street"; - j["address"]["housenumber"] = "12"; - - try - { - int housenumber = j["address"]["housenumber"]; - } - catch (json::exception& e) - { - std::cout << e.what() << '\n'; - } -} diff --git a/docs/examples/diagnostics_standard.output b/docs/examples/diagnostics_standard.output deleted file mode 100644 index 79707a0cb9..0000000000 --- a/docs/examples/diagnostics_standard.output +++ /dev/null @@ -1 +0,0 @@ -[json.exception.type_error.302] type must be number, but is string diff --git a/docs/examples/diff.cpp b/docs/examples/diff.cpp deleted file mode 100644 index ef01332a14..0000000000 --- a/docs/examples/diff.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -int main() -{ - // the source document - json source = R"( - { - "baz": "qux", - "foo": "bar" - } - )"_json; - - // the target document - json target = R"( - { - "baz": "boo", - "hello": [ - "world" - ] - } - )"_json; - - // create the patch - json patch = json::diff(source, target); - - // roundtrip - json patched_source = source.patch(patch); - - // output patch and roundtrip result - std::cout << std::setw(4) << patch << "\n\n" - << std::setw(4) << patched_source << std::endl; -} diff --git a/docs/examples/diff.output b/docs/examples/diff.output deleted file mode 100644 index 7dc79791f5..0000000000 --- a/docs/examples/diff.output +++ /dev/null @@ -1,25 +0,0 @@ -[ - { - "op": "replace", - "path": "/baz", - "value": "boo" - }, - { - "op": "remove", - "path": "/foo" - }, - { - "op": "add", - "path": "/hello", - "value": [ - "world" - ] - } -] - -{ - "baz": "boo", - "hello": [ - "world" - ] -} diff --git a/docs/examples/dump.cpp b/docs/examples/dump.cpp deleted file mode 100644 index eb2d71f0ee..0000000000 --- a/docs/examples/dump.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hellö 😀!"; - - // call dump() - std::cout << "objects:" << '\n' - << j_object.dump() << "\n\n" - << j_object.dump(-1) << "\n\n" - << j_object.dump(0) << "\n\n" - << j_object.dump(4) << "\n\n" - << j_object.dump(1, '\t') << "\n\n"; - - std::cout << "arrays:" << '\n' - << j_array.dump() << "\n\n" - << j_array.dump(-1) << "\n\n" - << j_array.dump(0) << "\n\n" - << j_array.dump(4) << "\n\n" - << j_array.dump(1, '\t') << "\n\n"; - - std::cout << "strings:" << '\n' - << j_string.dump() << '\n' - << j_string.dump(-1, ' ', true) << '\n'; - - // create JSON value with invalid UTF-8 byte sequence - json j_invalid = "ä\xA9ü"; - try - { - std::cout << j_invalid.dump() << std::endl; - } - catch (json::type_error& e) - { - std::cout << e.what() << std::endl; - } - - std::cout << "string with replaced invalid characters: " - << j_invalid.dump(-1, ' ', false, json::error_handler_t::replace) - << "\nstring with ignored invalid characters: " - << j_invalid.dump(-1, ' ', false, json::error_handler_t::ignore) - << '\n'; -} diff --git a/docs/examples/dump.output b/docs/examples/dump.output deleted file mode 100644 index 43009fe62f..0000000000 --- a/docs/examples/dump.output +++ /dev/null @@ -1,55 +0,0 @@ -objects: -{"one":1,"two":2} - -{"one":1,"two":2} - -{ -"one": 1, -"two": 2 -} - -{ - "one": 1, - "two": 2 -} - -{ - "one": 1, - "two": 2 -} - -arrays: -[1,2,4,8,16] - -[1,2,4,8,16] - -[ -1, -2, -4, -8, -16 -] - -[ - 1, - 2, - 4, - 8, - 16 -] - -[ - 1, - 2, - 4, - 8, - 16 -] - -strings: -"Hellö 😀!" -"Hell\u00f6 \ud83d\ude00!" -[json.exception.type_error.316] invalid UTF-8 byte at index 2: 0xA9 -string with replaced invalid characters: "ä�ü" -string with ignored invalid characters: "äü" diff --git a/docs/examples/emplace.cpp b/docs/examples/emplace.cpp deleted file mode 100644 index a5314910f5..0000000000 --- a/docs/examples/emplace.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json object = {{"one", 1}, {"two", 2}}; - json null; - - // print values - std::cout << object << '\n'; - std::cout << null << '\n'; - - // add values - auto res1 = object.emplace("three", 3); - null.emplace("A", "a"); - null.emplace("B", "b"); - - // the following call will not add an object, because there is already - // a value stored at key "B" - auto res2 = null.emplace("B", "c"); - - // print values - std::cout << object << '\n'; - std::cout << *res1.first << " " << std::boolalpha << res1.second << '\n'; - - std::cout << null << '\n'; - std::cout << *res2.first << " " << std::boolalpha << res2.second << '\n'; -} diff --git a/docs/examples/emplace.output b/docs/examples/emplace.output deleted file mode 100644 index 83d6f77300..0000000000 --- a/docs/examples/emplace.output +++ /dev/null @@ -1,6 +0,0 @@ -{"one":1,"two":2} -null -{"one":1,"three":3,"two":2} -3 true -{"A":"a","B":"b"} -"b" false diff --git a/docs/examples/emplace_back.cpp b/docs/examples/emplace_back.cpp deleted file mode 100644 index e979a945cc..0000000000 --- a/docs/examples/emplace_back.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json array = {1, 2, 3, 4, 5}; - json null; - - // print values - std::cout << array << '\n'; - std::cout << null << '\n'; - - // add values - array.emplace_back(6); - null.emplace_back("first"); - null.emplace_back(3, "second"); - - // print values - std::cout << array << '\n'; - std::cout << null << '\n'; -} diff --git a/docs/examples/emplace_back.output b/docs/examples/emplace_back.output deleted file mode 100644 index bdd80d82da..0000000000 --- a/docs/examples/emplace_back.output +++ /dev/null @@ -1,4 +0,0 @@ -[1,2,3,4,5] -null -[1,2,3,4,5,6] -["first",["second","second","second"]] diff --git a/docs/examples/empty.cpp b/docs/examples/empty.cpp deleted file mode 100644 index 6ef6e40edb..0000000000 --- a/docs/examples/empty.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = 17; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_object_empty(json::value_t::object); - json j_array = {1, 2, 4, 8, 16}; - json j_array_empty(json::value_t::array); - json j_string = "Hello, world"; - - // call empty() - std::cout << std::boolalpha; - std::cout << j_null.empty() << '\n'; - std::cout << j_boolean.empty() << '\n'; - std::cout << j_number_integer.empty() << '\n'; - std::cout << j_number_float.empty() << '\n'; - std::cout << j_object.empty() << '\n'; - std::cout << j_object_empty.empty() << '\n'; - std::cout << j_array.empty() << '\n'; - std::cout << j_array_empty.empty() << '\n'; - std::cout << j_string.empty() << '\n'; -} diff --git a/docs/examples/empty.output b/docs/examples/empty.output deleted file mode 100644 index d071a39808..0000000000 --- a/docs/examples/empty.output +++ /dev/null @@ -1,9 +0,0 @@ -true -false -false -false -false -true -false -true -false diff --git a/docs/examples/end.cpp b/docs/examples/end.cpp deleted file mode 100644 index 47beedb77a..0000000000 --- a/docs/examples/end.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create an array value - json array = {1, 2, 3, 4, 5}; - - // get an iterator to one past the last element - json::iterator it = array.end(); - - // decrement the iterator to point to the last element - --it; - - // serialize the element that the iterator points to - std::cout << *it << '\n'; -} diff --git a/docs/examples/end.output b/docs/examples/end.output deleted file mode 100644 index 7ed6ff82de..0000000000 --- a/docs/examples/end.output +++ /dev/null @@ -1 +0,0 @@ -5 diff --git a/docs/examples/erase__IteratorType.cpp b/docs/examples/erase__IteratorType.cpp deleted file mode 100644 index f0d4ec6fb6..0000000000 --- a/docs/examples/erase__IteratorType.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_boolean = true; - json j_number_integer = 17; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - - // call erase() - j_boolean.erase(j_boolean.begin()); - j_number_integer.erase(j_number_integer.begin()); - j_number_float.erase(j_number_float.begin()); - j_object.erase(j_object.find("two")); - j_array.erase(j_array.begin() + 2); - j_string.erase(j_string.begin()); - - // print values - std::cout << j_boolean << '\n'; - std::cout << j_number_integer << '\n'; - std::cout << j_number_float << '\n'; - std::cout << j_object << '\n'; - std::cout << j_array << '\n'; - std::cout << j_string << '\n'; -} diff --git a/docs/examples/erase__IteratorType.output b/docs/examples/erase__IteratorType.output deleted file mode 100644 index e392f8eaf3..0000000000 --- a/docs/examples/erase__IteratorType.output +++ /dev/null @@ -1,6 +0,0 @@ -null -null -null -{"one":1} -[1,2,8,16] -null diff --git a/docs/examples/erase__IteratorType_IteratorType.cpp b/docs/examples/erase__IteratorType_IteratorType.cpp deleted file mode 100644 index 392511ffee..0000000000 --- a/docs/examples/erase__IteratorType_IteratorType.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_boolean = true; - json j_number_integer = 17; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - - // call erase() - j_boolean.erase(j_boolean.begin(), j_boolean.end()); - j_number_integer.erase(j_number_integer.begin(), j_number_integer.end()); - j_number_float.erase(j_number_float.begin(), j_number_float.end()); - j_object.erase(j_object.find("two"), j_object.end()); - j_array.erase(j_array.begin() + 1, j_array.begin() + 3); - j_string.erase(j_string.begin(), j_string.end()); - - // print values - std::cout << j_boolean << '\n'; - std::cout << j_number_integer << '\n'; - std::cout << j_number_float << '\n'; - std::cout << j_object << '\n'; - std::cout << j_array << '\n'; - std::cout << j_string << '\n'; -} diff --git a/docs/examples/erase__IteratorType_IteratorType.output b/docs/examples/erase__IteratorType_IteratorType.output deleted file mode 100644 index 5d01f0089e..0000000000 --- a/docs/examples/erase__IteratorType_IteratorType.output +++ /dev/null @@ -1,6 +0,0 @@ -null -null -null -{"one":1} -[1,8,16] -null diff --git a/docs/examples/erase__keytype.c++17.cpp b/docs/examples/erase__keytype.c++17.cpp deleted file mode 100644 index c5e4bed5d5..0000000000 --- a/docs/examples/erase__keytype.c++17.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include -#include - -using namespace std::string_view_literals; -using json = nlohmann::json; - -int main() -{ - // create a JSON object - json j_object = {{"one", 1}, {"two", 2}}; - - // call erase() - auto count_one = j_object.erase("one"sv); - auto count_three = j_object.erase("three"sv); - - // print values - std::cout << j_object << '\n'; - std::cout << count_one << " " << count_three << '\n'; -} diff --git a/docs/examples/erase__keytype.c++17.output b/docs/examples/erase__keytype.c++17.output deleted file mode 100644 index 28d79391a0..0000000000 --- a/docs/examples/erase__keytype.c++17.output +++ /dev/null @@ -1,2 +0,0 @@ -{"two":2} -1 0 diff --git a/docs/examples/erase__object_t_key_type.cpp b/docs/examples/erase__object_t_key_type.cpp deleted file mode 100644 index 2fd84c86eb..0000000000 --- a/docs/examples/erase__object_t_key_type.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON object - json j_object = {{"one", 1}, {"two", 2}}; - - // call erase() - auto count_one = j_object.erase("one"); - auto count_three = j_object.erase("three"); - - // print values - std::cout << j_object << '\n'; - std::cout << count_one << " " << count_three << '\n'; -} diff --git a/docs/examples/erase__object_t_key_type.output b/docs/examples/erase__object_t_key_type.output deleted file mode 100644 index 28d79391a0..0000000000 --- a/docs/examples/erase__object_t_key_type.output +++ /dev/null @@ -1,2 +0,0 @@ -{"two":2} -1 0 diff --git a/docs/examples/erase__size_type.cpp b/docs/examples/erase__size_type.cpp deleted file mode 100644 index 810062387c..0000000000 --- a/docs/examples/erase__size_type.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON array - json j_array = {0, 1, 2, 3, 4, 5}; - - // call erase() - j_array.erase(2); - - // print values - std::cout << j_array << '\n'; -} diff --git a/docs/examples/erase__size_type.output b/docs/examples/erase__size_type.output deleted file mode 100644 index 4ad74061f1..0000000000 --- a/docs/examples/erase__size_type.output +++ /dev/null @@ -1 +0,0 @@ -[0,1,3,4,5] diff --git a/docs/examples/error_handler_t.cpp b/docs/examples/error_handler_t.cpp deleted file mode 100644 index add3f3b2d7..0000000000 --- a/docs/examples/error_handler_t.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON value with invalid UTF-8 byte sequence - json j_invalid = "ä\xA9ü"; - try - { - std::cout << j_invalid.dump() << std::endl; - } - catch (json::type_error& e) - { - std::cout << e.what() << std::endl; - } - - std::cout << "string with replaced invalid characters: " - << j_invalid.dump(-1, ' ', false, json::error_handler_t::replace) - << "\nstring with ignored invalid characters: " - << j_invalid.dump(-1, ' ', false, json::error_handler_t::ignore) - << '\n'; -} diff --git a/docs/examples/error_handler_t.output b/docs/examples/error_handler_t.output deleted file mode 100644 index 718d62bee5..0000000000 --- a/docs/examples/error_handler_t.output +++ /dev/null @@ -1,3 +0,0 @@ -[json.exception.type_error.316] invalid UTF-8 byte at index 2: 0xA9 -string with replaced invalid characters: "ä�ü" -string with ignored invalid characters: "äü" diff --git a/docs/examples/exception.cpp b/docs/examples/exception.cpp deleted file mode 100644 index 82696e6142..0000000000 --- a/docs/examples/exception.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - try - { - // calling at() for a non-existing key - json j = {{"foo", "bar"}}; - json k = j.at("non-existing"); - } - catch (json::exception& e) - { - // output exception information - std::cout << "message: " << e.what() << '\n' - << "exception id: " << e.id << std::endl; - } -} diff --git a/docs/examples/exception.output b/docs/examples/exception.output deleted file mode 100644 index fa20df6e84..0000000000 --- a/docs/examples/exception.output +++ /dev/null @@ -1,2 +0,0 @@ -message: [json.exception.out_of_range.403] key 'non-existing' not found -exception id: 403 diff --git a/docs/examples/find__keytype.c++17.cpp b/docs/examples/find__keytype.c++17.cpp deleted file mode 100644 index da94cf0ad4..0000000000 --- a/docs/examples/find__keytype.c++17.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include -#include - -using namespace std::string_view_literals; -using json = nlohmann::json; - -int main() -{ - // create a JSON object - json j_object = {{"one", 1}, {"two", 2}}; - - // call find - auto it_two = j_object.find("two"sv); - auto it_three = j_object.find("three"sv); - - // print values - std::cout << std::boolalpha; - std::cout << "\"two\" was found: " << (it_two != j_object.end()) << '\n'; - std::cout << "value at key \"two\": " << *it_two << '\n'; - std::cout << "\"three\" was found: " << (it_three != j_object.end()) << '\n'; -} diff --git a/docs/examples/find__keytype.c++17.output b/docs/examples/find__keytype.c++17.output deleted file mode 100644 index 509bb42d5c..0000000000 --- a/docs/examples/find__keytype.c++17.output +++ /dev/null @@ -1,3 +0,0 @@ -"two" was found: true -value at key "two": 2 -"three" was found: false diff --git a/docs/examples/find__object_t_key_type.cpp b/docs/examples/find__object_t_key_type.cpp deleted file mode 100644 index 685ba77633..0000000000 --- a/docs/examples/find__object_t_key_type.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON object - json j_object = {{"one", 1}, {"two", 2}}; - - // call find - auto it_two = j_object.find("two"); - auto it_three = j_object.find("three"); - - // print values - std::cout << std::boolalpha; - std::cout << "\"two\" was found: " << (it_two != j_object.end()) << '\n'; - std::cout << "value at key \"two\": " << *it_two << '\n'; - std::cout << "\"three\" was found: " << (it_three != j_object.end()) << '\n'; -} diff --git a/docs/examples/find__object_t_key_type.output b/docs/examples/find__object_t_key_type.output deleted file mode 100644 index 509bb42d5c..0000000000 --- a/docs/examples/find__object_t_key_type.output +++ /dev/null @@ -1,3 +0,0 @@ -"two" was found: true -value at key "two": 2 -"three" was found: false diff --git a/docs/examples/flatten.cpp b/docs/examples/flatten.cpp deleted file mode 100644 index 83f3ff6c36..0000000000 --- a/docs/examples/flatten.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON value - json j = - { - {"pi", 3.141}, - {"happy", true}, - {"name", "Niels"}, - {"nothing", nullptr}, - { - "answer", { - {"everything", 42} - } - }, - {"list", {1, 0, 2}}, - { - "object", { - {"currency", "USD"}, - {"value", 42.99} - } - } - }; - - // call flatten() - std::cout << std::setw(4) << j.flatten() << '\n'; -} diff --git a/docs/examples/flatten.output b/docs/examples/flatten.output deleted file mode 100644 index 33bd4c4b9f..0000000000 --- a/docs/examples/flatten.output +++ /dev/null @@ -1,12 +0,0 @@ -{ - "/answer/everything": 42, - "/happy": true, - "/list/0": 1, - "/list/1": 0, - "/list/2": 2, - "/name": "Niels", - "/nothing": null, - "/object/currency": "USD", - "/object/value": 42.99, - "/pi": 3.141 -} diff --git a/docs/examples/from_bjdata.cpp b/docs/examples/from_bjdata.cpp deleted file mode 100644 index 961164c29f..0000000000 --- a/docs/examples/from_bjdata.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create byte vector - std::vector v = {0x7B, 0x69, 0x07, 0x63, 0x6F, 0x6D, 0x70, 0x61, - 0x63, 0x74, 0x54, 0x69, 0x06, 0x73, 0x63, 0x68, - 0x65, 0x6D, 0x61, 0x69, 0x00, 0x7D - }; - - // deserialize it with BJData - json j = json::from_bjdata(v); - - // print the deserialized JSON value - std::cout << std::setw(2) << j << std::endl; -} diff --git a/docs/examples/from_bjdata.output b/docs/examples/from_bjdata.output deleted file mode 100644 index 259f63bd45..0000000000 --- a/docs/examples/from_bjdata.output +++ /dev/null @@ -1,4 +0,0 @@ -{ - "compact": true, - "schema": 0 -} diff --git a/docs/examples/from_bson.cpp b/docs/examples/from_bson.cpp deleted file mode 100644 index c9d9fdfa66..0000000000 --- a/docs/examples/from_bson.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create byte vector - std::vector v = {0x1b, 0x00, 0x00, 0x00, 0x08, 0x63, 0x6f, 0x6d, - 0x70, 0x61, 0x63, 0x74, 0x00, 0x01, 0x10, 0x73, - 0x63, 0x68, 0x65, 0x6d, 0x61, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00 - }; - - // deserialize it with BSON - json j = json::from_bson(v); - - // print the deserialized JSON value - std::cout << std::setw(2) << j << std::endl; -} diff --git a/docs/examples/from_bson.output b/docs/examples/from_bson.output deleted file mode 100644 index 259f63bd45..0000000000 --- a/docs/examples/from_bson.output +++ /dev/null @@ -1,4 +0,0 @@ -{ - "compact": true, - "schema": 0 -} diff --git a/docs/examples/from_cbor.cpp b/docs/examples/from_cbor.cpp deleted file mode 100644 index e685329efc..0000000000 --- a/docs/examples/from_cbor.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create byte vector - std::vector v = {0xa2, 0x67, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, - 0x74, 0xf5, 0x66, 0x73, 0x63, 0x68, 0x65, 0x6d, - 0x61, 0x00 - }; - - // deserialize it with CBOR - json j = json::from_cbor(v); - - // print the deserialized JSON value - std::cout << std::setw(2) << j << std::endl; -} diff --git a/docs/examples/from_cbor.output b/docs/examples/from_cbor.output deleted file mode 100644 index 259f63bd45..0000000000 --- a/docs/examples/from_cbor.output +++ /dev/null @@ -1,4 +0,0 @@ -{ - "compact": true, - "schema": 0 -} diff --git a/docs/examples/from_json__default_constructible.cpp b/docs/examples/from_json__default_constructible.cpp deleted file mode 100644 index 07d71ac951..0000000000 --- a/docs/examples/from_json__default_constructible.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -namespace ns -{ -// a simple struct to model a person -struct person -{ - std::string name; - std::string address; - int age; -}; -} // namespace ns - -namespace ns -{ -void from_json(const json& j, person& p) -{ - j.at("name").get_to(p.name); - j.at("address").get_to(p.address); - j.at("age").get_to(p.age); -} -} // namespace ns - -int main() -{ - json j; - j["name"] = "Ned Flanders"; - j["address"] = "744 Evergreen Terrace"; - j["age"] = 60; - - auto p = j.template get(); - - std::cout << p.name << " (" << p.age << ") lives in " << p.address << std::endl; -} diff --git a/docs/examples/from_json__default_constructible.output b/docs/examples/from_json__default_constructible.output deleted file mode 100644 index b92452326d..0000000000 --- a/docs/examples/from_json__default_constructible.output +++ /dev/null @@ -1 +0,0 @@ -Ned Flanders (60) lives in 744 Evergreen Terrace diff --git a/docs/examples/from_json__non_default_constructible.cpp b/docs/examples/from_json__non_default_constructible.cpp deleted file mode 100644 index ec8206eade..0000000000 --- a/docs/examples/from_json__non_default_constructible.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -namespace ns -{ -// a simple struct to model a person (not default constructible) -struct person -{ - person(std::string n, std::string a, int aa) - : name(std::move(n)), address(std::move(a)), age(aa) - {} - - std::string name; - std::string address; - int age; -}; -} // namespace ns - -namespace nlohmann -{ -template <> -struct adl_serializer -{ - static ns::person from_json(const json& j) - { - return {j.at("name"), j.at("address"), j.at("age")}; - } - - // Here's the catch! You must provide a to_json method! Otherwise, you - // will not be able to convert person to json, since you fully - // specialized adl_serializer on that type - static void to_json(json& j, ns::person p) - { - j["name"] = p.name; - j["address"] = p.address; - j["age"] = p.age; - } -}; -} // namespace nlohmann - -int main() -{ - json j; - j["name"] = "Ned Flanders"; - j["address"] = "744 Evergreen Terrace"; - j["age"] = 60; - - auto p = j.template get(); - - std::cout << p.name << " (" << p.age << ") lives in " << p.address << std::endl; -} diff --git a/docs/examples/from_json__non_default_constructible.output b/docs/examples/from_json__non_default_constructible.output deleted file mode 100644 index b92452326d..0000000000 --- a/docs/examples/from_json__non_default_constructible.output +++ /dev/null @@ -1 +0,0 @@ -Ned Flanders (60) lives in 744 Evergreen Terrace diff --git a/docs/examples/from_msgpack.cpp b/docs/examples/from_msgpack.cpp deleted file mode 100644 index 5c2183f1e2..0000000000 --- a/docs/examples/from_msgpack.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create byte vector - std::vector v = {0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, - 0x74, 0xc3, 0xa6, 0x73, 0x63, 0x68, 0x65, 0x6d, - 0x61, 0x00 - }; - - // deserialize it with MessagePack - json j = json::from_msgpack(v); - - // print the deserialized JSON value - std::cout << std::setw(2) << j << std::endl; -} diff --git a/docs/examples/from_msgpack.output b/docs/examples/from_msgpack.output deleted file mode 100644 index 259f63bd45..0000000000 --- a/docs/examples/from_msgpack.output +++ /dev/null @@ -1,4 +0,0 @@ -{ - "compact": true, - "schema": 0 -} diff --git a/docs/examples/from_ubjson.cpp b/docs/examples/from_ubjson.cpp deleted file mode 100644 index 1e85e4e360..0000000000 --- a/docs/examples/from_ubjson.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create byte vector - std::vector v = {0x7B, 0x69, 0x07, 0x63, 0x6F, 0x6D, 0x70, 0x61, - 0x63, 0x74, 0x54, 0x69, 0x06, 0x73, 0x63, 0x68, - 0x65, 0x6D, 0x61, 0x69, 0x00, 0x7D - }; - - // deserialize it with UBJSON - json j = json::from_ubjson(v); - - // print the deserialized JSON value - std::cout << std::setw(2) << j << std::endl; -} diff --git a/docs/examples/from_ubjson.output b/docs/examples/from_ubjson.output deleted file mode 100644 index 259f63bd45..0000000000 --- a/docs/examples/from_ubjson.output +++ /dev/null @@ -1,4 +0,0 @@ -{ - "compact": true, - "schema": 0 -} diff --git a/docs/examples/front.cpp b/docs/examples/front.cpp deleted file mode 100644 index a0f6306897..0000000000 --- a/docs/examples/front.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = 17; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_object_empty(json::value_t::object); - json j_array = {1, 2, 4, 8, 16}; - json j_array_empty(json::value_t::array); - json j_string = "Hello, world"; - - // call front() - //std::cout << j_null.front() << '\n'; // would throw - std::cout << j_boolean.front() << '\n'; - std::cout << j_number_integer.front() << '\n'; - std::cout << j_number_float.front() << '\n'; - std::cout << j_object.front() << '\n'; - //std::cout << j_object_empty.front() << '\n'; // undefined behavior - std::cout << j_array.front() << '\n'; - //std::cout << j_array_empty.front() << '\n'; // undefined behavior - std::cout << j_string.front() << '\n'; -} diff --git a/docs/examples/front.output b/docs/examples/front.output deleted file mode 100644 index 6301db533f..0000000000 --- a/docs/examples/front.output +++ /dev/null @@ -1,6 +0,0 @@ -true -17 -23.42 -1 -1 -"Hello, world" diff --git a/docs/examples/get__PointerType.cpp b/docs/examples/get__PointerType.cpp deleted file mode 100644 index 309c8deebb..0000000000 --- a/docs/examples/get__PointerType.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON number - json value = 17; - - // explicitly getting pointers - auto p1 = value.template get(); - auto p2 = value.template get(); - auto p3 = value.template get(); - auto p4 = value.template get(); - auto p5 = value.template get(); - - // print the pointees - std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n'; - std::cout << std::boolalpha << (p5 == nullptr) << '\n'; -} diff --git a/docs/examples/get__PointerType.output b/docs/examples/get__PointerType.output deleted file mode 100644 index a15dd774e8..0000000000 --- a/docs/examples/get__PointerType.output +++ /dev/null @@ -1,2 +0,0 @@ -17 17 17 17 -true diff --git a/docs/examples/get__ValueType_const.cpp b/docs/examples/get__ValueType_const.cpp deleted file mode 100644 index db63791fcb..0000000000 --- a/docs/examples/get__ValueType_const.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON value with different types - json json_types = - { - {"boolean", true}, - { - "number", { - {"integer", 42}, - {"floating-point", 17.23} - } - }, - {"string", "Hello, world!"}, - {"array", {1, 2, 3, 4, 5}}, - {"null", nullptr} - }; - - // use explicit conversions - auto v1 = json_types["boolean"].template get(); - auto v2 = json_types["number"]["integer"].template get(); - auto v3 = json_types["number"]["integer"].template get(); - auto v4 = json_types["number"]["floating-point"].template get(); - auto v5 = json_types["number"]["floating-point"].template get(); - auto v6 = json_types["string"].template get(); - auto v7 = json_types["array"].template get>(); - auto v8 = json_types.template get>(); - - // print the conversion results - std::cout << v1 << '\n'; - std::cout << v2 << ' ' << v3 << '\n'; - std::cout << v4 << ' ' << v5 << '\n'; - std::cout << v6 << '\n'; - - for (auto i : v7) - { - std::cout << i << ' '; - } - std::cout << "\n\n"; - - for (auto i : v8) - { - std::cout << i.first << ": " << i.second << '\n'; - } -} diff --git a/docs/examples/get__ValueType_const.output b/docs/examples/get__ValueType_const.output deleted file mode 100644 index 5cd9cd3aa8..0000000000 --- a/docs/examples/get__ValueType_const.output +++ /dev/null @@ -1,11 +0,0 @@ -1 -42 42 -17.23 17 -Hello, world! -1 2 3 4 5 - -string: "Hello, world!" -number: {"floating-point":17.23,"integer":42} -null: null -boolean: true -array: [1,2,3,4,5] diff --git a/docs/examples/get_allocator.cpp b/docs/examples/get_allocator.cpp deleted file mode 100644 index 35079a10c7..0000000000 --- a/docs/examples/get_allocator.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - auto alloc = json::get_allocator(); - using traits_t = std::allocator_traits; - - json* j = traits_t::allocate(alloc, 1); - traits_t::construct(alloc, j, "Hello, world!"); - - std::cout << *j << std::endl; - - traits_t::destroy(alloc, j); - traits_t::deallocate(alloc, j, 1); -} diff --git a/docs/examples/get_allocator.output b/docs/examples/get_allocator.output deleted file mode 100644 index 8effb3e8c6..0000000000 --- a/docs/examples/get_allocator.output +++ /dev/null @@ -1 +0,0 @@ -"Hello, world!" diff --git a/docs/examples/get_binary.cpp b/docs/examples/get_binary.cpp deleted file mode 100644 index 617ce60960..0000000000 --- a/docs/examples/get_binary.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a binary vector - std::vector vec = {0xCA, 0xFE, 0xBA, 0xBE}; - - // create a binary JSON value with subtype 42 - json j = json::binary(vec, 42); - - // output type and subtype - std::cout << "type: " << j.type_name() << ", subtype: " << j.get_binary().subtype() << std::endl; -} diff --git a/docs/examples/get_binary.output b/docs/examples/get_binary.output deleted file mode 100644 index 74b05d23fe..0000000000 --- a/docs/examples/get_binary.output +++ /dev/null @@ -1 +0,0 @@ -type: binary, subtype: 42 diff --git a/docs/examples/get_ptr.cpp b/docs/examples/get_ptr.cpp deleted file mode 100644 index 564ce0f4e1..0000000000 --- a/docs/examples/get_ptr.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON number - json value = 17; - - // explicitly getting pointers - auto p1 = value.get_ptr(); - auto p2 = value.get_ptr(); - auto p3 = value.get_ptr(); - auto p4 = value.get_ptr(); - auto p5 = value.get_ptr(); - - // print the pointees - std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n'; - std::cout << std::boolalpha << (p5 == nullptr) << '\n'; -} diff --git a/docs/examples/get_ptr.output b/docs/examples/get_ptr.output deleted file mode 100644 index a15dd774e8..0000000000 --- a/docs/examples/get_ptr.output +++ /dev/null @@ -1,2 +0,0 @@ -17 17 17 17 -true diff --git a/docs/examples/get_ref.cpp b/docs/examples/get_ref.cpp deleted file mode 100644 index ab25946bb3..0000000000 --- a/docs/examples/get_ref.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON number - json value = 17; - - // explicitly getting references - auto r1 = value.get_ref(); - auto r2 = value.get_ref(); - - // print the values - std::cout << r1 << ' ' << r2 << '\n'; - - // incompatible type throws exception - try - { - auto r3 = value.get_ref(); - } - catch (json::type_error& ex) - { - std::cout << ex.what() << '\n'; - } -} diff --git a/docs/examples/get_ref.output b/docs/examples/get_ref.output deleted file mode 100644 index 3811afa2f4..0000000000 --- a/docs/examples/get_ref.output +++ /dev/null @@ -1,2 +0,0 @@ -17 17 -[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number diff --git a/docs/examples/get_to.cpp b/docs/examples/get_to.cpp deleted file mode 100644 index 4705b172f4..0000000000 --- a/docs/examples/get_to.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON value with different types - json json_types = - { - {"boolean", true}, - { - "number", { - {"integer", 42}, - {"floating-point", 17.23} - } - }, - {"string", "Hello, world!"}, - {"array", {1, 2, 3, 4, 5}}, - {"null", nullptr} - }; - - bool v1; - int v2; - short v3; - float v4; - int v5; - std::string v6; - std::vector v7; - std::unordered_map v8; - - - // use explicit conversions - json_types["boolean"].get_to(v1); - json_types["number"]["integer"].get_to(v2); - json_types["number"]["integer"].get_to(v3); - json_types["number"]["floating-point"].get_to(v4); - json_types["number"]["floating-point"].get_to(v5); - json_types["string"].get_to(v6); - json_types["array"].get_to(v7); - json_types.get_to(v8); - - // print the conversion results - std::cout << v1 << '\n'; - std::cout << v2 << ' ' << v3 << '\n'; - std::cout << v4 << ' ' << v5 << '\n'; - std::cout << v6 << '\n'; - - for (auto i : v7) - { - std::cout << i << ' '; - } - std::cout << "\n\n"; - - for (auto i : v8) - { - std::cout << i.first << ": " << i.second << '\n'; - } -} diff --git a/docs/examples/get_to.output b/docs/examples/get_to.output deleted file mode 100644 index 5cd9cd3aa8..0000000000 --- a/docs/examples/get_to.output +++ /dev/null @@ -1,11 +0,0 @@ -1 -42 42 -17.23 17 -Hello, world! -1 2 3 4 5 - -string: "Hello, world!" -number: {"floating-point":17.23,"integer":42} -null: null -boolean: true -array: [1,2,3,4,5] diff --git a/docs/examples/insert.cpp b/docs/examples/insert.cpp deleted file mode 100644 index 4ee609876a..0000000000 --- a/docs/examples/insert.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON array - json v = {1, 2, 3, 4}; - - // insert number 10 before number 3 - auto new_pos = v.insert(v.begin() + 2, 10); - - // output new array and result of insert call - std::cout << *new_pos << '\n'; - std::cout << v << '\n'; -} diff --git a/docs/examples/insert.output b/docs/examples/insert.output deleted file mode 100644 index ed5cab1d04..0000000000 --- a/docs/examples/insert.output +++ /dev/null @@ -1,2 +0,0 @@ -10 -[1,2,10,3,4] diff --git a/docs/examples/insert__count.cpp b/docs/examples/insert__count.cpp deleted file mode 100644 index ce33b93e42..0000000000 --- a/docs/examples/insert__count.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON array - json v = {1, 2, 3, 4}; - - // insert number 7 copies of number 7 before number 3 - auto new_pos = v.insert(v.begin() + 2, 7, 7); - - // output new array and result of insert call - std::cout << *new_pos << '\n'; - std::cout << v << '\n'; -} diff --git a/docs/examples/insert__count.output b/docs/examples/insert__count.output deleted file mode 100644 index 294685ac40..0000000000 --- a/docs/examples/insert__count.output +++ /dev/null @@ -1,2 +0,0 @@ -7 -[1,2,7,7,7,7,7,7,7,3,4] diff --git a/docs/examples/insert__ilist.cpp b/docs/examples/insert__ilist.cpp deleted file mode 100644 index a20766a140..0000000000 --- a/docs/examples/insert__ilist.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON array - json v = {1, 2, 3, 4}; - - // insert range from v2 before the end of array v - auto new_pos = v.insert(v.end(), {7, 8, 9}); - - // output new array and result of insert call - std::cout << *new_pos << '\n'; - std::cout << v << '\n'; -} diff --git a/docs/examples/insert__ilist.output b/docs/examples/insert__ilist.output deleted file mode 100644 index b2fc7eeb95..0000000000 --- a/docs/examples/insert__ilist.output +++ /dev/null @@ -1,2 +0,0 @@ -7 -[1,2,3,4,7,8,9] diff --git a/docs/examples/insert__range.cpp b/docs/examples/insert__range.cpp deleted file mode 100644 index 92fe63b0d7..0000000000 --- a/docs/examples/insert__range.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON array - json v = {1, 2, 3, 4}; - - // create a JSON array to copy values from - json v2 = {"one", "two", "three", "four"}; - - // insert range from v2 before the end of array v - auto new_pos = v.insert(v.end(), v2.begin(), v2.end()); - - // output new array and result of insert call - std::cout << *new_pos << '\n'; - std::cout << v << '\n'; -} diff --git a/docs/examples/insert__range.output b/docs/examples/insert__range.output deleted file mode 100644 index d50e9f63ae..0000000000 --- a/docs/examples/insert__range.output +++ /dev/null @@ -1,2 +0,0 @@ -"one" -[1,2,3,4,"one","two","three","four"] diff --git a/docs/examples/insert__range_object.cpp b/docs/examples/insert__range_object.cpp deleted file mode 100644 index 97373d3b4f..0000000000 --- a/docs/examples/insert__range_object.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create two JSON objects - json j1 = {{"one", "eins"}, {"two", "zwei"}}; - json j2 = {{"eleven", "elf"}, {"seventeen", "siebzehn"}}; - - // output objects - std::cout << j1 << '\n'; - std::cout << j2 << '\n'; - - // insert range from j2 to j1 - j1.insert(j2.begin(), j2.end()); - - // output result of insert call - std::cout << j1 << '\n'; -} diff --git a/docs/examples/insert__range_object.output b/docs/examples/insert__range_object.output deleted file mode 100644 index a5985158a4..0000000000 --- a/docs/examples/insert__range_object.output +++ /dev/null @@ -1,3 +0,0 @@ -{"one":"eins","two":"zwei"} -{"eleven":"elf","seventeen":"siebzehn"} -{"eleven":"elf","one":"eins","seventeen":"siebzehn","two":"zwei"} diff --git a/docs/examples/invalid_iterator.cpp b/docs/examples/invalid_iterator.cpp deleted file mode 100644 index 5d3e622e64..0000000000 --- a/docs/examples/invalid_iterator.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - try - { - // calling iterator::key() on non-object iterator - json j = "string"; - json::iterator it = j.begin(); - auto k = it.key(); - } - catch (json::invalid_iterator& e) - { - // output exception information - std::cout << "message: " << e.what() << '\n' - << "exception id: " << e.id << std::endl; - } -} diff --git a/docs/examples/invalid_iterator.output b/docs/examples/invalid_iterator.output deleted file mode 100644 index 8668c16d17..0000000000 --- a/docs/examples/invalid_iterator.output +++ /dev/null @@ -1,2 +0,0 @@ -message: [json.exception.invalid_iterator.207] cannot use key() for non-object iterators -exception id: 207 diff --git a/docs/examples/is_array.cpp b/docs/examples/is_array.cpp deleted file mode 100644 index 8ecc45035d..0000000000 --- a/docs/examples/is_array.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = 17; - json j_number_unsigned_integer = 12345678987654321u; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - json j_binary = json::binary({1, 2, 3}); - - // call is_array() - std::cout << std::boolalpha; - std::cout << j_null.is_array() << '\n'; - std::cout << j_boolean.is_array() << '\n'; - std::cout << j_number_integer.is_array() << '\n'; - std::cout << j_number_unsigned_integer.is_array() << '\n'; - std::cout << j_number_float.is_array() << '\n'; - std::cout << j_object.is_array() << '\n'; - std::cout << j_array.is_array() << '\n'; - std::cout << j_string.is_array() << '\n'; - std::cout << j_binary.is_array() << '\n'; -} diff --git a/docs/examples/is_array.output b/docs/examples/is_array.output deleted file mode 100644 index 7b7ef3f191..0000000000 --- a/docs/examples/is_array.output +++ /dev/null @@ -1,9 +0,0 @@ -false -false -false -false -false -false -true -false -false diff --git a/docs/examples/is_binary.cpp b/docs/examples/is_binary.cpp deleted file mode 100644 index d7f049ec46..0000000000 --- a/docs/examples/is_binary.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = 17; - json j_number_unsigned_integer = 12345678987654321u; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - json j_binary = json::binary({1, 2, 3}); - - // call is_binary() - std::cout << std::boolalpha; - std::cout << j_null.is_binary() << '\n'; - std::cout << j_boolean.is_binary() << '\n'; - std::cout << j_number_integer.is_binary() << '\n'; - std::cout << j_number_unsigned_integer.is_binary() << '\n'; - std::cout << j_number_float.is_binary() << '\n'; - std::cout << j_object.is_binary() << '\n'; - std::cout << j_array.is_binary() << '\n'; - std::cout << j_string.is_binary() << '\n'; - std::cout << j_binary.is_binary() << '\n'; -} diff --git a/docs/examples/is_binary.output b/docs/examples/is_binary.output deleted file mode 100644 index 505e76e4ff..0000000000 --- a/docs/examples/is_binary.output +++ /dev/null @@ -1,9 +0,0 @@ -false -false -false -false -false -false -false -false -true diff --git a/docs/examples/is_boolean.cpp b/docs/examples/is_boolean.cpp deleted file mode 100644 index 0b79819556..0000000000 --- a/docs/examples/is_boolean.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = 17; - json j_number_unsigned_integer = 12345678987654321u; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - json j_binary = json::binary({1, 2, 3}); - - // call is_boolean() - std::cout << std::boolalpha; - std::cout << j_null.is_boolean() << '\n'; - std::cout << j_boolean.is_boolean() << '\n'; - std::cout << j_number_integer.is_boolean() << '\n'; - std::cout << j_number_unsigned_integer.is_boolean() << '\n'; - std::cout << j_number_float.is_boolean() << '\n'; - std::cout << j_object.is_boolean() << '\n'; - std::cout << j_array.is_boolean() << '\n'; - std::cout << j_string.is_boolean() << '\n'; - std::cout << j_binary.is_boolean() << '\n'; -} diff --git a/docs/examples/is_boolean.output b/docs/examples/is_boolean.output deleted file mode 100644 index eace89d22e..0000000000 --- a/docs/examples/is_boolean.output +++ /dev/null @@ -1,9 +0,0 @@ -false -true -false -false -false -false -false -false -false diff --git a/docs/examples/is_discarded.cpp b/docs/examples/is_discarded.cpp deleted file mode 100644 index 09016655e0..0000000000 --- a/docs/examples/is_discarded.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = 17; - json j_number_unsigned_integer = 12345678987654321u; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - json j_binary = json::binary({1, 2, 3}); - - // call is_discarded() - std::cout << std::boolalpha; - std::cout << j_null.is_discarded() << '\n'; - std::cout << j_boolean.is_discarded() << '\n'; - std::cout << j_number_integer.is_discarded() << '\n'; - std::cout << j_number_unsigned_integer.is_discarded() << '\n'; - std::cout << j_number_float.is_discarded() << '\n'; - std::cout << j_object.is_discarded() << '\n'; - std::cout << j_array.is_discarded() << '\n'; - std::cout << j_string.is_discarded() << '\n'; - std::cout << j_binary.is_discarded() << '\n'; -} diff --git a/docs/examples/is_discarded.output b/docs/examples/is_discarded.output deleted file mode 100644 index 14718f64ea..0000000000 --- a/docs/examples/is_discarded.output +++ /dev/null @@ -1,9 +0,0 @@ -false -false -false -false -false -false -false -false -false diff --git a/docs/examples/is_null.cpp b/docs/examples/is_null.cpp deleted file mode 100644 index 8a8433260d..0000000000 --- a/docs/examples/is_null.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = 17; - json j_number_unsigned_integer = 12345678987654321u; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - json j_binary = json::binary({1, 2, 3}); - - // call is_null() - std::cout << std::boolalpha; - std::cout << j_null.is_null() << '\n'; - std::cout << j_boolean.is_null() << '\n'; - std::cout << j_number_integer.is_null() << '\n'; - std::cout << j_number_unsigned_integer.is_null() << '\n'; - std::cout << j_number_float.is_null() << '\n'; - std::cout << j_object.is_null() << '\n'; - std::cout << j_array.is_null() << '\n'; - std::cout << j_string.is_null() << '\n'; - std::cout << j_binary.is_null() << '\n'; -} diff --git a/docs/examples/is_null.output b/docs/examples/is_null.output deleted file mode 100644 index 42bbee2a79..0000000000 --- a/docs/examples/is_null.output +++ /dev/null @@ -1,9 +0,0 @@ -true -false -false -false -false -false -false -false -false diff --git a/docs/examples/is_number.cpp b/docs/examples/is_number.cpp deleted file mode 100644 index f107a048a3..0000000000 --- a/docs/examples/is_number.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = 17; - json j_number_unsigned_integer = 12345678987654321u; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - json j_binary = json::binary({1, 2, 3}); - - // call is_number() - std::cout << std::boolalpha; - std::cout << j_null.is_number() << '\n'; - std::cout << j_boolean.is_number() << '\n'; - std::cout << j_number_integer.is_number() << '\n'; - std::cout << j_number_unsigned_integer.is_number() << '\n'; - std::cout << j_number_float.is_number() << '\n'; - std::cout << j_object.is_number() << '\n'; - std::cout << j_array.is_number() << '\n'; - std::cout << j_string.is_number() << '\n'; - std::cout << j_binary.is_number() << '\n'; -} diff --git a/docs/examples/is_number.output b/docs/examples/is_number.output deleted file mode 100644 index 53ef340bb0..0000000000 --- a/docs/examples/is_number.output +++ /dev/null @@ -1,9 +0,0 @@ -false -false -true -true -true -false -false -false -false diff --git a/docs/examples/is_number_float.cpp b/docs/examples/is_number_float.cpp deleted file mode 100644 index bba2b446fb..0000000000 --- a/docs/examples/is_number_float.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = 17; - json j_number_unsigned_integer = 12345678987654321u; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - json j_binary = json::binary({1, 2, 3}); - - // call is_number_float() - std::cout << std::boolalpha; - std::cout << j_null.is_number_float() << '\n'; - std::cout << j_boolean.is_number_float() << '\n'; - std::cout << j_number_integer.is_number_float() << '\n'; - std::cout << j_number_unsigned_integer.is_number_float() << '\n'; - std::cout << j_number_float.is_number_float() << '\n'; - std::cout << j_object.is_number_float() << '\n'; - std::cout << j_array.is_number_float() << '\n'; - std::cout << j_string.is_number_float() << '\n'; - std::cout << j_binary.is_number_float() << '\n'; -} diff --git a/docs/examples/is_number_float.output b/docs/examples/is_number_float.output deleted file mode 100644 index 0e64601abd..0000000000 --- a/docs/examples/is_number_float.output +++ /dev/null @@ -1,9 +0,0 @@ -false -false -false -false -true -false -false -false -false diff --git a/docs/examples/is_number_integer.cpp b/docs/examples/is_number_integer.cpp deleted file mode 100644 index 8d6a5ae16d..0000000000 --- a/docs/examples/is_number_integer.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = 17; - json j_number_unsigned_integer = 12345678987654321u; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - json j_binary = json::binary({1, 2, 3}); - - // call is_number_integer() - std::cout << std::boolalpha; - std::cout << j_null.is_number_integer() << '\n'; - std::cout << j_boolean.is_number_integer() << '\n'; - std::cout << j_number_integer.is_number_integer() << '\n'; - std::cout << j_number_unsigned_integer.is_number_integer() << '\n'; - std::cout << j_number_float.is_number_integer() << '\n'; - std::cout << j_object.is_number_integer() << '\n'; - std::cout << j_array.is_number_integer() << '\n'; - std::cout << j_string.is_number_integer() << '\n'; - std::cout << j_binary.is_number_integer() << '\n'; -} diff --git a/docs/examples/is_number_integer.output b/docs/examples/is_number_integer.output deleted file mode 100644 index c1df310f4c..0000000000 --- a/docs/examples/is_number_integer.output +++ /dev/null @@ -1,9 +0,0 @@ -false -false -true -true -false -false -false -false -false diff --git a/docs/examples/is_number_unsigned.cpp b/docs/examples/is_number_unsigned.cpp deleted file mode 100644 index b52ac6b31c..0000000000 --- a/docs/examples/is_number_unsigned.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = 17; - json j_number_unsigned_integer = 12345678987654321u; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - json j_binary = json::binary({1, 2, 3}); - - // call is_number_unsigned() - std::cout << std::boolalpha; - std::cout << j_null.is_number_unsigned() << '\n'; - std::cout << j_boolean.is_number_unsigned() << '\n'; - std::cout << j_number_integer.is_number_unsigned() << '\n'; - std::cout << j_number_unsigned_integer.is_number_unsigned() << '\n'; - std::cout << j_number_float.is_number_unsigned() << '\n'; - std::cout << j_object.is_number_unsigned() << '\n'; - std::cout << j_array.is_number_unsigned() << '\n'; - std::cout << j_string.is_number_unsigned() << '\n'; - std::cout << j_binary.is_number_unsigned() << '\n'; -} diff --git a/docs/examples/is_number_unsigned.output b/docs/examples/is_number_unsigned.output deleted file mode 100644 index e6059d48fd..0000000000 --- a/docs/examples/is_number_unsigned.output +++ /dev/null @@ -1,9 +0,0 @@ -false -false -false -true -false -false -false -false -false diff --git a/docs/examples/is_object.cpp b/docs/examples/is_object.cpp deleted file mode 100644 index a0216fd210..0000000000 --- a/docs/examples/is_object.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = 17; - json j_number_float = 23.42; - json j_number_unsigned_integer = 12345678987654321u; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - json j_binary = json::binary({1, 2, 3}); - - // call is_object() - std::cout << std::boolalpha; - std::cout << j_null.is_object() << '\n'; - std::cout << j_boolean.is_object() << '\n'; - std::cout << j_number_integer.is_object() << '\n'; - std::cout << j_number_unsigned_integer.is_object() << '\n'; - std::cout << j_number_float.is_object() << '\n'; - std::cout << j_object.is_object() << '\n'; - std::cout << j_array.is_object() << '\n'; - std::cout << j_string.is_object() << '\n'; - std::cout << j_binary.is_object() << '\n'; -} diff --git a/docs/examples/is_object.output b/docs/examples/is_object.output deleted file mode 100644 index d9a429f8fd..0000000000 --- a/docs/examples/is_object.output +++ /dev/null @@ -1,9 +0,0 @@ -false -false -false -false -false -true -false -false -false diff --git a/docs/examples/is_primitive.cpp b/docs/examples/is_primitive.cpp deleted file mode 100644 index af3968e83b..0000000000 --- a/docs/examples/is_primitive.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = 17; - json j_number_float = 23.42; - json j_number_unsigned_integer = 12345678987654321u; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - json j_binary = json::binary({1, 2, 3}); - - // call is_primitive() - std::cout << std::boolalpha; - std::cout << j_null.is_primitive() << '\n'; - std::cout << j_boolean.is_primitive() << '\n'; - std::cout << j_number_integer.is_primitive() << '\n'; - std::cout << j_number_unsigned_integer.is_primitive() << '\n'; - std::cout << j_number_float.is_primitive() << '\n'; - std::cout << j_object.is_primitive() << '\n'; - std::cout << j_array.is_primitive() << '\n'; - std::cout << j_string.is_primitive() << '\n'; - std::cout << j_binary.is_primitive() << '\n'; -} diff --git a/docs/examples/is_primitive.output b/docs/examples/is_primitive.output deleted file mode 100644 index 77af24c009..0000000000 --- a/docs/examples/is_primitive.output +++ /dev/null @@ -1,9 +0,0 @@ -true -true -true -true -true -false -false -true -true diff --git a/docs/examples/is_string.cpp b/docs/examples/is_string.cpp deleted file mode 100644 index c89f550b06..0000000000 --- a/docs/examples/is_string.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = 17; - json j_number_float = 23.42; - json j_number_unsigned_integer = 12345678987654321u; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - json j_binary = json::binary({1, 2, 3}); - - // call is_string() - std::cout << std::boolalpha; - std::cout << j_null.is_string() << '\n'; - std::cout << j_boolean.is_string() << '\n'; - std::cout << j_number_integer.is_string() << '\n'; - std::cout << j_number_unsigned_integer.is_string() << '\n'; - std::cout << j_number_float.is_string() << '\n'; - std::cout << j_object.is_string() << '\n'; - std::cout << j_array.is_string() << '\n'; - std::cout << j_string.is_string() << '\n'; - std::cout << j_binary.is_string() << '\n'; -} diff --git a/docs/examples/is_string.output b/docs/examples/is_string.output deleted file mode 100644 index 6446f18784..0000000000 --- a/docs/examples/is_string.output +++ /dev/null @@ -1,9 +0,0 @@ -false -false -false -false -false -false -false -true -false diff --git a/docs/examples/is_structured.cpp b/docs/examples/is_structured.cpp deleted file mode 100644 index 41947b1be4..0000000000 --- a/docs/examples/is_structured.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = 17; - json j_number_float = 23.42; - json j_number_unsigned_integer = 12345678987654321u; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - json j_binary = json::binary({1, 2, 3}); - - // call is_structured() - std::cout << std::boolalpha; - std::cout << j_null.is_structured() << '\n'; - std::cout << j_boolean.is_structured() << '\n'; - std::cout << j_number_integer.is_structured() << '\n'; - std::cout << j_number_unsigned_integer.is_structured() << '\n'; - std::cout << j_number_float.is_structured() << '\n'; - std::cout << j_object.is_structured() << '\n'; - std::cout << j_array.is_structured() << '\n'; - std::cout << j_string.is_structured() << '\n'; - std::cout << j_binary.is_structured() << '\n'; -} diff --git a/docs/examples/is_structured.output b/docs/examples/is_structured.output deleted file mode 100644 index 625c124b52..0000000000 --- a/docs/examples/is_structured.output +++ /dev/null @@ -1,9 +0,0 @@ -false -false -false -false -false -true -true -false -false diff --git a/docs/examples/items.cpp b/docs/examples/items.cpp deleted file mode 100644 index 9cd2b51b17..0000000000 --- a/docs/examples/items.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - - // example for an object - for (auto& x : j_object.items()) - { - std::cout << "key: " << x.key() << ", value: " << x.value() << '\n'; - } - - // example for an array - for (auto& x : j_array.items()) - { - std::cout << "key: " << x.key() << ", value: " << x.value() << '\n'; - } -} diff --git a/docs/examples/items.output b/docs/examples/items.output deleted file mode 100644 index 89b09f5249..0000000000 --- a/docs/examples/items.output +++ /dev/null @@ -1,7 +0,0 @@ -key: one, value: 1 -key: two, value: 2 -key: 0, value: 1 -key: 1, value: 2 -key: 2, value: 4 -key: 3, value: 8 -key: 4, value: 16 diff --git a/docs/examples/json_base_class_t.cpp b/docs/examples/json_base_class_t.cpp deleted file mode 100644 index d993522a70..0000000000 --- a/docs/examples/json_base_class_t.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include -#include - -class visitor_adaptor_with_metadata -{ - public: - template - void visit(const Fnc& fnc) const; - - int metadata = 42; - private: - template - 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, - visitor_adaptor_with_metadata - >; - -template -void visitor_adaptor_with_metadata::visit(const Fnc& fnc) const -{ - do_visit(json::json_pointer{}, fnc); -} - -template -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(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'; - }); -} diff --git a/docs/examples/json_base_class_t.output b/docs/examples/json_base_class_t.output deleted file mode 100644 index 83ce1f693d..0000000000 --- a/docs/examples/json_base_class_t.output +++ /dev/null @@ -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 diff --git a/docs/examples/json_lines.cpp b/docs/examples/json_lines.cpp deleted file mode 100644 index 233c81a4a1..0000000000 --- a/docs/examples/json_lines.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // JSON Lines (see https://jsonlines.org) - std::stringstream input; - input << R"({"name": "Gilbert", "wins": [["straight", "7♣"], ["one pair", "10♥"]]} -{"name": "Alexa", "wins": [["two pair", "4♠"], ["two pair", "9♠"]]} -{"name": "May", "wins": []} -{"name": "Deloise", "wins": [["three of a kind", "5♣"]]} -)"; - - std::string line; - while (std::getline(input, line)) - { - std::cout << json::parse(line) << std::endl; - } -} diff --git a/docs/examples/json_lines.output b/docs/examples/json_lines.output deleted file mode 100644 index 1b4122480b..0000000000 --- a/docs/examples/json_lines.output +++ /dev/null @@ -1,4 +0,0 @@ -{"name":"Gilbert","wins":[["straight","7♣"],["one pair","10♥"]]} -{"name":"Alexa","wins":[["two pair","4♠"],["two pair","9♠"]]} -{"name":"May","wins":[]} -{"name":"Deloise","wins":[["three of a kind","5♣"]]} diff --git a/docs/examples/json_pointer.cpp b/docs/examples/json_pointer.cpp deleted file mode 100644 index 75b9717584..0000000000 --- a/docs/examples/json_pointer.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // correct JSON pointers - json::json_pointer p1; - json::json_pointer p2(""); - json::json_pointer p3("/"); - json::json_pointer p4("//"); - json::json_pointer p5("/foo/bar"); - json::json_pointer p6("/foo/bar/-"); - json::json_pointer p7("/foo/~0"); - json::json_pointer p8("/foo/~1"); - - // error: JSON pointer does not begin with a slash - try - { - json::json_pointer p9("foo"); - } - catch (json::parse_error& e) - { - std::cout << e.what() << '\n'; - } - - // error: JSON pointer uses escape symbol ~ not followed by 0 or 1 - try - { - json::json_pointer p10("/foo/~"); - } - catch (json::parse_error& e) - { - std::cout << e.what() << '\n'; - } - - // error: JSON pointer uses escape symbol ~ not followed by 0 or 1 - try - { - json::json_pointer p11("/foo/~3"); - } - catch (json::parse_error& e) - { - std::cout << e.what() << '\n'; - } -} diff --git a/docs/examples/json_pointer.output b/docs/examples/json_pointer.output deleted file mode 100644 index 9e027d6dcc..0000000000 --- a/docs/examples/json_pointer.output +++ /dev/null @@ -1,3 +0,0 @@ -[json.exception.parse_error.107] parse error at byte 1: JSON pointer must be empty or begin with '/' - was: 'foo' -[json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1' -[json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1' diff --git a/docs/examples/json_pointer__back.cpp b/docs/examples/json_pointer__back.cpp deleted file mode 100644 index dd3b210bf1..0000000000 --- a/docs/examples/json_pointer__back.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // different JSON Pointers - json::json_pointer ptr1("/foo"); - json::json_pointer ptr2("/foo/0"); - - // call empty() - std::cout << "last reference token of \"" << ptr1 << "\" is \"" << ptr1.back() << "\"\n" - << "last reference token of \"" << ptr2 << "\" is \"" << ptr2.back() << "\"" << std::endl; -} diff --git a/docs/examples/json_pointer__back.output b/docs/examples/json_pointer__back.output deleted file mode 100644 index a89357b49b..0000000000 --- a/docs/examples/json_pointer__back.output +++ /dev/null @@ -1,2 +0,0 @@ -last reference token of "/foo" is "foo" -last reference token of "/foo/0" is "0" diff --git a/docs/examples/json_pointer__empty.cpp b/docs/examples/json_pointer__empty.cpp deleted file mode 100644 index 57257e8b16..0000000000 --- a/docs/examples/json_pointer__empty.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // different JSON Pointers - json::json_pointer ptr0; - json::json_pointer ptr1(""); - json::json_pointer ptr2("/foo"); - json::json_pointer ptr3("/foo/0"); - - // call empty() - std::cout << std::boolalpha - << "\"" << ptr0 << "\": " << ptr0.empty() << '\n' - << "\"" << ptr1 << "\": " << ptr1.empty() << '\n' - << "\"" << ptr2 << "\": " << ptr2.empty() << '\n' - << "\"" << ptr3 << "\": " << ptr3.empty() << std::endl; -} diff --git a/docs/examples/json_pointer__empty.output b/docs/examples/json_pointer__empty.output deleted file mode 100644 index a7ee49c173..0000000000 --- a/docs/examples/json_pointer__empty.output +++ /dev/null @@ -1,4 +0,0 @@ -"": true -"": true -"/foo": false -"/foo/0": false diff --git a/docs/examples/json_pointer__operator__equal.cpp b/docs/examples/json_pointer__operator__equal.cpp deleted file mode 100644 index dce6df03c3..0000000000 --- a/docs/examples/json_pointer__operator__equal.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // different JSON pointers - json::json_pointer ptr0; - json::json_pointer ptr1(""); - json::json_pointer ptr2("/foo"); - - // compare JSON pointers - std::cout << std::boolalpha - << "\"" << ptr0 << "\" == \"" << ptr0 << "\": " << (ptr0 == ptr0) << '\n' - << "\"" << ptr0 << "\" == \"" << ptr1 << "\": " << (ptr0 == ptr1) << '\n' - << "\"" << ptr1 << "\" == \"" << ptr2 << "\": " << (ptr1 == ptr2) << '\n' - << "\"" << ptr2 << "\" == \"" << ptr2 << "\": " << (ptr2 == ptr2) << std::endl; -} diff --git a/docs/examples/json_pointer__operator__equal.output b/docs/examples/json_pointer__operator__equal.output deleted file mode 100644 index 9a76125808..0000000000 --- a/docs/examples/json_pointer__operator__equal.output +++ /dev/null @@ -1,4 +0,0 @@ -"" == "": true -"" == "": true -"" == "/foo": false -"/foo" == "/foo": true diff --git a/docs/examples/json_pointer__operator__equal_stringtype.cpp b/docs/examples/json_pointer__operator__equal_stringtype.cpp deleted file mode 100644 index af8ec5a29c..0000000000 --- a/docs/examples/json_pointer__operator__equal_stringtype.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // different JSON pointers - json::json_pointer ptr0; - json::json_pointer ptr1(""); - json::json_pointer ptr2("/foo"); - - // different strings - std::string str0(""); - std::string str1("/foo"); - std::string str2("bar"); - - // compare JSON pointers and strings - std::cout << std::boolalpha - << "\"" << ptr0 << "\" == \"" << str0 << "\": " << (ptr0 == str0) << '\n' - << "\"" << str0 << "\" == \"" << ptr1 << "\": " << (str0 == ptr1) << '\n' - << "\"" << ptr2 << "\" == \"" << str1 << "\": " << (ptr2 == str1) << std::endl; - - try - { - std::cout << "\"" << str2 << "\" == \"" << ptr2 << "\": " << (str2 == ptr2) << std::endl; - } - catch (const json::parse_error& ex) - { - std::cout << ex.what() << std::endl; - } -} diff --git a/docs/examples/json_pointer__operator__equal_stringtype.output b/docs/examples/json_pointer__operator__equal_stringtype.output deleted file mode 100644 index 7fb299d3d8..0000000000 --- a/docs/examples/json_pointer__operator__equal_stringtype.output +++ /dev/null @@ -1,4 +0,0 @@ -"" == "": true -"" == "": true -"/foo" == "/foo": true -"bar" == "/foo": [json.exception.parse_error.107] parse error at byte 1: JSON pointer must be empty or begin with '/' - was: 'bar' diff --git a/docs/examples/json_pointer__operator__notequal.cpp b/docs/examples/json_pointer__operator__notequal.cpp deleted file mode 100644 index 9bbdd53107..0000000000 --- a/docs/examples/json_pointer__operator__notequal.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // different JSON pointers - json::json_pointer ptr0; - json::json_pointer ptr1(""); - json::json_pointer ptr2("/foo"); - - // compare JSON pointers - std::cout << std::boolalpha - << "\"" << ptr0 << "\" != \"" << ptr0 << "\": " << (ptr0 != ptr0) << '\n' - << "\"" << ptr0 << "\" != \"" << ptr1 << "\": " << (ptr0 != ptr1) << '\n' - << "\"" << ptr1 << "\" != \"" << ptr2 << "\": " << (ptr1 != ptr2) << '\n' - << "\"" << ptr2 << "\" != \"" << ptr2 << "\": " << (ptr2 != ptr2) << std::endl; -} diff --git a/docs/examples/json_pointer__operator__notequal.output b/docs/examples/json_pointer__operator__notequal.output deleted file mode 100644 index de891f0c6d..0000000000 --- a/docs/examples/json_pointer__operator__notequal.output +++ /dev/null @@ -1,4 +0,0 @@ -"" != "": false -"" != "": false -"" != "/foo": true -"/foo" != "/foo": false diff --git a/docs/examples/json_pointer__operator__notequal_stringtype.cpp b/docs/examples/json_pointer__operator__notequal_stringtype.cpp deleted file mode 100644 index b9b8987282..0000000000 --- a/docs/examples/json_pointer__operator__notequal_stringtype.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // different JSON pointers - json::json_pointer ptr0; - json::json_pointer ptr1(""); - json::json_pointer ptr2("/foo"); - - // different strings - std::string str0(""); - std::string str1("/foo"); - std::string str2("bar"); - - // compare JSON pointers and strings - std::cout << std::boolalpha - << "\"" << ptr0 << "\" != \"" << str0 << "\": " << (ptr0 != str0) << '\n' - << "\"" << str0 << "\" != \"" << ptr1 << "\": " << (str0 != ptr1) << '\n' - << "\"" << ptr2 << "\" != \"" << str1 << "\": " << (ptr2 != str1) << std::endl; - - try - { - std::cout << "\"" << str2 << "\" != \"" << ptr2 << "\": " << (str2 != ptr2) << std::endl; - } - catch (const json::parse_error& ex) - { - std::cout << ex.what() << std::endl; - } -} diff --git a/docs/examples/json_pointer__operator__notequal_stringtype.output b/docs/examples/json_pointer__operator__notequal_stringtype.output deleted file mode 100644 index 61331b7524..0000000000 --- a/docs/examples/json_pointer__operator__notequal_stringtype.output +++ /dev/null @@ -1,4 +0,0 @@ -"" != "": false -"" != "": false -"/foo" != "/foo": false -"bar" != "/foo": [json.exception.parse_error.107] parse error at byte 1: JSON pointer must be empty or begin with '/' - was: 'bar' diff --git a/docs/examples/json_pointer__operator_add.cpp b/docs/examples/json_pointer__operator_add.cpp deleted file mode 100644 index 14bd74561c..0000000000 --- a/docs/examples/json_pointer__operator_add.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON pointer - json::json_pointer ptr("/foo"); - std::cout << "\"" << ptr << "\"\n"; - - // append a JSON Pointer - ptr /= json::json_pointer("/bar/baz"); - std::cout << "\"" << ptr << "\"\n"; - - // append a string - ptr /= "fob"; - std::cout << "\"" << ptr << "\"\n"; - - // append an array index - ptr /= 42; - std::cout << "\"" << ptr << "\"" << std::endl; -} diff --git a/docs/examples/json_pointer__operator_add.output b/docs/examples/json_pointer__operator_add.output deleted file mode 100644 index ae13afe27c..0000000000 --- a/docs/examples/json_pointer__operator_add.output +++ /dev/null @@ -1,4 +0,0 @@ -"/foo" -"/foo/bar/baz" -"/foo/bar/baz/fob" -"/foo/bar/baz/fob/42" diff --git a/docs/examples/json_pointer__operator_add_binary.cpp b/docs/examples/json_pointer__operator_add_binary.cpp deleted file mode 100644 index d26a0d1714..0000000000 --- a/docs/examples/json_pointer__operator_add_binary.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON pointer - json::json_pointer ptr("/foo"); - - // append a JSON Pointer - std::cout << "\"" << ptr / json::json_pointer("/bar/baz") << "\"\n"; - - // append a string - std::cout << "\"" << ptr / "fob" << "\"\n"; - - // append an array index - std::cout << "\"" << ptr / 42 << "\"" << std::endl; -} diff --git a/docs/examples/json_pointer__operator_add_binary.output b/docs/examples/json_pointer__operator_add_binary.output deleted file mode 100644 index 7536042c02..0000000000 --- a/docs/examples/json_pointer__operator_add_binary.output +++ /dev/null @@ -1,3 +0,0 @@ -"/foo/bar/baz" -"/foo/fob" -"/foo/42" diff --git a/docs/examples/json_pointer__operator_string_t.cpp b/docs/examples/json_pointer__operator_string_t.cpp deleted file mode 100644 index 56f2130205..0000000000 --- a/docs/examples/json_pointer__operator_string_t.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // different JSON Pointers - json::json_pointer ptr1("/foo/0"); - json::json_pointer ptr2("/a~1b"); - - // implicit conversion to string - std::string s; - s += ptr1; - s += "\n"; - s += ptr2; - - std::cout << s << std::endl; -} diff --git a/docs/examples/json_pointer__operator_string_t.output b/docs/examples/json_pointer__operator_string_t.output deleted file mode 100644 index ec6aba2c2e..0000000000 --- a/docs/examples/json_pointer__operator_string_t.output +++ /dev/null @@ -1,2 +0,0 @@ -/foo/0 -/a~1b diff --git a/docs/examples/json_pointer__parent_pointer.cpp b/docs/examples/json_pointer__parent_pointer.cpp deleted file mode 100644 index ef9df4534a..0000000000 --- a/docs/examples/json_pointer__parent_pointer.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // different JSON Pointers - json::json_pointer ptr1(""); - json::json_pointer ptr2("/foo"); - json::json_pointer ptr3("/foo/0"); - - // call parent_pointer() - std::cout << std::boolalpha - << "parent of \"" << ptr1 << "\" is \"" << ptr1.parent_pointer() << "\"\n" - << "parent of \"" << ptr2 << "\" is \"" << ptr2.parent_pointer() << "\"\n" - << "parent of \"" << ptr3 << "\" is \"" << ptr3.parent_pointer() << "\"" << std::endl; -} diff --git a/docs/examples/json_pointer__parent_pointer.output b/docs/examples/json_pointer__parent_pointer.output deleted file mode 100644 index 4cc6f3f1bc..0000000000 --- a/docs/examples/json_pointer__parent_pointer.output +++ /dev/null @@ -1,3 +0,0 @@ -parent of "" is "" -parent of "/foo" is "" -parent of "/foo/0" is "/foo" diff --git a/docs/examples/json_pointer__pop_back.cpp b/docs/examples/json_pointer__pop_back.cpp deleted file mode 100644 index fd077b7e9d..0000000000 --- a/docs/examples/json_pointer__pop_back.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create empty JSON Pointer - json::json_pointer ptr("/foo/bar/baz"); - std::cout << "\"" << ptr << "\"\n"; - - // call pop_back() - ptr.pop_back(); - std::cout << "\"" << ptr << "\"\n"; - - ptr.pop_back(); - std::cout << "\"" << ptr << "\"\n"; - - ptr.pop_back(); - std::cout << "\"" << ptr << "\"\n"; -} diff --git a/docs/examples/json_pointer__pop_back.output b/docs/examples/json_pointer__pop_back.output deleted file mode 100644 index b0468dc51b..0000000000 --- a/docs/examples/json_pointer__pop_back.output +++ /dev/null @@ -1,4 +0,0 @@ -"/foo/bar/baz" -"/foo/bar" -"/foo" -"" diff --git a/docs/examples/json_pointer__push_back.cpp b/docs/examples/json_pointer__push_back.cpp deleted file mode 100644 index e6b59a1251..0000000000 --- a/docs/examples/json_pointer__push_back.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create empty JSON Pointer - json::json_pointer ptr; - std::cout << "\"" << ptr << "\"\n"; - - // call push_back() - ptr.push_back("foo"); - std::cout << "\"" << ptr << "\"\n"; - - ptr.push_back("0"); - std::cout << "\"" << ptr << "\"\n"; - - ptr.push_back("bar"); - std::cout << "\"" << ptr << "\"\n"; -} diff --git a/docs/examples/json_pointer__push_back.output b/docs/examples/json_pointer__push_back.output deleted file mode 100644 index 92c019cd36..0000000000 --- a/docs/examples/json_pointer__push_back.output +++ /dev/null @@ -1,4 +0,0 @@ -"" -"/foo" -"/foo/0" -"/foo/0/bar" diff --git a/docs/examples/json_pointer__string_t.cpp b/docs/examples/json_pointer__string_t.cpp deleted file mode 100644 index fbe0f179e8..0000000000 --- a/docs/examples/json_pointer__string_t.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - json::json_pointer::string_t s = "This is a string."; - - std::cout << s << std::endl; - - std::cout << std::boolalpha << std::is_same::value << std::endl; -} diff --git a/docs/examples/json_pointer__string_t.output b/docs/examples/json_pointer__string_t.output deleted file mode 100644 index d87113724a..0000000000 --- a/docs/examples/json_pointer__string_t.output +++ /dev/null @@ -1,2 +0,0 @@ -This is a string. -true diff --git a/docs/examples/json_pointer__to_string.cpp b/docs/examples/json_pointer__to_string.cpp deleted file mode 100644 index 31d35a724a..0000000000 --- a/docs/examples/json_pointer__to_string.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // different JSON Pointers - json::json_pointer ptr1(""); - json::json_pointer ptr2("/foo"); - json::json_pointer ptr3("/foo/0"); - json::json_pointer ptr4("/"); - json::json_pointer ptr5("/a~1b"); - json::json_pointer ptr6("/c%d"); - json::json_pointer ptr7("/e^f"); - json::json_pointer ptr8("/g|h"); - json::json_pointer ptr9("/i\\j"); - json::json_pointer ptr10("/k\"l"); - json::json_pointer ptr11("/ "); - json::json_pointer ptr12("/m~0n"); - - std::cout << "\"" << ptr1.to_string() << "\"\n" - << "\"" << ptr2.to_string() << "\"\n" - << "\"" << ptr3.to_string() << "\"\n" - << "\"" << ptr4.to_string() << "\"\n" - << "\"" << ptr5.to_string() << "\"\n" - << "\"" << ptr6.to_string() << "\"\n" - << "\"" << ptr7.to_string() << "\"\n" - << "\"" << ptr8.to_string() << "\"\n" - << "\"" << ptr9.to_string() << "\"\n" - << "\"" << ptr10.to_string() << "\"\n" - << "\"" << ptr11.to_string() << "\"\n" - << "\"" << ptr12.to_string() << "\"" << std::endl; -} diff --git a/docs/examples/json_pointer__to_string.output b/docs/examples/json_pointer__to_string.output deleted file mode 100644 index 3c441357e8..0000000000 --- a/docs/examples/json_pointer__to_string.output +++ /dev/null @@ -1,12 +0,0 @@ -"" -"/foo" -"/foo/0" -"/" -"/a~1b" -"/c%d" -"/e^f" -"/g|h" -"/i\j" -"/k"l" -"/ " -"/m~0n" diff --git a/docs/examples/max_size.cpp b/docs/examples/max_size.cpp deleted file mode 100644 index c2ffc54680..0000000000 --- a/docs/examples/max_size.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = 17; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - - // call max_size() - std::cout << j_null.max_size() << '\n'; - std::cout << j_boolean.max_size() << '\n'; - std::cout << j_number_integer.max_size() << '\n'; - std::cout << j_number_float.max_size() << '\n'; - std::cout << j_object.max_size() << '\n'; - std::cout << j_array.max_size() << '\n'; - std::cout << j_string.max_size() << '\n'; -} diff --git a/docs/examples/max_size.output b/docs/examples/max_size.output deleted file mode 100644 index b8dcb4d0cb..0000000000 --- a/docs/examples/max_size.output +++ /dev/null @@ -1,7 +0,0 @@ -0 -1 -1 -1 -115292150460684697 -576460752303423487 -1 diff --git a/docs/examples/merge_patch.cpp b/docs/examples/merge_patch.cpp deleted file mode 100644 index f3fee1ed1b..0000000000 --- a/docs/examples/merge_patch.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include -#include // for std::setw - -using json = nlohmann::json; -using namespace nlohmann::literals; - -int main() -{ - // the original document - json document = R"({ - "title": "Goodbye!", - "author": { - "givenName": "John", - "familyName": "Doe" - }, - "tags": [ - "example", - "sample" - ], - "content": "This will be unchanged" - })"_json; - - // the patch - json patch = R"({ - "title": "Hello!", - "phoneNumber": "+01-123-456-7890", - "author": { - "familyName": null - }, - "tags": [ - "example" - ] - })"_json; - - // apply the patch - document.merge_patch(patch); - - // output original and patched document - std::cout << std::setw(4) << document << std::endl; -} diff --git a/docs/examples/merge_patch.output b/docs/examples/merge_patch.output deleted file mode 100644 index 96adb7b3b4..0000000000 --- a/docs/examples/merge_patch.output +++ /dev/null @@ -1,11 +0,0 @@ -{ - "author": { - "givenName": "John" - }, - "content": "This will be unchanged", - "phoneNumber": "+01-123-456-7890", - "tags": [ - "example" - ], - "title": "Hello!" -} diff --git a/docs/examples/meta.cpp b/docs/examples/meta.cpp deleted file mode 100644 index a051575ba4..0000000000 --- a/docs/examples/meta.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // call meta() - std::cout << std::setw(4) << json::meta() << '\n'; -} diff --git a/docs/examples/meta.output b/docs/examples/meta.output deleted file mode 100644 index 9ceb5e201a..0000000000 --- a/docs/examples/meta.output +++ /dev/null @@ -1,17 +0,0 @@ -{ - "compiler": { - "c++": "201103", - "family": "gcc", - "version": "12.1.0" - }, - "copyright": "(C) 2013-2022 Niels Lohmann", - "name": "JSON for Modern C++", - "platform": "apple", - "url": "https://github.com/nlohmann/json", - "version": { - "major": 3, - "minor": 11, - "patch": 2, - "string": "3.11.2" - } -} diff --git a/docs/examples/nlohmann_define_type_intrusive_explicit.cpp b/docs/examples/nlohmann_define_type_intrusive_explicit.cpp deleted file mode 100644 index f2d6812cb0..0000000000 --- a/docs/examples/nlohmann_define_type_intrusive_explicit.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include - -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: - person() = default; - 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; - } - - friend void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t) - { - nlohmann_json_t.name = nlohmann_json_j.at("name"); - nlohmann_json_t.address = nlohmann_json_j.at("address"); - nlohmann_json_t.age = nlohmann_json_j.at("age"); - } -}; -} // namespace ns - -int main() -{ - ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; - - // serialization: person -> json - json j = p; - std::cout << "serialization: " << j << std::endl; - - // deserialization: json -> person - json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; - auto p2 = j2.template get(); - - // incomplete deserialization: - json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; - try - { - auto p3 = j3.template get(); - } - catch (json::exception& e) - { - std::cout << "deserialization failed: " << e.what() << std::endl; - } -} diff --git a/docs/examples/nlohmann_define_type_intrusive_explicit.output b/docs/examples/nlohmann_define_type_intrusive_explicit.output deleted file mode 100644 index 37f4eb4141..0000000000 --- a/docs/examples/nlohmann_define_type_intrusive_explicit.output +++ /dev/null @@ -1,2 +0,0 @@ -serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} -deserialization failed: [json.exception.out_of_range.403] key 'age' not found diff --git a/docs/examples/nlohmann_define_type_intrusive_macro.cpp b/docs/examples/nlohmann_define_type_intrusive_macro.cpp deleted file mode 100644 index 9c020689b8..0000000000 --- a/docs/examples/nlohmann_define_type_intrusive_macro.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include - -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: - person() = default; - 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; - - // deserialization: json -> person - json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; - auto p2 = j2.template get(); - - // incomplete deserialization: - json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; - try - { - auto p3 = j3.template get(); - } - catch (json::exception& e) - { - std::cout << "deserialization failed: " << e.what() << std::endl; - } -} diff --git a/docs/examples/nlohmann_define_type_intrusive_macro.output b/docs/examples/nlohmann_define_type_intrusive_macro.output deleted file mode 100644 index 37f4eb4141..0000000000 --- a/docs/examples/nlohmann_define_type_intrusive_macro.output +++ /dev/null @@ -1,2 +0,0 @@ -serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} -deserialization failed: [json.exception.out_of_range.403] key 'age' not found diff --git a/docs/examples/nlohmann_define_type_intrusive_with_default_explicit.cpp b/docs/examples/nlohmann_define_type_intrusive_with_default_explicit.cpp deleted file mode 100644 index 0fb2e1cb21..0000000000 --- a/docs/examples/nlohmann_define_type_intrusive_with_default_explicit.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include -#include - -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: - person() = default; - 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; - } - - friend void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t) - { - person nlohmann_json_default_obj; - nlohmann_json_t.name = nlohmann_json_j.value("name", nlohmann_json_default_obj.name); - nlohmann_json_t.address = nlohmann_json_j.value("address", nlohmann_json_default_obj.address); - nlohmann_json_t.age = nlohmann_json_j.value("age", nlohmann_json_default_obj.age); - } -}; -} // namespace ns - -int main() -{ - ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; - - // serialization: person -> json - json j = p; - std::cout << "serialization: " << j << std::endl; - - // deserialization: json -> person - json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; - auto p2 = j2.template get(); - - // incomplete deserialization: - json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; - auto p3 = j3.template get(); - std::cout << "roundtrip: " << json(p3) << std::endl; -} diff --git a/docs/examples/nlohmann_define_type_intrusive_with_default_explicit.output b/docs/examples/nlohmann_define_type_intrusive_with_default_explicit.output deleted file mode 100644 index 1a255f65c6..0000000000 --- a/docs/examples/nlohmann_define_type_intrusive_with_default_explicit.output +++ /dev/null @@ -1,2 +0,0 @@ -serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} -roundtrip: {"address":"742 Evergreen Terrace","age":-1,"name":"Maggie Simpson"} diff --git a/docs/examples/nlohmann_define_type_intrusive_with_default_macro.cpp b/docs/examples/nlohmann_define_type_intrusive_with_default_macro.cpp deleted file mode 100644 index 52668516b5..0000000000 --- a/docs/examples/nlohmann_define_type_intrusive_with_default_macro.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include - -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: - person() = default; - person(std::string name_, std::string address_, int age_) - : name(std::move(name_)), address(std::move(address_)), age(age_) - {} - - NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(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; - - // deserialization: json -> person - json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; - auto p2 = j2.template get(); - - // incomplete deserialization: - json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; - auto p3 = j3.template get(); - std::cout << "roundtrip: " << json(p3) << std::endl; -} diff --git a/docs/examples/nlohmann_define_type_intrusive_with_default_macro.output b/docs/examples/nlohmann_define_type_intrusive_with_default_macro.output deleted file mode 100644 index 1a255f65c6..0000000000 --- a/docs/examples/nlohmann_define_type_intrusive_with_default_macro.output +++ /dev/null @@ -1,2 +0,0 @@ -serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} -roundtrip: {"address":"742 Evergreen Terrace","age":-1,"name":"Maggie Simpson"} diff --git a/docs/examples/nlohmann_define_type_non_intrusive_explicit.cpp b/docs/examples/nlohmann_define_type_non_intrusive_explicit.cpp deleted file mode 100644 index b3040adc61..0000000000 --- a/docs/examples/nlohmann_define_type_non_intrusive_explicit.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include - -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; -} - -void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t) -{ - nlohmann_json_t.name = nlohmann_json_j.at("name"); - nlohmann_json_t.address = nlohmann_json_j.at("address"); - nlohmann_json_t.age = nlohmann_json_j.at("age"); -} -} // namespace ns - -int main() -{ - ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; - - // serialization: person -> json - json j = p; - std::cout << "serialization: " << j << std::endl; - - // deserialization: json -> person - json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; - auto p2 = j2.template get(); - - // incomplete deserialization: - json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; - try - { - auto p3 = j3.template get(); - } - catch (json::exception& e) - { - std::cout << "deserialization failed: " << e.what() << std::endl; - } -} diff --git a/docs/examples/nlohmann_define_type_non_intrusive_explicit.output b/docs/examples/nlohmann_define_type_non_intrusive_explicit.output deleted file mode 100644 index 37f4eb4141..0000000000 --- a/docs/examples/nlohmann_define_type_non_intrusive_explicit.output +++ /dev/null @@ -1,2 +0,0 @@ -serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} -deserialization failed: [json.exception.out_of_range.403] key 'age' not found diff --git a/docs/examples/nlohmann_define_type_non_intrusive_macro.cpp b/docs/examples/nlohmann_define_type_non_intrusive_macro.cpp deleted file mode 100644 index 2c76830d82..0000000000 --- a/docs/examples/nlohmann_define_type_non_intrusive_macro.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include - -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(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; - - // deserialization: json -> person - json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; - auto p2 = j2.template get(); - - // incomplete deserialization: - json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; - try - { - auto p3 = j3.template get(); - } - catch (json::exception& e) - { - std::cout << "deserialization failed: " << e.what() << std::endl; - } -} diff --git a/docs/examples/nlohmann_define_type_non_intrusive_macro.output b/docs/examples/nlohmann_define_type_non_intrusive_macro.output deleted file mode 100644 index 37f4eb4141..0000000000 --- a/docs/examples/nlohmann_define_type_non_intrusive_macro.output +++ /dev/null @@ -1,2 +0,0 @@ -serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} -deserialization failed: [json.exception.out_of_range.403] key 'age' not found diff --git a/docs/examples/nlohmann_define_type_non_intrusive_with_default_explicit.cpp b/docs/examples/nlohmann_define_type_non_intrusive_with_default_explicit.cpp deleted file mode 100644 index 855ab52b85..0000000000 --- a/docs/examples/nlohmann_define_type_non_intrusive_with_default_explicit.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -namespace ns -{ -struct person -{ - std::string name = "John Doe"; - std::string address = "123 Fake St"; - int age = -1; - - person() = default; - person(std::string name_, std::string address_, int age_) - : name(std::move(name_)), address(std::move(address_)), age(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; -} - -void from_json(const nlohmann::json& nlohmann_json_j, person& nlohmann_json_t) -{ - person nlohmann_json_default_obj; - nlohmann_json_t.name = nlohmann_json_j.value("name", nlohmann_json_default_obj.name); - nlohmann_json_t.address = nlohmann_json_j.value("address", nlohmann_json_default_obj.address); - nlohmann_json_t.age = nlohmann_json_j.value("age", nlohmann_json_default_obj.age); -} -} // namespace ns - -int main() -{ - ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; - - // serialization: person -> json - json j = p; - std::cout << "serialization: " << j << std::endl; - - // deserialization: json -> person - json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; - auto p2 = j2.template get(); - - // incomplete deserialization: - json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; - auto p3 = j3.template get(); - std::cout << "roundtrip: " << json(p3) << std::endl; -} diff --git a/docs/examples/nlohmann_define_type_non_intrusive_with_default_explicit.output b/docs/examples/nlohmann_define_type_non_intrusive_with_default_explicit.output deleted file mode 100644 index 1a255f65c6..0000000000 --- a/docs/examples/nlohmann_define_type_non_intrusive_with_default_explicit.output +++ /dev/null @@ -1,2 +0,0 @@ -serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} -roundtrip: {"address":"742 Evergreen Terrace","age":-1,"name":"Maggie Simpson"} diff --git a/docs/examples/nlohmann_define_type_non_intrusive_with_default_macro.cpp b/docs/examples/nlohmann_define_type_non_intrusive_with_default_macro.cpp deleted file mode 100644 index 8c41c65ecd..0000000000 --- a/docs/examples/nlohmann_define_type_non_intrusive_with_default_macro.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -namespace ns -{ -struct person -{ - std::string name = "John Doe"; - std::string address = "123 Fake St"; - int age = -1; - - person() = default; - person(std::string name_, std::string address_, int age_) - : name(std::move(name_)), address(std::move(address_)), age(age_) - {} -}; - -NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(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; - - // deserialization: json -> person - json j2 = R"({"address": "742 Evergreen Terrace", "age": 40, "name": "Homer Simpson"})"_json; - auto p2 = j2.template get(); - - // incomplete deserialization: - json j3 = R"({"address": "742 Evergreen Terrace", "name": "Maggie Simpson"})"_json; - auto p3 = j3.template get(); - std::cout << "roundtrip: " << json(p3) << std::endl; -} diff --git a/docs/examples/nlohmann_define_type_non_intrusive_with_default_macro.output b/docs/examples/nlohmann_define_type_non_intrusive_with_default_macro.output deleted file mode 100644 index 1a255f65c6..0000000000 --- a/docs/examples/nlohmann_define_type_non_intrusive_with_default_macro.output +++ /dev/null @@ -1,2 +0,0 @@ -serialization: {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} -roundtrip: {"address":"742 Evergreen Terrace","age":-1,"name":"Maggie Simpson"} diff --git a/docs/examples/nlohmann_json_namespace.cpp b/docs/examples/nlohmann_json_namespace.cpp deleted file mode 100644 index 4bad91f4be..0000000000 --- a/docs/examples/nlohmann_json_namespace.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include - -// possible use case: use NLOHMANN_JSON_NAMESPACE instead of nlohmann -using json = NLOHMANN_JSON_NAMESPACE::json; - -// macro needed to output the NLOHMANN_JSON_NAMESPACE as string literal -#define Q(x) #x -#define QUOTE(x) Q(x) - -int main() -{ - std::cout << QUOTE(NLOHMANN_JSON_NAMESPACE) << std::endl; -} diff --git a/docs/examples/nlohmann_json_namespace.output b/docs/examples/nlohmann_json_namespace.output deleted file mode 100644 index 1a1df5a3d2..0000000000 --- a/docs/examples/nlohmann_json_namespace.output +++ /dev/null @@ -1 +0,0 @@ -nlohmann::json_abi_v3_11_2 diff --git a/docs/examples/nlohmann_json_namespace_begin.c++17.cpp b/docs/examples/nlohmann_json_namespace_begin.c++17.cpp deleted file mode 100644 index 9385d593d5..0000000000 --- a/docs/examples/nlohmann_json_namespace_begin.c++17.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include - -// partial specialization (see https://json.nlohmann.me/features/arbitrary_types/) -NLOHMANN_JSON_NAMESPACE_BEGIN -template -struct adl_serializer> -{ - static void to_json(json& j, const std::optional& opt) - { - if (opt == std::nullopt) - { - j = nullptr; - } - else - { - j = *opt; - } - } -}; -NLOHMANN_JSON_NAMESPACE_END - -int main() -{ - std::optional o1 = 1; - std::optional o2 = std::nullopt; - - NLOHMANN_JSON_NAMESPACE::json j; - j.push_back(o1); - j.push_back(o2); - std::cout << j << std::endl; -} diff --git a/docs/examples/nlohmann_json_namespace_begin.c++17.output b/docs/examples/nlohmann_json_namespace_begin.c++17.output deleted file mode 100644 index b29d3b93ca..0000000000 --- a/docs/examples/nlohmann_json_namespace_begin.c++17.output +++ /dev/null @@ -1 +0,0 @@ -[1,null] diff --git a/docs/examples/nlohmann_json_namespace_no_version.cpp b/docs/examples/nlohmann_json_namespace_no_version.cpp deleted file mode 100644 index 97948dd7e1..0000000000 --- a/docs/examples/nlohmann_json_namespace_no_version.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include - -#define NLOHMANN_JSON_NAMESPACE_NO_VERSION 1 -#include - -// macro needed to output the NLOHMANN_JSON_NAMESPACE as string literal -#define Q(x) #x -#define QUOTE(x) Q(x) - -int main() -{ - std::cout << QUOTE(NLOHMANN_JSON_NAMESPACE) << std::endl; -} diff --git a/docs/examples/nlohmann_json_namespace_no_version.output b/docs/examples/nlohmann_json_namespace_no_version.output deleted file mode 100644 index 1c8f3132bb..0000000000 --- a/docs/examples/nlohmann_json_namespace_no_version.output +++ /dev/null @@ -1 +0,0 @@ -nlohmann::json_abi diff --git a/docs/examples/nlohmann_json_serialize_enum.cpp b/docs/examples/nlohmann_json_serialize_enum.cpp deleted file mode 100644 index a40db49eaa..0000000000 --- a/docs/examples/nlohmann_json_serialize_enum.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -namespace ns -{ -enum TaskState -{ - TS_STOPPED, - TS_RUNNING, - TS_COMPLETED, - TS_INVALID = -1 -}; - -NLOHMANN_JSON_SERIALIZE_ENUM(TaskState, -{ - { TS_INVALID, nullptr }, - { TS_STOPPED, "stopped" }, - { TS_RUNNING, "running" }, - { TS_COMPLETED, "completed" } -}) - -enum class Color -{ - red, green, blue, unknown -}; - -NLOHMANN_JSON_SERIALIZE_ENUM(Color, -{ - { Color::unknown, "unknown" }, { Color::red, "red" }, - { Color::green, "green" }, { Color::blue, "blue" } -}) -} // namespace ns - -int main() -{ - // serialization - json j_stopped = ns::TS_STOPPED; - json j_red = ns::Color::red; - std::cout << "ns::TS_STOPPED -> " << j_stopped - << ", ns::Color::red -> " << j_red << std::endl; - - // deserialization - json j_running = "running"; - json j_blue = "blue"; - auto running = j_running.template get(); - auto blue = j_blue.template get(); - std::cout << j_running << " -> " << running - << ", " << j_blue << " -> " << static_cast(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(); - auto unknown = j_pi.template get(); - std::cout << j_pi << " -> " << invalid << ", " - << j_pi << " -> " << static_cast(unknown) << std::endl; -} diff --git a/docs/examples/nlohmann_json_serialize_enum.output b/docs/examples/nlohmann_json_serialize_enum.output deleted file mode 100644 index f512563dda..0000000000 --- a/docs/examples/nlohmann_json_serialize_enum.output +++ /dev/null @@ -1,3 +0,0 @@ -ns::TS_STOPPED -> "stopped", ns::Color::red -> "red" -"running" -> 1, "blue" -> 2 -3.14 -> -1, 3.14 -> 3 diff --git a/docs/examples/nlohmann_json_serialize_enum_2.cpp b/docs/examples/nlohmann_json_serialize_enum_2.cpp deleted file mode 100644 index b35e94cc56..0000000000 --- a/docs/examples/nlohmann_json_serialize_enum_2.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -namespace ns -{ -enum class Color -{ - red, green, blue, unknown -}; - -NLOHMANN_JSON_SERIALIZE_ENUM(Color, -{ - { Color::unknown, "unknown" }, { Color::red, "red" }, - { Color::green, "green" }, { Color::blue, "blue" }, - { Color::red, "rot" } // a second conversion for Color::red -}) -} - -int main() -{ - // serialization - json j_red = ns::Color::red; - std::cout << static_cast(ns::Color::red) << " -> " << j_red << std::endl; - - // deserialization - json j_rot = "rot"; - auto rot = j_rot.template get(); - auto red = j_red.template get(); - std::cout << j_rot << " -> " << static_cast(rot) << std::endl; - std::cout << j_red << " -> " << static_cast(red) << std::endl; -} diff --git a/docs/examples/nlohmann_json_serialize_enum_2.output b/docs/examples/nlohmann_json_serialize_enum_2.output deleted file mode 100644 index 5dec31b4ad..0000000000 --- a/docs/examples/nlohmann_json_serialize_enum_2.output +++ /dev/null @@ -1,3 +0,0 @@ -0 -> "red" -"rot" -> 0 -"red" -> 0 diff --git a/docs/examples/nlohmann_json_version.cpp b/docs/examples/nlohmann_json_version.cpp deleted file mode 100644 index ca5f53728a..0000000000 --- a/docs/examples/nlohmann_json_version.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - std::cout << "JSON for Modern C++ version " - << NLOHMANN_JSON_VERSION_MAJOR << "." - << NLOHMANN_JSON_VERSION_MINOR << "." - << NLOHMANN_JSON_VERSION_PATCH << std::endl; -} diff --git a/docs/examples/nlohmann_json_version.output b/docs/examples/nlohmann_json_version.output deleted file mode 100644 index 043b9b234e..0000000000 --- a/docs/examples/nlohmann_json_version.output +++ /dev/null @@ -1 +0,0 @@ -JSON for Modern C++ version 3.11.2 diff --git a/docs/examples/number_float_t.cpp b/docs/examples/number_float_t.cpp deleted file mode 100644 index 21211dc51d..0000000000 --- a/docs/examples/number_float_t.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - std::cout << std::boolalpha << std::is_same::value << std::endl; -} diff --git a/docs/examples/number_float_t.output b/docs/examples/number_float_t.output deleted file mode 100644 index 27ba77ddaf..0000000000 --- a/docs/examples/number_float_t.output +++ /dev/null @@ -1 +0,0 @@ -true diff --git a/docs/examples/number_integer_t.cpp b/docs/examples/number_integer_t.cpp deleted file mode 100644 index 75ee57b63e..0000000000 --- a/docs/examples/number_integer_t.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - std::cout << std::boolalpha << std::is_same::value << std::endl; -} diff --git a/docs/examples/number_integer_t.output b/docs/examples/number_integer_t.output deleted file mode 100644 index 27ba77ddaf..0000000000 --- a/docs/examples/number_integer_t.output +++ /dev/null @@ -1 +0,0 @@ -true diff --git a/docs/examples/number_unsigned_t.cpp b/docs/examples/number_unsigned_t.cpp deleted file mode 100644 index ff3b86df80..0000000000 --- a/docs/examples/number_unsigned_t.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - std::cout << std::boolalpha << std::is_same::value << std::endl; -} diff --git a/docs/examples/number_unsigned_t.output b/docs/examples/number_unsigned_t.output deleted file mode 100644 index 27ba77ddaf..0000000000 --- a/docs/examples/number_unsigned_t.output +++ /dev/null @@ -1 +0,0 @@ -true diff --git a/docs/examples/object.cpp b/docs/examples/object.cpp deleted file mode 100644 index 733b89b530..0000000000 --- a/docs/examples/object.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON objects - json j_no_init_list = json::object(); - json j_empty_init_list = json::object({}); - json j_list_of_pairs = json::object({ {"one", 1}, {"two", 2} }); - - // serialize the JSON objects - std::cout << j_no_init_list << '\n'; - std::cout << j_empty_init_list << '\n'; - std::cout << j_list_of_pairs << '\n'; - - // example for an exception - try - { - // can only create an object from a list of pairs - json j_invalid_object = json::object({{ "one", 1, 2 }}); - } - catch (json::type_error& e) - { - std::cout << e.what() << '\n'; - } -} diff --git a/docs/examples/object.output b/docs/examples/object.output deleted file mode 100644 index 1a1d8140e0..0000000000 --- a/docs/examples/object.output +++ /dev/null @@ -1,4 +0,0 @@ -{} -{} -{"one":1,"two":2} -[json.exception.type_error.301] cannot create object from initializer list diff --git a/docs/examples/object_comparator_t.cpp b/docs/examples/object_comparator_t.cpp deleted file mode 100644 index 6b82c7ca61..0000000000 --- a/docs/examples/object_comparator_t.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - std::cout << std::boolalpha - << "json::object_comparator_t(\"one\", \"two\") = " << json::object_comparator_t{}("one", "two") << "\n" - << "json::object_comparator_t(\"three\", \"four\") = " << json::object_comparator_t{}("three", "four") << std::endl; -} diff --git a/docs/examples/object_comparator_t.output b/docs/examples/object_comparator_t.output deleted file mode 100644 index 63620edb43..0000000000 --- a/docs/examples/object_comparator_t.output +++ /dev/null @@ -1,2 +0,0 @@ -json::object_comparator_t("one", "two") = true -json::object_comparator_t("three", "four") = false diff --git a/docs/examples/object_t.cpp b/docs/examples/object_t.cpp deleted file mode 100644 index 85cfa3e33f..0000000000 --- a/docs/examples/object_t.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - std::cout << std::boolalpha << std::is_same, json::object_t>::value << std::endl; -} diff --git a/docs/examples/object_t.output b/docs/examples/object_t.output deleted file mode 100644 index 27ba77ddaf..0000000000 --- a/docs/examples/object_t.output +++ /dev/null @@ -1 +0,0 @@ -true diff --git a/docs/examples/operator__ValueType.cpp b/docs/examples/operator__ValueType.cpp deleted file mode 100644 index 66fcf310e5..0000000000 --- a/docs/examples/operator__ValueType.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON value with different types - json json_types = - { - {"boolean", true}, - { - "number", { - {"integer", 42}, - {"floating-point", 17.23} - } - }, - {"string", "Hello, world!"}, - {"array", {1, 2, 3, 4, 5}}, - {"null", nullptr} - }; - - // use implicit conversions - bool v1 = json_types["boolean"]; - int v2 = json_types["number"]["integer"]; - short v3 = json_types["number"]["integer"]; - float v4 = json_types["number"]["floating-point"]; - int v5 = json_types["number"]["floating-point"]; - std::string v6 = json_types["string"]; - std::vector v7 = json_types["array"]; - std::unordered_map v8 = json_types; - - // print the conversion results - std::cout << v1 << '\n'; - std::cout << v2 << ' ' << v3 << '\n'; - std::cout << v4 << ' ' << v5 << '\n'; - std::cout << v6 << '\n'; - - for (auto i : v7) - { - std::cout << i << ' '; - } - std::cout << "\n\n"; - - for (auto i : v8) - { - std::cout << i.first << ": " << i.second << '\n'; - } - - // example for an exception - try - { - bool v1 = json_types["string"]; - } - catch (json::type_error& e) - { - std::cout << e.what() << '\n'; - } -} diff --git a/docs/examples/operator__ValueType.output b/docs/examples/operator__ValueType.output deleted file mode 100644 index a3bd9fff4a..0000000000 --- a/docs/examples/operator__ValueType.output +++ /dev/null @@ -1,12 +0,0 @@ -1 -42 42 -17.23 17 -Hello, world! -1 2 3 4 5 - -string: "Hello, world!" -number: {"floating-point":17.23,"integer":42} -null: null -boolean: true -array: [1,2,3,4,5] -[json.exception.type_error.302] type must be boolean, but is string diff --git a/docs/examples/operator__equal.cpp b/docs/examples/operator__equal.cpp deleted file mode 100644 index 1426f489aa..0000000000 --- a/docs/examples/operator__equal.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create several JSON values - json array_1 = {1, 2, 3}; - json array_2 = {1, 2, 4}; - json object_1 = {{"A", "a"}, {"B", "b"}}; - json object_2 = {{"B", "b"}, {"A", "a"}}; - json number_1 = 17; - json number_2 = 17.000000000000001L; - json string_1 = "foo"; - json string_2 = "bar"; - - // output values and comparisons - std::cout << std::boolalpha; - std::cout << array_1 << " == " << array_2 << " " << (array_1 == array_2) << '\n'; - std::cout << object_1 << " == " << object_2 << " " << (object_1 == object_2) << '\n'; - std::cout << number_1 << " == " << number_2 << " " << (number_1 == number_2) << '\n'; - std::cout << string_1 << " == " << string_2 << " " << (string_1 == string_2) << '\n'; -} diff --git a/docs/examples/operator__equal.output b/docs/examples/operator__equal.output deleted file mode 100644 index 780673556c..0000000000 --- a/docs/examples/operator__equal.output +++ /dev/null @@ -1,4 +0,0 @@ -[1,2,3] == [1,2,4] false -{"A":"a","B":"b"} == {"A":"a","B":"b"} true -17 == 17.0 true -"foo" == "bar" false diff --git a/docs/examples/operator__equal__nullptr_t.cpp b/docs/examples/operator__equal__nullptr_t.cpp deleted file mode 100644 index dbb2103723..0000000000 --- a/docs/examples/operator__equal__nullptr_t.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create several JSON values - json array = {1, 2, 3}; - json object = {{"A", "a"}, {"B", "b"}}; - json number = 17; - json string = "foo"; - json null; - - // output values and comparisons - std::cout << std::boolalpha; - std::cout << array << " == nullptr " << (array == nullptr) << '\n'; - std::cout << object << " == nullptr " << (object == nullptr) << '\n'; - std::cout << number << " == nullptr " << (number == nullptr) << '\n'; - std::cout << string << " == nullptr " << (string == nullptr) << '\n'; - std::cout << null << " == nullptr " << (null == nullptr) << '\n'; -} diff --git a/docs/examples/operator__equal__nullptr_t.output b/docs/examples/operator__equal__nullptr_t.output deleted file mode 100644 index b7128e13d7..0000000000 --- a/docs/examples/operator__equal__nullptr_t.output +++ /dev/null @@ -1,5 +0,0 @@ -[1,2,3] == nullptr false -{"A":"a","B":"b"} == nullptr false -17 == nullptr false -"foo" == nullptr false -null == nullptr true diff --git a/docs/examples/operator__equal__specializations.cpp b/docs/examples/operator__equal__specializations.cpp deleted file mode 100644 index 97d5ecead3..0000000000 --- a/docs/examples/operator__equal__specializations.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - nlohmann::json uj1 = {{"version", 1}, {"type", "integer"}}; - nlohmann::json uj2 = {{"type", "integer"}, {"version", 1}}; - - nlohmann::ordered_json oj1 = {{"version", 1}, {"type", "integer"}}; - nlohmann::ordered_json oj2 = {{"type", "integer"}, {"version", 1}}; - - std::cout << std::boolalpha << (uj1 == uj2) << '\n' << (oj1 == oj2) << std::endl; -} diff --git a/docs/examples/operator__equal__specializations.output b/docs/examples/operator__equal__specializations.output deleted file mode 100644 index da29283aaa..0000000000 --- a/docs/examples/operator__equal__specializations.output +++ /dev/null @@ -1,2 +0,0 @@ -true -false diff --git a/docs/examples/operator__greater.cpp b/docs/examples/operator__greater.cpp deleted file mode 100644 index 65bb9c0497..0000000000 --- a/docs/examples/operator__greater.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create several JSON values - json array_1 = {1, 2, 3}; - json array_2 = {1, 2, 4}; - json object_1 = {{"A", "a"}, {"B", "b"}}; - json object_2 = {{"B", "b"}, {"A", "a"}}; - json number_1 = 17; - json number_2 = 17.0000000000001L; - json string_1 = "foo"; - json string_2 = "bar"; - - // output values and comparisons - std::cout << std::boolalpha; - std::cout << array_1 << " > " << array_2 << " " << (array_1 > array_2) << '\n'; - std::cout << object_1 << " > " << object_2 << " " << (object_1 > object_2) << '\n'; - std::cout << number_1 << " > " << number_2 << " " << (number_1 > number_2) << '\n'; - std::cout << string_1 << " > " << string_2 << " " << (string_1 > string_2) << '\n'; -} diff --git a/docs/examples/operator__greater.output b/docs/examples/operator__greater.output deleted file mode 100644 index 910c48e3e8..0000000000 --- a/docs/examples/operator__greater.output +++ /dev/null @@ -1,4 +0,0 @@ -[1,2,3] > [1,2,4] false -{"A":"a","B":"b"} > {"A":"a","B":"b"} false -17 > 17.0000000000001 false -"foo" > "bar" true diff --git a/docs/examples/operator__greaterequal.cpp b/docs/examples/operator__greaterequal.cpp deleted file mode 100644 index f8659ee07e..0000000000 --- a/docs/examples/operator__greaterequal.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create several JSON values - json array_1 = {1, 2, 3}; - json array_2 = {1, 2, 4}; - json object_1 = {{"A", "a"}, {"B", "b"}}; - json object_2 = {{"B", "b"}, {"A", "a"}}; - json number_1 = 17; - json number_2 = 17.0000000000001L; - json string_1 = "foo"; - json string_2 = "bar"; - - // output values and comparisons - std::cout << std::boolalpha; - std::cout << array_1 << " >= " << array_2 << " " << (array_1 >= array_2) << '\n'; - std::cout << object_1 << " >= " << object_2 << " " << (object_1 >= object_2) << '\n'; - std::cout << number_1 << " >= " << number_2 << " " << (number_1 >= number_2) << '\n'; - std::cout << string_1 << " >= " << string_2 << " " << (string_1 >= string_2) << '\n'; -} diff --git a/docs/examples/operator__greaterequal.output b/docs/examples/operator__greaterequal.output deleted file mode 100644 index c7b91514e2..0000000000 --- a/docs/examples/operator__greaterequal.output +++ /dev/null @@ -1,4 +0,0 @@ -[1,2,3] >= [1,2,4] false -{"A":"a","B":"b"} >= {"A":"a","B":"b"} true -17 >= 17.0000000000001 false -"foo" >= "bar" true diff --git a/docs/examples/operator__less.cpp b/docs/examples/operator__less.cpp deleted file mode 100644 index 64209a22a2..0000000000 --- a/docs/examples/operator__less.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create several JSON values - json array_1 = {1, 2, 3}; - json array_2 = {1, 2, 4}; - json object_1 = {{"A", "a"}, {"B", "b"}}; - json object_2 = {{"B", "b"}, {"A", "a"}}; - json number_1 = 17; - json number_2 = 17.0000000000001L; - json string_1 = "foo"; - json string_2 = "bar"; - - // output values and comparisons - std::cout << std::boolalpha; - std::cout << array_1 << " == " << array_2 << " " << (array_1 < array_2) << '\n'; - std::cout << object_1 << " == " << object_2 << " " << (object_1 < object_2) << '\n'; - std::cout << number_1 << " == " << number_2 << " " << (number_1 < number_2) << '\n'; - std::cout << string_1 << " == " << string_2 << " " << (string_1 < string_2) << '\n'; -} diff --git a/docs/examples/operator__less.output b/docs/examples/operator__less.output deleted file mode 100644 index abbbc455e8..0000000000 --- a/docs/examples/operator__less.output +++ /dev/null @@ -1,4 +0,0 @@ -[1,2,3] == [1,2,4] true -{"A":"a","B":"b"} == {"A":"a","B":"b"} false -17 == 17.0000000000001 true -"foo" == "bar" false diff --git a/docs/examples/operator__lessequal.cpp b/docs/examples/operator__lessequal.cpp deleted file mode 100644 index 543b9543f1..0000000000 --- a/docs/examples/operator__lessequal.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create several JSON values - json array_1 = {1, 2, 3}; - json array_2 = {1, 2, 4}; - json object_1 = {{"A", "a"}, {"B", "b"}}; - json object_2 = {{"B", "b"}, {"A", "a"}}; - json number_1 = 17; - json number_2 = 17.0000000000001L; - json string_1 = "foo"; - json string_2 = "bar"; - - // output values and comparisons - std::cout << std::boolalpha; - std::cout << array_1 << " <= " << array_2 << " " << (array_1 <= array_2) << '\n'; - std::cout << object_1 << " <= " << object_2 << " " << (object_1 <= object_2) << '\n'; - std::cout << number_1 << " <= " << number_2 << " " << (number_1 <= number_2) << '\n'; - std::cout << string_1 << " <= " << string_2 << " " << (string_1 <= string_2) << '\n'; -} diff --git a/docs/examples/operator__lessequal.output b/docs/examples/operator__lessequal.output deleted file mode 100644 index f7f0327ec8..0000000000 --- a/docs/examples/operator__lessequal.output +++ /dev/null @@ -1,4 +0,0 @@ -[1,2,3] <= [1,2,4] true -{"A":"a","B":"b"} <= {"A":"a","B":"b"} true -17 <= 17.0000000000001 true -"foo" <= "bar" false diff --git a/docs/examples/operator__notequal.cpp b/docs/examples/operator__notequal.cpp deleted file mode 100644 index 43e89509ce..0000000000 --- a/docs/examples/operator__notequal.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create several JSON values - json array_1 = {1, 2, 3}; - json array_2 = {1, 2, 4}; - json object_1 = {{"A", "a"}, {"B", "b"}}; - json object_2 = {{"B", "b"}, {"A", "a"}}; - json number_1 = 17; - json number_2 = 17.000000000000001L; - json string_1 = "foo"; - json string_2 = "bar"; - - // output values and comparisons - std::cout << std::boolalpha; - std::cout << array_1 << " != " << array_2 << " " << (array_1 != array_2) << '\n'; - std::cout << object_1 << " != " << object_2 << " " << (object_1 != object_2) << '\n'; - std::cout << number_1 << " != " << number_2 << " " << (number_1 != number_2) << '\n'; - std::cout << string_1 << " != " << string_2 << " " << (string_1 != string_2) << '\n'; -} diff --git a/docs/examples/operator__notequal.output b/docs/examples/operator__notequal.output deleted file mode 100644 index 6cbc0e8e6b..0000000000 --- a/docs/examples/operator__notequal.output +++ /dev/null @@ -1,4 +0,0 @@ -[1,2,3] != [1,2,4] true -{"A":"a","B":"b"} != {"A":"a","B":"b"} false -17 != 17.0 false -"foo" != "bar" true diff --git a/docs/examples/operator__notequal__nullptr_t.cpp b/docs/examples/operator__notequal__nullptr_t.cpp deleted file mode 100644 index dc7e6ac4c3..0000000000 --- a/docs/examples/operator__notequal__nullptr_t.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create several JSON values - json array = {1, 2, 3}; - json object = {{"A", "a"}, {"B", "b"}}; - json number = 17; - json string = "foo"; - json null; - - // output values and comparisons - std::cout << std::boolalpha; - std::cout << array << " != nullptr " << (array != nullptr) << '\n'; - std::cout << object << " != nullptr " << (object != nullptr) << '\n'; - std::cout << number << " != nullptr " << (number != nullptr) << '\n'; - std::cout << string << " != nullptr " << (string != nullptr) << '\n'; - std::cout << null << " != nullptr " << (null != nullptr) << '\n'; -} diff --git a/docs/examples/operator__notequal__nullptr_t.output b/docs/examples/operator__notequal__nullptr_t.output deleted file mode 100644 index 0fc36dcf59..0000000000 --- a/docs/examples/operator__notequal__nullptr_t.output +++ /dev/null @@ -1,5 +0,0 @@ -[1,2,3] != nullptr true -{"A":"a","B":"b"} != nullptr true -17 != nullptr true -"foo" != nullptr true -null != nullptr false diff --git a/docs/examples/operator__value_t.cpp b/docs/examples/operator__value_t.cpp deleted file mode 100644 index d9aac7978e..0000000000 --- a/docs/examples/operator__value_t.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = -17; - json j_number_unsigned = 42u; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - - // call operator value_t() - json::value_t t_null = j_null; - json::value_t t_boolean = j_boolean; - json::value_t t_number_integer = j_number_integer; - json::value_t t_number_unsigned = j_number_unsigned; - json::value_t t_number_float = j_number_float; - json::value_t t_object = j_object; - json::value_t t_array = j_array; - json::value_t t_string = j_string; - - // print types - std::cout << std::boolalpha; - std::cout << (t_null == json::value_t::null) << '\n'; - std::cout << (t_boolean == json::value_t::boolean) << '\n'; - std::cout << (t_number_integer == json::value_t::number_integer) << '\n'; - std::cout << (t_number_unsigned == json::value_t::number_unsigned) << '\n'; - std::cout << (t_number_float == json::value_t::number_float) << '\n'; - std::cout << (t_object == json::value_t::object) << '\n'; - std::cout << (t_array == json::value_t::array) << '\n'; - std::cout << (t_string == json::value_t::string) << '\n'; -} diff --git a/docs/examples/operator__value_t.output b/docs/examples/operator__value_t.output deleted file mode 100644 index 310e632aa8..0000000000 --- a/docs/examples/operator__value_t.output +++ /dev/null @@ -1,8 +0,0 @@ -true -true -true -true -true -true -true -true diff --git a/docs/examples/operator_array__json_pointer.cpp b/docs/examples/operator_array__json_pointer.cpp deleted file mode 100644 index 0fa207f026..0000000000 --- a/docs/examples/operator_array__json_pointer.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -int main() -{ - // create a JSON value - json j = - { - {"number", 1}, {"string", "foo"}, {"array", {1, 2}} - }; - - // read-only access - - // output element with JSON pointer "/number" - std::cout << j["/number"_json_pointer] << '\n'; - // output element with JSON pointer "/string" - std::cout << j["/string"_json_pointer] << '\n'; - // output element with JSON pointer "/array" - std::cout << j["/array"_json_pointer] << '\n'; - // output element with JSON pointer "/array/1" - std::cout << j["/array/1"_json_pointer] << '\n'; - - // writing access - - // change the string - j["/string"_json_pointer] = "bar"; - // output the changed string - std::cout << j["string"] << '\n'; - - // "change" a nonexisting object entry - j["/boolean"_json_pointer] = true; - // output the changed object - std::cout << j << '\n'; - - // change an array element - j["/array/1"_json_pointer] = 21; - // "change" an array element with nonexisting index - j["/array/4"_json_pointer] = 44; - // output the changed array - std::cout << j["array"] << '\n'; - - // "change" the array element past the end - j["/array/-"_json_pointer] = 55; - // output the changed array - std::cout << j["array"] << '\n'; -} diff --git a/docs/examples/operator_array__json_pointer.output b/docs/examples/operator_array__json_pointer.output deleted file mode 100644 index 1fd1b032d1..0000000000 --- a/docs/examples/operator_array__json_pointer.output +++ /dev/null @@ -1,8 +0,0 @@ -1 -"foo" -[1,2] -2 -"bar" -{"array":[1,2],"boolean":true,"number":1,"string":"bar"} -[1,21,null,null,44] -[1,21,null,null,44,55] diff --git a/docs/examples/operator_array__json_pointer_const.cpp b/docs/examples/operator_array__json_pointer_const.cpp deleted file mode 100644 index f40e2494a7..0000000000 --- a/docs/examples/operator_array__json_pointer_const.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -int main() -{ - // create a JSON value - const json j = - { - {"number", 1}, {"string", "foo"}, {"array", {1, 2}} - }; - - // read-only access - - // output element with JSON pointer "/number" - std::cout << j["/number"_json_pointer] << '\n'; - // output element with JSON pointer "/string" - std::cout << j["/string"_json_pointer] << '\n'; - // output element with JSON pointer "/array" - std::cout << j["/array"_json_pointer] << '\n'; - // output element with JSON pointer "/array/1" - std::cout << j["/array/1"_json_pointer] << '\n'; -} diff --git a/docs/examples/operator_array__json_pointer_const.output b/docs/examples/operator_array__json_pointer_const.output deleted file mode 100644 index 7b9306bbc8..0000000000 --- a/docs/examples/operator_array__json_pointer_const.output +++ /dev/null @@ -1,4 +0,0 @@ -1 -"foo" -[1,2] -2 diff --git a/docs/examples/operator_array__keytype.c++17.cpp b/docs/examples/operator_array__keytype.c++17.cpp deleted file mode 100644 index 7f2b41dd84..0000000000 --- a/docs/examples/operator_array__keytype.c++17.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include -#include -#include - -using namespace std::string_view_literals; -using json = nlohmann::json; - -int main() -{ - // create a JSON object - json object = - { - {"one", 1}, {"two", 2}, {"three", 2.9} - }; - - // output element with key "two" - std::cout << object["two"sv] << "\n\n"; - - // change element with key "three" - object["three"sv] = 3; - - // output changed array - std::cout << std::setw(4) << object << "\n\n"; - - // mention nonexisting key - object["four"sv]; - - // write to nonexisting key - object["five"sv]["really"sv]["nested"sv] = true; - - // output changed object - std::cout << std::setw(4) << object << '\n'; -} diff --git a/docs/examples/operator_array__keytype.c++17.output b/docs/examples/operator_array__keytype.c++17.output deleted file mode 100644 index b643587f16..0000000000 --- a/docs/examples/operator_array__keytype.c++17.output +++ /dev/null @@ -1,19 +0,0 @@ -2 - -{ - "one": 1, - "three": 3, - "two": 2 -} - -{ - "five": { - "really": { - "nested": true - } - }, - "four": null, - "one": 1, - "three": 3, - "two": 2 -} diff --git a/docs/examples/operator_array__keytype_const.c++17.cpp b/docs/examples/operator_array__keytype_const.c++17.cpp deleted file mode 100644 index 2cf94f40fc..0000000000 --- a/docs/examples/operator_array__keytype_const.c++17.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include -#include - -using namespace std::string_view_literals; -using json = nlohmann::json; - -int main() -{ - // create a JSON object - const json object = - { - {"one", 1}, {"two", 2}, {"three", 2.9} - }; - - // output element with key "two" - std::cout << object["two"sv] << '\n'; -} diff --git a/docs/examples/operator_array__keytype_const.c++17.output b/docs/examples/operator_array__keytype_const.c++17.output deleted file mode 100644 index 0cfbf08886..0000000000 --- a/docs/examples/operator_array__keytype_const.c++17.output +++ /dev/null @@ -1 +0,0 @@ -2 diff --git a/docs/examples/operator_array__object_t_key_type.cpp b/docs/examples/operator_array__object_t_key_type.cpp deleted file mode 100644 index f9b7f73180..0000000000 --- a/docs/examples/operator_array__object_t_key_type.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON object - json object = - { - {"one", 1}, {"two", 2}, {"three", 2.9} - }; - - // output element with key "two" - std::cout << object["two"] << "\n\n"; - - // change element with key "three" - object["three"] = 3; - - // output changed array - std::cout << std::setw(4) << object << "\n\n"; - - // mention nonexisting key - object["four"]; - - // write to nonexisting key - object["five"]["really"]["nested"] = true; - - // output changed object - std::cout << std::setw(4) << object << '\n'; -} diff --git a/docs/examples/operator_array__object_t_key_type.output b/docs/examples/operator_array__object_t_key_type.output deleted file mode 100644 index b643587f16..0000000000 --- a/docs/examples/operator_array__object_t_key_type.output +++ /dev/null @@ -1,19 +0,0 @@ -2 - -{ - "one": 1, - "three": 3, - "two": 2 -} - -{ - "five": { - "really": { - "nested": true - } - }, - "four": null, - "one": 1, - "three": 3, - "two": 2 -} diff --git a/docs/examples/operator_array__object_t_key_type_const.cpp b/docs/examples/operator_array__object_t_key_type_const.cpp deleted file mode 100644 index 1bdb340248..0000000000 --- a/docs/examples/operator_array__object_t_key_type_const.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON object - const json object = - { - {"one", 1}, {"two", 2}, {"three", 2.9} - }; - - // output element with key "two" - std::cout << object["two"] << '\n'; -} diff --git a/docs/examples/operator_array__object_t_key_type_const.output b/docs/examples/operator_array__object_t_key_type_const.output deleted file mode 100644 index 0cfbf08886..0000000000 --- a/docs/examples/operator_array__object_t_key_type_const.output +++ /dev/null @@ -1 +0,0 @@ -2 diff --git a/docs/examples/operator_array__size_type.cpp b/docs/examples/operator_array__size_type.cpp deleted file mode 100644 index d6f3e153c6..0000000000 --- a/docs/examples/operator_array__size_type.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON array - json array = {1, 2, 3, 4, 5}; - - // output element at index 3 (fourth element) - std::cout << array[3] << '\n'; - - // change last element to 6 - array[array.size() - 1] = 6; - - // output changed array - std::cout << array << '\n'; - - // write beyond array limit - array[10] = 11; - - // output changed array - std::cout << array << '\n'; -} diff --git a/docs/examples/operator_array__size_type.output b/docs/examples/operator_array__size_type.output deleted file mode 100644 index a91a106982..0000000000 --- a/docs/examples/operator_array__size_type.output +++ /dev/null @@ -1,3 +0,0 @@ -4 -[1,2,3,4,6] -[1,2,3,4,6,null,null,null,null,null,11] diff --git a/docs/examples/operator_array__size_type_const.cpp b/docs/examples/operator_array__size_type_const.cpp deleted file mode 100644 index d56fa0a437..0000000000 --- a/docs/examples/operator_array__size_type_const.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON array - const json array = {"first", "2nd", "third", "fourth"}; - - // output element at index 2 (third element) - std::cout << array.at(2) << '\n'; -} diff --git a/docs/examples/operator_array__size_type_const.output b/docs/examples/operator_array__size_type_const.output deleted file mode 100644 index 4450c9f002..0000000000 --- a/docs/examples/operator_array__size_type_const.output +++ /dev/null @@ -1 +0,0 @@ -"third" diff --git a/docs/examples/operator_deserialize.cpp b/docs/examples/operator_deserialize.cpp deleted file mode 100644 index 8e3d8bd83e..0000000000 --- a/docs/examples/operator_deserialize.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create stream with serialized JSON - std::stringstream ss; - ss << R"({ - "number": 23, - "string": "Hello, world!", - "array": [1, 2, 3, 4, 5], - "boolean": false, - "null": null - })"; - - // create JSON value and read the serialization from the stream - json j; - ss >> j; - - // serialize JSON - std::cout << std::setw(2) << j << '\n'; -} diff --git a/docs/examples/operator_deserialize.output b/docs/examples/operator_deserialize.output deleted file mode 100644 index 81a203fb06..0000000000 --- a/docs/examples/operator_deserialize.output +++ /dev/null @@ -1,13 +0,0 @@ -{ - "array": [ - 1, - 2, - 3, - 4, - 5 - ], - "boolean": false, - "null": null, - "number": 23, - "string": "Hello, world!" -} diff --git a/docs/examples/operator_literal_json.cpp b/docs/examples/operator_literal_json.cpp deleted file mode 100644 index 84ca6297d4..0000000000 --- a/docs/examples/operator_literal_json.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -int main() -{ - json j = R"( {"hello": "world", "answer": 42} )"_json; - - std::cout << std::setw(2) << j << '\n'; -} diff --git a/docs/examples/operator_literal_json.output b/docs/examples/operator_literal_json.output deleted file mode 100644 index 6c0a7b34bd..0000000000 --- a/docs/examples/operator_literal_json.output +++ /dev/null @@ -1,4 +0,0 @@ -{ - "answer": 42, - "hello": "world" -} diff --git a/docs/examples/operator_literal_json_pointer.cpp b/docs/examples/operator_literal_json_pointer.cpp deleted file mode 100644 index aba93e88e4..0000000000 --- a/docs/examples/operator_literal_json_pointer.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -int main() -{ - json j = R"( {"hello": "world", "answer": 42} )"_json; - auto val = j["/hello"_json_pointer]; - - std::cout << std::setw(2) << val << '\n'; -} diff --git a/docs/examples/operator_literal_json_pointer.output b/docs/examples/operator_literal_json_pointer.output deleted file mode 100644 index b0fcd3479e..0000000000 --- a/docs/examples/operator_literal_json_pointer.output +++ /dev/null @@ -1 +0,0 @@ -"world" diff --git a/docs/examples/operator_ltlt__basic_json.cpp b/docs/examples/operator_ltlt__basic_json.cpp deleted file mode 100644 index 3bd4ad5775..0000000000 --- a/docs/examples/operator_ltlt__basic_json.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - - // serialize without indentation - std::cout << j_object << "\n\n"; - std::cout << j_array << "\n\n"; - - // serialize with indentation - std::cout << std::setw(4) << j_object << "\n\n"; - std::cout << std::setw(2) << j_array << "\n\n"; - std::cout << std::setw(1) << std::setfill('\t') << j_object << "\n\n"; -} diff --git a/docs/examples/operator_ltlt__basic_json.output b/docs/examples/operator_ltlt__basic_json.output deleted file mode 100644 index 7e86bfa2eb..0000000000 --- a/docs/examples/operator_ltlt__basic_json.output +++ /dev/null @@ -1,22 +0,0 @@ -{"one":1,"two":2} - -[1,2,4,8,16] - -{ - "one": 1, - "two": 2 -} - -[ - 1, - 2, - 4, - 8, - 16 -] - -{ - "one": 1, - "two": 2 -} - diff --git a/docs/examples/operator_ltlt__json_pointer.cpp b/docs/examples/operator_ltlt__json_pointer.cpp deleted file mode 100644 index f4fac886d6..0000000000 --- a/docs/examples/operator_ltlt__json_pointer.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON poiner - json::json_pointer ptr("/foo/bar/baz"); - - // write string representation to stream - std::cout << ptr << std::endl; -} diff --git a/docs/examples/operator_ltlt__json_pointer.output b/docs/examples/operator_ltlt__json_pointer.output deleted file mode 100644 index ed359432d2..0000000000 --- a/docs/examples/operator_ltlt__json_pointer.output +++ /dev/null @@ -1 +0,0 @@ -/foo/bar/baz diff --git a/docs/examples/operator_spaceship__const_reference.c++20.cpp b/docs/examples/operator_spaceship__const_reference.c++20.cpp deleted file mode 100644 index 3c6c8b8c57..0000000000 --- a/docs/examples/operator_spaceship__const_reference.c++20.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -const char* to_string(const std::partial_ordering& po) -{ - if (std::is_lt(po)) - { - return "less"; - } - else if (std::is_gt(po)) - { - return "greater"; - } - else if (std::is_eq(po)) - { - return "equivalent"; - } - return "unordered"; -} - -int main() -{ - // create several JSON values - json array_1 = {1, 2, 3}; - json array_2 = {1, 2, 4}; - json object_1 = {{"A", "a"}, {"B", "b"}}; - json object_2 = {{"B", "b"}, {"A", "a"}}; - json number = 17; - 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* - std::cout << string << " <=> " << number << " := " << to_string(string <=> number) << '\n'; // *NOPAD* - std::cout << string << " <=> " << discarded << " := " << to_string(string <=> discarded) << '\n'; // *NOPAD* -} diff --git a/docs/examples/operator_spaceship__const_reference.c++20.output b/docs/examples/operator_spaceship__const_reference.c++20.output deleted file mode 100644 index 2e8bf9f643..0000000000 --- a/docs/examples/operator_spaceship__const_reference.c++20.output +++ /dev/null @@ -1,4 +0,0 @@ -[1,2,3] <=> [1,2,4] := less -{"A":"a","B":"b"} <=> {"A":"a","B":"b"} := equivalent -"foo" <=> 17 := greater -"foo" <=> := unordered diff --git a/docs/examples/operator_spaceship__scalartype.c++20.cpp b/docs/examples/operator_spaceship__scalartype.c++20.cpp deleted file mode 100644 index d9dc3ca492..0000000000 --- a/docs/examples/operator_spaceship__scalartype.c++20.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -const char* to_string(const std::partial_ordering& po) -{ - if (std::is_lt(po)) - { - return "less"; - } - else if (std::is_gt(po)) - { - return "greater"; - } - else if (std::is_eq(po)) - { - return "equivalent"; - } - return "unordered"; -} - -int main() -{ - using float_limits = std::numeric_limits; - constexpr auto nan = float_limits::quiet_NaN(); - - // create several JSON values - json boolean = false; - 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* - std::cout << number << " <=> " << 17.0 << " := " << to_string(number <=> 17.0) << '\n'; // *NOPAD* - std::cout << number << " <=> " << nan << " := " << to_string(number <=> nan) << '\n'; // *NOPAD* - std::cout << string << " <=> " << 17 << " := " << to_string(string <=> 17) << '\n'; // *NOPAD* -} diff --git a/docs/examples/operator_spaceship__scalartype.c++20.output b/docs/examples/operator_spaceship__scalartype.c++20.output deleted file mode 100644 index b2939a5f59..0000000000 --- a/docs/examples/operator_spaceship__scalartype.c++20.output +++ /dev/null @@ -1,4 +0,0 @@ -false <=> true := less -17 <=> 17.000000 := equivalent -17 <=> nan := unordered -"17" <=> 17 := greater diff --git a/docs/examples/ordered_json.cpp b/docs/examples/ordered_json.cpp deleted file mode 100644 index effad530c4..0000000000 --- a/docs/examples/ordered_json.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include - -using ordered_json = nlohmann::ordered_json; - -int main() -{ - ordered_json j; - j["one"] = 1; - j["two"] = 2; - j["three"] = 3; - - std::cout << j.dump(2) << '\n'; -} diff --git a/docs/examples/ordered_json.output b/docs/examples/ordered_json.output deleted file mode 100644 index 120cbb2840..0000000000 --- a/docs/examples/ordered_json.output +++ /dev/null @@ -1,5 +0,0 @@ -{ - "one": 1, - "two": 2, - "three": 3 -} diff --git a/docs/examples/ordered_map.cpp b/docs/examples/ordered_map.cpp deleted file mode 100644 index dcc60cb526..0000000000 --- a/docs/examples/ordered_map.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include - -// simple output function -template -void output(const char* prefix, const Map& m) -{ - std::cout << prefix << " = { "; - for (auto& element : m) - { - std::cout << element.first << ":" << element.second << ' '; - } - std::cout << "}" << std::endl; -} - -int main() -{ - // create and fill two maps - nlohmann::ordered_map m_ordered; - m_ordered["one"] = "eins"; - m_ordered["two"] = "zwei"; - m_ordered["three"] = "drei"; - - std::map m_std; - m_std["one"] = "eins"; - m_std["two"] = "zwei"; - m_std["three"] = "drei"; - - // output: m_ordered is ordered by insertion order, m_std is ordered by key - output("m_ordered", m_ordered); - output("m_std", m_std); - - // erase and re-add "one" key - m_ordered.erase("one"); - m_ordered["one"] = "eins"; - - m_std.erase("one"); - m_std["one"] = "eins"; - - // output: m_ordered shows newly added key at the end; m_std is again ordered by key - output("m_ordered", m_ordered); - output("m_std", m_std); -} diff --git a/docs/examples/ordered_map.output b/docs/examples/ordered_map.output deleted file mode 100644 index a4ffc454ac..0000000000 --- a/docs/examples/ordered_map.output +++ /dev/null @@ -1,4 +0,0 @@ -m_ordered = { one:eins two:zwei three:drei } -m_std = { one:eins three:drei two:zwei } -m_ordered = { two:zwei three:drei one:eins } -m_std = { one:eins three:drei two:zwei } diff --git a/docs/examples/other_error.cpp b/docs/examples/other_error.cpp deleted file mode 100644 index 99c4be70e6..0000000000 --- a/docs/examples/other_error.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -int main() -{ - try - { - // executing a failing JSON Patch operation - json value = R"({ - "best_biscuit": { - "name": "Oreo" - } - })"_json; - json patch = R"([{ - "op": "test", - "path": "/best_biscuit/name", - "value": "Choco Leibniz" - }])"_json; - value.patch(patch); - } - catch (json::other_error& e) - { - // output exception information - std::cout << "message: " << e.what() << '\n' - << "exception id: " << e.id << std::endl; - } -} diff --git a/docs/examples/other_error.output b/docs/examples/other_error.output deleted file mode 100644 index b80f1cb389..0000000000 --- a/docs/examples/other_error.output +++ /dev/null @@ -1,2 +0,0 @@ -message: [json.exception.other_error.501] unsuccessful: {"op":"test","path":"/best_biscuit/name","value":"Choco Leibniz"} -exception id: 501 diff --git a/docs/examples/out_of_range.cpp b/docs/examples/out_of_range.cpp deleted file mode 100644 index e7116408a9..0000000000 --- a/docs/examples/out_of_range.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - try - { - // calling at() for an invalid index - json j = {1, 2, 3, 4}; - j.at(4) = 10; - } - catch (json::out_of_range& e) - { - // output exception information - std::cout << "message: " << e.what() << '\n' - << "exception id: " << e.id << std::endl; - } -} diff --git a/docs/examples/out_of_range.output b/docs/examples/out_of_range.output deleted file mode 100644 index 29ec76b3ce..0000000000 --- a/docs/examples/out_of_range.output +++ /dev/null @@ -1,2 +0,0 @@ -message: [json.exception.out_of_range.401] array index 4 is out of range -exception id: 401 diff --git a/docs/examples/parse__allow_exceptions.cpp b/docs/examples/parse__allow_exceptions.cpp deleted file mode 100644 index 82449a526a..0000000000 --- a/docs/examples/parse__allow_exceptions.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // an invalid JSON text - std::string text = R"( - { - "key": "value without closing quotes - } - )"; - - // parse with exceptions - try - { - json j = json::parse(text); - } - catch (json::parse_error& e) - { - std::cout << e.what() << std::endl; - } - - // parse without exceptions - json j = json::parse(text, nullptr, false); - - if (j.is_discarded()) - { - std::cout << "the input is invalid JSON" << std::endl; - } - else - { - std::cout << "the input is valid JSON: " << j << std::endl; - } -} diff --git a/docs/examples/parse__allow_exceptions.output b/docs/examples/parse__allow_exceptions.output deleted file mode 100644 index d650824d28..0000000000 --- a/docs/examples/parse__allow_exceptions.output +++ /dev/null @@ -1,2 +0,0 @@ -[json.exception.parse_error.101] parse error at line 4, column 0: syntax error while parsing value - invalid string: control character U+000A (LF) must be escaped to \u000A or \n; last read: '"value without closing quotes' -the input is invalid JSON diff --git a/docs/examples/parse__array__parser_callback_t.cpp b/docs/examples/parse__array__parser_callback_t.cpp deleted file mode 100644 index 63f0a0e4d0..0000000000 --- a/docs/examples/parse__array__parser_callback_t.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // a JSON text - char text[] = R"( - { - "Image": { - "Width": 800, - "Height": 600, - "Title": "View from 15th Floor", - "Thumbnail": { - "Url": "http://www.example.com/image/481989943", - "Height": 125, - "Width": 100 - }, - "Animated" : false, - "IDs": [116, 943, 234, 38793] - } - } - )"; - - // parse and serialize JSON - json j_complete = json::parse(text); - std::cout << std::setw(4) << j_complete << "\n\n"; -} diff --git a/docs/examples/parse__array__parser_callback_t.output b/docs/examples/parse__array__parser_callback_t.output deleted file mode 100644 index 62bb85863e..0000000000 --- a/docs/examples/parse__array__parser_callback_t.output +++ /dev/null @@ -1,20 +0,0 @@ -{ - "Image": { - "Animated": false, - "Height": 600, - "IDs": [ - 116, - 943, - 234, - 38793 - ], - "Thumbnail": { - "Height": 125, - "Url": "http://www.example.com/image/481989943", - "Width": 100 - }, - "Title": "View from 15th Floor", - "Width": 800 - } -} - diff --git a/docs/examples/parse__contiguouscontainer__parser_callback_t.cpp b/docs/examples/parse__contiguouscontainer__parser_callback_t.cpp deleted file mode 100644 index 6eb409bba8..0000000000 --- a/docs/examples/parse__contiguouscontainer__parser_callback_t.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // a JSON text given as std::vector - std::vector text = {'[', '1', ',', '2', ',', '3', ']', '\0'}; - - // parse and serialize JSON - json j_complete = json::parse(text); - std::cout << std::setw(4) << j_complete << "\n\n"; -} diff --git a/docs/examples/parse__contiguouscontainer__parser_callback_t.output b/docs/examples/parse__contiguouscontainer__parser_callback_t.output deleted file mode 100644 index 74633e8086..0000000000 --- a/docs/examples/parse__contiguouscontainer__parser_callback_t.output +++ /dev/null @@ -1,6 +0,0 @@ -[ - 1, - 2, - 3 -] - diff --git a/docs/examples/parse__istream__parser_callback_t.cpp b/docs/examples/parse__istream__parser_callback_t.cpp deleted file mode 100644 index afcaa39d07..0000000000 --- a/docs/examples/parse__istream__parser_callback_t.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // a JSON text - auto text = R"( - { - "Image": { - "Width": 800, - "Height": 600, - "Title": "View from 15th Floor", - "Thumbnail": { - "Url": "http://www.example.com/image/481989943", - "Height": 125, - "Width": 100 - }, - "Animated" : false, - "IDs": [116, 943, 234, 38793] - } - } - )"; - - // fill a stream with JSON text - std::stringstream ss; - ss << text; - - // parse and serialize JSON - 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) - { - // skip object elements with key "Thumbnail" - if (event == json::parse_event_t::key and parsed == json("Thumbnail")) - { - return false; - } - else - { - return true; - } - }; - - // fill a stream with JSON text - ss.clear(); - ss << text; - - // parse (with callback) and serialize JSON - json j_filtered = json::parse(ss, cb); - std::cout << std::setw(4) << j_filtered << '\n'; -} \ No newline at end of file diff --git a/docs/examples/parse__istream__parser_callback_t.output b/docs/examples/parse__istream__parser_callback_t.output deleted file mode 100644 index 279a7ff745..0000000000 --- a/docs/examples/parse__istream__parser_callback_t.output +++ /dev/null @@ -1,34 +0,0 @@ -{ - "Image": { - "Animated": false, - "Height": 600, - "IDs": [ - 116, - 943, - 234, - 38793 - ], - "Thumbnail": { - "Height": 125, - "Url": "http://www.example.com/image/481989943", - "Width": 100 - }, - "Title": "View from 15th Floor", - "Width": 800 - } -} - -{ - "Image": { - "Animated": false, - "Height": 600, - "IDs": [ - 116, - 943, - 234, - 38793 - ], - "Title": "View from 15th Floor", - "Width": 800 - } -} diff --git a/docs/examples/parse__iterator_pair.cpp b/docs/examples/parse__iterator_pair.cpp deleted file mode 100644 index d0c30c1a5c..0000000000 --- a/docs/examples/parse__iterator_pair.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // a JSON text given an input with other values - std::vector input = {'[', '1', ',', '2', ',', '3', ']', 'o', 't', 'h', 'e', 'r'}; - - // parse and serialize JSON - json j_complete = json::parse(input.begin(), input.begin() + 7); - std::cout << std::setw(4) << j_complete << "\n\n"; -} diff --git a/docs/examples/parse__iterator_pair.link b/docs/examples/parse__iterator_pair.link deleted file mode 100644 index f464e54c8d..0000000000 --- a/docs/examples/parse__iterator_pair.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/docs/examples/parse__iterator_pair.output b/docs/examples/parse__iterator_pair.output deleted file mode 100644 index 74633e8086..0000000000 --- a/docs/examples/parse__iterator_pair.output +++ /dev/null @@ -1,6 +0,0 @@ -[ - 1, - 2, - 3 -] - diff --git a/docs/examples/parse__pointers.cpp b/docs/examples/parse__pointers.cpp deleted file mode 100644 index a5a16eea99..0000000000 --- a/docs/examples/parse__pointers.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // a JSON text given as string that is not null-terminated - const char* ptr = "[1,2,3]another value"; - - // parse and serialize JSON - json j_complete = json::parse(ptr, ptr + 7); - std::cout << std::setw(4) << j_complete << "\n\n"; -} diff --git a/docs/examples/parse__pointers.link b/docs/examples/parse__pointers.link deleted file mode 100644 index 9a93ef1c59..0000000000 --- a/docs/examples/parse__pointers.link +++ /dev/null @@ -1 +0,0 @@ -online \ No newline at end of file diff --git a/docs/examples/parse__pointers.output b/docs/examples/parse__pointers.output deleted file mode 100644 index 74633e8086..0000000000 --- a/docs/examples/parse__pointers.output +++ /dev/null @@ -1,6 +0,0 @@ -[ - 1, - 2, - 3 -] - diff --git a/docs/examples/parse__string__parser_callback_t.cpp b/docs/examples/parse__string__parser_callback_t.cpp deleted file mode 100644 index 2ae4410a83..0000000000 --- a/docs/examples/parse__string__parser_callback_t.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // a JSON text - auto text = R"( - { - "Image": { - "Width": 800, - "Height": 600, - "Title": "View from 15th Floor", - "Thumbnail": { - "Url": "http://www.example.com/image/481989943", - "Height": 125, - "Width": 100 - }, - "Animated" : false, - "IDs": [116, 943, 234, 38793] - } - } - )"; - - // parse and serialize JSON - 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) - { - // skip object elements with key "Thumbnail" - if (event == json::parse_event_t::key and parsed == json("Thumbnail")) - { - return false; - } - else - { - return true; - } - }; - - // parse (with callback) and serialize JSON - json j_filtered = json::parse(text, cb); - std::cout << std::setw(4) << j_filtered << '\n'; -} diff --git a/docs/examples/parse__string__parser_callback_t.output b/docs/examples/parse__string__parser_callback_t.output deleted file mode 100644 index 279a7ff745..0000000000 --- a/docs/examples/parse__string__parser_callback_t.output +++ /dev/null @@ -1,34 +0,0 @@ -{ - "Image": { - "Animated": false, - "Height": 600, - "IDs": [ - 116, - 943, - 234, - 38793 - ], - "Thumbnail": { - "Height": 125, - "Url": "http://www.example.com/image/481989943", - "Width": 100 - }, - "Title": "View from 15th Floor", - "Width": 800 - } -} - -{ - "Image": { - "Animated": false, - "Height": 600, - "IDs": [ - 116, - 943, - 234, - 38793 - ], - "Title": "View from 15th Floor", - "Width": 800 - } -} diff --git a/docs/examples/parse_error.cpp b/docs/examples/parse_error.cpp deleted file mode 100644 index 9b27b58fab..0000000000 --- a/docs/examples/parse_error.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - try - { - // parsing input with a syntax error - json::parse("[1,2,3,]"); - } - catch (json::parse_error& e) - { - // output exception information - std::cout << "message: " << e.what() << '\n' - << "exception id: " << e.id << '\n' - << "byte position of error: " << e.byte << std::endl; - } -} diff --git a/docs/examples/parse_error.output b/docs/examples/parse_error.output deleted file mode 100644 index fe366ff8a9..0000000000 --- a/docs/examples/parse_error.output +++ /dev/null @@ -1,3 +0,0 @@ -message: [json.exception.parse_error.101] parse error at line 1, column 8: syntax error while parsing value - unexpected ']'; expected '[', '{', or a literal -exception id: 101 -byte position of error: 8 diff --git a/docs/examples/patch.cpp b/docs/examples/patch.cpp deleted file mode 100644 index b7ecb8eee6..0000000000 --- a/docs/examples/patch.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -int main() -{ - // the original document - json doc = R"( - { - "baz": "qux", - "foo": "bar" - } - )"_json; - - // the patch - json patch = R"( - [ - { "op": "replace", "path": "/baz", "value": "boo" }, - { "op": "add", "path": "/hello", "value": ["world"] }, - { "op": "remove", "path": "/foo"} - ] - )"_json; - - // apply the patch - json patched_doc = doc.patch(patch); - - // output original and patched document - std::cout << std::setw(4) << doc << "\n\n" - << std::setw(4) << patched_doc << std::endl; -} diff --git a/docs/examples/patch.output b/docs/examples/patch.output deleted file mode 100644 index eb558fe25b..0000000000 --- a/docs/examples/patch.output +++ /dev/null @@ -1,11 +0,0 @@ -{ - "baz": "qux", - "foo": "bar" -} - -{ - "baz": "boo", - "hello": [ - "world" - ] -} diff --git a/docs/examples/patch_inplace.cpp b/docs/examples/patch_inplace.cpp deleted file mode 100644 index 061708a2d2..0000000000 --- a/docs/examples/patch_inplace.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -int main() -{ - // the original document - json doc = R"( - { - "baz": "qux", - "foo": "bar" - } - )"_json; - - // the patch - json patch = R"( - [ - { "op": "replace", "path": "/baz", "value": "boo" }, - { "op": "add", "path": "/hello", "value": ["world"] }, - { "op": "remove", "path": "/foo"} - ] - )"_json; - - // output original document - std::cout << "Before\n" << std::setw(4) << doc << std::endl; - - // apply the patch - doc.patch_inplace(patch); - - // output patched document - std::cout << "\nAfter\n" << std::setw(4) << doc << std::endl; -} diff --git a/docs/examples/patch_inplace.output b/docs/examples/patch_inplace.output deleted file mode 100644 index 9d31b8ba47..0000000000 --- a/docs/examples/patch_inplace.output +++ /dev/null @@ -1,13 +0,0 @@ -Before -{ - "baz": "qux", - "foo": "bar" -} - -After -{ - "baz": "boo", - "hello": [ - "world" - ] -} diff --git a/docs/examples/push_back.cpp b/docs/examples/push_back.cpp deleted file mode 100644 index bbddf4f51b..0000000000 --- a/docs/examples/push_back.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json array = {1, 2, 3, 4, 5}; - json null; - - // print values - std::cout << array << '\n'; - std::cout << null << '\n'; - - // add values - array.push_back(6); - array += 7; - null += "first"; - null += "second"; - - // print values - std::cout << array << '\n'; - std::cout << null << '\n'; -} diff --git a/docs/examples/push_back.output b/docs/examples/push_back.output deleted file mode 100644 index 3306b60e3e..0000000000 --- a/docs/examples/push_back.output +++ /dev/null @@ -1,4 +0,0 @@ -[1,2,3,4,5] -null -[1,2,3,4,5,6,7] -["first","second"] diff --git a/docs/examples/push_back__initializer_list.cpp b/docs/examples/push_back__initializer_list.cpp deleted file mode 100644 index e96645f160..0000000000 --- a/docs/examples/push_back__initializer_list.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json object = {{"one", 1}, {"two", 2}}; - json null; - - // print values - std::cout << object << '\n'; - std::cout << null << '\n'; - - // add values: - object.push_back({"three", 3}); // object is extended - object += {"four", 4}; // object is extended - null.push_back({"five", 5}); // null is converted to array - - // print values - std::cout << object << '\n'; - std::cout << null << '\n'; - - // would throw: - //object.push_back({1, 2, 3}); -} diff --git a/docs/examples/push_back__initializer_list.output b/docs/examples/push_back__initializer_list.output deleted file mode 100644 index 668eb25d74..0000000000 --- a/docs/examples/push_back__initializer_list.output +++ /dev/null @@ -1,4 +0,0 @@ -{"one":1,"two":2} -null -{"four":4,"one":1,"three":3,"two":2} -[["five",5]] diff --git a/docs/examples/push_back__object_t__value.cpp b/docs/examples/push_back__object_t__value.cpp deleted file mode 100644 index 5d694e9388..0000000000 --- a/docs/examples/push_back__object_t__value.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json object = {{"one", 1}, {"two", 2}}; - json null; - - // print values - std::cout << object << '\n'; - std::cout << null << '\n'; - - // add values - object.push_back(json::object_t::value_type("three", 3)); - object += json::object_t::value_type("four", 4); - null += json::object_t::value_type("A", "a"); - null += json::object_t::value_type("B", "b"); - - // print values - std::cout << object << '\n'; - std::cout << null << '\n'; -} diff --git a/docs/examples/push_back__object_t__value.output b/docs/examples/push_back__object_t__value.output deleted file mode 100644 index b8a7d35604..0000000000 --- a/docs/examples/push_back__object_t__value.output +++ /dev/null @@ -1,4 +0,0 @@ -{"one":1,"two":2} -null -{"four":4,"one":1,"three":3,"two":2} -{"A":"a","B":"b"} diff --git a/docs/examples/rbegin.cpp b/docs/examples/rbegin.cpp deleted file mode 100644 index 239f7a6899..0000000000 --- a/docs/examples/rbegin.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create an array value - json array = {1, 2, 3, 4, 5}; - - // get an iterator to the reverse-beginning - json::reverse_iterator it = array.rbegin(); - - // serialize the element that the iterator points to - std::cout << *it << '\n'; -} diff --git a/docs/examples/rbegin.output b/docs/examples/rbegin.output deleted file mode 100644 index 7ed6ff82de..0000000000 --- a/docs/examples/rbegin.output +++ /dev/null @@ -1 +0,0 @@ -5 diff --git a/docs/examples/rend.cpp b/docs/examples/rend.cpp deleted file mode 100644 index adadbbdc25..0000000000 --- a/docs/examples/rend.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create an array value - json array = {1, 2, 3, 4, 5}; - - // get an iterator to the reverse-end - json::reverse_iterator it = array.rend(); - - // increment the iterator to point to the first element - --it; - - // serialize the element that the iterator points to - std::cout << *it << '\n'; -} diff --git a/docs/examples/rend.output b/docs/examples/rend.output deleted file mode 100644 index d00491fd7e..0000000000 --- a/docs/examples/rend.output +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/docs/examples/sax_parse.cpp b/docs/examples/sax_parse.cpp deleted file mode 100644 index 8602687e3f..0000000000 --- a/docs/examples/sax_parse.cpp +++ /dev/null @@ -1,131 +0,0 @@ -#include -#include -#include -#include - -using json = nlohmann::json; - -// a simple event consumer that collects string representations of the passed -// values; note inheriting from json::json_sax_t is not required, but can -// help not to forget a required function -class sax_event_consumer : public json::json_sax_t -{ - public: - std::vector events; - - bool null() override - { - events.push_back("null()"); - return true; - } - - bool boolean(bool val) override - { - events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")"); - return true; - } - - bool number_integer(number_integer_t val) override - { - events.push_back("number_integer(val=" + std::to_string(val) + ")"); - return true; - } - - bool number_unsigned(number_unsigned_t val) override - { - events.push_back("number_unsigned(val=" + std::to_string(val) + ")"); - return true; - } - - bool number_float(number_float_t val, const string_t& s) override - { - events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")"); - return true; - } - - bool string(string_t& val) override - { - events.push_back("string(val=" + val + ")"); - return true; - } - - bool start_object(std::size_t elements) override - { - events.push_back("start_object(elements=" + std::to_string(elements) + ")"); - return true; - } - - bool end_object() override - { - events.push_back("end_object()"); - return true; - } - - bool start_array(std::size_t elements) override - { - events.push_back("start_array(elements=" + std::to_string(elements) + ")"); - return true; - } - - bool end_array() override - { - events.push_back("end_array()"); - return true; - } - - bool key(string_t& val) override - { - events.push_back("key(val=" + val + ")"); - return true; - } - - bool binary(json::binary_t& val) override - { - events.push_back("binary(val=[...])"); - return true; - } - - bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override - { - events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n ex=" + std::string(ex.what()) + ")"); - return false; - } -}; - -int main() -{ - // a JSON text - auto text = R"( - { - "Image": { - "Width": 800, - "Height": 600, - "Title": "View from 15th Floor", - "Thumbnail": { - "Url": "http://www.example.com/image/481989943", - "Height": 125, - "Width": 100 - }, - "Animated" : false, - "IDs": [116, 943, 234, -38793], - "DeletionDate": null, - "Distance": 12.723374634 - } - }] - )"; - - // create a SAX event consumer object - sax_event_consumer sec; - - // parse JSON - bool result = json::sax_parse(text, &sec); - - // output the recorded events - for (auto& event : sec.events) - { - std::cout << event << "\n"; - } - - // output the result of sax_parse - std::cout << "\nresult: " << std::boolalpha << result << std::endl; -} diff --git a/docs/examples/sax_parse.output b/docs/examples/sax_parse.output deleted file mode 100644 index dd2fc2f05d..0000000000 --- a/docs/examples/sax_parse.output +++ /dev/null @@ -1,37 +0,0 @@ -start_object(elements=18446744073709551615) -key(val=Image) -start_object(elements=18446744073709551615) -key(val=Width) -number_unsigned(val=800) -key(val=Height) -number_unsigned(val=600) -key(val=Title) -string(val=View from 15th Floor) -key(val=Thumbnail) -start_object(elements=18446744073709551615) -key(val=Url) -string(val=http://www.example.com/image/481989943) -key(val=Height) -number_unsigned(val=125) -key(val=Width) -number_unsigned(val=100) -end_object() -key(val=Animated) -boolean(val=false) -key(val=IDs) -start_array(elements=18446744073709551615) -number_unsigned(val=116) -number_unsigned(val=943) -number_unsigned(val=234) -number_integer(val=-38793) -end_array() -key(val=DeletionDate) -null() -key(val=Distance) -number_float(val=12.723375, s=12.723374634) -end_object() -end_object() -parse_error(position=460, last_token=12.723374634 } }], - ex=[json.exception.parse_error.101] parse error at line 17, column 6: syntax error while parsing value - unexpected ']'; expected end of input) - -result: false diff --git a/docs/examples/sax_parse__binary.cpp b/docs/examples/sax_parse__binary.cpp deleted file mode 100644 index 08bc85df6d..0000000000 --- a/docs/examples/sax_parse__binary.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include -#include -#include -#include - -using json = nlohmann::json; - -// a simple event consumer that collects string representations of the passed -// values; note inheriting from json::json_sax_t is not required, but can -// help not to forget a required function -class sax_event_consumer : public json::json_sax_t -{ - public: - std::vector events; - - bool null() override - { - events.push_back("null()"); - return true; - } - - bool boolean(bool val) override - { - events.push_back("boolean(val=" + std::string(val ? "true" : "false") + ")"); - return true; - } - - bool number_integer(number_integer_t val) override - { - events.push_back("number_integer(val=" + std::to_string(val) + ")"); - return true; - } - - bool number_unsigned(number_unsigned_t val) override - { - events.push_back("number_unsigned(val=" + std::to_string(val) + ")"); - return true; - } - - bool number_float(number_float_t val, const string_t& s) override - { - events.push_back("number_float(val=" + std::to_string(val) + ", s=" + s + ")"); - return true; - } - - bool string(string_t& val) override - { - events.push_back("string(val=" + val + ")"); - return true; - } - - bool start_object(std::size_t elements) override - { - events.push_back("start_object(elements=" + std::to_string(elements) + ")"); - return true; - } - - bool end_object() override - { - events.push_back("end_object()"); - return true; - } - - bool start_array(std::size_t elements) override - { - events.push_back("start_array(elements=" + std::to_string(elements) + ")"); - return true; - } - - bool end_array() override - { - events.push_back("end_array()"); - return true; - } - - bool key(string_t& val) override - { - events.push_back("key(val=" + val + ")"); - return true; - } - - bool binary(json::binary_t& val) override - { - events.push_back("binary(val=[...])"); - return true; - } - - bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override - { - events.push_back("parse_error(position=" + std::to_string(position) + ", last_token=" + last_token + ",\n ex=" + std::string(ex.what()) + ")"); - return false; - } -}; - -int main() -{ - // CBOR byte string - std::vector vec = {{0x44, 0xcA, 0xfe, 0xba, 0xbe}}; - - // create a SAX event consumer object - sax_event_consumer sec; - - // parse CBOR - bool result = json::sax_parse(vec, &sec, json::input_format_t::cbor); - - // output the recorded events - for (auto& event : sec.events) - { - std::cout << event << "\n"; - } - - // output the result of sax_parse - std::cout << "\nresult: " << std::boolalpha << result << std::endl; -} diff --git a/docs/examples/sax_parse__binary.output b/docs/examples/sax_parse__binary.output deleted file mode 100644 index f880896103..0000000000 --- a/docs/examples/sax_parse__binary.output +++ /dev/null @@ -1,3 +0,0 @@ -binary(val=[...]) - -result: true diff --git a/docs/examples/size.cpp b/docs/examples/size.cpp deleted file mode 100644 index 2375483775..0000000000 --- a/docs/examples/size.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = 17; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_object_empty(json::value_t::object); - json j_array = {1, 2, 4, 8, 16}; - json j_array_empty(json::value_t::array); - json j_string = "Hello, world"; - - // call size() - std::cout << j_null.size() << '\n'; - std::cout << j_boolean.size() << '\n'; - std::cout << j_number_integer.size() << '\n'; - std::cout << j_number_float.size() << '\n'; - std::cout << j_object.size() << '\n'; - std::cout << j_object_empty.size() << '\n'; - std::cout << j_array.size() << '\n'; - std::cout << j_array_empty.size() << '\n'; - std::cout << j_string.size() << '\n'; -} diff --git a/docs/examples/size.output b/docs/examples/size.output deleted file mode 100644 index 3831387b1a..0000000000 --- a/docs/examples/size.output +++ /dev/null @@ -1,9 +0,0 @@ -0 -1 -1 -1 -2 -0 -5 -0 -1 diff --git a/docs/examples/std_hash.cpp b/docs/examples/std_hash.cpp deleted file mode 100644 index 9721910eb9..0000000000 --- a/docs/examples/std_hash.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -int main() -{ - std::cout << "hash(null) = " << std::hash {}(json(nullptr)) << '\n' - << "hash(false) = " << std::hash {}(json(false)) << '\n' - << "hash(0) = " << std::hash {}(json(0)) << '\n' - << "hash(0U) = " << std::hash {}(json(0U)) << '\n' - << "hash(\"\") = " << std::hash {}(json("")) << '\n' - << "hash({}) = " << std::hash {}(json::object()) << '\n' - << "hash([]) = " << std::hash {}(json::array()) << '\n' - << "hash({\"hello\": \"world\"}) = " << std::hash {}("{\"hello\": \"world\"}"_json) - << std::endl; -} diff --git a/docs/examples/std_hash.output b/docs/examples/std_hash.output deleted file mode 100644 index 521d2b4b8a..0000000000 --- a/docs/examples/std_hash.output +++ /dev/null @@ -1,8 +0,0 @@ -hash(null) = 2654435769 -hash(false) = 2654436030 -hash(0) = 2654436095 -hash(0U) = 2654436156 -hash("") = 6142509191626859748 -hash({}) = 2654435832 -hash([]) = 2654435899 -hash({"hello": "world"}) = 4469488738203676328 diff --git a/docs/examples/std_swap.cpp b/docs/examples/std_swap.cpp deleted file mode 100644 index 36ab3ce6b6..0000000000 --- a/docs/examples/std_swap.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j1 = {{"one", 1}, {"two", 2}}; - json j2 = {1, 2, 4, 8, 16}; - - std::cout << "j1 = " << j1 << " | j2 = " << j2 << '\n'; - - // swap values - std::swap(j1, j2); - - std::cout << "j1 = " << j1 << " | j2 = " << j2 << std::endl; -} diff --git a/docs/examples/std_swap.output b/docs/examples/std_swap.output deleted file mode 100644 index 5ae6db7804..0000000000 --- a/docs/examples/std_swap.output +++ /dev/null @@ -1,2 +0,0 @@ -j1 = {"one":1,"two":2} | j2 = [1,2,4,8,16] -j1 = [1,2,4,8,16] | j2 = {"one":1,"two":2} diff --git a/docs/examples/string_t.cpp b/docs/examples/string_t.cpp deleted file mode 100644 index 77a9ea4809..0000000000 --- a/docs/examples/string_t.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - std::cout << std::boolalpha << std::is_same::value << std::endl; -} diff --git a/docs/examples/string_t.output b/docs/examples/string_t.output deleted file mode 100644 index 27ba77ddaf..0000000000 --- a/docs/examples/string_t.output +++ /dev/null @@ -1 +0,0 @@ -true diff --git a/docs/examples/swap__array_t.cpp b/docs/examples/swap__array_t.cpp deleted file mode 100644 index 2119dd5523..0000000000 --- a/docs/examples/swap__array_t.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON value - json value = {{"array", {1, 2, 3, 4}}}; - - // create an array_t - json::array_t array = {"Snap", "Crackle", "Pop"}; - - // swap the array stored in the JSON value - value["array"].swap(array); - - // output the values - std::cout << "value = " << value << '\n'; - std::cout << "array = " << array << '\n'; -} diff --git a/docs/examples/swap__array_t.output b/docs/examples/swap__array_t.output deleted file mode 100644 index 365302cc17..0000000000 --- a/docs/examples/swap__array_t.output +++ /dev/null @@ -1,2 +0,0 @@ -value = {"array":["Snap","Crackle","Pop"]} -array = [1,2,3,4] diff --git a/docs/examples/swap__binary_t.cpp b/docs/examples/swap__binary_t.cpp deleted file mode 100644 index 4b8fc3db7b..0000000000 --- a/docs/examples/swap__binary_t.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a binary value - json value = json::binary({1, 2, 3}); - - // create a binary_t - json::binary_t binary = {{4, 5, 6}}; - - // swap the object stored in the JSON value - value.swap(binary); - - // output the values - std::cout << "value = " << value << '\n'; - std::cout << "binary = " << json(binary) << '\n'; -} diff --git a/docs/examples/swap__binary_t.output b/docs/examples/swap__binary_t.output deleted file mode 100644 index 68cd768921..0000000000 --- a/docs/examples/swap__binary_t.output +++ /dev/null @@ -1,2 +0,0 @@ -value = {"bytes":[4,5,6],"subtype":null} -binary = {"bytes":[1,2,3],"subtype":null} diff --git a/docs/examples/swap__object_t.cpp b/docs/examples/swap__object_t.cpp deleted file mode 100644 index 301b558d3e..0000000000 --- a/docs/examples/swap__object_t.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON value - json value = { {"translation", {{"one", "eins"}, {"two", "zwei"}}} }; - - // create an object_t - json::object_t object = {{"cow", "Kuh"}, {"dog", "Hund"}}; - - // swap the object stored in the JSON value - value["translation"].swap(object); - - // output the values - std::cout << "value = " << value << '\n'; - std::cout << "object = " << object << '\n'; -} diff --git a/docs/examples/swap__object_t.output b/docs/examples/swap__object_t.output deleted file mode 100644 index b5c9791bf6..0000000000 --- a/docs/examples/swap__object_t.output +++ /dev/null @@ -1,2 +0,0 @@ -value = {"translation":{"cow":"Kuh","dog":"Hund"}} -object = {"one":"eins","two":"zwei"} diff --git a/docs/examples/swap__reference.cpp b/docs/examples/swap__reference.cpp deleted file mode 100644 index 34182ad24d..0000000000 --- a/docs/examples/swap__reference.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create two JSON values - json j1 = {1, 2, 3, 4, 5}; - json j2 = {{"pi", 3.141592653589793}, {"e", 2.718281828459045}}; - - // swap the values - j1.swap(j2); - - // output the values - std::cout << "j1 = " << j1 << '\n'; - std::cout << "j2 = " << j2 << '\n'; -} diff --git a/docs/examples/swap__reference.output b/docs/examples/swap__reference.output deleted file mode 100644 index 96b07b0944..0000000000 --- a/docs/examples/swap__reference.output +++ /dev/null @@ -1,2 +0,0 @@ -j1 = {"e":2.718281828459045,"pi":3.141592653589793} -j2 = [1,2,3,4,5] diff --git a/docs/examples/swap__string_t.cpp b/docs/examples/swap__string_t.cpp deleted file mode 100644 index b5d58316fd..0000000000 --- a/docs/examples/swap__string_t.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON value - json value = { "the good", "the bad", "the ugly" }; - - // create string_t - json::string_t string = "the fast"; - - // swap the object stored in the JSON value - value[1].swap(string); - - // output the values - std::cout << "value = " << value << '\n'; - std::cout << "string = " << string << '\n'; -} diff --git a/docs/examples/swap__string_t.output b/docs/examples/swap__string_t.output deleted file mode 100644 index ae2a0976b0..0000000000 --- a/docs/examples/swap__string_t.output +++ /dev/null @@ -1,2 +0,0 @@ -value = ["the good","the fast","the ugly"] -string = the bad diff --git a/docs/examples/to_bjdata.cpp b/docs/examples/to_bjdata.cpp deleted file mode 100644 index 9b7abac4ee..0000000000 --- a/docs/examples/to_bjdata.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -// function to print BJData's diagnostic format -void print_byte(uint8_t byte) -{ - if (32 < byte and byte < 128) - { - std::cout << (char)byte; - } - else - { - std::cout << (int)byte; - } -} - -int main() -{ - // create a JSON value - json j = R"({"compact": true, "schema": false})"_json; - - // serialize it to BJData - std::vector v = json::to_bjdata(j); - - // print the vector content - for (auto& byte : v) - { - print_byte(byte); - } - std::cout << std::endl; - - // create an array of numbers - json array = {1, 2, 3, 4, 5, 6, 7, 8}; - - // serialize it to BJData using default representation - std::vector v_array = json::to_bjdata(array); - // serialize it to BJData using size optimization - std::vector v_array_size = json::to_bjdata(array, true); - // serialize it to BJData using type optimization - std::vector v_array_size_and_type = json::to_bjdata(array, true, true); - - // print the vector contents - for (auto& byte : v_array) - { - print_byte(byte); - } - std::cout << std::endl; - - for (auto& byte : v_array_size) - { - print_byte(byte); - } - std::cout << std::endl; - - for (auto& byte : v_array_size_and_type) - { - print_byte(byte); - } - std::cout << std::endl; -} diff --git a/docs/examples/to_bjdata.output b/docs/examples/to_bjdata.output deleted file mode 100644 index 087980cb9c..0000000000 --- a/docs/examples/to_bjdata.output +++ /dev/null @@ -1,4 +0,0 @@ -{i7compactTi6schemaF} -[i1i2i3i4i5i6i7i8] -[#i8i1i2i3i4i5i6i7i8 -[$i#i812345678 diff --git a/docs/examples/to_bson.cpp b/docs/examples/to_bson.cpp deleted file mode 100644 index 3484b0b760..0000000000 --- a/docs/examples/to_bson.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include -#include - -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 BSON - std::vector v = json::to_bson(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; -} diff --git a/docs/examples/to_bson.output b/docs/examples/to_bson.output deleted file mode 100644 index 379532a2f2..0000000000 --- a/docs/examples/to_bson.output +++ /dev/null @@ -1 +0,0 @@ -0x1b 0x00 0x00 0x00 0x08 0x63 0x6f 0x6d 0x70 0x61 0x63 0x74 0x00 0x01 0x10 0x73 0x63 0x68 0x65 0x6d 0x61 0x00 0x00 0x00 0x00 0x00 0x00 diff --git a/docs/examples/to_cbor.cpp b/docs/examples/to_cbor.cpp deleted file mode 100644 index 3d5e041508..0000000000 --- a/docs/examples/to_cbor.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include -#include - -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 CBOR - std::vector v = json::to_cbor(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; -} diff --git a/docs/examples/to_cbor.output b/docs/examples/to_cbor.output deleted file mode 100644 index 02c9adab38..0000000000 --- a/docs/examples/to_cbor.output +++ /dev/null @@ -1 +0,0 @@ -0xa2 0x67 0x63 0x6f 0x6d 0x70 0x61 0x63 0x74 0xf5 0x66 0x73 0x63 0x68 0x65 0x6d 0x61 0x00 diff --git a/docs/examples/to_json.cpp b/docs/examples/to_json.cpp deleted file mode 100644 index 1f82a4de4e..0000000000 --- a/docs/examples/to_json.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -namespace ns -{ -// a simple struct to model a person -struct person -{ - std::string name; - std::string address; - int age; -}; -} // namespace ns - -namespace ns -{ -void to_json(json& j, const person& p) -{ - j = json{ {"name", p.name}, {"address", p.address}, {"age", p.age} }; -} -} // namespace ns - -int main() -{ - ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; - - json j = p; - - std::cout << j << std::endl; -} diff --git a/docs/examples/to_json.output b/docs/examples/to_json.output deleted file mode 100644 index e9c5bf381d..0000000000 --- a/docs/examples/to_json.output +++ /dev/null @@ -1 +0,0 @@ -{"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} diff --git a/docs/examples/to_msgpack.cpp b/docs/examples/to_msgpack.cpp deleted file mode 100644 index b29ae8c7c7..0000000000 --- a/docs/examples/to_msgpack.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include -#include - -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 MessagePack - std::vector v = json::to_msgpack(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; -} diff --git a/docs/examples/to_msgpack.output b/docs/examples/to_msgpack.output deleted file mode 100644 index 4d6c40abaa..0000000000 --- a/docs/examples/to_msgpack.output +++ /dev/null @@ -1 +0,0 @@ -0x82 0xa7 0x63 0x6f 0x6d 0x70 0x61 0x63 0x74 0xc3 0xa6 0x73 0x63 0x68 0x65 0x6d 0x61 0x00 diff --git a/docs/examples/to_string.cpp b/docs/examples/to_string.cpp deleted file mode 100644 index ee44283f3a..0000000000 --- a/docs/examples/to_string.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -using json = nlohmann::json; -using std::to_string; - -int main() -{ - // create values - json j = {{"one", 1}, {"two", 2}}; - int i = 42; - - // use ADL to select best to_string function - auto j_str = to_string(j); // calling nlohmann::to_string - auto i_str = to_string(i); // calling std::to_string - - // serialize without indentation - std::cout << j_str << "\n\n" - << i_str << std::endl; -} diff --git a/docs/examples/to_string.output b/docs/examples/to_string.output deleted file mode 100644 index b261f35e3d..0000000000 --- a/docs/examples/to_string.output +++ /dev/null @@ -1,3 +0,0 @@ -{"one":1,"two":2} - -42 diff --git a/docs/examples/to_ubjson.cpp b/docs/examples/to_ubjson.cpp deleted file mode 100644 index fd267a85a4..0000000000 --- a/docs/examples/to_ubjson.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -// function to print UBJSON's diagnostic format -void print_byte(uint8_t byte) -{ - if (32 < byte and byte < 128) - { - std::cout << (char)byte; - } - else - { - std::cout << (int)byte; - } -} - -int main() -{ - // create a JSON value - json j = R"({"compact": true, "schema": false})"_json; - - // serialize it to UBJSON - std::vector v = json::to_ubjson(j); - - // print the vector content - for (auto& byte : v) - { - print_byte(byte); - } - std::cout << std::endl; - - // create an array of numbers - json array = {1, 2, 3, 4, 5, 6, 7, 8}; - - // serialize it to UBJSON using default representation - std::vector v_array = json::to_ubjson(array); - // serialize it to UBJSON using size optimization - std::vector v_array_size = json::to_ubjson(array, true); - // serialize it to UBJSON using type optimization - std::vector v_array_size_and_type = json::to_ubjson(array, true, true); - - // print the vector contents - for (auto& byte : v_array) - { - print_byte(byte); - } - std::cout << std::endl; - - for (auto& byte : v_array_size) - { - print_byte(byte); - } - std::cout << std::endl; - - for (auto& byte : v_array_size_and_type) - { - print_byte(byte); - } - std::cout << std::endl; -} diff --git a/docs/examples/to_ubjson.output b/docs/examples/to_ubjson.output deleted file mode 100644 index 087980cb9c..0000000000 --- a/docs/examples/to_ubjson.output +++ /dev/null @@ -1,4 +0,0 @@ -{i7compactTi6schemaF} -[i1i2i3i4i5i6i7i8] -[#i8i1i2i3i4i5i6i7i8 -[$i#i812345678 diff --git a/docs/examples/type.cpp b/docs/examples/type.cpp deleted file mode 100644 index 68fba3a917..0000000000 --- a/docs/examples/type.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = -17; - json j_number_unsigned = 42u; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - - // call type() - std::cout << std::boolalpha; - std::cout << (j_null.type() == json::value_t::null) << '\n'; - std::cout << (j_boolean.type() == json::value_t::boolean) << '\n'; - std::cout << (j_number_integer.type() == json::value_t::number_integer) << '\n'; - std::cout << (j_number_unsigned.type() == json::value_t::number_unsigned) << '\n'; - std::cout << (j_number_float.type() == json::value_t::number_float) << '\n'; - std::cout << (j_object.type() == json::value_t::object) << '\n'; - std::cout << (j_array.type() == json::value_t::array) << '\n'; - std::cout << (j_string.type() == json::value_t::string) << '\n'; -} diff --git a/docs/examples/type.output b/docs/examples/type.output deleted file mode 100644 index 310e632aa8..0000000000 --- a/docs/examples/type.output +++ /dev/null @@ -1,8 +0,0 @@ -true -true -true -true -true -true -true -true diff --git a/docs/examples/type_error.cpp b/docs/examples/type_error.cpp deleted file mode 100644 index d4f18b1800..0000000000 --- a/docs/examples/type_error.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - try - { - // calling push_back() on a string value - json j = "string"; - j.push_back("another string"); - } - catch (json::type_error& e) - { - // output exception information - std::cout << "message: " << e.what() << '\n' - << "exception id: " << e.id << std::endl; - } -} diff --git a/docs/examples/type_error.output b/docs/examples/type_error.output deleted file mode 100644 index 1a67339076..0000000000 --- a/docs/examples/type_error.output +++ /dev/null @@ -1,2 +0,0 @@ -message: [json.exception.type_error.308] cannot use push_back() with string -exception id: 308 diff --git a/docs/examples/type_name.cpp b/docs/examples/type_name.cpp deleted file mode 100644 index 32d3590cc9..0000000000 --- a/docs/examples/type_name.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON values - json j_null; - json j_boolean = true; - json j_number_integer = -17; - json j_number_unsigned = 42u; - json j_number_float = 23.42; - json j_object = {{"one", 1}, {"two", 2}}; - json j_array = {1, 2, 4, 8, 16}; - json j_string = "Hello, world"; - - // call type_name() - std::cout << j_null << " is a " << j_null.type_name() << '\n'; - std::cout << j_boolean << " is a " << j_boolean.type_name() << '\n'; - std::cout << j_number_integer << " is a " << j_number_integer.type_name() << '\n'; - std::cout << j_number_unsigned << " is a " << j_number_unsigned.type_name() << '\n'; - std::cout << j_number_float << " is a " << j_number_float.type_name() << '\n'; - std::cout << j_object << " is an " << j_object.type_name() << '\n'; - std::cout << j_array << " is an " << j_array.type_name() << '\n'; - std::cout << j_string << " is a " << j_string.type_name() << '\n'; -} diff --git a/docs/examples/type_name.output b/docs/examples/type_name.output deleted file mode 100644 index f394e819f5..0000000000 --- a/docs/examples/type_name.output +++ /dev/null @@ -1,8 +0,0 @@ -null is a null -true is a boolean --17 is a number -42 is a number -23.42 is a number -{"one":1,"two":2} is an object -[1,2,4,8,16] is an array -"Hello, world" is a string diff --git a/docs/examples/unflatten.cpp b/docs/examples/unflatten.cpp deleted file mode 100644 index 75fb02d03f..0000000000 --- a/docs/examples/unflatten.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create JSON value - json j_flattened = - { - {"/answer/everything", 42}, - {"/happy", true}, - {"/list/0", 1}, - {"/list/1", 0}, - {"/list/2", 2}, - {"/name", "Niels"}, - {"/nothing", nullptr}, - {"/object/currency", "USD"}, - {"/object/value", 42.99}, - {"/pi", 3.141} - }; - - // call unflatten() - std::cout << std::setw(4) << j_flattened.unflatten() << '\n'; -} diff --git a/docs/examples/unflatten.output b/docs/examples/unflatten.output deleted file mode 100644 index ed48385ae7..0000000000 --- a/docs/examples/unflatten.output +++ /dev/null @@ -1,18 +0,0 @@ -{ - "answer": { - "everything": 42 - }, - "happy": true, - "list": [ - 1, - 0, - 2 - ], - "name": "Niels", - "nothing": null, - "object": { - "currency": "USD", - "value": 42.99 - }, - "pi": 3.141 -} diff --git a/docs/examples/update.cpp b/docs/examples/update.cpp deleted file mode 100644 index ff94b67fa9..0000000000 --- a/docs/examples/update.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -int main() -{ - // create two JSON objects - json o1 = R"( {"color": "red", "price": 17.99, "names": {"de": "Flugzeug"}} )"_json; - json o2 = R"( {"color": "blue", "speed": 100, "names": {"en": "plane"}} )"_json; - json o3 = o1; - - // add all keys from o2 to o1 (updating "color", replacing "names") - o1.update(o2); - - // add all keys from o2 to o1 (updating "color", merging "names") - o3.update(o2, true); - - // output updated object o1 and o3 - std::cout << std::setw(2) << o1 << '\n'; - std::cout << std::setw(2) << o3 << '\n'; -} diff --git a/docs/examples/update.output b/docs/examples/update.output deleted file mode 100644 index c35a74513a..0000000000 --- a/docs/examples/update.output +++ /dev/null @@ -1,17 +0,0 @@ -{ - "color": "blue", - "names": { - "en": "plane" - }, - "price": 17.99, - "speed": 100 -} -{ - "color": "blue", - "names": { - "de": "Flugzeug", - "en": "plane" - }, - "price": 17.99, - "speed": 100 -} diff --git a/docs/examples/update__range.cpp b/docs/examples/update__range.cpp deleted file mode 100644 index 5b43850463..0000000000 --- a/docs/examples/update__range.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -int main() -{ - // create two JSON objects - json o1 = R"( {"color": "red", "price": 17.99, "names": {"de": "Flugzeug"}} )"_json; - json o2 = R"( {"color": "blue", "speed": 100, "names": {"en": "plane"}} )"_json; - json o3 = o1; - - // add all keys from o2 to o1 (updating "color", replacing "names") - o1.update(o2.begin(), o2.end()); - - // add all keys from o2 to o1 (updating "color", merging "names") - o3.update(o2.begin(), o2.end(), true); - - // output updated object o1 and o3 - std::cout << std::setw(2) << o1 << '\n'; - std::cout << std::setw(2) << o3 << '\n'; -} diff --git a/docs/examples/update__range.output b/docs/examples/update__range.output deleted file mode 100644 index c35a74513a..0000000000 --- a/docs/examples/update__range.output +++ /dev/null @@ -1,17 +0,0 @@ -{ - "color": "blue", - "names": { - "en": "plane" - }, - "price": 17.99, - "speed": 100 -} -{ - "color": "blue", - "names": { - "de": "Flugzeug", - "en": "plane" - }, - "price": 17.99, - "speed": 100 -} diff --git a/docs/examples/value__json_ptr.cpp b/docs/examples/value__json_ptr.cpp deleted file mode 100644 index d866ef0767..0000000000 --- a/docs/examples/value__json_ptr.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -using json = nlohmann::json; -using namespace nlohmann::literals; - -int main() -{ - // create a JSON object with different entry types - json j = - { - {"integer", 1}, - {"floating", 42.23}, - {"string", "hello world"}, - {"boolean", true}, - {"object", {{"key1", 1}, {"key2", 2}}}, - {"array", {1, 2, 3}} - }; - - // access existing values - int v_integer = j.value("/integer"_json_pointer, 0); - double v_floating = j.value("/floating"_json_pointer, 47.11); - - // access nonexisting values and rely on default value - std::string v_string = j.value("/nonexisting"_json_pointer, "oops"); - bool v_boolean = j.value("/nonexisting"_json_pointer, false); - - // output values - std::cout << std::boolalpha << v_integer << " " << v_floating - << " " << v_string << " " << v_boolean << "\n"; -} diff --git a/docs/examples/value__json_ptr.output b/docs/examples/value__json_ptr.output deleted file mode 100644 index dfc40e58c9..0000000000 --- a/docs/examples/value__json_ptr.output +++ /dev/null @@ -1 +0,0 @@ -1 42.23 oops false diff --git a/docs/examples/value__keytype.c++17.cpp b/docs/examples/value__keytype.c++17.cpp deleted file mode 100644 index 1f6ff5c30d..0000000000 --- a/docs/examples/value__keytype.c++17.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include - -using namespace std::string_view_literals; -using json = nlohmann::json; - -int main() -{ - // create a JSON object with different entry types - json j = - { - {"integer", 1}, - {"floating", 42.23}, - {"string", "hello world"}, - {"boolean", true}, - {"object", {{"key1", 1}, {"key2", 2}}}, - {"array", {1, 2, 3}} - }; - - // access existing values - int v_integer = j.value("integer"sv, 0); - double v_floating = j.value("floating"sv, 47.11); - - // access nonexisting values and rely on default value - std::string v_string = j.value("nonexisting"sv, "oops"); - bool v_boolean = j.value("nonexisting"sv, false); - - // output values - std::cout << std::boolalpha << v_integer << " " << v_floating - << " " << v_string << " " << v_boolean << "\n"; -} diff --git a/docs/examples/value__keytype.c++17.output b/docs/examples/value__keytype.c++17.output deleted file mode 100644 index dfc40e58c9..0000000000 --- a/docs/examples/value__keytype.c++17.output +++ /dev/null @@ -1 +0,0 @@ -1 42.23 oops false diff --git a/docs/examples/value__object_t_key_type.cpp b/docs/examples/value__object_t_key_type.cpp deleted file mode 100644 index 9488d30efe..0000000000 --- a/docs/examples/value__object_t_key_type.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - // create a JSON object with different entry types - json j = - { - {"integer", 1}, - {"floating", 42.23}, - {"string", "hello world"}, - {"boolean", true}, - {"object", {{"key1", 1}, {"key2", 2}}}, - {"array", {1, 2, 3}} - }; - - // access existing values - int v_integer = j.value("integer", 0); - double v_floating = j.value("floating", 47.11); - - // access nonexisting values and rely on default value - std::string v_string = j.value("nonexisting", "oops"); - bool v_boolean = j.value("nonexisting", false); - - // output values - std::cout << std::boolalpha << v_integer << " " << v_floating - << " " << v_string << " " << v_boolean << "\n"; -} diff --git a/docs/examples/value__object_t_key_type.output b/docs/examples/value__object_t_key_type.output deleted file mode 100644 index dfc40e58c9..0000000000 --- a/docs/examples/value__object_t_key_type.output +++ /dev/null @@ -1 +0,0 @@ -1 42.23 oops false diff --git a/docs/json.gif b/docs/json.gif deleted file mode 100644 index 8219866317..0000000000 Binary files a/docs/json.gif and /dev/null differ diff --git a/docs/mkdocs/Makefile b/docs/mkdocs/Makefile deleted file mode 100644 index e4731bfd79..0000000000 --- a/docs/mkdocs/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -# serve the site locally -serve: prepare_files style_check - venv/bin/mkdocs serve - -serve_dirty: prepare_files style_check - venv/bin/mkdocs serve --dirtyreload - -build: prepare_files style_check - venv/bin/mkdocs build - -# create files that are not versioned inside the mkdocs folder (images, examples) -prepare_files: clean - mkdir docs/examples - cp -r ../json.gif docs/images - cp -r ../examples/*.cpp ../examples/*.output docs/examples - -style_check: - @cd docs ; python3 ../scripts/check_structure.py - -# clean subfolders -clean: - rm -fr docs/images/json.gif docs/examples - -# publish site to GitHub pages -publish: prepare_files - venv/bin/mkdocs gh-deploy --clean --force - -# install a Python virtual environment -install_venv: requirements.txt - python3 -mvenv venv - venv/bin/pip install --upgrade pip - venv/bin/pip install wheel - venv/bin/pip install -r requirements.txt - -# uninstall the virtual environment -uninstall_venv: clean - rm -fr venv diff --git a/docs/mkdocs/docs/api/adl_serializer/from_json.md b/docs/mkdocs/docs/api/adl_serializer/from_json.md deleted file mode 100644 index fa19c96f24..0000000000 --- a/docs/mkdocs/docs/api/adl_serializer/from_json.md +++ /dev/null @@ -1,73 +0,0 @@ -# nlohmann::adl_serializer::from_json - -```cpp -// (1) -template -static auto from_json(BasicJsonType && j, TargetType& val) noexcept( - noexcept(::nlohmann::from_json(std::forward(j), val))) --> decltype(::nlohmann::from_json(std::forward(j), val), void()) - -// (2) -template -static auto from_json(BasicJsonType && j) noexcept( -noexcept(::nlohmann::from_json(std::forward(j), detail::identity_tag {}))) --> decltype(::nlohmann::from_json(std::forward(j), detail::identity_tag {})) -``` - -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. -2. This function is chosen for value types which are not default-constructible. - -## Parameters - -`j` (in) -: JSON value to read from - -`val` (out) -: value to write to - -## Return value - -Copy of the JSON value, converted to `ValueType` - -## Examples - -??? 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()` is called. - - ```cpp - --8<-- "examples/from_json__default_constructible.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_json__default_constructible.output" - ``` - -??? example "Example: (2) Non-default-constructible type" - - The example below shows how a `from_json` is implemented as part of a specialization of the `adl_serializer` to - realize the conversion of a non-default-constructible type. - - ```cpp - --8<-- "examples/from_json__non_default_constructible.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_json__non_default_constructible.output" - ``` - -## See also - -- [to_json](to_json.md) - -## Version history - -- Added in version 2.1.0. diff --git a/docs/mkdocs/docs/api/adl_serializer/index.md b/docs/mkdocs/docs/api/adl_serializer/index.md deleted file mode 100644 index 95f35cddf0..0000000000 --- a/docs/mkdocs/docs/api/adl_serializer/index.md +++ /dev/null @@ -1,35 +0,0 @@ -# nlohmann::adl_serializer - -```cpp -template -struct adl_serializer; -``` - -Serializer that uses ADL ([Argument-Dependent Lookup](https://en.cppreference.com/w/cpp/language/adl)) to choose -`to_json`/`from_json` functions from the types' namespaces. - -It is implemented similar to - -```cpp -template -struct adl_serializer { - template - static void to_json(BasicJsonType& j, const T& value) { - // calls the "to_json" method in T's namespace - } - - template - static void from_json(const BasicJsonType& j, T& value) { - // same thing, but with the "from_json" method - } -}; -``` - -## Member functions - -- [**from_json**](from_json.md) - convert a JSON value to any value type -- [**to_json**](to_json.md) - convert any value type to a JSON value - -## Version history - -- Added in version 2.1.0. diff --git a/docs/mkdocs/docs/api/adl_serializer/to_json.md b/docs/mkdocs/docs/api/adl_serializer/to_json.md deleted file mode 100644 index f8419bd81f..0000000000 --- a/docs/mkdocs/docs/api/adl_serializer/to_json.md +++ /dev/null @@ -1,43 +0,0 @@ -# nlohmann::adl_serializer::to_json - -```cpp -template -static auto to_json(BasicJsonType& j, TargetType && val) noexcept( - noexcept(::nlohmann::to_json(j, std::forward(val)))) --> decltype(::nlohmann::to_json(j, std::forward(val)), void()) -``` - -This function is usually called by the constructors of the [basic_json](../basic_json) class. - -## Parameters - -`j` (out) -: JSON value to write to - -`val` (in) -: value to read from - -## Examples - -??? example - - The example below shows how a `to_json` function can be implemented for a user-defined type. This function is called - by the `adl_serializer` when the constructor `basic_json(ns::person)` is called. - - ```cpp - --8<-- "examples/to_json.cpp" - ``` - - Output: - - ```json - --8<-- "examples/to_json.output" - ``` - -## See also - -- [from_json](from_json.md) - -## Version history - -- Added in version 2.1.0. diff --git a/docs/mkdocs/docs/api/basic_json/accept.md b/docs/mkdocs/docs/api/basic_json/accept.md deleted file mode 100644 index 1c806e82f4..0000000000 --- a/docs/mkdocs/docs/api/basic_json/accept.md +++ /dev/null @@ -1,113 +0,0 @@ -# nlohmann::basic_json::accept - -```cpp -// (1) -template -static bool accept(InputType&& i, - const bool ignore_comments = false); - -// (2) -template -static bool accept(IteratorType first, IteratorType last, - const bool ignore_comments = false); -``` - -Checks whether the input is valid JSON. - -1. Reads from a compatible input. -2. Reads from a pair of character iterators - - The value_type of the iterator must be an integral type with size of 1, 2 or 4 bytes, which will be interpreted - respectively as UTF-8, UTF-16 and UTF-32. - -Unlike the [`parse`](parse.md) function, this function neither throws an exception in case of invalid JSON input -(i.e., a parse error) nor creates diagnostic information. - -## Template parameters - -`InputType` -: A compatible input, for instance: - - - an `std::istream` object - - a `FILE` pointer (must not be null) - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - a `std::string` - - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. - -`IteratorType` -: a compatible iterator type, for instance. - - - a pair of `std::string::iterator` or `std::vector::iterator` - - a pair of pointers such as `ptr` and `ptr + len` - -## Parameters - -`i` (in) -: Input to parse from. - -`ignore_comments` (in) -: whether comments should be ignored and treated like whitespace (`#!cpp true`) or yield a parse error - (`#!cpp false`); (optional, `#!cpp false` by default) - -`first` (in) -: iterator to start of character range - -`last` (in) -: iterator to end of character range - -## Return value - -Whether the input is valid JSON. - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Complexity - -Linear in the length of the input. The parser is a predictive LL(1) parser. - -## Notes - -(1) A UTF-8 byte order mark is silently ignored. - -!!! danger "Runtime assertion" - - The precondition that a passed `#!cpp FILE` pointer must not be null is enforced with a - [runtime assertion](../../features/assertions.md). - -## Examples - -??? example - - The example below demonstrates the `accept()` function reading from a string. - - ```cpp - --8<-- "examples/accept__string.cpp" - ``` - - Output: - - ```json - --8<-- "examples/accept__string.output" - ``` - -## See also - -- [parse](parse.md) - deserialize from a compatible input -- [operator>>](../operator_gtgt.md) - deserialize from stream - -## Version history - -- Added in version 3.0.0. -- Ignoring comments via `ignore_comments` added in version 3.9.0. - -!!! warning "Deprecation" - - Overload (2) replaces calls to `accept` with a pair of iterators as their first parameter which has been - deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like - `#!cpp accept({ptr, ptr+len}, ...);` with `#!cpp accept(ptr, ptr+len, ...);`. - - You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated - function. diff --git a/docs/mkdocs/docs/api/basic_json/array.md b/docs/mkdocs/docs/api/basic_json/array.md deleted file mode 100644 index 22b2ee1db1..0000000000 --- a/docs/mkdocs/docs/api/basic_json/array.md +++ /dev/null @@ -1,60 +0,0 @@ -# nlohmann::basic_json::array - -```cpp -static basic_json array(initializer_list_t init = {}); -``` - -Creates a JSON array value from a given initializer list. That is, given a list of values `a, b, c`, creates the JSON -value `#!json [a, b, c]`. If the initializer list is empty, the empty array `#!json []` is created. - -## Parameters - -`init` (in) -: initializer list with JSON values to create an array from (optional) - -## Return value - -JSON array value - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Complexity - -Linear in the size of `init`. - -## Notes - -This function is only needed to express two edge cases that cannot be realized with the initializer list constructor -([`basic_json(initializer_list_t, bool, value_t)`](basic_json.md)). These cases are: - -1. creating an array whose elements are all pairs whose first element is a string -- in this case, the initializer list - constructor would create an object, taking the first elements as keys -2. creating an empty array -- passing the empty initializer list to the initializer list constructor yields an empty - object - -## Examples - -??? example - - The following code shows an example for the `array` function. - - ```cpp - --8<-- "examples/array.cpp" - ``` - - Output: - - ```json - --8<-- "examples/array.output" - ``` - -## See also - -- [`basic_json(initializer_list_t)`](basic_json.md) - create a JSON value from an initializer list -- [`object`](object.md) - create a JSON object value from an initializer list - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/array_t.md b/docs/mkdocs/docs/api/basic_json/array_t.md deleted file mode 100644 index dd2b901d55..0000000000 --- a/docs/mkdocs/docs/api/basic_json/array_t.md +++ /dev/null @@ -1,68 +0,0 @@ -# nlohmann::basic_json::array_t - -```cpp -using array_t = ArrayType>; -``` - -The type used to store JSON arrays. - -[RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON arrays as follows: -> An array is an ordered sequence of zero or more values. - -To store objects in C++, a type is defined by the template parameters explained below. - -## Template parameters - -`ArrayType` -: container type to store arrays (e.g., `std::vector` or `std::list`) - -`AllocatorType` -: the allocator to use for objects (e.g., `std::allocator`) - -## Notes - -#### Default type - -With the default values for `ArrayType` (`std::vector`) and `AllocatorType` (`std::allocator`), the default value for -`array_t` is: - -```cpp -std::vector< - basic_json, // value_type - std::allocator // allocator_type -> -``` - -#### Limits - -[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: -> An implementation may set limits on the maximum depth of nesting. - -In this class, the array's limit of nesting is not explicitly constrained. However, a maximum depth of nesting may be -introduced by the compiler or runtime environment. A theoretical limit can be queried by calling the -[`max_size`](max_size.md) function of a JSON array. - -#### Storage - -Arrays are stored as pointers in a `basic_json` type. That is, for any access to array values, a pointer of type -`#!cpp array_t*` must be dereferenced. - -## Examples - -??? example - - The following code shows that `array_t` is by default, a typedef to `#!cpp std::vector`. - - ```cpp - --8<-- "examples/array_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/array_t.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/at.md b/docs/mkdocs/docs/api/basic_json/at.md deleted file mode 100644 index 5e95045087..0000000000 --- a/docs/mkdocs/docs/api/basic_json/at.md +++ /dev/null @@ -1,226 +0,0 @@ -# nlohmann::basic_json::at - -```cpp -// (1) -reference at(size_type idx); -const_reference at(size_type idx) const; - -// (2) -reference at(const typename object_t::key_type& key); -const_reference at(const typename object_t::key_type& key) const; - -// (3) -template -reference at(KeyType&& key); -template -const_reference at(KeyType&& key) const; - -// (4) -reference at(const json_pointer& ptr); -const_reference at(const json_pointer& ptr) const; -``` - -1. Returns a reference to the array element at specified location `idx`, with bounds checking. -2. Returns a reference to the object element with specified key `key`, with bounds checking. -3. See 2. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and - `#!cpp typename object_comparator_t::is_transparent` denotes a type. -4. Returns a reference to the element at specified JSON pointer `ptr`, with bounds checking. - -## Template parameters - -`KeyType` -: A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with - [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). - This can also be a string view (C++17). - -## Parameters - -`idx` (in) -: index of the element to access - -`key` (in) -: object key of the elements to access - -`ptr` (in) -: JSON pointer to the desired element - -## Return value - -1. reference to the element at index `idx` -2. reference to the element at key `key` -3. reference to the element at key `key` -4. reference to the element pointed to by `ptr` - -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - -## Exceptions - -1. The function can throw the following exceptions: - - Throws [`type_error.304`](../../home/exceptions.md#jsonexceptiontype_error304) if the JSON value is not an array; - in this case, calling `at` with an index makes no sense. See example below. - - Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) if the index `idx` is out of - range of the array; that is, `idx >= size()`. See example below. -2. The function can throw the following exceptions: - - Throws [`type_error.304`](../../home/exceptions.md#jsonexceptiontype_error304) if the JSON value is not an object; - in this case, calling `at` with a key makes no sense. See example below. - - Throws [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if the key `key` is not - stored in the object; that is, `find(key) == end()`. See example below. -3. See 2. -4. The function can throw the following exceptions: - - Throws [`parse_error.106`](../../home/exceptions.md#jsonexceptionparse_error106) if an array index in the passed - JSON pointer `ptr` begins with '0'. See example below. - - Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) if an array index in the passed - JSON pointer `ptr` is not a number. See example below. - - Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) if an array index in the passed - JSON pointer `ptr` is out of range. See example below. - - Throws [`out_of_range.402`](../../home/exceptions.md#jsonexceptionout_of_range402) if the array index '-' is used - in the passed JSON pointer `ptr`. As `at` provides checked access (and no elements are implicitly inserted), the - index '-' is always invalid. See example below. - - Throws [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if the JSON pointer describes a - key of an object which cannot be found. See example below. - - Throws [`out_of_range.404`](../../home/exceptions.md#jsonexceptionout_of_range404) if the JSON pointer `ptr` can - not be resolved. See example below. - -## Complexity - -1. Constant. -2. Logarithmic in the size of the container. -3. Logarithmic in the size of the container. -4. Logarithmic in the size of the container. - -## Examples - -??? example "Example: (1) access specified array element with bounds checking" - - The example below shows how array elements can be read and written using `at()`. It also demonstrates the different - exceptions that can be thrown. - - ```cpp - --8<-- "examples/at__size_type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/at__size_type.output" - ``` - -??? example "Example: (1) access specified array element with bounds checking" - - The example below shows how array elements can be read using `at()`. It also demonstrates the different exceptions - that can be thrown. - - ```cpp - --8<-- "examples/at__size_type_const.cpp" - ``` - - Output: - - ```json - --8<-- "examples/at__size_type_const.output" - ``` - -??? example "Example: (2) access specified object element with bounds checking" - - The example below shows how object elements can be read and written using `at()`. It also demonstrates the different - exceptions that can be thrown. - - ```cpp - --8<-- "examples/at__object_t_key_type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/at__object_t_key_type.output" - ``` - -??? example "Example: (2) access specified object element with bounds checking" - - The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions - that can be thrown. - - ```cpp - --8<-- "examples/at__object_t_key_type_const.cpp" - ``` - - Output: - - ```json - --8<-- "examples/at__object_t_key_type_const.output" - ``` - -??? example "Example: (3) access specified object element using string_view with bounds checking" - - The example below shows how object elements can be read and written using `at()`. It also demonstrates the different - exceptions that can be thrown. - - ```cpp - --8<-- "examples/at__keytype.c++17.cpp" - ``` - - Output: - - ```json - --8<-- "examples/at__keytype.c++17.output" - ``` - -??? example "Example: (3) access specified object element using string_view with bounds checking" - - The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions - that can be thrown. - - ```cpp - --8<-- "examples/at__keytype_const.c++17.cpp" - ``` - - Output: - - ```json - --8<-- "examples/at__keytype_const.c++17.output" - ``` - -??? example "Example: (4) access specified element via JSON Pointer" - - The example below shows how object elements can be read and written using `at()`. It also demonstrates the different - exceptions that can be thrown. - - ```cpp - --8<-- "examples/at__json_pointer.cpp" - ``` - - Output: - - ```json - --8<-- "examples/at__json_pointer.output" - ``` - -??? example "Example: (4) access specified element via JSON Pointer" - - The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions - that can be thrown. - - ```cpp - --8<-- "examples/at__json_pointer_const.cpp" - ``` - - Output: - - ```json - --8<-- "examples/at__json_pointer_const.output" - ``` - -## See also - -- documentation on [checked access](../../features/element_access/checked_access.md) -- see [`operator[]`](operator%5B%5D.md) for unchecked access by reference -- see [`value`](value.md) for access with default value - -## Version history - -1. Added in version 1.0.0. -2. Added in version 1.0.0. -3. Added in version 3.11.0. -4. Added in version 2.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/back.md b/docs/mkdocs/docs/api/basic_json/back.md deleted file mode 100644 index 1a715284dc..0000000000 --- a/docs/mkdocs/docs/api/basic_json/back.md +++ /dev/null @@ -1,65 +0,0 @@ -# nlohmann::basic_json::back - -```cpp -reference back(); - -const_reference back() const; -``` - -Returns a reference to the last element in the container. For a JSON container `c`, the expression `c.back()` is -equivalent to - -```cpp -auto tmp = c.end(); ---tmp; -return *tmp; -``` - -## Return value - -In case of a structured type (array or object), a reference to the last element is returned. In case of number, string, -boolean, or binary values, a reference to the value is returned. - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Exceptions - -If the JSON value is `#!json null`, exception -[`invalid_iterator.214`](../../home/exceptions.md#jsonexceptioninvalid_iterator214) is thrown. - -## Complexity - -Constant. - -## Notes - -!!! info "Precondition" - - The array or object must not be empty. Calling `back` on an empty array or object yields undefined behavior. - -## Examples - -??? example - - The following code shows an example for `back()`. - - ```cpp - --8<-- "examples/back.cpp" - ``` - - Output: - - ```json - --8<-- "examples/back.output" - ``` - -## See also - -- [front](front.md) to access the first element - -## Version history - -- Added in version 1.0.0. -- Adjusted code to return reference to binary values in version 3.8.0. diff --git a/docs/mkdocs/docs/api/basic_json/basic_json.md b/docs/mkdocs/docs/api/basic_json/basic_json.md deleted file mode 100644 index e2e73612c3..0000000000 --- a/docs/mkdocs/docs/api/basic_json/basic_json.md +++ /dev/null @@ -1,402 +0,0 @@ -# nlohmann::basic_json::basic_json - -```cpp -// (1) -basic_json(const value_t v); - -// (2) -basic_json(std::nullptr_t = nullptr) noexcept; - -// (3) -template -basic_json(CompatibleType&& val) noexcept(noexcept( - JSONSerializer::to_json(std::declval(), - std::forward(val)))); - -// (4) -template -basic_json(const BasicJsonType& val); - -// (5) -basic_json(initializer_list_t init, - bool type_deduction = true, - value_t manual_type = value_t::array); - -// (6) -basic_json(size_type cnt, const basic_json& val); - -// (7) -basic_json(iterator first, iterator last); -basic_json(const_iterator first, const_iterator last); - -// (8) -basic_json(const basic_json& other); - -// (9) -basic_json(basic_json&& other) noexcept; -``` - -1. Create an empty JSON value with a given type. The value will be default initialized with an empty value which depends - on the type: - - | Value type | initial value | - |------------|----------------| - | null | `#!json null` | - | boolean | `#!json false` | - | string | `#!json ""` | - | number | `#!json 0` | - | object | `#!json {}` | - | array | `#!json []` | - | binary | empty array | - - The postcondition of this constructor can be restored by calling [`clear()`](clear.md). - -2. Create a `#!json null` JSON value. It either takes a null pointer as parameter (explicitly creating `#!json null`) - or no parameter (implicitly creating `#!json null`). The passed null pointer itself is not read -- it is only used to - choose the right constructor. - -3. This is a "catch all" constructor for all compatible JSON types; that is, types for which a `to_json()` method - exists. The constructor forwards the parameter `val` to that method (to `json_serializer::to_json` method with - `U = uncvref_t`, to be exact). - - Template type `CompatibleType` includes, but is not limited to, the following types: - - - **arrays**: [`array_t`](array_t.md) and all kinds of compatible containers such as `std::vector`, `std::deque`, - `std::list`, `std::forward_list`, `std::array`, `std::valarray`, `std::set`, `std::unordered_set`, `std::multiset`, - and `std::unordered_multiset` with a `value_type` from which a `basic_json` value can be constructed. - - **objects**: [`object_t`](object_t.md) and all kinds of compatible associative containers such as `std::map`, - `std::unordered_map`, `std::multimap`, and `std::unordered_multimap` with a `key_type` compatible to `string_t` - and a `value_type` from which a `basic_json` value can be constructed. - - **strings**: `string_t`, string literals, and all compatible string containers can be used. - - **numbers**: [`number_integer_t`](number_integer_t.md), [`number_unsigned_t`](number_unsigned_t.md), - [`number_float_t`](number_float_t.md), and all convertible number types such as `int`, `size_t`, `int64_t`, `float` - or `double` can be used. - - **boolean**: `boolean_t` / `bool` can be used. - - **binary**: `binary_t` / `std::vector` may be used; unfortunately because string literals cannot be - distinguished from binary character arrays by the C++ type system, all types compatible with `const char*` will be - directed to the string constructor instead. This is both for backwards compatibility, and due to the fact that a - binary type is not a standard JSON type. - - See the examples below. - -4. This is a constructor for existing `basic_json` types. It does not hijack copy/move constructors, since the parameter - has different template arguments than the current ones. - - The constructor tries to convert the internal `m_value` of the parameter. - -5. Creates a JSON value of type array or object from the passed initializer list `init`. In case `type_deduction` is - `#!cpp true` (default), the type of the JSON value to be created is deducted from the initializer list `init` - according to the following rules: - - 1. If the list is empty, an empty JSON object value `{}` is created. - 2. If the list consists of pairs whose first element is a string, a JSON object value is created where the first - elements of the pairs are treated as keys and the second elements are as values. - 3. In all other cases, an array is created. - - The rules aim to create the best fit between a C++ initializer list and JSON values. The rationale is as follows: - - 1. The empty initializer list is written as `#!cpp {}` which is exactly an empty JSON object. - 2. C++ has no way of describing mapped types other than to list a list of pairs. As JSON requires that keys must be - of type string, rule 2 is the weakest constraint one can pose on initializer lists to interpret them as an - object. - 3. In all other cases, the initializer list could not be interpreted as JSON object type, so interpreting it as JSON - array type is safe. - - With the rules described above, the following JSON values cannot be expressed by an initializer list: - - - the empty array (`#!json []`): use `array(initializer_list_t)` with an empty initializer list in this case - - arrays whose elements satisfy rule 2: use `array(initializer_list_t)` with the same initializer list in this case - - Function [`array()`](array.md) and [`object()`](object.md) force array and object creation from initializer lists, - respectively. - -6. Constructs a JSON array value by creating `cnt` copies of a passed value. In case `cnt` is `0`, an empty array is - created. - -7. Constructs the JSON value with the contents of the range `[first, last)`. The semantics depends on the different - types a JSON value can have: - - - In case of a `#!json null` type, [invalid_iterator.206](../../home/exceptions.md#jsonexceptioninvalid_iterator206) - is thrown. - - In case of other primitive types (number, boolean, or string), `first` must be `begin()` and `last` must be - `end()`. In this case, the value is copied. Otherwise, - [`invalid_iterator.204`](../../home/exceptions.md#jsonexceptioninvalid_iterator204) is thrown. - - In case of structured types (array, object), the constructor behaves as similar versions for `std::vector` or - `std::map`; that is, a JSON array or object is constructed from the values in the range. - -8. Creates a copy of a given JSON value. - -9. Move constructor. Constructs a JSON value with the contents of the given value `other` using move semantics. It - "steals" the resources from `other` and leaves it as JSON `#!json null` value. - -## Template parameters - -`CompatibleType` -: a type such that: - - - `CompatibleType` is not derived from `std::istream`, - - `CompatibleType` is not `basic_json` (to avoid hijacking copy/move constructors), - - `CompatibleType` is not a different `basic_json` type (i.e. with different template arguments) - - `CompatibleType` is not a `basic_json` nested type (e.g., `json_pointer`, `iterator`, etc.) - - `json_serializer` (with `U = uncvref_t`) has a `to_json(basic_json_t&, CompatibleType&&)` - method - -`BasicJsonType`: -: a type such that: - - - `BasicJsonType` is a `basic_json` type. - - `BasicJsonType` has different template arguments than `basic_json_t`. - -`U`: -: `uncvref_t` - -## Parameters - -`v` (in) -: the type of the value to create - -`val` (in) -: the value to be forwarded to the respective constructor - -`init` (in) -: initializer list with JSON values - -`type_deduction` (in) -: internal parameter; when set to `#!cpp true`, the type of the JSON value is deducted from the initializer list - `init`; when set to `#!cpp false`, the type provided via `manual_type` is forced. This mode is used by the functions - `array(initializer_list_t)` and `object(initializer_list_t)`. - -`manual_type` (in) -: internal parameter; when `type_deduction` is set to `#!cpp false`, the created JSON value will use the provided type - (only `value_t::array` and `value_t::object` are valid); when `type_deduction` is set to `#!cpp true`, this - parameter has no effect - -`cnt` (in) -: the number of JSON copies of `val` to create - -`first` (in) -: begin of the range to copy from (included) - -`last` (in) -: end of the range to copy from (excluded) - -`other` (in) -: the JSON value to copy/move - -## Exception safety - -1. Strong guarantee: if an exception is thrown, there are no changes to any JSON value. -2. No-throw guarantee: this constructor never throws exceptions. -3. Depends on the called constructor. For types directly supported by the library (i.e., all types for which no - `to_json()` function was provided), strong guarantee holds: if an exception is thrown, there are no changes to any - JSON value. -4. Depends on the called constructor. For types directly supported by the library (i.e., all types for which no - `to_json()` function was provided), strong guarantee holds: if an exception is thrown, there are no changes to any - JSON value. -5. Strong guarantee: if an exception is thrown, there are no changes to any JSON value. -6. Strong guarantee: if an exception is thrown, there are no changes to any JSON value. -7. Strong guarantee: if an exception is thrown, there are no changes to any JSON value. -8. Strong guarantee: if an exception is thrown, there are no changes to any JSON value. -9. No-throw guarantee: this constructor never throws exceptions. - -## Exceptions - -1. (none) -2. The function does not throw exceptions. -3. (none) -4. (none) -5. The function can throw the following exceptions: - - Throws [`type_error.301`](../../home/exceptions.md#jsonexceptiontype_error301) if `type_deduction` is - `#!cpp false`, `manual_type` is `value_t::object`, but `init` contains an element which is not a pair whose first - element is a string. In this case, the constructor could not create an object. If `type_deduction` would have been - `#!cpp true`, an array would have been created. See `object(initializer_list_t)` for an example. -6. (none) -7. The function can throw the following exceptions: - - Throws [`invalid_iterator.201`](../../home/exceptions.md#jsonexceptioninvalid_iterator201) if iterators `first` - and `last` are not compatible (i.e., do not belong to the same JSON value). In this case, the range - `[first, last)` is undefined. - - Throws [`invalid_iterator.204`](../../home/exceptions.md#jsonexceptioninvalid_iterator204) if iterators `first` - and `last` belong to a primitive type (number, boolean, or string), but `first` does not point to the first - element anymore. In this case, the range `[first, last)` is undefined. See example code below. - - Throws [`invalid_iterator.206`](../../home/exceptions.md#jsonexceptioninvalid_iterator206) if iterators `first` - and `last` belong to a `#!json null` value. In this case, the range `[first, last)` is undefined. -8. (none) -9. The function does not throw exceptions. - -## Complexity - -1. Constant. -2. Constant. -3. Usually linear in the size of the passed `val`, also depending on the implementation of the called `to_json()` - method. -4. Usually linear in the size of the passed `val`, also depending on the implementation of the called `to_json()` - method. -5. Linear in the size of the initializer list `init`. -6. Linear in `cnt`. -7. Linear in distance between `first` and `last`. -8. Linear in the size of `other`. -9. Constant. - -## Notes - -- Overload 5: - - !!! note "Empty initializer list" - - When used without parentheses around an empty initializer list, `basic_json()` is called instead of this - function, yielding the JSON `#!json null` value. - -- Overload 7: - - !!! info "Preconditions" - - - Iterators `first` and `last` must be initialized. **This precondition is enforced with a - [runtime assertion](../../features/assertions.md). - - Range `[first, last)` is valid. Usually, this precondition cannot be checked efficiently. Only certain edge - cases are detected; see the description of the exceptions above. A violation of this precondition yields - undefined behavior. - - !!! danger "Runtime assertion" - - A precondition is enforced with a [runtime assertion](../../features/assertions.md). - -- Overload 8: - - !!! info "Postcondition" - - `#!cpp *this == other` - -- Overload 9: - - !!! info "Postconditions" - - - `#!cpp `*this` has the same value as `other` before the call. - - `other` is a JSON `#!json null` value - -## Examples - -??? example "Example: (1) create an empty value with a given type" - - The following code shows the constructor for different `value_t` values. - - ```cpp - --8<-- "examples/basic_json__value_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/basic_json__value_t.output" - ``` - -??? example "Example: (2) create a `#!json null` object" - - The following code shows the constructor with and without a null pointer parameter. - - ```cpp - --8<-- "examples/basic_json__nullptr_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/basic_json__nullptr_t.output" - ``` - -??? example "Example: (3) create a JSON value from compatible types" - - The following code shows the constructor with several compatible types. - - ```cpp - --8<-- "examples/basic_json__CompatibleType.cpp" - ``` - - Output: - - ```json - --8<-- "examples/basic_json__CompatibleType.output" - ``` - - Note the output is platform-dependent. - -??? example "Example: (5) create a container (array or object) from an initializer list" - - The example below shows how JSON values are created from initializer lists. - - ```cpp - --8<-- "examples/basic_json__list_init_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/basic_json__list_init_t.output" - ``` - -??? example "Example: (6) construct an array with count copies of given value" - - The following code shows examples for creating arrays with several copies of a given value. - - ```cpp - --8<-- "examples/basic_json__size_type_basic_json.cpp" - ``` - - Output: - - ```json - --8<-- "examples/basic_json__size_type_basic_json.output" - ``` - -??? example "Example: (7) construct a JSON container given an iterator range" - - The example below shows several ways to create JSON values by specifying a subrange with iterators. - - ```cpp - --8<-- "examples/basic_json__InputIt_InputIt.cpp" - ``` - - Output: - - ```json - --8<-- "examples/basic_json__InputIt_InputIt.output" - ``` - -??? example "Example: (8) copy constructor" - - The following code shows an example for the copy constructor. - - ```cpp - --8<-- "examples/basic_json__basic_json.cpp" - ``` - - Output: - - ```json - --8<-- "examples/basic_json__basic_json.output" - ``` - -??? example "Example: (9) move constructor" - - The code below shows the move constructor explicitly called via `std::move`. - - ```cpp - --8<-- "examples/basic_json__moveconstructor.cpp" - ``` - - Output: - - ```json - --8<-- "examples/basic_json__moveconstructor.output" - ``` - -## Version history - -1. Since version 1.0.0. -2. Since version 1.0.0. -3. Since version 2.1.0. -4. Since version 3.2.0. -5. Since version 1.0.0. -6. Since version 1.0.0. -7. Since version 1.0.0. -8. Since version 1.0.0. -9. Since version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/begin.md b/docs/mkdocs/docs/api/basic_json/begin.md deleted file mode 100644 index ef623a5ff2..0000000000 --- a/docs/mkdocs/docs/api/basic_json/begin.md +++ /dev/null @@ -1,42 +0,0 @@ -# nlohmann::basic_json::begin - -```cpp -iterator begin() noexcept; -const_iterator begin() const noexcept; -``` - -Returns an iterator to the first element. - -![Illustration from cppreference.com](../../images/range-begin-end.svg) - -## Return value - -iterator to the first element - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code shows an example for `begin()`. - - ```cpp - --8<-- "examples/begin.cpp" - ``` - - Output: - - ```json - --8<-- "examples/begin.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/binary.md b/docs/mkdocs/docs/api/basic_json/binary.md deleted file mode 100644 index ce45d8a0fb..0000000000 --- a/docs/mkdocs/docs/api/basic_json/binary.md +++ /dev/null @@ -1,66 +0,0 @@ -# nlohmann::basic_json::binary - -```cpp -// (1) -static basic_json binary(const typename binary_t::container_type& init); -static basic_json binary(typename binary_t::container_type&& init); - -// (2) -static basic_json binary(const typename binary_t::container_type& init, - std::uint8_t subtype); -static basic_json binary(typename binary_t::container_type&& init, - std::uint8_t subtype); -``` - -1. Creates a JSON binary array value from a given binary container. -2. Creates a JSON binary array value from a given binary container with subtype. - -Binary values are part of various binary formats, such as CBOR, MessagePack, and BSON. This constructor is used to -create a value for serialization to those formats. - -## Parameters - -`init` (in) -: container containing bytes to use as binary type - -`subtype` (in) -: subtype to use in CBOR, MessagePack, and BSON - -## Return value - -JSON binary array value - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Complexity - -Linear in the size of `init`; constant for `typename binary_t::container_type&& init` versions. - -## Notes - -Note, this function exists because of the difficulty in correctly specifying the correct template overload in the -standard value ctor, as both JSON arrays and JSON binary arrays are backed with some form of a `std::vector`. Because -JSON binary arrays are a non-standard extension it was decided that it would be best to prevent automatic initialization -of a binary array type, for backwards compatibility and so it does not happen on accident. - -## Examples - -??? example - - The following code shows how to create a binary value. - - ```cpp - --8<-- "examples/binary.cpp" - ``` - - Output: - - ```json - --8<-- "examples/binary.output" - ``` - -## Version history - -- Added in version 3.8.0. diff --git a/docs/mkdocs/docs/api/basic_json/binary_t.md b/docs/mkdocs/docs/api/basic_json/binary_t.md deleted file mode 100644 index 705c92cb58..0000000000 --- a/docs/mkdocs/docs/api/basic_json/binary_t.md +++ /dev/null @@ -1,89 +0,0 @@ -# nlohmann::basic_json::binary_t - -```cpp -using binary_t = byte_container_with_subtype; -``` - -This type is a type designed to carry binary data that appears in various serialized formats, such as CBOR's Major Type -2, MessagePack's bin, and BSON's generic binary subtype. This type is NOT a part of standard JSON and exists solely for -compatibility with these binary types. As such, it is simply defined as an ordered sequence of zero or more byte values. - -Additionally, as an implementation detail, the subtype of the binary data is carried around as a `std::uint64_t`, which -is compatible with both of the binary data formats that use binary subtyping, (though the specific numbering is -incompatible with each other, and it is up to the user to translate between them). The subtype is added to `BinaryType` -via the helper type [byte_container_with_subtype](../byte_container_with_subtype/index.md). - -[CBOR's RFC 7049](https://tools.ietf.org/html/rfc7049) describes this type as: -> Major type 2: a byte string. The string's length in bytes is represented following the rules for positive integers -> (major type 0). - -[MessagePack's documentation on the bin type -family](https://github.com/msgpack/msgpack/blob/master/spec.md#bin-format-family) describes this type as: -> Bin format family stores a byte array in 2, 3, or 5 bytes of extra bytes in addition to the size of the byte array. - -[BSON's specifications](http://bsonspec.org/spec.html) describe several binary types; however, this type is intended to -represent the generic binary type which has the description: -> Generic binary subtype - This is the most commonly used binary subtype and should be the 'default' for drivers and -> tools. - -None of these impose any limitations on the internal representation other than the basic unit of storage be some type of -array whose parts are decomposable into bytes. - -The default representation of this binary format is a `#!cpp std::vector`, which is a very common way to -represent a byte array in modern C++. - -## Template parameters - -`BinaryType` -: container type to store arrays - -## Notes - -#### Default type - -The default values for `BinaryType` is `#!cpp std::vector`. - -#### Storage - -Binary Arrays are stored as pointers in a `basic_json` type. That is, for any access to array values, a pointer of the -type `#!cpp binary_t*` must be dereferenced. - -#### Notes on subtypes - -- CBOR - - Binary values are represented as byte strings. Subtypes are written as tags. - -- MessagePack - - If a subtype is given and the binary array contains exactly 1, 2, 4, 8, or 16 elements, the fixext family (fixext1, - fixext2, fixext4, fixext8) is used. For other sizes, the ext family (ext8, ext16, ext32) is used. The subtype is - then added as signed 8-bit integer. - - If no subtype is given, the bin family (bin8, bin16, bin32) is used. - -- BSON - - If a subtype is given, it is used and added as unsigned 8-bit integer. - - If no subtype is given, the generic binary subtype 0x00 is used. - -## Examples - -??? example - - The following code shows that `binary_t` is by default, a typedef to - `#!cpp nlohmann::byte_container_with_subtype>`. - - ```cpp - --8<-- "examples/binary_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/binary_t.output" - ``` - -## See also - -- [byte_container_with_subtype](../byte_container_with_subtype/index.md) - -## Version history - -- Added in version 3.8.0. Changed type of subtype to `std::uint64_t` in version 3.10.0. diff --git a/docs/mkdocs/docs/api/basic_json/boolean_t.md b/docs/mkdocs/docs/api/basic_json/boolean_t.md deleted file mode 100644 index e3a7830270..0000000000 --- a/docs/mkdocs/docs/api/basic_json/boolean_t.md +++ /dev/null @@ -1,42 +0,0 @@ -# nlohmann::basic_json::boolean_t - -```cpp -using boolean_t = BooleanType; -``` - -The type used to store JSON booleans. - -[RFC 8259](https://tools.ietf.org/html/rfc8259) implicitly describes a boolean as a type which differentiates the two -literals `#!json true` and `#!json false`. - -To store objects in C++, a type is defined by the template parameter `BooleanType` which chooses the type to use. - -## Notes - -#### Default type - -With the default values for `BooleanType` (`#!cpp bool`), the default value for `boolean_t` is `#!cpp bool`. - -#### Storage - -Boolean values are stored directly inside a `basic_json` type. - -## Examples - -??? example - - The following code shows that `boolean_t` is by default, a typedef to `#!cpp bool`. - - ```cpp - --8<-- "examples/boolean_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/boolean_t.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/cbegin.md b/docs/mkdocs/docs/api/basic_json/cbegin.md deleted file mode 100644 index 06504fee60..0000000000 --- a/docs/mkdocs/docs/api/basic_json/cbegin.md +++ /dev/null @@ -1,41 +0,0 @@ -# nlohmann::basic_json::cbegin - -```cpp -const_iterator cbegin() const noexcept; -``` - -Returns an iterator to the first element. - -![Illustration from cppreference.com](../../images/range-begin-end.svg) - -## Return value - -iterator to the first element - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code shows an example for `cbegin()`. - - ```cpp - --8<-- "examples/cbegin.cpp" - ``` - - Output: - - ```json - --8<-- "examples/cbegin.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/cbor_tag_handler_t.md b/docs/mkdocs/docs/api/basic_json/cbor_tag_handler_t.md deleted file mode 100644 index e19c3edd91..0000000000 --- a/docs/mkdocs/docs/api/basic_json/cbor_tag_handler_t.md +++ /dev/null @@ -1,42 +0,0 @@ -# nlohmann::basic_json::cbor_tag_handler_t - -```cpp -enum class cbor_tag_handler_t -{ - error, - ignore, - store -}; -``` - -This enumeration is used in the [`from_cbor`](from_cbor.md) function to choose how to treat tags: - -error -: throw a `parse_error` exception in case of a tag - -ignore -: ignore tags - -store -: store tagged values as binary container with subtype (for bytes 0xd8..0xdb) - -## Examples - -??? example - - The example below shows how the different values of the `cbor_tag_handler_t` influence the behavior of - [`from_cbor`](from_cbor.md) when reading a tagged byte string. - - ```cpp - --8<-- "examples/cbor_tag_handler_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/cbor_tag_handler_t.output" - ``` - -## Version history - -- Added in version 3.9.0. Added value `store` in 3.10.0. diff --git a/docs/mkdocs/docs/api/basic_json/cend.md b/docs/mkdocs/docs/api/basic_json/cend.md deleted file mode 100644 index 3f3aa949de..0000000000 --- a/docs/mkdocs/docs/api/basic_json/cend.md +++ /dev/null @@ -1,41 +0,0 @@ -# nlohmann::basic_json::cend - -```cpp -const_iterator cend() const noexcept; -``` - -Returns an iterator to one past the last element. - -![Illustration from cppreference.com](../../images/range-begin-end.svg) - -## Return value - -iterator one past the last element - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code shows an example for `cend()`. - - ```cpp - --8<-- "examples/cend.cpp" - ``` - - Output: - - ```json - --8<-- "examples/cend.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/clear.md b/docs/mkdocs/docs/api/basic_json/clear.md deleted file mode 100644 index ff04b08e6d..0000000000 --- a/docs/mkdocs/docs/api/basic_json/clear.md +++ /dev/null @@ -1,58 +0,0 @@ -# nlohmann::basic_json::clear - -```cpp -void clear() noexcept; -``` - -Clears the content of a JSON value and resets it to the default value as if [`basic_json(value_t)`](basic_json.md) would -have been called with the current value type from [`type()`](type.md): - -| Value type | initial value | -|------------|----------------------| -| null | `null` | -| boolean | `false` | -| string | `""` | -| number | `0` | -| binary | An empty byte vector | -| object | `{}` | -| array | `[]` | - -Has the same effect as calling - -```.cpp -*this = basic_json(type()); -``` - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Linear in the size of the JSON value. - -## Notes - -All iterators, pointers and references related to this container are invalidated. - -## Examples - -??? example - - The example below shows the effect of `clear()` to different - JSON types. - - ```cpp - --8<-- "examples/clear.cpp" - ``` - - Output: - - ```json - --8<-- "examples/clear.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Added support for binary types in version 3.8.0. diff --git a/docs/mkdocs/docs/api/basic_json/contains.md b/docs/mkdocs/docs/api/basic_json/contains.md deleted file mode 100644 index ba2c3df2d7..0000000000 --- a/docs/mkdocs/docs/api/basic_json/contains.md +++ /dev/null @@ -1,118 +0,0 @@ -# nlohmann::basic_json::contains - -```cpp -// (1) -bool contains(const typename object_t::key_type& key) const; - -// (2) -template -bool contains(KeyType&& key) const; - -// (3) -bool contains(const json_pointer& ptr) const; -``` - -1. Check whether an element exists in a JSON object with a key equivalent to `key`. If the element is not found or the - JSON value is not an object, `#!cpp false` is returned. -2. See 1. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and - `#!cpp typename object_comparator_t::is_transparent` denotes a type. -3. Check whether the given JSON pointer `ptr` can be resolved in the current JSON value. - -## Template parameters - -`KeyType` -: A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with - [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). - This can also be a string view (C++17). - -## Parameters - -`key` (in) -: key value to check its existence. - -`ptr` (in) -: JSON pointer to check its existence. - -## Return value - -1. `#!cpp true` if an element with specified `key` exists. If no such element with such key is found or the JSON value - is not an object, `#!cpp false` is returned. -2. See 1. -3. `#!cpp true` if the JSON pointer can be resolved to a stored value, `#!cpp false` otherwise. - -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - -## Exceptions - -1. The function does not throw exceptions. -2. The function does not throw exceptions. -3. The function can throw the following exceptions: - - Throws [`parse_error.106`](../../home/exceptions.md#jsonexceptionparse_error106) if an array index begins with - `0`. - - Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) if an array index was not a - number. - -## Complexity - -Logarithmic in the size of the JSON object. - -## Notes - -- This method always returns `#!cpp false` when executed on a JSON type that is not an object. -- This method can be executed on any JSON value type. - -!!! info "Postconditions" - - If `#!cpp j.contains(x)` returns `#!c true` for a key or JSON pointer `x`, then it is safe to call `j[x]`. - -## Examples - -??? example "Example: (1) check with key" - - The example shows how `contains()` is used. - - ```cpp - --8<-- "examples/contains__object_t_key_type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/contains__object_t_key_type.output" - ``` - -??? example "Example: (2) check with key using string_view" - - The example shows how `contains()` is used. - - ```cpp - --8<-- "examples/contains__keytype.c++17.cpp" - ``` - - Output: - - ```json - --8<-- "examples/contains__keytype.c++17.output" - ``` - -??? example "Example: (3) check with JSON pointer" - - The example shows how `contains()` is used. - - ```cpp - --8<-- "examples/contains__json_pointer.cpp" - ``` - - Output: - - ```json - --8<-- "examples/contains__json_pointer.output" - ``` - -## Version history - -1. Added in version 3.11.0. -2. Added in version 3.6.0. Extended template `KeyType` to support comparable types in version 3.11.0. -3. Added in version 3.7.0. diff --git a/docs/mkdocs/docs/api/basic_json/count.md b/docs/mkdocs/docs/api/basic_json/count.md deleted file mode 100644 index 4f3a310550..0000000000 --- a/docs/mkdocs/docs/api/basic_json/count.md +++ /dev/null @@ -1,78 +0,0 @@ -# nlohmann::basic_json::count - -```cpp -// (1) -size_type count(const typename object_t::key_type& key) const; - -// (2) -template -size_type count(KeyType&& key) const; -``` - -1. Returns the number of elements with key `key`. If `ObjectType` is the default `std::map` type, the return value will - always be `0` (`key` was not found) or `1` (`key` was found). -2. See 1. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and - `#!cpp typename object_comparator_t::is_transparent` denotes a type. - -## Template parameters - -`KeyType` -: A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with - [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). - This can also be a string view (C++17). - -## Parameters - -`key` (in) -: key value of the element to count. - -## Return value - -Number of elements with key `key`. If the JSON value is not an object, the return value will be `0`. - -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - -## Complexity - -Logarithmic in the size of the JSON object. - -## Notes - -This method always returns `0` when executed on a JSON type that is not an object. - -## Examples - -??? example "Example: (1) count number of elements" - - The example shows how `count()` is used. - - ```cpp - --8<-- "examples/count__object_t_key_type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/count__object_t_key_type.output" - ``` - -??? example "Example: (2) count number of elements using string_view" - - The example shows how `count()` is used. - - ```cpp - --8<-- "examples/count__keytype.c++17.cpp" - ``` - - Output: - - ```json - --8<-- "examples/count__keytype.c++17.output" - ``` - -## Version history - -1. Added in version 3.11.0. -2. Added in version 1.0.0. Changed parameter `key` type to `KeyType&&` in version 3.11.0. diff --git a/docs/mkdocs/docs/api/basic_json/crbegin.md b/docs/mkdocs/docs/api/basic_json/crbegin.md deleted file mode 100644 index 7af5ecae43..0000000000 --- a/docs/mkdocs/docs/api/basic_json/crbegin.md +++ /dev/null @@ -1,41 +0,0 @@ -# nlohmann::basic_json::crbegin - -```cpp -const_reverse_iterator crbegin() const noexcept; -``` - -Returns an iterator to the reverse-beginning; that is, the last element. - -![Illustration from cppreference.com](../../images/range-rbegin-rend.svg) - -## Return value - -reverse iterator to the first element - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code shows an example for `crbegin()`. - - ```cpp - --8<-- "examples/crbegin.cpp" - ``` - - Output: - - ```json - --8<-- "examples/crbegin.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/crend.md b/docs/mkdocs/docs/api/basic_json/crend.md deleted file mode 100644 index 0e6bc84740..0000000000 --- a/docs/mkdocs/docs/api/basic_json/crend.md +++ /dev/null @@ -1,42 +0,0 @@ -# nlohmann::basic_json::crend - -```cpp -const_reverse_iterator crend() const noexcept; -``` - -Returns an iterator to the reverse-end; that is, one before the first element. This element acts as a placeholder, -attempting to access it results in undefined behavior. - -![Illustration from cppreference.com](../../images/range-rbegin-rend.svg) - -## Return value - -reverse iterator to the element following the last element - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code shows an example for `eend()`. - - ```cpp - --8<-- "examples/crend.cpp" - ``` - - Output: - - ```json - --8<-- "examples/crend.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/default_object_comparator_t.md b/docs/mkdocs/docs/api/basic_json/default_object_comparator_t.md deleted file mode 100644 index 8a237f6623..0000000000 --- a/docs/mkdocs/docs/api/basic_json/default_object_comparator_t.md +++ /dev/null @@ -1,35 +0,0 @@ -# nlohmann::basic_json::default_object_comparator_t - -```cpp -using default_object_comparator_t = std::less; // until C++14 - -using default_object_comparator_t = std::less<>; // since C++14 -``` - -The default comparator used by [`object_t`](object_t.md). - -Since C++14 a transparent comparator is used which prevents unnecessary string construction -when looking up a key in an object. - -The actual comparator used depends on [`object_t`](object_t.md) and can be obtained via -[`object_comparator_t`](object_comparator_t.md). - -## Examples - -??? example - - The example below demonstrates the default comparator. - - ```cpp - --8<-- "examples/default_object_comparator_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/default_object_comparator_t.output" - ``` - -## Version history - -- Added in version 3.11.0. diff --git a/docs/mkdocs/docs/api/basic_json/diff.md b/docs/mkdocs/docs/api/basic_json/diff.md deleted file mode 100644 index 4e840684e0..0000000000 --- a/docs/mkdocs/docs/api/basic_json/diff.md +++ /dev/null @@ -1,62 +0,0 @@ -# nlohmann::basic_json::diff - -```cpp -static basic_json diff(const basic_json& source, - const basic_json& target); -``` - -Creates a [JSON Patch](http://jsonpatch.com) so that value `source` can be changed into the value `target` by calling -[`patch`](patch.md) function. - -For two JSON values `source` and `target`, the following code yields always `#!cpp true`: -```cpp -source.patch(diff(source, target)) == target; -``` - -## Parameters - -`source` (in) -: JSON value to compare from - -`target` (in) -: JSON value to compare against - -## Return value - -a JSON patch to convert the `source` to `target` - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Complexity - -Linear in the lengths of `source` and `target`. - -## Notes - -Currently, only `remove`, `add`, and `replace` operations are generated. - -## Examples - -??? example - - The following code shows how a JSON patch is created as a diff for two JSON values. - - ```cpp - --8<-- "examples/diff.cpp" - ``` - - Output: - - ```json - --8<-- "examples/diff.output" - ``` - -## See also - -- [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) - -## Version history - -- Added in version 2.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/dump.md b/docs/mkdocs/docs/api/basic_json/dump.md deleted file mode 100644 index 41adb154d6..0000000000 --- a/docs/mkdocs/docs/api/basic_json/dump.md +++ /dev/null @@ -1,79 +0,0 @@ -# nlohmann::basic_json::dump - -```cpp -string_t dump(const int indent = -1, - const char indent_char = ' ', - const bool ensure_ascii = false, - const error_handler_t error_handler = error_handler_t::strict) const; -``` - -Serialization function for JSON values. The function tries to mimic Python's -[`json.dumps()` function](https://docs.python.org/2/library/json.html#json.dump), and currently supports its `indent` -and `ensure_ascii` parameters. - -## Parameters - -`indent` (in) -: If `indent` is nonnegative, then array elements and object members will be pretty-printed with that indent level. An - indent level of `0` will only insert newlines. `-1` (the default) selects the most compact representation. - -`indent_char` (in) -: The character to use for indentation if `indent` is greater than `0`. The default is ` ` (space). - -`ensure_ascii` (in) -: If `ensure_ascii` is true, all non-ASCII characters in the output are escaped with `\uXXXX` sequences, and the - result consists of ASCII characters only. - -`error_handler` (in) -: how to react on decoding errors; there are three possible values (see [`error_handler_t`](error_handler_t.md): - `strict` (throws and exception in case a decoding error occurs; default), `replace` (replace invalid UTF-8 sequences - with U+FFFD), and `ignore` (ignore invalid UTF-8 sequences during serialization; all bytes are copied to the output - unchanged)). - -## Return value - -string containing the serialization of the JSON value - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes to any JSON value. - -## Exceptions - -Throws [`type_error.316`](../../home/exceptions.md#jsonexceptiontype_error316) if a string stored inside the JSON value -is not UTF-8 encoded and `error_handler` is set to `strict` - -## Complexity - -Linear. - -## Notes - -Binary values are serialized as object containing two keys: - -- "bytes": an array of bytes as integers -- "subtype": the subtype as integer or `#!json null` if the binary has no subtype - -## Examples - -??? example - - The following example shows the effect of different `indent`, `indent_char`, and `ensure_ascii` parameters to the - result of the serialization. - - ```cpp - --8<-- "examples/dump.cpp" - ``` - - Output: - - ```json - --8<-- "examples/dump.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Indentation character `indent_char`, option `ensure_ascii` and exceptions added in version 3.0.0. -- Error handlers added in version 3.4.0. -- Serialization of binary values added in version 3.8.0. diff --git a/docs/mkdocs/docs/api/basic_json/emplace.md b/docs/mkdocs/docs/api/basic_json/emplace.md deleted file mode 100644 index 6cc2c98d75..0000000000 --- a/docs/mkdocs/docs/api/basic_json/emplace.md +++ /dev/null @@ -1,56 +0,0 @@ -# nlohmann::basic_json::emplace - -```cpp -template -std::pair emplace(Args&& ... args); -``` - -Inserts a new element into a JSON object constructed in-place with the given `args` if there is no element with the key -in the container. If the function is called on a JSON null value, an empty object is created before appending the value -created from `args`. - -## Template parameters - -`Args` -: compatible types to create a `basic_json` object - -## Parameters - -`args` (in) -: arguments to forward to a constructor of `basic_json` - -## Return value - -a pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and -a `#!cpp bool` denoting whether the insertion took place. - -## Exceptions - -Throws [`type_error.311`](../../home/exceptions.md#jsonexceptiontype_error311) when called on a type other than JSON -object or `#!json null`; example: `"cannot use emplace() with number"` - -## Complexity - -Logarithmic in the size of the container, O(log(`size()`)). - -## Examples - -??? example - - The example shows how `emplace()` can be used to add elements to a JSON object. Note how the `#!json null` value was - silently converted to a JSON object. Further note how no value is added if there was already one value stored with - the same key. - - ```cpp - --8<-- "examples/emplace.cpp" - ``` - - Output: - - ```json - --8<-- "examples/emplace.output" - ``` - -## Version history - -- Since version 2.0.8. diff --git a/docs/mkdocs/docs/api/basic_json/emplace_back.md b/docs/mkdocs/docs/api/basic_json/emplace_back.md deleted file mode 100644 index 597ad41e45..0000000000 --- a/docs/mkdocs/docs/api/basic_json/emplace_back.md +++ /dev/null @@ -1,54 +0,0 @@ -# nlohmann::basic_json::emplace_back - -```cpp -template -reference emplace_back(Args&& ... args); -``` - -Creates a JSON value from the passed parameters `args` to the end of the JSON value. If the function is called on a JSON -`#!json null` value, an empty array is created before appending the value created from `args`. - -## Template parameters - -`Args` -: compatible types to create a `basic_json` object - -## Parameters - -`args` (in) -: arguments to forward to a constructor of `basic_json` - -## Return value - -reference to the inserted element - -## Exceptions - -Throws [`type_error.311`](../../home/exceptions.md#jsonexceptiontype_error311) when called on a type other than JSON -array or `#!json null`; example: `"cannot use emplace_back() with number"` - -## Complexity - -Amortized constant. - -## Examples - -??? example - - The example shows how `emplace_back()` can be used to add elements to a JSON array. Note how the `null` value was - silently converted to a JSON array. - - ```cpp - --8<-- "examples/emplace_back.cpp" - ``` - - Output: - - ```json - --8<-- "examples/emplace_back.output" - ``` - -## Version history - -- Since version 2.0.8. -- Returns reference since 3.7.0. diff --git a/docs/mkdocs/docs/api/basic_json/empty.md b/docs/mkdocs/docs/api/basic_json/empty.md deleted file mode 100644 index 26bf6e9aaa..0000000000 --- a/docs/mkdocs/docs/api/basic_json/empty.md +++ /dev/null @@ -1,66 +0,0 @@ -# nlohmann::basic_json::empty - -```cpp -bool empty() const noexcept; -``` - -Checks if a JSON value has no elements (i.e. whether its [`size()`](size.md) is `0`). - -## Return value - -The return value depends on the different types and is defined as follows: - -| Value type | return value | -|------------|----------------------------------------| -| null | `#!cpp true` | -| boolean | `#!cpp false` | -| string | `#!cpp false` | -| number | `#!cpp false` | -| binary | `#!cpp false` | -| object | result of function `object_t::empty()` | -| array | result of function `array_t::empty()` | - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Constant, as long as [`array_t`](array_t.md) and [`object_t`](object_t.md) satisfy the -[Container](https://en.cppreference.com/w/cpp/named_req/Container) concept; that is, their `empty()` functions have -constant complexity. - -## Possible implementation - -```cpp -bool empty() const noexcept -{ - return size() == 0; -} -``` - -## Notes - -This function does not return whether a string stored as JSON value is empty -- it returns whether the JSON container -itself is empty which is `#!cpp false` in the case of a string. - -## Examples - -??? example - - The following code uses `empty()` to check if a JSON object contains any elements. - - ```cpp - --8<-- "examples/empty.cpp" - ``` - - Output: - - ```json - --8<-- "examples/empty.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Extended to return `#!cpp false` for binary types in version 3.8.0. diff --git a/docs/mkdocs/docs/api/basic_json/end.md b/docs/mkdocs/docs/api/basic_json/end.md deleted file mode 100644 index 179ce9e67d..0000000000 --- a/docs/mkdocs/docs/api/basic_json/end.md +++ /dev/null @@ -1,42 +0,0 @@ -# nlohmann::basic_json::end - -```cpp -iterator end() noexcept; -const_iterator end() const noexcept; -``` - -Returns an iterator to one past the last element. - -![Illustration from cppreference.com](../../images/range-begin-end.svg) - -## Return value - -iterator one past the last element - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code shows an example for `end()`. - - ```cpp - --8<-- "examples/end.cpp" - ``` - - Output: - - ```json - --8<-- "examples/end.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/erase.md b/docs/mkdocs/docs/api/basic_json/erase.md deleted file mode 100644 index 1187995b61..0000000000 --- a/docs/mkdocs/docs/api/basic_json/erase.md +++ /dev/null @@ -1,211 +0,0 @@ -# nlohmann::basic_json::erase - -```cpp -// (1) -iterator erase(iterator pos); -const_iterator erase(const_iterator pos); - -// (2) -iterator erase(iterator first, iterator last); -const_iterator erase(const_iterator first, const_iterator last); - -// (3) -size_type erase(const typename object_t::key_type& key); - -// (4) -template -size_type erase(KeyType&& key); - -// (5) -void erase(const size_type idx); -``` - -1. Removes an element from a JSON value specified by iterator `pos`. The iterator `pos` must be valid and - dereferenceable. Thus, the `end()` iterator (which is valid, but is not dereferenceable) cannot be used as a value for - `pos`. - - If called on a primitive type other than `#!json null`, the resulting JSON value will be `#!json null`. - -2. Remove an element range specified by `[first; last)` from a JSON value. The iterator `first` does not need to be - dereferenceable if `first == last`: erasing an empty range is a no-op. - - If called on a primitive type other than `#!json null`, the resulting JSON value will be `#!json null`. - -3. Removes an element from a JSON object by key. - -4. See 3. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and - `#!cpp typename object_comparator_t::is_transparent` denotes a type. - -5. Removes an element from a JSON array by index. - -## Template parameters - -`KeyType` -: A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with - [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). - This can also be a string view (C++17). - -## Parameters - -`pos` (in) -: iterator to the element to remove - -`first` (in) -: iterator to the beginning of the range to remove - -`last` (in) -: iterator past the end of the range to remove - -`key` (in) -: object key of the elements to remove - -`idx` (in) -: array index of the element to remove - -## Return value - -1. Iterator following the last removed element. If the iterator `pos` refers to the last element, the `end()` iterator - is returned. -2. Iterator following the last removed element. If the iterator `last` refers to the last element, the `end()` iterator - is returned. -3. Number of elements removed. If `ObjectType` is the default `std::map` type, the return value will always be `0` - (`key` was not found) or `1` (`key` was found). -4. See 3. -5. (none) - -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - -## Exceptions - -1. The function can throw the following exceptions: - - Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) if called on a `null` value; - example: `"cannot use erase() with null"` - - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an - iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` - - Throws [`invalid_iterator.205`](../../home/exceptions.md#jsonexceptioninvalid_iterator205) if called on a - primitive type with invalid iterator (i.e., any iterator which is not `begin()`); example: `"iterator out of - range"` -2. The function can throw the following exceptions: - - Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) if called on a `null` value; - example: `"cannot use erase() with null"` - - Throws [`invalid_iterator.203`](../../home/exceptions.md#jsonexceptioninvalid_iterator203) if called on iterators - which does not belong to the current JSON value; example: `"iterators do not fit current value"` - - Throws [`invalid_iterator.204`](../../home/exceptions.md#jsonexceptioninvalid_iterator204) if called on a - primitive type with invalid iterators (i.e., if `first != begin()` and `last != end()`); example: `"iterators out - of range"` -3. The function can throw the following exceptions: - - Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) when called on a type other than - JSON object; example: `"cannot use erase() with null"` -4. See 3. -5. The function can throw the following exceptions: - - Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) when called on a type other than - JSON object; example: `"cannot use erase() with null"` - - Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) when `idx >= size()`; example: - `"array index 17 is out of range"` - -## Complexity - -1. The complexity depends on the type: - - objects: amortized constant - - arrays: linear in distance between `pos` and the end of the container - - strings and binary: linear in the length of the member - - other types: constant -2. The complexity depends on the type: - - objects: `log(size()) + std::distance(first, last)` - - arrays: linear in the distance between `first` and `last`, plus linear - in the distance between `last` and end of the container - - strings and binary: linear in the length of the member - - other types: constant -3. `log(size()) + count(key)` -4. `log(size()) + count(key)` -5. Linear in distance between `idx` and the end of the container. - -## Notes - -1. Invalidates iterators and references at or after the point of the `erase`, including the `end()` iterator. -2. (none) -3. References and iterators to the erased elements are invalidated. Other references and iterators are not affected. -4. See 3. -5. (none) - -## Examples - -??? example "Example: (1) remove element given an iterator" - - The example shows the effect of `erase()` for different JSON types using an iterator. - - ```cpp - --8<-- "examples/erase__IteratorType.cpp" - ``` - - Output: - - ```json - --8<-- "examples/erase__IteratorType.output" - ``` - -??? example "Example: (2) remove elements given an iterator range" - - The example shows the effect of `erase()` for different JSON types using an iterator range. - - ```cpp - --8<-- "examples/erase__IteratorType_IteratorType.cpp" - ``` - - Output: - - ```json - --8<-- "examples/erase__IteratorType_IteratorType.output" - ``` - -??? example "Example: (3) remove element from a JSON object given a key" - - The example shows the effect of `erase()` for different JSON types using an object key. - - ```cpp - --8<-- "examples/erase__object_t_key_type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/erase__object_t_key_type.output" - ``` - -??? example "Example: (4) remove element from a JSON object given a key using string_view" - - The example shows the effect of `erase()` for different JSON types using an object key. - - ```cpp - --8<-- "examples/erase__keytype.c++17.cpp" - ``` - - Output: - - ```json - --8<-- "examples/erase__keytype.c++17.output" - ``` - -??? example "Example: (5) remove element from a JSON array given an index" - - The example shows the effect of `erase()` using an array index. - - ```cpp - --8<-- "examples/erase__size_type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/erase__size_type.output" - ``` - -## Version history - -1. Added in version 1.0.0. Added support for binary types in version 3.8.0. -2. Added in version 1.0.0. Added support for binary types in version 3.8.0. -3. Added in version 1.0.0. -4. Added in version 3.11.0. -5. Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/error_handler_t.md b/docs/mkdocs/docs/api/basic_json/error_handler_t.md deleted file mode 100644 index dc32ced9b9..0000000000 --- a/docs/mkdocs/docs/api/basic_json/error_handler_t.md +++ /dev/null @@ -1,42 +0,0 @@ -# nlohmann::basic_json::error_handler_t - -```cpp -enum class error_handler_t { - strict, - replace, - ignore -}; -``` - -This enumeration is used in the [`dump`](dump.md) function to choose how to treat decoding errors while serializing a -`basic_json` value. Three values are differentiated: - -strict -: throw a `type_error` exception in case of invalid UTF-8 - -replace -: replace invalid UTF-8 sequences with U+FFFD (� REPLACEMENT CHARACTER) - -ignore -: ignore invalid UTF-8 sequences; all bytes are copied to the output unchanged - -## Examples - -??? example - - The example below shows how the different values of the `error_handler_t` influence the behavior of - [`dump`](dump.md) when reading serializing an invalid UTF-8 sequence. - - ```cpp - --8<-- "examples/error_handler_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/error_handler_t.output" - ``` - -## Version history - -- Added in version 3.4.0. diff --git a/docs/mkdocs/docs/api/basic_json/exception.md b/docs/mkdocs/docs/api/basic_json/exception.md deleted file mode 100644 index b492666d85..0000000000 --- a/docs/mkdocs/docs/api/basic_json/exception.md +++ /dev/null @@ -1,75 +0,0 @@ -# nlohmann::basic_json::exception - -```cpp -class exception : public std::exception; -``` - -This class is an extension of [`std::exception`](https://en.cppreference.com/w/cpp/error/exception) objects with a -member `id` for exception ids. It is used as the base class for all exceptions thrown by the `basic_json` class. This -class can hence be used as "wildcard" to catch exceptions, see example below. - -```plantuml -std::exception <|-- basic_json::exception -basic_json::exception <|-- basic_json::parse_error -basic_json::exception <|-- basic_json::invalid_iterator -basic_json::exception <|-- basic_json::type_error -basic_json::exception <|-- basic_json::out_of_range -basic_json::exception <|-- basic_json::other_error - -interface std::exception {} - -class basic_json::exception #FFFF00 { - + const int id - + const char* what() const -} - -class basic_json::parse_error { - + const std::size_t byte -} -``` - -Subclasses: - -- [`parse_error`](parse_error.md) for exceptions indicating a parse error -- [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators -- [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type -- [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range -- [`other_error`](other_error.md) for exceptions indicating other library errors - -## Member functions - -- **what** - returns explanatory string - -## Member variables - -- **id** - the id of the exception - -## Notes - -To have nothrow-copy-constructible exceptions, we internally use `std::runtime_error` which can cope with -arbitrary-length error messages. Intermediate strings are built with static functions and then passed to the actual -constructor. - -## Examples - -??? example - - The following code shows how arbitrary library exceptions can be caught. - - ```cpp - --8<-- "examples/exception.cpp" - ``` - - Output: - - ```json - --8<-- "examples/exception.output" - ``` - -## See also - -[List of exceptions](127.0.0.1:8000/home/exceptions/) - -## Version history - -- Since version 3.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/find.md b/docs/mkdocs/docs/api/basic_json/find.md deleted file mode 100644 index c64350718d..0000000000 --- a/docs/mkdocs/docs/api/basic_json/find.md +++ /dev/null @@ -1,86 +0,0 @@ -# nlohmann::basic_json::find - -```cpp -// (1) -iterator find(const typename object_t::key_type& key); -const_iterator find(const typename object_t::key_type& key) const; - -// (2) -template -iterator find(KeyType&& key); -template -const_iterator find(KeyType&& key) const; -``` - -1. Finds an element in a JSON object with a key equivalent to `key`. If the element is not found or the - JSON value is not an object, `end()` is returned. -2. See 1. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and - `#!cpp typename object_comparator_t::is_transparent` denotes a type. - -## Template parameters - -`KeyType` -: A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with - [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). - This can also be a string view (C++17). - -## Parameters - -`key` (in) -: key value of the element to search for. - -## Return value - -Iterator to an element with a key equivalent to `key`. If no such element is found or the JSON value is not an object, -a past-the-end iterator (see `end()`) is returned. - -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - -## Complexity - -Logarithmic in the size of the JSON object. - -## Notes - -This method always returns `end()` when executed on a JSON type that is not an object. - -## Examples - -??? example "Example: (1) find object element by key" - - The example shows how `find()` is used. - - ```cpp - --8<-- "examples/find__object_t_key_type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/find__object_t_key_type.output" - ``` - -??? example "Example: (2) find object element by key using string_view" - - The example shows how `find()` is used. - - ```cpp - --8<-- "examples/find__keytype.c++17.cpp" - ``` - - Output: - - ```json - --8<-- "examples/find__keytype.c++17.output" - ``` - -## See also - -- [contains](contains.md) checks whether a key exists - -## Version history - -1. Added in version 3.11.0. -2. Added in version 1.0.0. Changed to support comparable types in version 3.11.0. diff --git a/docs/mkdocs/docs/api/basic_json/flatten.md b/docs/mkdocs/docs/api/basic_json/flatten.md deleted file mode 100644 index 8703e86d1c..0000000000 --- a/docs/mkdocs/docs/api/basic_json/flatten.md +++ /dev/null @@ -1,50 +0,0 @@ -# nlohmann::basic_json::flatten - -```cpp -basic_json flatten() const; -``` - -The function creates a JSON object whose keys are JSON pointers (see [RFC 6901](https://tools.ietf.org/html/rfc6901)) -and whose values are all primitive (see [`is_primitive()`](is_primitive.md) for more information). The original JSON -value can be restored using the [`unflatten()`](unflatten.md) function. - -## Return value - -an object that maps JSON pointers to primitive values - -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - -## Complexity - -Linear in the size the JSON value. - -## Notes - -Empty objects and arrays are flattened to `#!json null` and will not be reconstructed correctly by the -[`unflatten()`](unflatten.md) function. - -## Examples - -??? example - - The following code shows how a JSON object is flattened to an object whose keys consist of JSON pointers. - - ```cpp - --8<-- "examples/flatten.cpp" - ``` - - Output: - - ```json - --8<-- "examples/flatten.output" - ``` - -## See also - -- [unflatten](unflatten.md) the reverse function - -## Version history - -- Added in version 2.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/from_bjdata.md b/docs/mkdocs/docs/api/basic_json/from_bjdata.md deleted file mode 100644 index 3c5eeb351f..0000000000 --- a/docs/mkdocs/docs/api/basic_json/from_bjdata.md +++ /dev/null @@ -1,93 +0,0 @@ -# nlohmann::basic_json::from_bjdata - -```cpp -// (1) -template -static basic_json from_bjdata(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true); -// (2) -template -static basic_json from_bjdata(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true); -``` - -Deserializes a given input to a JSON value using the BJData (Binary JData) serialization format. - -1. Reads from a compatible input. -2. Reads from an iterator range. - -The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/bjdata.md). - -## Template parameters - -`InputType` -: A compatible input, for instance: - - - an `std::istream` object - - a `FILE` pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. - -`IteratorType` -: a compatible iterator type - -## Parameters - -`i` (in) -: an input in BJData format convertible to an input adapter - -`first` (in) -: iterator to start of the input - -`last` (in) -: iterator to end of the input - -`strict` (in) -: whether to expect the input to be consumed until EOF (`#!cpp true` by default) - -`allow_exceptions` (in) -: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) - -## Return value - -deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be -`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Exceptions - -- Throws [parse_error.110](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or - the end of file was not reached when `strict` was set to true -- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs -- Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string could not be parsed - successfully - -## Complexity - -Linear in the size of the input. - -## Examples - -??? example - - The example shows the deserialization of a byte vector in BJData format to a JSON value. - - ```cpp - --8<-- "examples/from_bjdata.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_bjdata.output" - ``` - -## Version history - -- Added in version 3.11.0. diff --git a/docs/mkdocs/docs/api/basic_json/from_bson.md b/docs/mkdocs/docs/api/basic_json/from_bson.md deleted file mode 100644 index 77549370c5..0000000000 --- a/docs/mkdocs/docs/api/basic_json/from_bson.md +++ /dev/null @@ -1,110 +0,0 @@ -# nlohmann::basic_json::from_bson - -```cpp -// (1) -template -static basic_json from_bson(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true); -// (2) -template -static basic_json from_bson(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true); -``` - -Deserializes a given input to a JSON value using the BSON (Binary JSON) serialization format. - -1. Reads from a compatible input. -2. Reads from an iterator range. - -The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/bson.md). - -## Template parameters - -`InputType` -: A compatible input, for instance: - - - an `std::istream` object - - a `FILE` pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. - -`IteratorType` -: a compatible iterator type - -## Parameters - -`i` (in) -: an input in BSON format convertible to an input adapter - -`first` (in) -: iterator to start of the input - -`last` (in) -: iterator to end of the input - -`strict` (in) -: whether to expect the input to be consumed until EOF (`#!cpp true` by default) - -`allow_exceptions` (in) -: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) - -## Return value - -deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be -`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Exceptions - -Throws [`parse_error.114`](../../home/exceptions.md#jsonexceptionparse_error114) if an unsupported BSON record type is -encountered. - -## Complexity - -Linear in the size of the input. - -## Examples - -??? example - - The example shows the deserialization of a byte vector in BSON format to a JSON value. - - ```cpp - --8<-- "examples/from_bson.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_bson.output" - ``` - -## See also - -- [BSON specification](http://bsonspec.org/spec.html) -- [to_bson](to_bson.md) for the analogous serialization -- [from_cbor](from_cbor.md) for the related CBOR format -- [from_msgpack](from_msgpack.md) for the related MessagePack format -- [from_ubjson](from_ubjson.md) for the related UBJSON format - -## Version history - -- Added in version 3.4.0. - -!!! warning "Deprecation" - - - Overload (2) replaces calls to `from_bson` with a pointer and a length as first two parameters, which has been - deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like - `#!cpp from_bson(ptr, len, ...);` with `#!cpp from_bson(ptr, ptr+len, ...);`. - - Overload (2) replaces calls to `from_bson` with a pair of iterators as their first parameter, which has been - deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like - `#!cpp from_bson({ptr, ptr+len}, ...);` with `#!cpp from_bson(ptr, ptr+len, ...);`. - - You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated - function. diff --git a/docs/mkdocs/docs/api/basic_json/from_cbor.md b/docs/mkdocs/docs/api/basic_json/from_cbor.md deleted file mode 100644 index 3aa57b9ec9..0000000000 --- a/docs/mkdocs/docs/api/basic_json/from_cbor.md +++ /dev/null @@ -1,117 +0,0 @@ -# nlohmann::basic_json::from_cbor - -```cpp -// (1) -template -static basic_json from_cbor(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error); - -// (2) -template -static basic_json from_cbor(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error); -``` - -Deserializes a given input to a JSON value using the CBOR (Concise Binary Object Representation) serialization format. - -1. Reads from a compatible input. -2. Reads from an iterator range. - -The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/cbor.md). - -## Template parameters - -`InputType` -: A compatible input, for instance: - - - an `std::istream` object - - a `FILE` pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. - -`IteratorType` -: a compatible iterator type - -## Parameters - -`i` (in) -: an input in CBOR format convertible to an input adapter - -`first` (in) -: iterator to start of the input - -`last` (in) -: iterator to end of the input - -`strict` (in) -: whether to expect the input to be consumed until EOF (`#!cpp true` by default) - -`allow_exceptions` (in) -: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) - -`tag_handler` (in) -: how to treat CBOR tags (optional, `error` by default); see [`cbor_tag_handler_t`](cbor_tag_handler_t.md) for more - information - -## Return value - -deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be -`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Exceptions - -- Throws [parse_error.110](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or - the end of file was not reached when `strict` was set to true -- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if unsupported features from CBOR were - used in the given input or if the input is not valid CBOR -- Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string was expected as map key, - but not found - -## Complexity - -Linear in the size of the input. - -## Examples - -??? example - - The example shows the deserialization of a byte vector in CBOR format to a JSON value. - - ```cpp - --8<-- "examples/from_cbor.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_cbor.output" - ``` - -## Version history - -- Added in version 2.0.9. -- Parameter `start_index` since version 2.1.1. -- Changed to consume input adapters, removed `start_index` parameter, and added `strict` parameter in version 3.0.0. -- Added `allow_exceptions` parameter in version 3.2.0. -- Added `tag_handler` parameter in version 3.9.0. - -!!! warning "Deprecation" - - - Overload (2) replaces calls to `from_cbor` with a pointer and a length as first two parameters, which has been - deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like - `#!cpp from_cbor(ptr, len, ...);` with `#!cpp from_cbor(ptr, ptr+len, ...);`. - - Overload (2) replaces calls to `from_cbor` with a pair of iterators as their first parameter, which has been - deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like - `#!cpp from_cbor({ptr, ptr+len}, ...);` with `#!cpp from_cbor(ptr, ptr+len, ...);`. - - You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated - function. diff --git a/docs/mkdocs/docs/api/basic_json/from_msgpack.md b/docs/mkdocs/docs/api/basic_json/from_msgpack.md deleted file mode 100644 index 117c3865fd..0000000000 --- a/docs/mkdocs/docs/api/basic_json/from_msgpack.md +++ /dev/null @@ -1,109 +0,0 @@ -# nlohmann::basic_json::from_msgpack - -```cpp -// (1) -template -static basic_json from_msgpack(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true); -// (2) -template -static basic_json from_msgpack(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true); -``` - -Deserializes a given input to a JSON value using the MessagePack serialization format. - -1. Reads from a compatible input. -2. Reads from an iterator range. - -The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/messagepack.md). - -## Template parameters - -`InputType` -: A compatible input, for instance: - - - an `std::istream` object - - a `FILE` pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. - -`IteratorType` -: a compatible iterator type - -## Parameters - -`i` (in) -: an input in MessagePack format convertible to an input adapter - -`first` (in) -: iterator to start of the input - -`last` (in) -: iterator to end of the input - -`strict` (in) -: whether to expect the input to be consumed until EOF (`#!cpp true` by default) - -`allow_exceptions` (in) -: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) - -## Return value - -deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be -`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Exceptions - -- Throws [parse_error.110](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or - the end of file was not reached when `strict` was set to true -- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if unsupported features from - MessagePack were used in the given input or if the input is not valid MessagePack -- Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string was expected as map key, - but not found - -## Complexity - -Linear in the size of the input. - -## Examples - -??? example - - The example shows the deserialization of a byte vector in MessagePack format to a JSON value. - - ```cpp - --8<-- "examples/from_msgpack.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_msgpack.output" - ``` - -## Version history - -- Added in version 2.0.9. -- Parameter `start_index` since version 2.1.1. -- Changed to consume input adapters, removed `start_index` parameter, and added `strict` parameter in version 3.0.0. -- Added `allow_exceptions` parameter in version 3.2.0. - -!!! warning "Deprecation" - - - Overload (2) replaces calls to `from_msgpack` with a pointer and a length as first two parameters, which has been - deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like - `#!cpp from_msgpack(ptr, len, ...);` with `#!cpp from_msgpack(ptr, ptr+len, ...);`. - - Overload (2) replaces calls to `from_cbor` with a pair of iterators as their first parameter, which has been - deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like - `#!cpp from_msgpack({ptr, ptr+len}, ...);` with `#!cpp from_msgpack(ptr, ptr+len, ...);`. - - You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated - function. diff --git a/docs/mkdocs/docs/api/basic_json/from_ubjson.md b/docs/mkdocs/docs/api/basic_json/from_ubjson.md deleted file mode 100644 index 08117e89b4..0000000000 --- a/docs/mkdocs/docs/api/basic_json/from_ubjson.md +++ /dev/null @@ -1,106 +0,0 @@ -# nlohmann::basic_json::from_ubjson - -```cpp -// (1) -template -static basic_json from_ubjson(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true); -// (2) -template -static basic_json from_ubjson(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true); -``` - -Deserializes a given input to a JSON value using the UBJSON (Universal Binary JSON) serialization format. - -1. Reads from a compatible input. -2. Reads from an iterator range. - -The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/ubjson.md). - -## Template parameters - -`InputType` -: A compatible input, for instance: - - - an `std::istream` object - - a `FILE` pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. - -`IteratorType` -: a compatible iterator type - -## Parameters - -`i` (in) -: an input in UBJSON format convertible to an input adapter - -`first` (in) -: iterator to start of the input - -`last` (in) -: iterator to end of the input - -`strict` (in) -: whether to expect the input to be consumed until EOF (`#!cpp true` by default) - -`allow_exceptions` (in) -: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) - -## Return value - -deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be -`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Exceptions - -- Throws [parse_error.110](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or - the end of file was not reached when `strict` was set to true -- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs -- Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string could not be parsed - successfully - -## Complexity - -Linear in the size of the input. - -## Examples - -??? example - - The example shows the deserialization of a byte vector in UBJSON format to a JSON value. - - ```cpp - --8<-- "examples/from_ubjson.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_ubjson.output" - ``` - -## Version history - -- Added in version 3.1.0. -- Added `allow_exceptions` parameter in version 3.2.0. - -!!! warning "Deprecation" - - - Overload (2) replaces calls to `from_ubjson` with a pointer and a length as first two parameters, which has been - deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like - `#!cpp from_ubjson(ptr, len, ...);` with `#!cpp from_ubjson(ptr, ptr+len, ...);`. - - Overload (2) replaces calls to `from_ubjson` with a pair of iterators as their first parameter, which has been - deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like - `#!cpp from_ubjson({ptr, ptr+len}, ...);` with `#!cpp from_ubjson(ptr, ptr+len, ...);`. - - You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated - function. diff --git a/docs/mkdocs/docs/api/basic_json/front.md b/docs/mkdocs/docs/api/basic_json/front.md deleted file mode 100644 index e258c36a06..0000000000 --- a/docs/mkdocs/docs/api/basic_json/front.md +++ /dev/null @@ -1,58 +0,0 @@ -# nlohmann::basic_json::front - -```cpp -reference front(); -const_reference front() const; -``` - -Returns a reference to the first element in the container. For a JSON container `#!cpp c`, the expression -`#!cpp c.front()` is equivalent to `#!cpp *c.begin()`. - -## Return value - -In case of a structured type (array or object), a reference to the first element is returned. In case of number, string, -boolean, or binary values, a reference to the value is returned. - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Exceptions - -If the JSON value is `#!json null`, exception -[`invalid_iterator.214`](../../home/exceptions.md#jsonexceptioninvalid_iterator214) is thrown. - -## Complexity - -Constant. - -## Notes - -!!! info "Precondition" - - The array or object must not be empty. Calling `front` on an empty array or object yields undefined behavior. - -## Examples - -??? example - - The following code shows an example for `front()`. - - ```cpp - --8<-- "examples/front.cpp" - ``` - - Output: - - ```json - --8<-- "examples/front.output" - ``` - -## See also - -- [back](back.md) to access the last element - -## Version history - -- Added in version 1.0.0. -- Adjusted code to return reference to binary values in version 3.8.0. diff --git a/docs/mkdocs/docs/api/basic_json/get.md b/docs/mkdocs/docs/api/basic_json/get.md deleted file mode 100644 index 96fc221daa..0000000000 --- a/docs/mkdocs/docs/api/basic_json/get.md +++ /dev/null @@ -1,136 +0,0 @@ -# nlohmann::basic_json::get - -```cpp -// (1) -template -ValueType get() const noexcept( - noexcept(JSONSerializer::from_json( - std::declval(), std::declval()))); - -// (2) -template -BasicJsonType get() const; - -// (3) -template -PointerType get_ptr(); - -template -constexpr const PointerType get_ptr() const noexcept; -``` - -1. Explicit type conversion between the JSON value and a compatible value which is - [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible) and - [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). The value is converted by - calling the `json_serializer` `from_json()` method. - - The function is equivalent to executing - ```cpp - ValueType ret; - JSONSerializer::from_json(*this, ret); - return ret; - ``` - - This overload is chosen if: - - - `ValueType` is not `basic_json`, - - `json_serializer` has a `from_json()` method of the form - `void from_json(const basic_json&, ValueType&)`, and - - `json_serializer` does not have a `from_json()` method of the form - `ValueType from_json(const basic_json&)` - - If the type is **not** [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible) and - **not** [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible), the value is - converted by calling the `json_serializer` `from_json()` method. - - The function is then equivalent to executing - ```cpp - return JSONSerializer::from_json(*this); - ``` - - This overload is chosen if: - - - `ValueType` is not `basic_json` and - - `json_serializer` has a `from_json()` method of the form - `ValueType from_json(const basic_json&)` - - If `json_serializer` has both overloads of `from_json()`, the latter one is chosen. - -2. Overload for `basic_json` specializations. The function is equivalent to executing - ```cpp - return *this; - ``` - -3. Explicit pointer access to the internally stored JSON value. No copies are made. - -## Template parameters - -`ValueType` -: the value type to return - -`BasicJsonType` -: a specialization of `basic_json` - -`PointerType` -: pointer type; must be a pointer to [`array_t`](array_t.md), [`object_t`](object_t.md), [`string_t`](string_t.md), - [`boolean_t`](boolean_t.md), [`number_integer_t`](number_integer_t.md), or - [`number_unsigned_t`](number_unsigned_t.md), [`number_float_t`](number_float_t.md), or [`binary_t`](binary_t.md). - Other types will not compile. - -## Return value - -1. copy of the JSON value, converted to `ValueType` -2. a copy of `#!cpp *this`, converted into `BasicJsonType` -3. pointer to the internally stored JSON value if the requested pointer type fits to the JSON value; `#!cpp nullptr` - otherwise - -## Exceptions - -Depends on what `json_serializer` `from_json()` method throws - -## Notes - -!!! danger "Undefined behavior" - - Writing data to the pointee (overload 3) of the result yields an undefined state. - -## Examples - -??? example - - The example below shows several conversions from JSON values - to other types. There a few things to note: (1) Floating-point numbers can - be converted to integers, (2) A JSON array can be converted to a standard - `std::vector`, (3) A JSON object can be converted to C++ - associative containers such as `std::unordered_map`. - - ```cpp - --8<-- "examples/get__ValueType_const.cpp" - ``` - - Output: - - ```json - --8<-- "examples/get__ValueType_const.output" - ``` - -??? example - - The example below shows how pointers to internal values of a JSON value can be requested. Note that no type - conversions are made and a `#cpp nullptr` is returned if the value and the requested pointer type does not match. - - ```cpp - --8<-- "examples/get__PointerType.cpp" - ``` - - Output: - - ```json - --8<-- "examples/get__PointerType.output" - ``` - -## Version history - -1. Since version 2.1.0. -2. Since version 2.1.0. Extended to work with other specializations of `basic_json` in version 3.2.0. -3. Since version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/get_allocator.md b/docs/mkdocs/docs/api/basic_json/get_allocator.md deleted file mode 100644 index 07a4d84560..0000000000 --- a/docs/mkdocs/docs/api/basic_json/get_allocator.md +++ /dev/null @@ -1,31 +0,0 @@ -# nlohmann::basic_json::get_allocator - -```cpp -static allocator_type get_allocator(); -``` - -Returns the allocator associated with the container. - -## Return value - -associated allocator - -## Examples - -??? example - - The example shows how `get_allocator()` is used to created `json` values. - - ```cpp - --8<-- "examples/get_allocator.cpp" - ``` - - Output: - - ```json - --8<-- "examples/get_allocator.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/get_binary.md b/docs/mkdocs/docs/api/basic_json/get_binary.md deleted file mode 100644 index a910f3aa56..0000000000 --- a/docs/mkdocs/docs/api/basic_json/get_binary.md +++ /dev/null @@ -1,45 +0,0 @@ -# nlohmann::basic_json::get_binary - -```cpp -binary_t& get_binary(); - -const binary_t& get_binary() const; -``` - -Returns a reference to the stored binary value. - -## Return value - -Reference to binary value. - -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - -## Exceptions - -Throws [`type_error.302`](../../home/exceptions.md#jsonexceptiontype_error302) if the value is not binary - -## Complexity - -Constant. - -## Examples - -??? example - - The following code shows how to query a binary value. - - ```cpp - --8<-- "examples/get_binary.cpp" - ``` - - Output: - - ```json - --8<-- "examples/get_binary.output" - ``` - -## Version history - -- Added in version 3.8.0. diff --git a/docs/mkdocs/docs/api/basic_json/get_ptr.md b/docs/mkdocs/docs/api/basic_json/get_ptr.md deleted file mode 100644 index 2441e1156e..0000000000 --- a/docs/mkdocs/docs/api/basic_json/get_ptr.md +++ /dev/null @@ -1,60 +0,0 @@ -# nlohmann::basic_json::get_ptr - -```cpp -template -PointerType get_ptr() noexcept; - -template -constexpr const PointerType get_ptr() const noexcept; -``` - -Implicit pointer access to the internally stored JSON value. No copies are made. - -## Template parameters - -`PointerType` -: pointer type; must be a pointer to [`array_t`](array_t.md), [`object_t`](object_t.md), [`string_t`](string_t.md), - [`boolean_t`](boolean_t.md), [`number_integer_t`](number_integer_t.md), or - [`number_unsigned_t`](number_unsigned_t.md), [`number_float_t`](number_float_t.md), or [`binary_t`](binary_t.md). - Other types will not compile. - -## Return value - -pointer to the internally stored JSON value if the requested pointer type fits to the JSON value; `#!cpp nullptr` -otherwise - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Constant. - -## Notes - -!!! danger "Undefined behavior" - - Writing data to the pointee of the result yields an undefined state. - -## Examples - -??? example - - The example below shows how pointers to internal values of a JSON value can be requested. Note that no type - conversions are made and a `#!cpp nullptr` is returned if the value and the requested pointer type does not match. - - ```cpp - --8<-- "examples/get_ptr.cpp" - ``` - - Output: - - ```json - --8<-- "examples/get_ptr.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Extended to binary types in version 3.8.0. diff --git a/docs/mkdocs/docs/api/basic_json/get_ref.md b/docs/mkdocs/docs/api/basic_json/get_ref.md deleted file mode 100644 index b1219742ca..0000000000 --- a/docs/mkdocs/docs/api/basic_json/get_ref.md +++ /dev/null @@ -1,64 +0,0 @@ -# nlohmann::basic_json::get_ref - -```cpp -template -ReferenceType get_ref(); - -template -const ReferenceType get_ref() const; -``` - -Implicit reference access to the internally stored JSON value. No copies are made. - -## Template parameters - -`ReferenceType` -: reference type; must be a reference to [`array_t`](array_t.md), [`object_t`](object_t.md), - [`string_t`](string_t.md), [`boolean_t`](boolean_t.md), [`number_integer_t`](number_integer_t.md), or - [`number_unsigned_t`](number_unsigned_t.md), [`number_float_t`](number_float_t.md), or [`binary_t`](binary_t.md). - Enforced by a static assertion. - -## Return value - -reference to the internally stored JSON value if the requested reference type fits to the JSON value; throws -[`type_error.303`](../../home/exceptions.md#jsonexceptiontype_error303) otherwise - -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - -## Exceptions - -Throws [`type_error.303`](../../home/exceptions.md#jsonexceptiontype_error303) if the requested reference type does not -match the stored JSON value type; example: `"incompatible ReferenceType for get_ref, actual type is binary"`. - -## Complexity - -Constant. - -## Notes - -!!! danger "Undefined behavior" - - Writing data to the referee of the result yields an undefined state. - -## Examples - -??? example - - The example shows several calls to `get_ref()`. - - ```cpp - --8<-- "examples/get_ref.cpp" - ``` - - Output: - - ```json - --8<-- "examples/get_ref.output" - ``` - -## Version history - -- Added in version 1.1.0. -- Extended to binary types in version 3.8.0. diff --git a/docs/mkdocs/docs/api/basic_json/get_to.md b/docs/mkdocs/docs/api/basic_json/get_to.md deleted file mode 100644 index 6af6d212c7..0000000000 --- a/docs/mkdocs/docs/api/basic_json/get_to.md +++ /dev/null @@ -1,58 +0,0 @@ -# nlohmann::basic_json::get_to - -```cpp -template -ValueType& get_to(ValueType& v) const noexcept( - noexcept(JSONSerializer::from_json( - std::declval(), v))); -``` - -Explicit type conversion between the JSON value and a compatible value. The value is filled into the input parameter by -calling the `json_serializer` `from_json()` method. - -The function is equivalent to executing -```cpp -ValueType v; -JSONSerializer::from_json(*this, v); -``` - -This overload is chosen if: - -- `ValueType` is not `basic_json`, -- `json_serializer` has a `from_json()` method of the form `void from_json(const basic_json&, ValueType&)` - -## Template parameters - -`ValueType` -: the value type to return - -## Return value - -the input parameter, allowing chaining calls - -## Exceptions - -Depends on what `json_serializer` `from_json()` method throws - -## Examples - -??? example - - The example below shows several conversions from JSON values to other types. There a few things to note: (1) - Floating-point numbers can be converted to integers, (2) A JSON array can be converted to a standard - `#!cpp std::vector`, (3) A JSON object can be converted to C++ associative containers such as - `#cpp std::unordered_map`. - - ```cpp - --8<-- "examples/get_to.cpp" - ``` - - Output: - - ```json - --8<-- "examples/get_to.output" - ``` - -## Version history - -- Since version 3.3.0. diff --git a/docs/mkdocs/docs/api/basic_json/index.md b/docs/mkdocs/docs/api/basic_json/index.md deleted file mode 100644 index fb2be8fefa..0000000000 --- a/docs/mkdocs/docs/api/basic_json/index.md +++ /dev/null @@ -1,323 +0,0 @@ -# nlohmann::basic_json - -Defined in header `` - -```cpp -template< - template class ObjectType = std::map, - template class ArrayType = std::vector, - class StringType = std::string, - class BooleanType = bool, - class NumberIntegerType = std::int64_t, - class NumberUnsignedType = std::uint64_t, - class NumberFloatType = double, - template class AllocatorType = std::allocator, - template class JSONSerializer = adl_serializer, - class BinaryType = std::vector -> -class basic_json; -``` - -## Template parameters - -| Template parameter | Description | Derived type | -|----------------------|---------------------------------------------------------------------------|---------------------------------------------| -| `ObjectType` | type for JSON objects | [`object_t`](object_t.md) | -| `ArrayType` | type for JSON arrays | [`array_t`](array_t.md) | -| `StringType` | type for JSON strings and object keys | [`string_t`](string_t.md) | -| `BooleanType` | type for JSON booleans | [`boolean_t`](boolean_t.md) | -| `NumberIntegerType` | type for JSON integer numbers | [`number_integer_t`](number_integer_t.md) | -| `NumberUnsignedType` | type for JSON unsigned integer numbers | [`number_unsigned_t`](number_unsigned_t.md) | -| `NumberFloatType` | type for JSON floating-point numbers | [`number_float_t`](number_float_t.md) | -| `AllocatorType` | type of the allocator to use | | -| `JSONSerializer` | the serializer to resolve internal calls to `to_json()` and `from_json()` | [`json_serializer`](json_serializer.md) | -| `BinaryType` | type for binary arrays | [`binary_t`](binary_t.md) | -| `CustomBaseClass` | extension point for user code | [`json_base_class_t`](json_base_class_t.md) | - -## Specializations - -- [**json**](../json.md) - default specialization -- [**ordered_json**](../ordered_json.md) - specialization that maintains the insertion order of object keys - -## Iterator invalidation - -Todo - -## Requirements - -The class satisfies the following concept requirements: - -### Basic - -- [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible): JSON values can be default - constructed. The result will be a JSON null value. -- [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible): A JSON value can be constructed - from an rvalue argument. -- [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible): A JSON value can be - copy-constructed from an lvalue expression. -- [MoveAssignable](https://en.cppreference.com/w/cpp/named_req/MoveAssignable): A JSON value can be assigned from an - rvalue argument. -- [CopyAssignable](https://en.cppreference.com/w/cpp/named_req/CopyAssignable): A JSON value can be copy-assigned from - an lvalue expression. -- [Destructible](https://en.cppreference.com/w/cpp/named_req/Destructible): JSON values can be destructed. - -### Layout - -- [StandardLayoutType](https://en.cppreference.com/w/cpp/named_req/StandardLayoutType): JSON values have - [standard layout](https://en.cppreference.com/w/cpp/language/data_members#Standard_layout): All non-static data - members are private and standard layout types, the class has no virtual functions or (virtual) base classes. - -### Library-wide - -- [EqualityComparable](https://en.cppreference.com/w/cpp/named_req/EqualityComparable): JSON values can be compared with - `==`, see [`operator==`](operator_eq.md). -- [LessThanComparable](https://en.cppreference.com/w/cpp/named_req/LessThanComparable): JSON values can be compared with - `<`, see [`operator<`](operator_le). -- [Swappable](https://en.cppreference.com/w/cpp/named_req/Swappable): Any JSON lvalue or rvalue of can be swapped with - any lvalue or rvalue of other compatible types, using unqualified function `swap`. -- [NullablePointer](https://en.cppreference.com/w/cpp/named_req/NullablePointer): JSON values can be compared against - `std::nullptr_t` objects which are used to model the `null` value. - -### Container - -- [Container](https://en.cppreference.com/w/cpp/named_req/Container): JSON values can be used like STL containers and - provide iterator access. -- [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer): JSON values can be used like - STL containers and provide reverse iterator access. - -## Member types - -- [**adl_serializer**](../adl_serializer) - the default serializer -- [**value_t**](value_t.md) - the JSON type enumeration -- [**json_pointer**](../json_pointer/index.md) - JSON Pointer implementation -- [**json_serializer**](json_serializer.md) - type of the serializer to for conversions from/to JSON -- [**error_handler_t**](error_handler_t.md) - type to choose behavior on decoding errors -- [**cbor_tag_handler_t**](cbor_tag_handler_t.md) - type to choose how to handle CBOR tags -- **initializer_list_t** - type for initializer lists of `basic_json` values -- [**input_format_t**](input_format_t.md) - type to choose the format to parse -- [**json_sax_t**](../json_sax/index.md) - type for SAX events - -### Exceptions - -- [**exception**](exception.md) - general exception of the `basic_json` class - - [**parse_error**](parse_error.md) - exception indicating a parse error - - [**invalid_iterator**](invalid_iterator.md) - exception indicating errors with iterators - - [**type_error**](type_error.md) - exception indicating executing a member function with a wrong type - - [**out_of_range**](out_of_range.md) - exception indicating access out of the defined range - - [**other_error**](other_error.md) - exception indicating other library errors - -### Container types - -| Type | Definition | -|--------------------------|-----------------------------------------------------------------------------------------------------------| -| `value_type` | `#!cpp basic_json` | -| `reference` | `#!cpp value_type&` | -| `const_reference` | `#!cpp const value_type&` | -| `difference_type` | `#!cpp std::ptrdiff_t` | -| `size_type` | `#!cpp std::size_t` | -| `allocator_type` | `#!cpp AllocatorType` | -| `pointer` | `#!cpp std::allocator_traits::pointer` | -| `const_pointer` | `#!cpp std::allocator_traits::const_pointer` | -| `iterator` | [LegacyBidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator) | -| `const_iterator` | constant [LegacyBidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator) | -| `reverse_iterator` | reverse iterator, derived from `iterator` | -| `const_reverse_iterator` | reverse iterator, derived from `const_iterator` | -| `iteration_proxy` | helper type for [`items`](items.md) function | - -### JSON value data types - -- [**array_t**](array_t.md) - type for arrays -- [**binary_t**](binary_t.md) - type for binary arrays -- [**boolean_t**](boolean_t.md) - type for booleans -- [**default_object_comparator_t**](default_object_comparator_t.md) - default comparator for objects -- [**number_float_t**](number_float_t.md) - type for numbers (floating-point) -- [**number_integer_t**](number_integer_t.md) - type for numbers (integer) -- [**number_unsigned_t**](number_unsigned_t.md) - type for numbers (unsigned) -- [**object_comparator_t**](object_comparator_t.md) - comparator for objects -- [**object_t**](object_t.md) - type for objects -- [**string_t**](string_t.md) - type for strings - -### Parser callback - -- [**parse_event_t**](parse_event_t.md) - parser event types -- [**parser_callback_t**](parser_callback_t.md) - per-element parser callback type - -## Member functions - -- [(constructor)](basic_json.md) -- [(destructor)](~basic_json.md) -- [**operator=**](operator=.md) - copy assignment -- [**array**](array_t.md) (_static_) - explicitly create an array -- [**binary**](binary.md) (_static_) - explicitly create a binary array -- [**object**](object_t.md) (_static_) - explicitly create an object - -### Object inspection - -Functions to inspect the type of a JSON value. - -- [**type**](type.md) - return the type of the JSON value -- [**operator value_t**](operator_value_t.md) - return the type of the JSON value -- [**type_name**](type_name.md) - return the type as string -- [**is_primitive**](is_primitive.md) - return whether type is primitive -- [**is_structured**](is_structured.md) - return whether type is structured -- [**is_null**](is_null.md) - return whether value is null -- [**is_boolean**](is_boolean.md) - return whether value is a boolean -- [**is_number**](is_number.md) - return whether value is a number -- [**is_number_integer**](is_number_integer.md) - return whether value is an integer number -- [**is_number_unsigned**](is_number_unsigned.md) - return whether value is an unsigned integer number -- [**is_number_float**](is_number_float.md) - return whether value is a floating-point number -- [**is_object**](is_object.md) - return whether value is an object -- [**is_array**](is_array.md) - return whether value is an array -- [**is_string**](is_string.md) - return whether value is a string -- [**is_binary**](is_binary.md) - return whether value is a binary array -- [**is_discarded**](is_discarded.md) - return whether value is discarded - -### Value access - -Direct access to the stored value of a JSON value. - -- [**get**](get.md) - get a value -- [**get_to**](get_to.md) - get a value and write it to a destination -- [**get_ptr**](get_ptr.md) - get a pointer value -- [**get_ref**](get_ref.md) - get a reference value -- [**operator ValueType**](operator_ValueType.md) - get a value -- [**get_binary**](get_binary.md) - get a binary value - -### Element access - -Access to the JSON value - -- [**at**](at.md) - access specified element with bounds checking -- [**operator[]**](operator[].md) - access specified element -- [**value**](value.md) - access specified object element with default value -- [**front**](front.md) - access the first element -- [**back**](back.md) - access the last element - -### Lookup - -- [**find**](find.md) - find an element in a JSON object -- [**count**](count.md) - returns the number of occurrences of a key in a JSON object -- [**contains**](contains.md) - check the existence of an element in a JSON object - -### Iterators - -- [**begin**](begin.md) - returns an iterator to the first element -- [**cbegin**](cbegin.md) - returns a const iterator to the first element -- [**end**](end.md) - returns an iterator to one past the last element -- [**cend**](cend.md) - returns a const iterator to one past the last element -- [**rbegin**](rbegin.md) - returns an iterator to the reverse-beginning -- [**rend**](rend.md) - returns an iterator to the reverse-end -- [**crbegin**](crbegin.md) - returns a const iterator to the reverse-beginning -- [**crend**](crend.md) - returns a const iterator to the reverse-end -- [**items**](items.md) - wrapper to access iterator member functions in range-based for - -### Capacity - -- [**empty**](empty.md) - checks whether the container is empty -- [**size**](size.md) - returns the number of elements -- [**max_size**](max_size.md) - returns the maximum possible number of elements - -### Modifiers - -- [**clear**](clear.md) - clears the contents -- [**push_back**](push_back.md) - add a value to an array/object -- [**operator+=**](operator+=.md) - add a value to an array/object -- [**emplace_back**](emplace_back.md) - add a value to an array -- [**emplace**](emplace.md) - add a value to an object if key does not exist -- [**erase**](erase.md) - remove elements -- [**insert**](insert.md) - inserts elements -- [**update**](update.md) - updates a JSON object from another object, overwriting existing keys -- [**swap**](swap.md) - exchanges the values - -### Lexicographical comparison operators - -- [**operator==**](operator_eq.md) - comparison: equal -- [**operator!=**](operator_ne.md) - comparison: not equal -- [**operator<**](operator_lt.md) - comparison: less than -- [**operator>**](operator_gt.md) - comparison: greater than -- [**operator<=**](operator_le.md) - comparison: less than or equal -- [**operator>=**](operator_ge.md) - comparison: greater than or equal -- [**operator<=>**](operator_spaceship.md) - comparison: 3-way - -### Serialization / Dumping - -- [**dump**](dump.md) - serialization - -### Deserialization / Parsing - -- [**parse**](parse.md) (_static_) - deserialize from a compatible input -- [**accept**](accept.md) (_static_) - check if the input is valid JSON -- [**sax_parse**](sax_parse.md) (_static_) - generate SAX events - -### JSON Pointer functions - -- [**flatten**](flatten.md) - return flattened JSON value -- [**unflatten**](unflatten.md) - unflatten a previously flattened JSON value - -### JSON Patch functions - -- [**patch**](patch.md) - applies a JSON patch -- [**patch_inplace**](patch_inplace.md) - applies a JSON patch in place -- [**diff**](diff.md) (_static_) - creates a diff as a JSON patch - -### JSON Merge Patch functions - -- [**merge_patch**](merge_patch.md) - applies a JSON Merge Patch - -## Static functions - -- [**meta**](meta.md) - returns version information on the library -- [**get_allocator**](get_allocator.md) - returns the allocator associated with the container - -### Binary formats - -- [**from_bjdata**](from_bjdata.md) (_static_) - create a JSON value from an input in BJData format -- [**from_bson**](from_bson.md) (_static_) - create a JSON value from an input in BSON format -- [**from_cbor**](from_cbor.md) (_static_) - create a JSON value from an input in CBOR format -- [**from_msgpack**](from_msgpack.md) (_static_) - create a JSON value from an input in MessagePack format -- [**from_ubjson**](from_ubjson.md) (_static_) - create a JSON value from an input in UBJSON format -- [**to_bjdata**](to_bjdata.md) (_static_) - create a BJData serialization of a given JSON value -- [**to_bson**](to_bson.md) (_static_) - create a BSON serialization of a given JSON value -- [**to_cbor**](to_cbor.md) (_static_) - create a CBOR serialization of a given JSON value -- [**to_msgpack**](to_msgpack.md) (_static_) - create a MessagePack serialization of a given JSON value -- [**to_ubjson**](to_ubjson.md) (_static_) - create a UBJSON serialization of a given JSON value - -## Non-member functions - -- [**operator<<(std::ostream&)**](../operator_ltlt.md) - serialize to stream -- [**operator>>(std::istream&)**](../operator_gtgt.md) - deserialize from stream -- [**to_string**](to_string.md) - user-defined `to_string` function for JSON values - -## Literals - -- [**operator""_json**](../operator_literal_json.md) - user-defined string literal for JSON values - -## Helper classes - -- [**std::hash<basic_json>**](std_hash.md) - return a hash value for a JSON object -- [**std::swap<basic_json>**](std_swap.md) - exchanges the values of two JSON objects - -## Examples - -??? example - - The example shows how the library is used. - - ```cpp - --8<-- "examples/README.cpp" - ``` - - Output: - - ```json - --8<-- "examples/README.output" - ``` - -## See also - -- [RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format](https://tools.ietf.org/html/rfc8259) - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/input_format_t.md b/docs/mkdocs/docs/api/basic_json/input_format_t.md deleted file mode 100644 index a3baabab8e..0000000000 --- a/docs/mkdocs/docs/api/basic_json/input_format_t.md +++ /dev/null @@ -1,52 +0,0 @@ -# nlohmann::basic_json::input_format_t - -```cpp -enum class input_format_t { - json, - cbor, - msgpack, - ubjson, - bson, - bjdata -}; -``` - -This enumeration is used in the [`sax_parse`](sax_parse.md) function to choose the input format to parse: - -json -: JSON (JavaScript Object Notation) - -cbor -: CBOR (Concise Binary Object Representation) - -msgpack -: MessagePack - -ubjson -: UBJSON (Universal Binary JSON) - -bson -: BSON (Binary JSON) - -bjdata -: BJData (Binary JData) - -## Examples - -??? example - - The example below shows how an `input_format_t` enum value is passed to `sax_parse` to set the input format to CBOR. - - ```cpp - --8<-- "examples/sax_parse__binary.cpp" - ``` - - Output: - - ```json - --8<-- "examples/sax_parse__binary.output" - ``` - -## Version history - -- Added in version 3.2.0. diff --git a/docs/mkdocs/docs/api/basic_json/insert.md b/docs/mkdocs/docs/api/basic_json/insert.md deleted file mode 100644 index 2e6b29301e..0000000000 --- a/docs/mkdocs/docs/api/basic_json/insert.md +++ /dev/null @@ -1,179 +0,0 @@ -# nlohmann::basic_json::insert - -```cpp -// (1) -iterator insert(const_iterator pos, const basic_json& val); -iterator insert(const_iterator pos, basic_json&& val); - -// (2) -iterator insert(const_iterator pos, size_type cnt, const basic_json& val); - -// (3) -iterator insert(const_iterator pos, const_iterator first, const_iterator last); - -// (4) -iterator insert(const_iterator pos, initializer_list_t ilist); - -// (5) -void insert(const_iterator first, const_iterator last); -``` - -1. Inserts element `val` into array before iterator `pos`. -2. Inserts `cnt` copies of `val` into array before iterator `pos`. -3. Inserts elements from range `[first, last)` into array before iterator `pos`. -4. Inserts elements from initializer list `ilist` into array before iterator `pos`. -5. Inserts elements from range `[first, last)` into object. - -## Parameters - -`pos` (in) -: iterator before which the content will be inserted; may be the `end()` iterator - -`val` (in) -: value to insert - -`cnt` (in) -: number of copies of `val` to insert - -`first` (in) -: begin of the range of elements to insert - -`last` (in) -: end of the range of elements to insert - -`ilist` (in) -: initializer list to insert the values from - -## Return value - -1. iterator pointing to the inserted `val`. -2. iterator pointing to the first element inserted, or `pos` if `#!cpp cnt==0` -3. iterator pointing to the first element inserted, or `pos` if `#!cpp first==last` -4. iterator pointing to the first element inserted, or `pos` if `ilist` is empty -5. (none) - -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - -## Exceptions - -1. The function can throw the following exceptions: - - Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than - arrays; example: `"cannot use insert() with string"` - - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an - iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` -2. The function can throw the following exceptions: - - Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than - arrays; example: `"cannot use insert() with string"` - - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an - iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` -3. The function can throw the following exceptions: - - Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than - arrays; example: `"cannot use insert() with string"` - - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an - iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` - - Throws [`invalid_iterator.210`](../../home/exceptions.md#jsonexceptioninvalid_iterator210) if `first` and `last` - do not belong to the same JSON value; example: `"iterators do not fit"` - - Throws [`invalid_iterator.211`](../../home/exceptions.md#jsonexceptioninvalid_iterator211) if `first` or `last` - are iterators into container for which insert is called; example: `"passed iterators may not belong to container"` -4. The function can throw the following exceptions: - - Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than - arrays; example: `"cannot use insert() with string"` - - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an - iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` -5. The function can throw the following exceptions: - - Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than - objects; example: `"cannot use insert() with string"` - - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an - iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` - - Throws [`invalid_iterator.210`](../../home/exceptions.md#jsonexceptioninvalid_iterator210) if `first` and `last` - do not belong to the same JSON value; example: `"iterators do not fit"` - -## Complexity - -1. Constant plus linear in the distance between `pos` and end of the container. -2. Linear in `cnt` plus linear in the distance between `pos` and end of the container. -3. Linear in `#!cpp std::distance(first, last)` plus linear in the distance between `pos` and end of the container. -4. Linear in `ilist.size()` plus linear in the distance between `pos` and end of the container. -5. Logarithmic: `O(N*log(size() + N))`, where `N` is the number of elements to insert. - -## Examples - -??? example "Example (1): insert element into array" - - The example shows how `insert()` is used. - - ```cpp - --8<-- "examples/insert.cpp" - ``` - - Output: - - ```json - --8<-- "examples/insert.output" - ``` - -??? example "Example (2): insert copies of element into array" - - The example shows how `insert()` is used. - - ```cpp - --8<-- "examples/insert__count.cpp" - ``` - - Output: - - ```json - --8<-- "examples/insert__count.output" - ``` - -??? example "Example (3): insert range of elements into array" - - The example shows how `insert()` is used. - - ```cpp - --8<-- "examples/insert__range.cpp" - ``` - - Output: - - ```json - --8<-- "examples/insert__range.output" - ``` - -??? example "Example (4): insert elements from initializer list into array" - - The example shows how `insert()` is used. - - ```cpp - --8<-- "examples/insert__ilist.cpp" - ``` - - Output: - - ```json - --8<-- "examples/insert__ilist.output" - ``` - -??? example "Example (5): insert range of elements into object" - - The example shows how `insert()` is used. - - ```cpp - --8<-- "examples/insert__range_object.cpp" - ``` - - Output: - - ```json - --8<-- "examples/insert__range_object.output" - ``` - -## Version history - -1. Added in version 1.0.0. -2. Added in version 1.0.0. -3. Added in version 1.0.0. -4. Added in version 1.0.0. -5. Added in version 3.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/invalid_iterator.md b/docs/mkdocs/docs/api/basic_json/invalid_iterator.md deleted file mode 100644 index f9fdce5b41..0000000000 --- a/docs/mkdocs/docs/api/basic_json/invalid_iterator.md +++ /dev/null @@ -1,67 +0,0 @@ -# nlohmann::basic_json::invalid_iterator - -```cpp -class invalid_iterator : public exception; -``` - -This exception is thrown if iterators passed to a library function do not match the expected semantics. - -Exceptions have ids 2xx (see [list of iterator errors](../../home/exceptions.md#iterator-errors)). - -```plantuml -std::exception <|-- basic_json::exception -basic_json::exception <|-- basic_json::parse_error -basic_json::exception <|-- basic_json::invalid_iterator -basic_json::exception <|-- basic_json::type_error -basic_json::exception <|-- basic_json::out_of_range -basic_json::exception <|-- basic_json::other_error - -interface std::exception {} - -class basic_json::exception { - + const int id - + const char* what() const -} - -class basic_json::parse_error { - + const std::size_t byte -} - -class basic_json::invalid_iterator #FFFF00 {} -``` - -## Member functions - -- **what** - returns explanatory string - -## Member variables - -- **id** - the id of the exception - -## Examples - -??? example - - The following code shows how a `invalid_iterator` exception can be caught. - - ```cpp - --8<-- "examples/invalid_iterator.cpp" - ``` - - Output: - - ```json - --8<-- "examples/invalid_iterator.output" - ``` - -## See also - -- [List of iterator errors](../../home/exceptions.md#iterator-errors) -- [`parse_error`](parse_error.md) for exceptions indicating a parse error -- [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type -- [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range -- [`other_error`](other_error.md) for exceptions indicating other library errors - -## Version history - -- Since version 3.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/is_array.md b/docs/mkdocs/docs/api/basic_json/is_array.md deleted file mode 100644 index 64468c3578..0000000000 --- a/docs/mkdocs/docs/api/basic_json/is_array.md +++ /dev/null @@ -1,39 +0,0 @@ -# nlohmann::basic_json::is_array - -```cpp -constexpr bool is_array() const noexcept; -``` - -This function returns `#!cpp true` if and only if the JSON value is an array. - -## Return value - -`#!cpp true` if type is an array, `#!cpp false` otherwise. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code exemplifies `is_array()` for all JSON types. - - ```cpp - --8<-- "examples/is_array.cpp" - ``` - - Output: - - ```json - --8<-- "examples/is_array.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/is_binary.md b/docs/mkdocs/docs/api/basic_json/is_binary.md deleted file mode 100644 index ea48d745ca..0000000000 --- a/docs/mkdocs/docs/api/basic_json/is_binary.md +++ /dev/null @@ -1,39 +0,0 @@ -# nlohmann::basic_json::is_binary - -```cpp -constexpr bool is_binary() const noexcept; -``` - -This function returns `#!cpp true` if and only if the JSON value is binary array. - -## Return value - -`#!cpp true` if type is binary, `#!cpp false` otherwise. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code exemplifies `is_binary()` for all JSON types. - - ```cpp - --8<-- "examples/is_binary.cpp" - ``` - - Output: - - ```json - --8<-- "examples/is_binary.output" - ``` - -## Version history - -- Added in version 3.8.0. diff --git a/docs/mkdocs/docs/api/basic_json/is_boolean.md b/docs/mkdocs/docs/api/basic_json/is_boolean.md deleted file mode 100644 index dc41d84bdf..0000000000 --- a/docs/mkdocs/docs/api/basic_json/is_boolean.md +++ /dev/null @@ -1,39 +0,0 @@ -# nlohmann::basic_json::is_boolean - -```cpp -constexpr bool is_boolean() const noexcept; -``` - -This function returns `#!cpp true` if and only if the JSON value is `#!json true` or `#!json false`. - -## Return value - -`#!cpp true` if type is boolean, `#!cpp false` otherwise. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code exemplifies `is_boolean()` for all JSON types. - - ```cpp - --8<-- "examples/is_boolean.cpp" - ``` - - Output: - - ```json - --8<-- "examples/is_boolean.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/is_discarded.md b/docs/mkdocs/docs/api/basic_json/is_discarded.md deleted file mode 100644 index 663cbf889e..0000000000 --- a/docs/mkdocs/docs/api/basic_json/is_discarded.md +++ /dev/null @@ -1,72 +0,0 @@ -# nlohmann::basic_json::is_discarded - -```cpp -constexpr bool is_discarded() const noexcept; -``` - -This function returns `#!cpp true` for a JSON value if either: - -- the value was discarded during parsing with a callback function (see [`parser_callback_t`](parser_callback_t.md)), or -- the value is the result of parsing invalid JSON with parameter `allow_exceptions` set to `#!cpp false`; see - [`parse`](parse.md) for more information. - -## Return value - -`#!cpp true` if type is discarded, `#!cpp false` otherwise. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Notes - -!!! note "Comparisons" - - Discarded values are never compared equal with [`operator==`](operator_eq.md). That is, checking whether a JSON - value `j` is discarded will only work via: - - ```cpp - j.is_discarded() - ``` - - because - - ```cpp - j == json::value_t::discarded - ``` - - will always be `#!cpp false`. - -!!! note "Removal during parsing with callback functions" - - When a value is discarded by a callback function (see [`parser_callback_t`](parser_callback_t.md)) during parsing, - then it is removed when it is part of a structured value. For instance, if the second value of an array is discarded, - instead of `#!json [null, discarded, false]`, the array `#!json [null, false]` is returned. Only if the top-level - value is discarded, the return value of the `parse` call is discarded. - -This function will always be `#!cpp false` for JSON values after parsing. That is, discarded values can only occur -during parsing, but will be removed when inside a structured value or replaced by null in other cases. - -## Examples - -??? example - - The following code exemplifies `is_discarded()` for all JSON types. - - ```cpp - --8<-- "examples/is_discarded.cpp" - ``` - - Output: - - ```json - --8<-- "examples/is_discarded.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/is_null.md b/docs/mkdocs/docs/api/basic_json/is_null.md deleted file mode 100644 index d080ad32f4..0000000000 --- a/docs/mkdocs/docs/api/basic_json/is_null.md +++ /dev/null @@ -1,39 +0,0 @@ -# nlohmann::basic_json::is_null - -```cpp -constexpr bool is_null() const noexcept; -``` - -This function returns `#!cpp true` if and only if the JSON value is `#!json null`. - -## Return value - -`#!cpp true` if type is `#!json null`, `#!cpp false` otherwise. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code exemplifies `is_null()` for all JSON types. - - ```cpp - --8<-- "examples/is_null.cpp" - ``` - - Output: - - ```json - --8<-- "examples/is_null.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/is_number.md b/docs/mkdocs/docs/api/basic_json/is_number.md deleted file mode 100644 index 9807911bc2..0000000000 --- a/docs/mkdocs/docs/api/basic_json/is_number.md +++ /dev/null @@ -1,56 +0,0 @@ -# nlohmann::basic_json::is_number - -```cpp -constexpr bool is_number() const noexcept; -``` - -This function returns `#!cpp true` if and only if the JSON value is a number. This includes both integer (signed and -unsigned) and floating-point values. - -## Return value - -`#!cpp true` if type is number (regardless whether integer, unsigned integer or floating-type), `#!cpp false` otherwise. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Possible implementation - -```cpp -constexpr bool is_number() const noexcept -{ - return is_number_integer() || is_number_float(); -} -``` - -## Examples - -??? example - - The following code exemplifies `is_number()` for all JSON types. - - ```cpp - --8<-- "examples/is_number.cpp" - ``` - - Output: - - ```json - --8<-- "examples/is_number.output" - ``` - -## See also - -- [is_number_integer()](is_number_integer.md) check if value is an integer or unsigned integer number -- [is_number_unsigned()](is_number_unsigned.md) check if value is an unsigned integer number -- [is_number_float()](is_number_float.md) check if value is a floating-point number - -## Version history - -- Added in version 1.0.0. -- Extended to also return `#!cpp true` for unsigned integers in 2.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/is_number_float.md b/docs/mkdocs/docs/api/basic_json/is_number_float.md deleted file mode 100644 index 68d0cfb01c..0000000000 --- a/docs/mkdocs/docs/api/basic_json/is_number_float.md +++ /dev/null @@ -1,46 +0,0 @@ -# nlohmann::basic_json::is_number_float - -```cpp -constexpr bool is_number_float() const noexcept; -``` - -This function returns `#!cpp true` if and only if the JSON value is a floating-point number. This excludes signed and -unsigned integer values. - -## Return value - -`#!cpp true` if type is a floating-point number, `#!cpp false` otherwise. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code exemplifies `is_number_float()` for all JSON types. - - ```cpp - --8<-- "examples/is_number_float.cpp" - ``` - - Output: - - ```json - --8<-- "examples/is_number_float.output" - ``` - -## See also - -- [is_number()](is_number.md) check if value is a number -- [is_number_integer()](is_number_integer.md) check if value is an integer or unsigned integer number -- [is_number_unsigned()](is_number_unsigned.md) check if value is an unsigned integer number - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/is_number_integer.md b/docs/mkdocs/docs/api/basic_json/is_number_integer.md deleted file mode 100644 index 8ca214aed7..0000000000 --- a/docs/mkdocs/docs/api/basic_json/is_number_integer.md +++ /dev/null @@ -1,47 +0,0 @@ -# nlohmann::basic_json::is_number_integer - -```cpp -constexpr bool is_number_integer() const noexcept; -``` - -This function returns `#!cpp true` if and only if the JSON value is a signed or unsigned integer number. This excludes -floating-point values. - -## Return value - -`#!cpp true` if type is an integer or unsigned integer number, `#!cpp false` otherwise. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code exemplifies `is_number_integer()` for all JSON types. - - ```cpp - --8<-- "examples/is_number_integer.cpp" - ``` - - Output: - - ```json - --8<-- "examples/is_number_integer.output" - ``` - -## See also - -- [is_number()](is_number.md) check if value is a number -- [is_number_unsigned()](is_number_unsigned.md) check if value is an unsigned integer number -- [is_number_float()](is_number_float.md) check if value is a floating-point number - -## Version history - -- Added in version 1.0.0. -- Extended to also return `#!cpp true` for unsigned integers in 2.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/is_number_unsigned.md b/docs/mkdocs/docs/api/basic_json/is_number_unsigned.md deleted file mode 100644 index 2ac98a5f09..0000000000 --- a/docs/mkdocs/docs/api/basic_json/is_number_unsigned.md +++ /dev/null @@ -1,46 +0,0 @@ -# nlohmann::basic_json::is_number_unsigned - -```cpp -constexpr bool is_number_unsigned() const noexcept; -``` - -This function returns `#!cpp true` if and only if the JSON value is an unsigned integer number. This excludes -floating-point and signed integer values. - -## Return value - -`#!cpp true` if type is an unsigned integer number, `#!cpp false` otherwise. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code exemplifies `is_number_unsigned()` for all JSON types. - - ```cpp - --8<-- "examples/is_number_unsigned.cpp" - ``` - - Output: - - ```json - --8<-- "examples/is_number_unsigned.output" - ``` - -## See also - -- [is_number()](is_number.md) check if value is a number -- [is_number_integer()](is_number_integer.md) check if value is an integer or unsigned integer number -- [is_number_float()](is_number_float.md) check if value is a floating-point number - -## Version history - -- Added in version 2.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/is_object.md b/docs/mkdocs/docs/api/basic_json/is_object.md deleted file mode 100644 index 04457013ba..0000000000 --- a/docs/mkdocs/docs/api/basic_json/is_object.md +++ /dev/null @@ -1,39 +0,0 @@ -# nlohmann::basic_json::is_object - -```cpp -constexpr bool is_object() const noexcept; -``` - -This function returns `#!cpp true` if and only if the JSON value is an object. - -## Return value - -`#!cpp true` if type is an object, `#!cpp false` otherwise. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code exemplifies `is_object()` for all JSON types. - - ```cpp - --8<-- "examples/is_object.cpp" - ``` - - Output: - - ```json - --8<-- "examples/is_object.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/is_primitive.md b/docs/mkdocs/docs/api/basic_json/is_primitive.md deleted file mode 100644 index cf6cbbd4c9..0000000000 --- a/docs/mkdocs/docs/api/basic_json/is_primitive.md +++ /dev/null @@ -1,69 +0,0 @@ -# nlohmann::basic_json::is_primitive - -```cpp -constexpr bool is_primitive() const noexcept; -``` - -This function returns `#!cpp true` if and only if the JSON type is primitive (string, number, boolean, `#!json null`, -binary). - -## Return value - -`#!cpp true` if type is primitive (string, number, boolean, `#!json null`, or binary), `#!cpp false` otherwise. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Possible implementation - -```cpp -constexpr bool is_primitive() const noexcept -{ - return is_null() || is_string() || is_boolean() || is_number() || is_binary(); -} -``` - -## Notes - -The term *primitive* stems from [RFC 8259](https://tools.ietf.org/html/rfc8259): - -> JSON can represent four primitive types (strings, numbers, booleans, and null) and two structured types (objects and -> arrays). - -This library extends primitive types to binary types, because binary types are roughly comparable to strings. Hence, -`is_primitive()` returns `#!cpp true` for binary values. - -## Examples - -??? example - - The following code exemplifies `is_primitive()` for all JSON types. - - ```cpp - --8<-- "examples/is_primitive.cpp" - ``` - - Output: - - ```json - --8<-- "examples/is_primitive.output" - ``` - -## See also - -- [is_structured()](is_structured.md) returns whether JSON value is structured -- [is_null()](is_null.md) returns whether JSON value is `null` -- [is_string()](is_string.md) returns whether JSON value is a string -- [is_boolean()](is_boolean.md) returns whether JSON value is a boolean -- [is_number()](is_number.md) returns whether JSON value is a number -- [is_binary()](is_binary.md) returns whether JSON value is a binary array - -## Version history - -- Added in version 1.0.0. -- Extended to return `#!cpp true` for binary types in version 3.8.0. diff --git a/docs/mkdocs/docs/api/basic_json/is_string.md b/docs/mkdocs/docs/api/basic_json/is_string.md deleted file mode 100644 index b82c924657..0000000000 --- a/docs/mkdocs/docs/api/basic_json/is_string.md +++ /dev/null @@ -1,39 +0,0 @@ -# nlohmann::basic_json::is_string - -```cpp -constexpr bool is_string() const noexcept; -``` - -This function returns `#!cpp true` if and only if the JSON value is a string. - -## Return value - -`#!cpp true` if type is a string, `#!cpp false` otherwise. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code exemplifies `is_string()` for all JSON types. - - ```cpp - --8<-- "examples/is_string.cpp" - ``` - - Output: - - ```json - --8<-- "examples/is_string.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/is_structured.md b/docs/mkdocs/docs/api/basic_json/is_structured.md deleted file mode 100644 index f8fe4dcbaa..0000000000 --- a/docs/mkdocs/docs/api/basic_json/is_structured.md +++ /dev/null @@ -1,63 +0,0 @@ -# nlohmann::basic_json::is_structured - -```cpp -constexpr bool is_structured() const noexcept; -``` - -This function returns `#!cpp true` if and only if the JSON type is structured (array or object). - -## Return value - -`#!cpp true` if type is structured (array or object), `#!cpp false` otherwise. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Possible implementation - -```cpp -constexpr bool is_primitive() const noexcept -{ - return is_array() || is_object(); -} -``` - -## Notes - -The term *structured* stems from [RFC 8259](https://tools.ietf.org/html/rfc8259): - -> JSON can represent four primitive types (strings, numbers, booleans, and null) and two structured types (objects and -> arrays). - -Note that though strings are containers in C++, they are treated as primitive values in JSON. - -## Examples - -??? example - - The following code exemplifies `is_structured()` for all JSON types. - - ```cpp - --8<-- "examples/is_structured.cpp" - ``` - - Output: - - ```json - --8<-- "examples/is_structured.output" - ``` - -## See also - -- [is_primitive()](is_primitive.md) returns whether JSON value is primitive -- [is_array()](is_array.md) returns whether value is an array -- [is_object()](is_object.md) returns whether value is an object - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/items.md b/docs/mkdocs/docs/api/basic_json/items.md deleted file mode 100644 index 0b34ddcba3..0000000000 --- a/docs/mkdocs/docs/api/basic_json/items.md +++ /dev/null @@ -1,100 +0,0 @@ -# nlohmann::basic_json::items - -```cpp -iteration_proxy items() noexcept; -iteration_proxy items() const noexcept; -``` - -This function allows accessing `iterator::key()` and `iterator::value()` during range-based for loops. In these loops, a -reference to the JSON values is returned, so there is no access to the underlying iterator. - -For loop without `items()` function: - -```cpp -for (auto it = j_object.begin(); it != j_object.end(); ++it) -{ - std::cout << "key: " << it.key() << ", value:" << it.value() << '\n'; -} -``` - -Range-based for loop without `items()` function: - -```cpp -for (auto it : j_object) -{ - // "it" is of type json::reference and has no key() member - std::cout << "value: " << it << '\n'; -} -``` - -Range-based for loop with `items()` function: - -```cpp -for (auto& el : j_object.items()) -{ - std::cout << "key: " << el.key() << ", value:" << el.value() << '\n'; -} -``` - -The `items()` function also allows using -[structured bindings](https://en.cppreference.com/w/cpp/language/structured_binding) (C++17): - -```cpp -for (auto& [key, val] : j_object.items()) -{ - std::cout << "key: " << key << ", value:" << val << '\n'; -} -``` - -## Return value - -iteration proxy object wrapping the current value with an interface to use in range-based for loops - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Complexity - -Constant. - -## Notes - -When iterating over an array, `key()` will return the index of the element as string (see example). For primitive types -(e.g., numbers), `key()` returns an empty string. - -!!! danger "Lifetime issues" - - Using `items()` on temporary objects is dangerous. Make sure the object's lifetime exceeds the iteration. See - for more information. - -## Examples - -??? example - - The following code shows an example for `items()`. - - ```cpp - --8<-- "examples/items.cpp" - ``` - - Output: - - ```json - --8<-- "examples/items.output" - ``` - -## Version history - -- Added `iterator_wrapper` in version 3.0.0. -- Added `items` and deprecated `iterator_wrapper` in version 3.1.0. -- Added structured binding support in version 3.5.0. - -!!! warning "Deprecation" - - This function replaces the static function `iterator_wrapper` which was introduced in version 1.0.0, but has been - deprecated in version 3.1.0. Function `iterator_wrapper` will be removed in version 4.0.0. Please replace all - occurrences of `#!cpp iterator_wrapper(j)` with `#!cpp j.items()`. - - You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated - function. diff --git a/docs/mkdocs/docs/api/basic_json/json_base_class_t.md b/docs/mkdocs/docs/api/basic_json/json_base_class_t.md deleted file mode 100644 index 75752049f0..0000000000 --- a/docs/mkdocs/docs/api/basic_json/json_base_class_t.md +++ /dev/null @@ -1,45 +0,0 @@ -# nlohmann::basic_json::json_base_class_t - -```cpp -using json_base_class_t = detail::json_base_class; -``` - -The base class used to inject custom functionality into each instance of `basic_json`. -Examples of such functionality might be metadata, additional member functions (e.g., visitors), or other application-specific code. - -## Template parameters - -`CustomBaseClass` -: the base class to be added to `basic_json` - -## Notes - -#### Default type - -The default value for `CustomBaseClass` is `void`. In this case an -[empty base class](https://en.cppreference.com/w/cpp/language/ebo) is used and no additional functionality is injected. - -#### Limitations - -The type `CustomBaseClass` has to be a default-constructible class. -`basic_json` only supports copy/move construction/assignment if `CustomBaseClass` does so as well. - -## Examples - -??? example - - The following code shows how to inject custom data and methods for each node. - - ```cpp - --8<-- "examples/json_base_class_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/json_base_class_t.output" - ``` - -## Version history - -- Added in version 3.12.0. diff --git a/docs/mkdocs/docs/api/basic_json/json_serializer.md b/docs/mkdocs/docs/api/basic_json/json_serializer.md deleted file mode 100644 index b8b67c5cc7..0000000000 --- a/docs/mkdocs/docs/api/basic_json/json_serializer.md +++ /dev/null @@ -1,41 +0,0 @@ -# nlohmann::basic_json::json_serializer - -```cpp -template -using json_serializer = JSONSerializer; -``` - -## Template parameters - -`T` -: type to convert; will be used in the `to_json`/`from_json` functions - -`SFINAE` -: type to add compile type checks via SFINAE; usually `#!cpp void` - -## Notes - -#### Default type - -The default values for `json_serializer` is [`adl_serializer`](../adl_serializer). - -## Examples - -??? example - - The example below shows how a conversion of a non-default-constructible type is implemented via a specialization of - the `adl_serializer`. - - ```cpp - --8<-- "examples/from_json__non_default_constructible.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_json__non_default_constructible.output" - ``` - -## Version history - -- Since version 2.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/max_size.md b/docs/mkdocs/docs/api/basic_json/max_size.md deleted file mode 100644 index 4c0c575209..0000000000 --- a/docs/mkdocs/docs/api/basic_json/max_size.md +++ /dev/null @@ -1,60 +0,0 @@ -# nlohmann::basic_json::max_size - -```cpp -size_type max_size() const noexcept; -``` - -Returns the maximum number of elements a JSON value is able to hold due to system or library implementation limitations, -i.e. `std::distance(begin(), end())` for the JSON value. - -## Return value - -The return value depends on the different types and is defined as follows: - -| Value type | return value | -|------------|-------------------------------------------| -| null | `0` (same as [`size()`](size.md)) | -| boolean | `1` (same as [`size()`](size.md)) | -| string | `1` (same as [`size()`](size.md)) | -| number | `1` (same as [`size()`](size.md)) | -| binary | `1` (same as [`size()`](size.md)) | -| object | result of function `object_t::max_size()` | -| array | result of function `array_t::max_size()` | - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Constant, as long as [`array_t`](array_t.md) and [`object_t`](object_t.md) satisfy the -[Container](https://en.cppreference.com/w/cpp/named_req/Container) concept; that is, their `max_size()` functions have -constant complexity. - -## Notes - -This function does not return the maximal length of a string stored as JSON value -- it returns the maximal number of -string elements the JSON value can store which is `1`. - -## Examples - -??? example - - The following code calls `max_size()` on the different value types. - - ```cpp - --8<-- "examples/max_size.cpp" - ``` - - Output: - - ```json - --8<-- "examples/max_size.output" - ``` - - Note the output is platform-dependent. - -## Version history - -- Added in version 1.0.0. -- Extended to return `1` for binary types in version 3.8.0. diff --git a/docs/mkdocs/docs/api/basic_json/merge_patch.md b/docs/mkdocs/docs/api/basic_json/merge_patch.md deleted file mode 100644 index 1718c92276..0000000000 --- a/docs/mkdocs/docs/api/basic_json/merge_patch.md +++ /dev/null @@ -1,63 +0,0 @@ -# nlohmann::basic_json::merge_patch - -```cpp -void merge_patch(const basic_json& apply_patch); -``` - -The merge patch format is primarily intended for use with the HTTP PATCH method as a means of describing a set of -modifications to a target resource's content. This function applies a merge patch to the current JSON value. - -The function implements the following algorithm from Section 2 of -[RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396): - -```python -define MergePatch(Target, Patch): - if Patch is an Object: - if Target is not an Object: - Target = {} // Ignore the contents and set it to an empty Object - for each Name/Value pair in Patch: - if Value is null: - if Name exists in Target: - remove the Name/Value pair from Target - else: - Target[Name] = MergePatch(Target[Name], Value) - return Target - else: - return Patch -``` - -Thereby, `Target` is the current object; that is, the patch is applied to the current value. - -## Parameters - -`apply_patch` (in) -: the patch to apply - -## Complexity - -Linear in the lengths of `apply_patch`. - -## Examples - -??? example - - The following code shows how a JSON Merge Patch is applied to a JSON document. - - ```cpp - --8<-- "examples/merge_patch.cpp" - ``` - - Output: - - ```json - --8<-- "examples/merge_patch.output" - ``` - -## See also - -- [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396) -- [patch](patch.md) apply a JSON patch - -## Version history - -- Added in version 3.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/meta.md b/docs/mkdocs/docs/api/basic_json/meta.md deleted file mode 100644 index c584f9b6db..0000000000 --- a/docs/mkdocs/docs/api/basic_json/meta.md +++ /dev/null @@ -1,56 +0,0 @@ -# nlohmann::basic_json::meta - -```cpp -static basic_json meta(); -``` - -This function returns a JSON object with information about the library, including the version number and information on -the platform and compiler. - -## Return value - -JSON object holding version information - -| key | description | -|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `compiler` | Information on the used compiler. It is an object with the following keys: `c++` (the used C++ standard), `family` (the compiler family; possible values are `clang`, `icc`, `gcc`, `ilecpp`, `msvc`, `pgcpp`, `sunpro`, and `unknown`), and `version` (the compiler version). | -| `copyright` | The copyright line for the library as string. | -| `name` | The name of the library as string. | -| `platform` | The used platform as string. Possible values are `win32`, `linux`, `apple`, `unix`, and `unknown`. | -| `url` | The URL of the project as string. | -| `version` | The version of the library. It is an object with the following keys: `major`, `minor`, and `patch` as defined by [Semantic Versioning](http://semver.org), and `string` (the version string). | - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes to any JSON value. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code shows an example output of the `meta()` function. - - ```cpp - --8<-- "examples/meta.cpp" - ``` - - Output: - - ```json - --8<-- "examples/meta.output" - ``` - - Note the output is platform-dependent. - -## See also - -- [**NLOHMANN_JSON_VERSION_MAJOR**/**NLOHMANN_JSON_VERSION_MINOR**/**NLOHMANN_JSON_VERSION_PATCH**](../macros/nlohmann_json_version_major.md) - \- library version information - -## Version history - -- Added in version 2.1.0. diff --git a/docs/mkdocs/docs/api/basic_json/number_float_t.md b/docs/mkdocs/docs/api/basic_json/number_float_t.md deleted file mode 100644 index 50aa43b483..0000000000 --- a/docs/mkdocs/docs/api/basic_json/number_float_t.md +++ /dev/null @@ -1,70 +0,0 @@ -# nlohmann::basic_json::number_float_t - -```cpp -using number_float_t = NumberFloatType; -``` - -The type used to store JSON numbers (floating-point). - -[RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows: -> The representation of numbers is similar to that used in most programming languages. A number is represented in base -> 10 using decimal digits. It contains an integer component that may be prefixed with an optional minus sign, which may -> be followed by a fraction part and/or an exponent part. Leading zeros are not allowed. (...) Numeric values that -> cannot be represented in the grammar below (such as Infinity and NaN) are not permitted. - -This description includes both integer and floating-point numbers. However, C++ allows more precise storage if it is -known whether the number is a signed integer, an unsigned integer or a floating-point number. Therefore, three different -types, [`number_integer_t`](number_integer_t.md), [`number_unsigned_t`](number_unsigned_t.md) and `number_float_t` are -used. - -To store floating-point numbers in C++, a type is defined by the template parameter `NumberFloatType` which chooses the -type to use. - -## Notes - -#### Default type - -With the default values for `NumberFloatType` (`double`), the default value for `number_float_t` is `#!cpp double`. - -#### Default behavior - -- The restrictions about leading zeros is not enforced in C++. Instead, leading zeros in floating-point literals will be - ignored. Internally, the value will be stored as decimal number. For instance, the C++ floating-point literal `01.2` - will be serialized to `1.2`. During deserialization, leading zeros yield an error. -- Not-a-number (NaN) values will be serialized to `null`. - -#### Limits - -[RFC 8259](https://tools.ietf.org/html/rfc8259) states: -> This specification allows implementations to set limits on the range and precision of numbers accepted. Since software -> that implements IEEE 754-2008 binary64 (double precision) numbers is generally available and widely used, good -> interoperability can be achieved by implementations that expect no more precision or range than these provide, in the -> sense that implementations will approximate JSON numbers within the expected precision. - -This implementation does exactly follow this approach, as it uses double precision floating-point numbers. Note values -smaller than `-1.79769313486232e+308` and values greater than `1.79769313486232e+308` will be stored as NaN internally -and be serialized to `null`. - -#### Storage - -Floating-point number values are stored directly inside a `basic_json` type. - -## Examples - -??? example - - The following code shows that `number_float_t` is by default, a typedef to `#!cpp double`. - - ```cpp - --8<-- "examples/number_float_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/number_float_t.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/number_integer_t.md b/docs/mkdocs/docs/api/basic_json/number_integer_t.md deleted file mode 100644 index 9bb3835a0a..0000000000 --- a/docs/mkdocs/docs/api/basic_json/number_integer_t.md +++ /dev/null @@ -1,76 +0,0 @@ -# nlohmann::basic_json::number_integer_t - -```cpp -using number_integer_t = NumberIntegerType; -``` - -The type used to store JSON numbers (integers). - -[RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows: -> The representation of numbers is similar to that used in most programming languages. A number is represented in base -> 10 using decimal digits. It contains an integer component that may be prefixed with an optional minus sign, which may -> be followed by a fraction part and/or an exponent part. Leading zeros are not allowed. (...) Numeric values that -> cannot be represented in the grammar below (such as Infinity and NaN) are not permitted. - -This description includes both integer and floating-point numbers. However, C++ allows more precise storage if it is -known whether the number is a signed integer, an unsigned integer or a floating-point number. Therefore, three different -types, `number_integer_t`, [`number_unsigned_t`](number_unsigned_t.md) and [`number_float_t`](number_float_t.md) are -used. - -To store integer numbers in C++, a type is defined by the template parameter `NumberIntegerType` which chooses the type -to use. - -## Notes - -#### Default type - -With the default values for `NumberIntegerType` (`std::int64_t`), the default value for `number_integer_t` is -`#!cpp std::int64_t`. - -#### Default behavior - -- The restrictions about leading zeros is not enforced in C++. Instead, leading zeros in integer literals lead to an - interpretation as octal number. Internally, the value will be stored as decimal number. For instance, the C++ integer - literal `010` will be serialized to `8`. During deserialization, leading zeros yield an error. -- Not-a-number (NaN) values will be serialized to `null`. - -#### Limits - -[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: -> An implementation may set limits on the range and precision of numbers. - -When the default type is used, the maximal integer number that can be stored is `9223372036854775807` (INT64_MAX) and -the minimal integer number that can be stored is `-9223372036854775808` (INT64_MIN). Integer numbers that are out of -range will yield over/underflow when used in a constructor. During deserialization, too large or small integer numbers -will be automatically be stored as [`number_unsigned_t`](number_unsigned_t.md) or [`number_float_t`](number_float_t.md). - -[RFC 8259](https://tools.ietf.org/html/rfc8259) further states: -> Note that when such software is used, numbers that are integers and are in the range $[-2^{53}+1, 2^{53}-1]$ are -> interoperable in the sense that implementations will agree exactly on their numeric values. - -As this range is a subrange of the exactly supported range [INT64_MIN, INT64_MAX], this class's integer type is -interoperable. - -#### Storage - -Integer number values are stored directly inside a `basic_json` type. - -## Examples - -??? example - - The following code shows that `number_integer_t` is by default, a typedef to `#!cpp std::int64_t`. - - ```cpp - --8<-- "examples/number_integer_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/number_integer_t.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/number_unsigned_t.md b/docs/mkdocs/docs/api/basic_json/number_unsigned_t.md deleted file mode 100644 index 8a1540a571..0000000000 --- a/docs/mkdocs/docs/api/basic_json/number_unsigned_t.md +++ /dev/null @@ -1,76 +0,0 @@ -# nlohmann::basic_json::number_unsigned_t - -```cpp -using number_unsigned_t = NumberUnsignedType; -``` - -The type used to store JSON numbers (unsigned). - -[RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows: -> The representation of numbers is similar to that used in most programming languages. A number is represented in base -> 10 using decimal digits. It contains an integer component that may be prefixed with an optional minus sign, which may -> be followed by a fraction part and/or an exponent part. Leading zeros are not allowed. (...) Numeric values that -> cannot be represented in the grammar below (such as Infinity and NaN) are not permitted. - -This description includes both integer and floating-point numbers. However, C++ allows more precise storage if it is -known whether the number is a signed integer, an unsigned integer or a floating-point number. Therefore, three different -types, [`number_integer_t`](number_integer_t.md), `number_unsigned_t` and [`number_float_t`](number_float_t.md) are -used. - -To store unsigned integer numbers in C++, a type is defined by the template parameter `NumberUnsignedType` which chooses -the type to use. - -## Notes - -#### Default type - -With the default values for `NumberUnsignedType` (`std::uint64_t`), the default value for `number_unsigned_t` is -`#!cpp std::uint64_t`. - -#### Default behavior - -- The restrictions about leading zeros is not enforced in C++. Instead, leading zeros in integer literals lead to an - interpretation as octal number. Internally, the value will be stored as decimal number. For instance, the C++ integer - literal `010` will be serialized to `8`. During deserialization, leading zeros yield an error. -- Not-a-number (NaN) values will be serialized to `null`. - -#### Limits - -[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: -> An implementation may set limits on the range and precision of numbers. - -When the default type is used, the maximal integer number that can be stored is `18446744073709551615` (UINT64_MAX) and -the minimal integer number that can be stored is `0`. Integer numbers that are out of range will yield over/underflow -when used in a constructor. During deserialization, too large or small integer numbers will be automatically be stored -as [`number_integer_t`](number_integer_t.md) or [`number_float_t`](number_float_t.md). - -[RFC 8259](https://tools.ietf.org/html/rfc8259) further states: -> Note that when such software is used, numbers that are integers and are in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are -> interoperable in the sense that implementations will agree exactly on their numeric values. - -As this range is a subrange (when considered in conjunction with the `number_integer_t` type) of the exactly supported -range [0, UINT64_MAX], this class's integer type is interoperable. - -#### Storage - -Integer number values are stored directly inside a `basic_json` type. - -## Examples - -??? example - - The following code shows that `number_unsigned_t` is by default, a typedef to `#!cpp std::uint64_t`. - - ```cpp - --8<-- "examples/number_unsigned_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/number_unsigned_t.output" - ``` - -## Version history - -- Added in version 2.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/object.md b/docs/mkdocs/docs/api/basic_json/object.md deleted file mode 100644 index 9bdbddb6a1..0000000000 --- a/docs/mkdocs/docs/api/basic_json/object.md +++ /dev/null @@ -1,63 +0,0 @@ -# nlohmann::basic_json::object - -```cpp -static basic_json object(initializer_list_t init = {}); -``` - -Creates a JSON object value from a given initializer list. The initializer lists elements must be pairs, and their first -elements must be strings. If the initializer list is empty, the empty object `#!json {}` is created. - -## Parameters - -`init` (in) -: initializer list with JSON values to create an object from (optional) - -## Return value - -JSON object value - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Exceptions - -Throws [`type_error.301`](../../home/exceptions.md#jsonexceptiontype_error301) if `init` is not a list of pairs whose -first elements are strings. In this case, no object can be created. When such a value is passed to -`basic_json(initializer_list_t, bool, value_t)`, an array would have been created from the passed initializer list -`init`. See example below. - -## Complexity - -Linear in the size of `init`. - -## Notes - -This function is only added for symmetry reasons. In contrast to the related function `array(initializer_list_t)`, there -are no cases which can only be expressed by this function. That is, any initializer list `init` can also be passed to -the initializer list constructor `basic_json(initializer_list_t, bool, value_t)`. - -## Examples - -??? example - - The following code shows an example for the `object` function. - - ```cpp - --8<-- "examples/object.cpp" - ``` - - Output: - - ```json - --8<-- "examples/object.output" - ``` - -## See also - -- [`basic_json(initializer_list_t)`](basic_json.md) - create a JSON value from an initializer list -- [`array`](array.md) - create a JSON array value from an initializer list - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/object_comparator_t.md b/docs/mkdocs/docs/api/basic_json/object_comparator_t.md deleted file mode 100644 index d41b982297..0000000000 --- a/docs/mkdocs/docs/api/basic_json/object_comparator_t.md +++ /dev/null @@ -1,32 +0,0 @@ -# nlohmann::basic_json::object_comparator_t - -```cpp -using object_comparator_t = typename object_t::key_compare; -// or -using object_comparator_t = default_object_comparator_t; -``` - -The comparator used by [`object_t`](object_t.md). Defined as `#!cpp typename object_t::key_compare` if available, -and [`default_object_comparator_t`](default_object_comparator_t.md) otherwise. - -## Examples - -??? example - - The example below demonstrates the used object comparator. - - ```cpp - --8<-- "examples/object_comparator_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/object_comparator_t.output" - ``` - -## Version history - -- Added in version 3.0.0. -- Changed to be conditionally defined as `#!cpp typename object_t::key_compare` or `default_object_comparator_t` in - version 3.11.0. diff --git a/docs/mkdocs/docs/api/basic_json/object_t.md b/docs/mkdocs/docs/api/basic_json/object_t.md deleted file mode 100644 index 39f68b0891..0000000000 --- a/docs/mkdocs/docs/api/basic_json/object_t.md +++ /dev/null @@ -1,114 +0,0 @@ -# nlohmann::basic_json::object_t - -```cpp -using object_t = ObjectType>>; -``` - -The type used to store JSON objects. - -[RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON objects as follows: -> An object is an unordered collection of zero or more name/value pairs, where a name is a string and a value is a -> string, number, boolean, null, object, or array. - -To store objects in C++, a type is defined by the template parameters described below. - -## Template parameters - -`ObjectType` -: the container to store objects (e.g., `std::map` or `std::unordered_map`) - -`StringType` -: the type of the keys or names (e.g., `std::string`). The comparison function `std::less` is used to - order elements inside the container. - -`AllocatorType` -: the allocator to use for objects (e.g., `std::allocator`) - -## Notes - -#### Default type - -With the default values for `ObjectType` (`std::map`), `StringType` (`std::string`), and `AllocatorType` -(`std::allocator`), the default value for `object_t` is: - -```cpp -// until C++14 -std::map< - std::string, // key_type - basic_json, // value_type - std::less, // key_compare - std::allocator> // allocator_type -> - -// since C++14 -std::map< - std::string, // key_type - basic_json, // value_type - std::less<>, // key_compare - std::allocator> // allocator_type -> -``` - -See [`default_object_comparator_t`](default_object_comparator_t.md) for more information. - -#### Behavior - -The choice of `object_t` influences the behavior of the JSON class. With the default type, objects have the following -behavior: - -- When all names are unique, objects will be interoperable in the sense that all software implementations receiving that - object will agree on the name-value mappings. -- When the names within an object are not unique, it is unspecified which one of the values for a given key will be - chosen. For instance, `#!json {"key": 2, "key": 1}` could be equal to either `#!json {"key": 1}` or - `#!json {"key": 2}`. -- Internally, name/value pairs are stored in lexicographical order of the names. Objects will also be serialized (see - [`dump`](dump.md)) in this order. For instance, `#!json {"b": 1, "a": 2}` and `#!json {"a": 2, "b": 1}` will be stored - and serialized as `#!json {"a": 2, "b": 1}`. -- When comparing objects, the order of the name/value pairs is irrelevant. This makes objects interoperable in the sense - that they will not be affected by these differences. For instance, `#!json {"b": 1, "a": 2}` and - `#!json {"a": 2, "b": 1}` will be treated as equal. - -#### Limits - -[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: -> An implementation may set limits on the maximum depth of nesting. - -In this class, the object's limit of nesting is not explicitly constrained. However, a maximum depth of nesting may be -introduced by the compiler or runtime environment. A theoretical limit can be queried by calling the -[`max_size`](max_size.md) function of a JSON object. - -#### Storage - -Objects are stored as pointers in a `basic_json` type. That is, for any access to object values, a pointer of type -`object_t*` must be dereferenced. - -#### Object key order - -The order name/value pairs are added to the object is *not* preserved by the library. Therefore, iterating an object may -return name/value pairs in a different order than they were originally stored. In fact, keys will be traversed in -alphabetical order as `std::map` with `std::less` is used by default. Please note this behavior conforms to -[RFC 8259](https://tools.ietf.org/html/rfc8259), because any order implements the specified "unordered" nature of JSON -objects. - -## Examples - -??? example - - The following code shows that `object_t` is by default, a typedef to `#!cpp std::map`. - - ```cpp - --8<-- "examples/object_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/object_t.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/operator+=.md b/docs/mkdocs/docs/api/basic_json/operator+=.md deleted file mode 100644 index dc5f2ecc44..0000000000 --- a/docs/mkdocs/docs/api/basic_json/operator+=.md +++ /dev/null @@ -1,110 +0,0 @@ -# nlohmann::basic_json::operator+= - -```cpp -// (1) -reference operator+=(basic_json&& val); -reference operator+=(const basic_json& val); - -// (2) -reference operator+=(const typename object_t::value_type& val); - -// (3) -reference operator+=(initializer_list_t init); -``` - -1. Appends the given element `val` to the end of the JSON array. If the function is called on a JSON null value, an - empty array is created before appending `val`. - -2. Inserts the given element `val` to the JSON object. If the function is called on a JSON null value, an empty object - is created before inserting `val`. - -3. This function allows using `operator+=` with an initializer list. In case - - 1. the current value is an object, - 2. the initializer list `init` contains only two elements, and - 3. the first element of `init` is a string, - - `init` is converted into an object element and added using `operator+=(const typename object_t::value_type&)`. - Otherwise, `init` is converted to a JSON value and added using `operator+=(basic_json&&)`. - -## Parameters - -`val` (in) -: the value to add to the JSON array/object - -`init` (in) -: an initializer list - -## Return value - -`#!cpp *this` - -## Exceptions - -All functions can throw the following exception: - - Throws [`type_error.308`](../../home/exceptions.md#jsonexceptiontype_error308) when called on a type other than - JSON array or null; example: `"cannot use operator+=() with number"` - -## Complexity - -1. Amortized constant. -2. Logarithmic in the size of the container, O(log(`size()`)). -3. Linear in the size of the initializer list `init`. - -## Notes - -(3) This function is required to resolve an ambiguous overload error, because pairs like `{"key", "value"}` can be both -interpreted as `object_t::value_type` or `std::initializer_list`, see -[#235](https://github.com/nlohmann/json/issues/235) for more information. - -## Examples - -??? example "Example: (1) add element to array" - - The example shows how `push_back()` and `+=` can be used to add elements to a JSON array. Note how the `null` value - was silently converted to a JSON array. - - ```cpp - --8<-- "examples/push_back.cpp" - ``` - - Output: - - ```json - --8<-- "examples/push_back.output" - ``` - -??? example "Example: (2) add element to object" - - The example shows how `push_back()` and `+=` can be used to add elements to a JSON object. Note how the `null` value - was silently converted to a JSON object. - - ```cpp - --8<-- "examples/push_back__object_t__value.cpp" - ``` - - Output: - - ```json - --8<-- "examples/push_back__object_t__value.output" - ``` - -??? example "Example: (3) add to object from initializer list" - - The example shows how initializer lists are treated as objects when possible. - - ```cpp - --8<-- "examples/push_back__initializer_list.cpp" - ``` - - Output: - - ```json - --8<-- "examples/push_back__initializer_list.output" - ``` - -## Version history - -1. Since version 1.0.0. -2. Since version 1.0.0. -2. Since version 2.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/operator=.md b/docs/mkdocs/docs/api/basic_json/operator=.md deleted file mode 100644 index 4e0b914464..0000000000 --- a/docs/mkdocs/docs/api/basic_json/operator=.md +++ /dev/null @@ -1,43 +0,0 @@ -# nlohmann::basic_json::operator= - -```cpp -basic_json& operator=(basic_json other) noexcept ( - std::is_nothrow_move_constructible::value && - std::is_nothrow_move_assignable::value && - std::is_nothrow_move_constructible::value && - std::is_nothrow_move_assignable::value -); -``` - -Copy assignment operator. Copies a JSON value via the "copy and swap" strategy: It is expressed in terms of the copy -constructor, destructor, and the `swap()` member function. - -## Parameters - -`other` (in) -: value to copy from - -## Complexity - -Linear. - -## Examples - -??? example - - The code below shows and example for the copy assignment. It creates a copy of value `a` which is then swapped with - `b`. Finally, the copy of `a` (which is the null value after the swap) is destroyed. - - ```cpp - --8<-- "examples/basic_json__copyassignment.cpp" - ``` - - Output: - - ```json - --8<-- "examples/basic_json__copyassignment.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/operator[].md b/docs/mkdocs/docs/api/basic_json/operator[].md deleted file mode 100644 index 51dd8588cb..0000000000 --- a/docs/mkdocs/docs/api/basic_json/operator[].md +++ /dev/null @@ -1,241 +0,0 @@ -# nlohmann::basic_json::operator[] - -```cpp -// (1) -reference operator[](size_type idx); -const_reference operator[](size_type idx) const; - -// (2) -reference operator[](typename object_t::key_type key); -const_reference operator[](const typename object_t::key_type& key) const; - -// (3) -template -reference operator[](KeyType&& key); -template -const_reference operator[](KeyType&& key) const; - -// (4) -reference operator[](const json_pointer& ptr); -const_reference operator[](const json_pointer& ptr) const; -``` - -1. Returns a reference to the array element at specified location `idx`. -2. Returns a reference to the object element with specified key `key`. The non-const qualified overload takes the key by - value. -3. See 2. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and - `#!cpp typename object_comparator_t::is_transparent` denotes a type. -4. Returns a reference to the element with specified JSON pointer `ptr`. - -## Template parameters - -`KeyType` -: A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with - [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). - This can also be a string view (C++17). - -## Parameters - -`idx` (in) -: index of the element to access - -`key` (in) -: object key of the element to access - -`ptr` (in) -: JSON pointer to the desired element - -## Return value - -1. (const) reference to the element at index `idx` -2. (const) reference to the element at key `key` -3. (const) reference to the element at key `key` -4. (const) reference to the element pointed to by `ptr` - -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - -## Exceptions - -1. The function can throw the following exceptions: - - Throws [`type_error.305`](../../home/exceptions.md#jsonexceptiontype_error305) if the JSON value is not an array - or null; in that case, using the `[]` operator with an index makes no sense. -2. The function can throw the following exceptions: - - Throws [`type_error.305`](../../home/exceptions.md#jsonexceptiontype_error305) if the JSON value is not an object - or null; in that case, using the `[]` operator with a key makes no sense. -3. See 2. -4. The function can throw the following exceptions: - - Throws [`parse_error.106`](../../home/exceptions.md#jsonexceptionparse_error106) if an array index in the passed - JSON pointer `ptr` begins with '0'. - - Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) if an array index in the passed - JSON pointer `ptr` is not a number. - - Throws [`out_of_range.402`](../../home/exceptions.md#jsonexceptionout_of_range402) if the array index '-' is used - in the passed JSON pointer `ptr` for the const version. - - Throws [`out_of_range.404`](../../home/exceptions.md#jsonexceptionout_of_range404) if the JSON pointer `ptr` can - not be resolved. - -## Complexity - -1. Constant if `idx` is in the range of the array. Otherwise, linear in `idx - size()`. -2. Logarithmic in the size of the container. -3. Logarithmic in the size of the container. -4. Logarithmic in the size of the container. - -## Notes - -!!! danger "Undefined behavior and runtime assertions" - - 1. If the element with key `idx` does not exist, the behavior is undefined. - 2. If the element with key `key` does not exist, the behavior is undefined and is **guarded by a - [runtime assertion](../../features/assertions.md)**! - -1. The non-const version may add values: If `idx` is beyond the range of the array (i.e., `idx >= size()`), then the - array is silently filled up with `#!json null` values to make `idx` a valid reference to the last stored element. In - case the value was `#!json null` before, it is converted to an array. - -2. If `key` is not found in the object, then it is silently added to the object and filled with a `#!json null` value to - make `key` a valid reference. In case the value was `#!json null` before, it is converted to an object. - -3. See 2. - -4. `null` values are created in arrays and objects if necessary. - - In particular: - - - If the JSON pointer points to an object key that does not exist, it is created and filled with a `#!json null` - value before a reference to it is returned. - - If the JSON pointer points to an array index that does not exist, it is created and filled with a `#!json null` - value before a reference to it is returned. All indices between the current maximum and the given index are also - filled with `#!json null`. - - The special value `-` is treated as a synonym for the index past the end. - -## Examples - -??? example "Example: (1) access specified array element" - - The example below shows how array elements can be read and written using `[]` operator. Note the addition of - `#!json null` values. - - ```cpp - --8<-- "examples/operator_array__size_type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator_array__size_type.output" - ``` - -??? example "Example: (1) access specified array element (const)" - - The example below shows how array elements can be read using the `[]` operator. - - ```cpp - --8<-- "examples/operator_array__size_type_const.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator_array__size_type_const.output" - ``` - -??? example "Example: (2) access specified object element" - - The example below shows how object elements can be read and written using the `[]` operator. - - ```cpp - --8<-- "examples/operator_array__object_t_key_type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator_array__object_t_key_type.output" - ``` - -??? example "Example: (2) access specified object element (const)" - - The example below shows how object elements can be read using the `[]` operator. - - ```cpp - --8<-- "examples/operator_array__object_t_key_type_const.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator_array__object_t_key_type_const.output" - ``` - -??? example "Example: (3) access specified object element using string_view" - - The example below shows how object elements can be read using the `[]` operator. - - ```cpp - --8<-- "examples/operator_array__keytype.c++17.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator_array__keytype.c++17.output" - ``` - -??? example "Example: (3) access specified object element using string_view (const)" - - The example below shows how object elements can be read using the `[]` operator. - - ```cpp - --8<-- "examples/operator_array__keytype_const.c++17.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator_array__keytype_const.c++17.output" - ``` - -??? example "Example: (4) access specified element via JSON Pointer" - - The example below shows how values can be read and written using JSON Pointers. - - ```cpp - --8<-- "examples/operator_array__json_pointer.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator_array__json_pointer.output" - ``` - -??? example "Example: (4) access specified element via JSON Pointer (const)" - - The example below shows how values can be read using JSON Pointers. - - ```cpp - --8<-- "examples/operator_array__json_pointer_const.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator_array__json_pointer_const.output" - ``` - -## See also - -- documentation on [unchecked access](../../features/element_access/unchecked_access.md) -- documentation on [runtime assertions](../../features/assertions.md) -- see [`at`](at.md) for access by reference with range checking -- see [`value`](value.md) for access with default value - -## Version history - -1. Added in version 1.0.0. -2. Added in version 1.0.0. Added overloads for `T* key` in version 1.1.0. Removed overloads for `T* key` (replaced by 3) - in version 3.11.0. -3. Added in version 3.11.0. -4. Added in version 2.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/operator_ValueType.md b/docs/mkdocs/docs/api/basic_json/operator_ValueType.md deleted file mode 100644 index bf38a3d21a..0000000000 --- a/docs/mkdocs/docs/api/basic_json/operator_ValueType.md +++ /dev/null @@ -1,82 +0,0 @@ -# nlohmann::basic_json::operator ValueType - -```cpp -template -JSON_EXPLICIT operator ValueType() const; -``` - -Implicit type conversion between the JSON value and a compatible value. The call is realized by calling -[`get()`](get.md). See [Notes](#notes) for the meaning of `JSON_EXPLICIT`. - -## Template parameters - -`ValueType` -: the value type to return - -## Return value - -copy of the JSON value, converted to `ValueType` - -## Exceptions - -Depends on what `json_serializer` `from_json()` method throws - -## Complexity - -Linear in the size of the JSON value. - -## Notes - -!!! note "Definition of `JSON_EXPLICIT`" - - By default `JSON_EXPLICIT` is defined to the empty string, so the signature is: - - ```cpp - template - operator ValueType() const; - ``` - - If [`JSON_USE_IMPLICIT_CONVERSIONS`](../macros/json_use_implicit_conversions.md) is set to `0`, - `JSON_EXPLICIT` is defined to `#!cpp explicit`: - - ```cpp - template - explicit operator ValueType() const; - ``` - - That is, implicit conversions can be switched off by defining - [`JSON_USE_IMPLICIT_CONVERSIONS`](../macros/json_use_implicit_conversions.md) to `0`. - -!!! info "Future behavior change" - - Implicit conversions will be switched off by default in the next major release of the library. That is, - `JSON_EXPLICIT` will be set to `#!cpp explicit` by default. - - You can prepare existing code by already defining - [`JSON_USE_IMPLICIT_CONVERSIONS`](../macros/json_use_implicit_conversions.md) to `0` and replace any implicit - conversions with calls to [`get`](../basic_json/get.md). - -## Examples - -??? example - - The example below shows several conversions from JSON values to other types. There are a few things to note: (1) - Floating-point numbers can be converted to integers, (2) A JSON array can be converted to a standard - `std::vector`, (3) A JSON object can be converted to C++ associative containers such as - `std::unordered_map`. - - ```cpp - --8<-- "examples/operator__ValueType.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator__ValueType.output" - ``` - -## Version history - -- Since version 1.0.0. -- Macros `JSON_EXPLICIT`/[`JSON_USE_IMPLICIT_CONVERSIONS`](../macros/json_use_implicit_conversions.md) added - in version 3.9.0. diff --git a/docs/mkdocs/docs/api/basic_json/operator_eq.md b/docs/mkdocs/docs/api/basic_json/operator_eq.md deleted file mode 100644 index a2ce6155c3..0000000000 --- a/docs/mkdocs/docs/api/basic_json/operator_eq.md +++ /dev/null @@ -1,168 +0,0 @@ -# nlohmann::basic_json::operator== - -```cpp -// until C++20 -bool operator==(const_reference lhs, const_reference rhs) noexcept; // (1) - -template -bool operator==(const_reference lhs, const ScalarType rhs) noexcept; // (2) - -template -bool operator==(ScalarType lhs, const const_reference rhs) noexcept; // (2) - -// since C++20 -class basic_json { - bool operator==(const_reference rhs) const noexcept; // (1) - - template - bool operator==(ScalarType rhs) const noexcept; // (2) -}; -``` - -1. Compares two JSON values for equality according to the following rules: - - Two JSON values are equal if (1) neither value is discarded, or (2) they are of the same type and their stored - values are the same according to their respective `operator==`. - - Integer and floating-point numbers are automatically converted before comparison. - -2. Compares a JSON value and a scalar or a scalar and a JSON value for equality by converting the - scalar to a JSON value and comparing both JSON values according to 1. - -## Template parameters - -`ScalarType` -: a scalar type according to `std::is_scalar::value` - -## Parameters - -`lhs` (in) -: first value to consider - -`rhs` (in) -: second value to consider - -## Return value - -whether the values `lhs`/`*this` and `rhs` are equal - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Linear. - -## Notes - -!!! note "Comparing special values" - - - `NaN` values are unordered within the domain of numbers. - The following comparisons all yield `#!cpp false`: - 1. Comparing a `NaN` with itself. - 2. Comparing a `NaN` with another `NaN`. - 3. Comparing a `NaN` and any other number. - - JSON `#!cpp null` values are all equal. - - Discarded values never compare equal to themselves. - -!!! note "Comparing floating-point numbers" - - Floating-point numbers inside JSON values numbers are compared with `json::number_float_t::operator==` which is - `double::operator==` by default. To compare floating-point while respecting an epsilon, an alternative - [comparison function](https://github.com/mariokonrad/marnav/blob/master/include/marnav/math/floatingpoint.hpp#L34-#L39) - could be used, for instance - - ```cpp - template::value, T>::type> - inline bool is_same(T a, T b, T epsilon = std::numeric_limits::epsilon()) noexcept - { - return std::abs(a - b) <= epsilon; - } - ``` - - Or you can self-defined operator equal function like this: - - ```cpp - bool my_equal(const_reference lhs, const_reference rhs) - { - const auto lhs_type lhs.type(); - const auto rhs_type rhs.type(); - if (lhs_type == rhs_type) - { - switch(lhs_type) - // self_defined case - case value_t::number_float: - return std::abs(lhs - rhs) <= std::numeric_limits::epsilon(); - // other cases remain the same with the original - ... - } - ... - } - ``` - -!!! note "Comparing different `basic_json` specializations" - - Comparing different `basic_json` specializations can have surprising effects. For instance, the result of comparing - the JSON objects - - ```json - { - "version": 1, - "type": "integer" - } - ``` - - and - - ```json - { - "type": "integer", - "version": 1 - } - ``` - - depends on whether [`nlohmann::json`](../json.md) or [`nlohmann::ordered_json`](../ordered_json.md) is used: - - ```cpp - --8<-- "examples/operator__equal__specializations.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator__equal__specializations.output" - ``` - -## Examples - -??? example - - The example demonstrates comparing several JSON types. - - ```cpp - --8<-- "examples/operator__equal.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator__equal.output" - ``` - -??? example - - The example demonstrates comparing several JSON types against the null pointer (JSON `#!json null`). - - ```cpp - --8<-- "examples/operator__equal__nullptr_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator__equal__nullptr_t.output" - ``` - -## Version history - -1. Added in version 1.0.0. Added C++20 member functions in version 3.11.0. -2. Added in version 1.0.0. Added C++20 member functions in version 3.11.0. diff --git a/docs/mkdocs/docs/api/basic_json/operator_ge.md b/docs/mkdocs/docs/api/basic_json/operator_ge.md deleted file mode 100644 index d4e2fb4a50..0000000000 --- a/docs/mkdocs/docs/api/basic_json/operator_ge.md +++ /dev/null @@ -1,86 +0,0 @@ -# nlohmann::basic_json::operator>= - -```cpp -// until C++20 -bool operator>=(const_reference lhs, const_reference rhs) noexcept; // (1) - -template -bool operator>=(const_reference lhs, const ScalarType rhs) noexcept; // (2) - -template -bool operator>=(ScalarType lhs, const const_reference rhs) noexcept; // (2) -``` - -1. Compares whether one JSON value `lhs` is greater than or equal to another JSON value `rhs` according to the following - rules: - - The comparison always yields `#!cpp false` if (1) either operand is discarded, or (2) either operand is `NaN` and - the other operand is either `NaN` or any other number. - - Otherwise, returns the result of `#!cpp !(lhs < rhs)` (see [**operator<**](operator_lt.md)). - -2. Compares whether a JSON value is greater than or equal to a scalar or a scalar is greater than or equal to a JSON - value by converting the scalar to a JSON value and comparing both JSON values according to 1. - -## Template parameters - -`ScalarType` -: a scalar type according to `std::is_scalar::value` - -## Parameters - -`lhs` (in) -: first value to consider - -`rhs` (in) -: second value to consider - -## Return value - -whether `lhs` is less than or equal to `rhs` - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Linear. - -## Notes - -!!! note "Comparing `NaN`" - - `NaN` values are unordered within the domain of numbers. - The following comparisons all yield `#!cpp false`: - 1. Comparing a `NaN` with itself. - 2. Comparing a `NaN` with another `NaN`. - 3. Comparing a `NaN` and any other number. - -!!! note "Operator overload resolution" - - Since C++20 overload resolution will consider the _rewritten candidate_ generated from - [`operator<=>`](operator_spaceship.md). - -## Examples - -??? example - - The example demonstrates comparing several JSON types. - - ```cpp - --8<-- "examples/operator__greaterequal.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator__greaterequal.output" - ``` - -## See also - -- [**operator<=>**](operator_spaceship.md) comparison: 3-way - -## Version history - -1. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0. -2. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0. diff --git a/docs/mkdocs/docs/api/basic_json/operator_gt.md b/docs/mkdocs/docs/api/basic_json/operator_gt.md deleted file mode 100644 index 9516656e08..0000000000 --- a/docs/mkdocs/docs/api/basic_json/operator_gt.md +++ /dev/null @@ -1,86 +0,0 @@ -# nlohmann::basic_json::operator> - -```cpp -// until C++20 -bool operator>(const_reference lhs, const_reference rhs) noexcept; // (1) - -template -bool operator>(const_reference lhs, const ScalarType rhs) noexcept; // (2) - -template -bool operator>(ScalarType lhs, const const_reference rhs) noexcept; // (2) -``` - -1. Compares whether one JSON value `lhs` is greater than another JSON value `rhs` according to the - following rules: - - The comparison always yields `#!cpp false` if (1) either operand is discarded, or (2) either - operand is `NaN` and the other operand is either `NaN` or any other number. - - Otherwise, returns the result of `#!cpp !(lhs <= rhs)` (see [**operator<=**](operator_le.md)). - -2. Compares wether a JSON value is greater than a scalar or a scalar is greater than a JSON value by - converting the scalar to a JSON value and comparing both JSON values according to 1. - -## Template parameters - -`ScalarType` -: a scalar type according to `std::is_scalar::value` - -## Parameters - -`lhs` (in) -: first value to consider - -`rhs` (in) -: second value to consider - -## Return value - -whether `lhs` is greater than `rhs` - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Linear. - -## Notes - -!!! note "Comparing `NaN`" - - `NaN` values are unordered within the domain of numbers. - The following comparisons all yield `#!cpp false`: - 1. Comparing a `NaN` with itself. - 2. Comparing a `NaN` with another `NaN`. - 3. Comparing a `NaN` and any other number. - -!!! note "Operator overload resolution" - - Since C++20 overload resolution will consider the _rewritten candidate_ generated from - [`operator<=>`](operator_spaceship.md). - -## Examples - -??? example - - The example demonstrates comparing several JSON types. - - ```cpp - --8<-- "examples/operator__greater.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator__greater.output" - ``` - -## See also - -- [**operator<=>**](operator_spaceship.md) comparison: 3-way - -## Version history - -1. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0. -2. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0. diff --git a/docs/mkdocs/docs/api/basic_json/operator_le.md b/docs/mkdocs/docs/api/basic_json/operator_le.md deleted file mode 100644 index 7b648e035c..0000000000 --- a/docs/mkdocs/docs/api/basic_json/operator_le.md +++ /dev/null @@ -1,87 +0,0 @@ -# nlohmann::basic_json::operator<= - -```cpp -// until C++20 -bool operator<=(const_reference lhs, const_reference rhs) noexcept; // (1) - -template -bool operator<=(const_reference lhs, const ScalarType rhs) noexcept; // (2) - -template -bool operator<=(ScalarType lhs, const const_reference rhs) noexcept; // (2) -``` - -1. Compares whether one JSON value `lhs` is less than or equal to another JSON value `rhs` - according to the following rules: - - The comparison always yields `#!cpp false` if (1) either operand is discarded, or (2) either - operand is `NaN` and the other operand is either `NaN` or any other number. - - Otherwise, returns the result of `#!cpp !(rhs < lhs)` (see [**operator<**](operator_lt.md)). - -1. Compares wether a JSON value is less than or equal to a scalar or a scalar is less than or equal - to a JSON value by converting the scalar to a JSON value and comparing both JSON values according - to 1. - -## Template parameters - -`ScalarType` -: a scalar type according to `std::is_scalar::value` - -## Parameters - -`lhs` (in) -: first value to consider - -`rhs` (in) -: second value to consider - -## Return value - -whether `lhs` is less than or equal to `rhs` - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Linear. - -## Notes - -!!! note "Comparing `NaN`" - - `NaN` values are unordered within the domain of numbers. - The following comparisons all yield `#!cpp false`: - 1. Comparing a `NaN` with itself. - 2. Comparing a `NaN` with another `NaN`. - 3. Comparing a `NaN` and any other number. - -!!! note "Operator overload resolution" - - Since C++20 overload resolution will consider the _rewritten candidate_ generated from - [`operator<=>`](operator_spaceship.md). - -## Examples - -??? example - - The example demonstrates comparing several JSON types. - - ```cpp - --8<-- "examples/operator__lessequal.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator__lessequal.output" - ``` - -## See also - -- [**operator<=>**](operator_spaceship.md) comparison: 3-way - -## Version history - -1. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0. -2. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0. diff --git a/docs/mkdocs/docs/api/basic_json/operator_lt.md b/docs/mkdocs/docs/api/basic_json/operator_lt.md deleted file mode 100644 index b5d191ec45..0000000000 --- a/docs/mkdocs/docs/api/basic_json/operator_lt.md +++ /dev/null @@ -1,96 +0,0 @@ -# nlohmann::basic_json::operator< - -```cpp -// until C++20 -bool operator<(const_reference lhs, const_reference rhs) noexcept; // (1) - -template -bool operator<(const_reference lhs, const ScalarType rhs) noexcept; // (2) - -template -bool operator<(ScalarType lhs, const const_reference rhs) noexcept; // (2) -``` - -1. Compares whether one JSON value `lhs` is less than another JSON value `rhs` according to the - following rules: - - If either operand is discarded, the comparison yields `#!cpp false`. - - If both operands have the same type, the values are compared using their respective `operator<`. - - Integer and floating-point numbers are automatically converted before comparison. - - In case `lhs` and `rhs` have different types, the values are ignored and the order of the types - is considered, which is: - 1. null - 2. boolean - 3. number (all types) - 4. object - 5. array - 6. string - 7. binary - For instance, any boolean value is considered less than any string. - -2. Compares wether a JSON value is less than a scalar or a scalar is less than a JSON value by converting - the scalar to a JSON value and comparing both JSON values according to 1. - -## Template parameters - -`ScalarType` -: a scalar type according to `std::is_scalar::value` - -## Parameters - -`lhs` (in) -: first value to consider - -`rhs` (in) -: second value to consider - -## Return value - -whether `lhs` is less than `rhs` - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Linear. - -## Notes - -!!! note "Comparing `NaN`" - - `NaN` values are unordered within the domain of numbers. - The following comparisons all yield `#!cpp false`: - 1. Comparing a `NaN` with itself. - 2. Comparing a `NaN` with another `NaN`. - 3. Comparing a `NaN` and any other number. - -!!! note "Operator overload resolution" - - Since C++20 overload resolution will consider the _rewritten candidate_ generated from - [`operator<=>`](operator_spaceship.md). - -## Examples - -??? example - - The example demonstrates comparing several JSON types. - - ```cpp - --8<-- "examples/operator__less.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator__less.output" - ``` - -## See also - -- [**operator<=>**](operator_spaceship.md) comparison: 3-way - -## Version history - -1. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0. -2. Added in version 1.0.0. Conditionally removed since C++20 in version 3.11.0. diff --git a/docs/mkdocs/docs/api/basic_json/operator_ne.md b/docs/mkdocs/docs/api/basic_json/operator_ne.md deleted file mode 100644 index 982a06764d..0000000000 --- a/docs/mkdocs/docs/api/basic_json/operator_ne.md +++ /dev/null @@ -1,98 +0,0 @@ -# nlohmann::basic_json::operator!= - -```cpp -// until C++20 -bool operator!=(const_reference lhs, const_reference rhs) noexcept; // (1) - -template -bool operator!=(const_reference lhs, const ScalarType rhs) noexcept; // (2) - -template -bool operator!=(ScalarType lhs, const const_reference rhs) noexcept; // (2) - -// since C++20 -class basic_json { - bool operator!=(const_reference rhs) const noexcept; // (1) - - template - bool operator!=(ScalarType rhs) const noexcept; // (2) -}; -``` - -1. Compares two JSON values for inequality according to the following rules: - - The comparison always yields `#!cpp false` if (1) either operand is discarded, or (2) either operand is `NaN` and - the other operand is either `NaN` or any other number. - - Otherwise, returns the result of `#!cpp !(lhs == rhs)` (until C++20) or `#!cpp !(*this == rhs)` (since C++20). - -2. Compares a JSON value and a scalar or a scalar and a JSON value for inequality by converting the scalar to a JSON - value and comparing both JSON values according to 1. - -## Template parameters - -`ScalarType` -: a scalar type according to `std::is_scalar::value` - -## Parameters - -`lhs` (in) -: first value to consider - -`rhs` (in) -: second value to consider - -## Return value - -whether the values `lhs`/`*this` and `rhs` are not equal - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Linear. - -## Notes - -!!! note "Comparing `NaN`" - - `NaN` values are unordered within the domain of numbers. - The following comparisons all yield `#!cpp false`: - 1. Comparing a `NaN` with itself. - 2. Comparing a `NaN` with another `NaN`. - 3. Comparing a `NaN` and any other number. - -## Examples - -??? example - - The example demonstrates comparing several JSON types. - - ```cpp - --8<-- "examples/operator__notequal.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator__notequal.output" - ``` - -??? example - - The example demonstrates comparing several JSON types against the null pointer (JSON `#!json null`). - - ```cpp - --8<-- "examples/operator__notequal__nullptr_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator__notequal__nullptr_t.output" - ``` - -## Version history - -1. Added in version 1.0.0. Added C++20 member functions in version 3.11.0. -2. Added in version 1.0.0. Added C++20 member functions in version 3.11.0. diff --git a/docs/mkdocs/docs/api/basic_json/operator_spaceship.md b/docs/mkdocs/docs/api/basic_json/operator_spaceship.md deleted file mode 100644 index 9e91d0d2da..0000000000 --- a/docs/mkdocs/docs/api/basic_json/operator_spaceship.md +++ /dev/null @@ -1,100 +0,0 @@ -# nlohmann::basic_json::operator<=> - -```cpp -// since C++20 -class basic_json { - std::partial_ordering operator<=>(const_reference rhs) const noexcept; // (1) - - template - std::partial_ordering operator<=>(const ScalarType rhs) const noexcept; // (2) -}; -``` - -1. 3-way compares two JSON values producing a result of type `std::partial_ordering` according to the following rules: - - Two JSON values compare with a result of `std::partial_ordering::unordered` if either value is discarded. - - If both JSON values are of the same type, the result is produced by 3-way comparing their stored values using - their respective `operator<=>`. - - Integer and floating-point numbers are converted to their common type and then 3-way compared using their - respective `operator<=>`. - For instance, comparing an integer and a floating-point value will 3-way compare the first value converted to - floating-point with the second value. - - Otherwise, yields a result by comparing the type (see [`value_t`](value_t.md)). - -2. 3-way compares a JSON value and a scalar or a scalar and a JSON value by converting the scalar to a JSON value and - 3-way comparing both JSON values (see 1). - -## Template parameters - -`ScalarType` -: a scalar type according to `std::is_scalar::value` - -## Parameters - -`rhs` (in) -: second value to consider - -## Return value - -the `std::partial_ordering` of the 3-way comparison of `*this` and `rhs` - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Linear. - -## Notes - -!!! note "Comparing `NaN`" - - - `NaN` values are unordered within the domain of numbers. - The following comparisons all yield `std::partial_ordering::unordered`: - 1. Comparing a `NaN` with itself. - 2. Comparing a `NaN` with another `NaN`. - 3. Comparing a `NaN` and any other number. - -## Examples - -??? example "Example: (1) comparing JSON values" - - The example demonstrates comparing several JSON values. - - ```cpp - --8<-- "examples/operator_spaceship__const_reference.c++20.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator_spaceship__const_reference.c++20.output" - ``` - -??? example "Example: (2) comparing JSON values and scalars" - - The example demonstrates comparing several JSON values and scalars. - - ```cpp - --8<-- "examples/operator_spaceship__scalartype.c++20.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator_spaceship__scalartype.c++20.output" - ``` - -## See also - -- [**operator==**](operator_eq.md) - comparison: equal -- [**operator!=**](operator_ne.md) - comparison: not equal -- [**operator<**](operator_lt.md) - comparison: less than -- [**operator<=**](operator_le.md) - comparison: less than or equal -- [**operator>**](operator_gt.md) - comparison: greater than -- [**operator>=**](operator_ge.md) - comparison: greater than or equal - -## Version history - -1. Added in version 3.11.0. -2. Added in version 3.11.0. diff --git a/docs/mkdocs/docs/api/basic_json/operator_value_t.md b/docs/mkdocs/docs/api/basic_json/operator_value_t.md deleted file mode 100644 index 0f08f42b04..0000000000 --- a/docs/mkdocs/docs/api/basic_json/operator_value_t.md +++ /dev/null @@ -1,54 +0,0 @@ -# nlohmann::basic_json::operator value_t - -```cpp -constexpr operator value_t() const noexcept; -``` - -Return the type of the JSON value as a value from the [`value_t`](value_t.md) enumeration. - -## Return value - -the type of the JSON value - -| Value type | return value | -|---------------------------|----------------------------| -| `#!json null` | `value_t::null` | -| boolean | `value_t::boolean` | -| string | `value_t::string` | -| number (integer) | `value_t::number_integer` | -| number (unsigned integer) | `value_t::number_unsigned` | -| number (floating-point) | `value_t::number_float` | -| object | `value_t::object` | -| array | `value_t::array` | -| binary | `value_t::binary` | -| discarded | `value_t::discarded` | - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code exemplifies `operator value_t()` for all JSON types. - - ```cpp - --8<-- "examples/operator__value_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator__value_t.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Added unsigned integer type in version 2.0.0. -- Added binary type in version 3.8.0. diff --git a/docs/mkdocs/docs/api/basic_json/other_error.md b/docs/mkdocs/docs/api/basic_json/other_error.md deleted file mode 100644 index 9a83340a04..0000000000 --- a/docs/mkdocs/docs/api/basic_json/other_error.md +++ /dev/null @@ -1,67 +0,0 @@ -# nlohmann::basic_json::other_error - -```cpp -class other_error : public exception; -``` - -This exception is thrown in case of errors that cannot be classified with the other exception types. - -Exceptions have ids 5xx (see [list of other errors](../../home/exceptions.md#further-exceptions)). - -```plantuml -std::exception <|-- basic_json::exception -basic_json::exception <|-- basic_json::parse_error -basic_json::exception <|-- basic_json::invalid_iterator -basic_json::exception <|-- basic_json::type_error -basic_json::exception <|-- basic_json::out_of_range -basic_json::exception <|-- basic_json::other_error - -interface std::exception {} - -class basic_json::exception { - + const int id - + const char* what() const -} - -class basic_json::parse_error { - + const std::size_t byte -} - -class basic_json::other_error #FFFF00 {} -``` - -## Member functions - -- **what** - returns explanatory string - -## Member variables - -- **id** - the id of the exception - -## Examples - -??? example - - The following code shows how a `other_error` exception can be caught. - - ```cpp - --8<-- "examples/other_error.cpp" - ``` - - Output: - - ```json - --8<-- "examples/other_error.output" - ``` - -## See also - -- [List of other errors](../../home/exceptions.md#further-exceptions) -- [`parse_error`](parse_error.md) for exceptions indicating a parse error -- [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators -- [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type -- [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range - -## Version history - -- Since version 3.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/out_of_range.md b/docs/mkdocs/docs/api/basic_json/out_of_range.md deleted file mode 100644 index 6c1f0dfbab..0000000000 --- a/docs/mkdocs/docs/api/basic_json/out_of_range.md +++ /dev/null @@ -1,68 +0,0 @@ -# nlohmann::basic_json::out_of_range - -```cpp -class out_of_range : public exception; -``` - -This exception is thrown in case a library function is called on an input parameter that exceeds the expected range, for -instance in case of array indices or nonexisting object keys. - -Exceptions have ids 4xx (see [list of out-of-range errors](../../home/exceptions.md#out-of-range)). - -```plantuml -std::exception <|-- basic_json::exception -basic_json::exception <|-- basic_json::parse_error -basic_json::exception <|-- basic_json::invalid_iterator -basic_json::exception <|-- basic_json::type_error -basic_json::exception <|-- basic_json::out_of_range -basic_json::exception <|-- basic_json::other_error - -interface std::exception {} - -class basic_json::exception { - + const int id - + const char* what() const -} - -class basic_json::parse_error { - + const std::size_t byte -} - -class basic_json::out_of_range #FFFF00 {} -``` - -## Member functions - -- **what** - returns explanatory string - -## Member variables - -- **id** - the id of the exception - -## Examples - -??? example - - The following code shows how a `out_of_range` exception can be caught. - - ```cpp - --8<-- "examples/out_of_range.cpp" - ``` - - Output: - - ```json - --8<-- "examples/out_of_range.output" - ``` - -## See also - -- [List of out-of-range errors](../../home/exceptions.md#out-of-range) -- [`parse_error`](parse_error.md) for exceptions indicating a parse error -- [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators -- [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type -- [`other_error`](other_error.md) for exceptions indicating other library errors - -## Version history - -- Since version 3.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/parse.md b/docs/mkdocs/docs/api/basic_json/parse.md deleted file mode 100644 index 49838ad1d4..0000000000 --- a/docs/mkdocs/docs/api/basic_json/parse.md +++ /dev/null @@ -1,214 +0,0 @@ -# nlohmann::basic_json::parse - -```cpp -// (1) -template -static basic_json parse(InputType&& i, - const parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false); - -// (2) -template -static basic_json parse(IteratorType first, IteratorType last, - const parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false); -``` - -1. Deserialize from a compatible input. -2. Deserialize from a pair of character iterators - - The `value_type` of the iterator must be an integral type with size of 1, 2 or 4 bytes, which will be interpreted - respectively as UTF-8, UTF-16 and UTF-32. - -## Template parameters - -`InputType` -: A compatible input, for instance: - - - an `std::istream` object - - a `FILE` pointer (must not be null) - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - a `std::string` - - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators. - -`IteratorType` -: a compatible iterator type, for instance. - - - a pair of `std::string::iterator` or `std::vector::iterator` - - a pair of pointers such as `ptr` and `ptr + len` - -## Parameters - -`i` (in) -: Input to parse from. - -`cb` (in) -: a parser callback function of type [`parser_callback_t`](parser_callback_t.md) which is used to control the - deserialization by filtering unwanted values (optional) - -`allow_exceptions` (in) -: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default) - -`ignore_comments` (in) -: whether comments should be ignored and treated like whitespace (`#!cpp true`) or yield a parse error - (`#!cpp false`); (optional, `#!cpp false` by default) - -`first` (in) -: iterator to start of character range - -`last` (in) -: iterator to end of character range - -## Return value - -Deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be -`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md). - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Exceptions - -- Throws [`parse_error.101`](../../home/exceptions.md#jsonexceptionparse_error101) in case of an unexpected token. -- Throws [`parse_error.102`](../../home/exceptions.md#jsonexceptionparse_error102) if to_unicode fails or surrogate - error. -- Throws [`parse_error.103`](../../home/exceptions.md#jsonexceptionparse_error103) if to_unicode fails. - -## Complexity - -Linear in the length of the input. The parser is a predictive LL(1) parser. The complexity can be higher if the parser -callback function `cb` or reading from (1) the input `i` or (2) the iterator range [`first`, `last`] has a -super-linear complexity. - -## Notes - -(1) A UTF-8 byte order mark is silently ignored. - -!!! danger "Runtime assertion" - - The precondition that a passed `#!cpp FILE` pointer must not be null is enforced with a - [runtime assertion](../../features/assertions.md). - -## Examples - -??? example "Parsing from a character array" - - The example below demonstrates the `parse()` function reading from an array. - - ```cpp - --8<-- "examples/parse__array__parser_callback_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/parse__array__parser_callback_t.output" - ``` - -??? example "Parsing from a string" - - The example below demonstrates the `parse()` function with and without callback function. - - ```cpp - --8<-- "examples/parse__string__parser_callback_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/parse__string__parser_callback_t.output" - ``` - -??? example "Parsing from an input stream" - - The example below demonstrates the `parse()` function with and without callback function. - - ```cpp - --8<-- "examples/parse__istream__parser_callback_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/parse__istream__parser_callback_t.output" - ``` - -??? example "Parsing from a contiguous container" - - The example below demonstrates the `parse()` function reading from a contiguous container. - - ```cpp - --8<-- "examples/parse__contiguouscontainer__parser_callback_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/parse__contiguouscontainer__parser_callback_t.output" - ``` - -??? example "Parsing from a non null-terminated string" - - The example below demonstrates the `parse()` function reading from a string that is not null-terminated. - - ```cpp - --8<-- "examples/parse__pointers.cpp" - ``` - - Output: - - ```json - --8<-- "examples/parse__pointers.output" - ``` - -??? example "Parsing from an iterator pair" - - The example below demonstrates the `parse()` function reading from an iterator pair. - - ```cpp - --8<-- "examples/parse__iterator_pair.cpp" - ``` - - Output: - - ```json - --8<-- "examples/parse__iterator_pair.output" - ``` - -??? example "Effect of `allow_exceptions` parameter" - - The example below demonstrates the effect of the `allow_exceptions` parameter in the ´parse()` function. - - ```cpp - --8<-- "examples/parse__allow_exceptions.cpp" - ``` - - Output: - - ```json - --8<-- "examples/parse__allow_exceptions.output" - ``` - -## See also - -- [accept](accept.md) - check if the input is valid JSON -- [operator>>](../operator_gtgt.md) - deserialize from stream - -## Version history - -- Added in version 1.0.0. -- Overload for contiguous containers (1) added in version 2.0.3. -- Ignoring comments via `ignore_comments` added in version 3.9.0. - -!!! warning "Deprecation" - - Overload (2) replaces calls to `parse` with a pair of iterators as their first parameter which has been - deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like - `#!cpp parse({ptr, ptr+len}, ...);` with `#!cpp parse(ptr, ptr+len, ...);`. - - You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated - function. diff --git a/docs/mkdocs/docs/api/basic_json/parse_error.md b/docs/mkdocs/docs/api/basic_json/parse_error.md deleted file mode 100644 index af3e1f0b36..0000000000 --- a/docs/mkdocs/docs/api/basic_json/parse_error.md +++ /dev/null @@ -1,74 +0,0 @@ -# nlohmann::basic_json::parse_error - -```cpp -class parse_error : public exception; -``` - -This exception is thrown by the library when a parse error occurs. Parse errors can occur during the deserialization of -JSON text, BSON, CBOR, MessagePack, UBJSON, as well as when using JSON Patch. - -Member `byte` holds the byte index of the last read character in the input file (see note below). - -Exceptions have ids 1xx (see [list of parse errors](../../home/exceptions.md#parse-errors)). - -```plantuml -std::exception <|-- basic_json::exception -basic_json::exception <|-- basic_json::parse_error -basic_json::exception <|-- basic_json::invalid_iterator -basic_json::exception <|-- basic_json::type_error -basic_json::exception <|-- basic_json::out_of_range -basic_json::exception <|-- basic_json::other_error - -interface std::exception {} - -class basic_json::exception { - + const int id - + const char* what() const -} - -class basic_json::parse_error #FFFF00 { - + const std::size_t byte -} -``` - -## Member functions - -- **what** - returns explanatory string - -## Member variables - -- **id** - the id of the exception -- **byte** - byte index of the parse error - -## Notes - -For an input with $n$ bytes, 1 is the index of the first character and $n+1$ is the index of the terminating null byte -or the end of file. This also holds true when reading a byte vector for binary formats. - -## Examples - -??? example - - The following code shows how a `parse_error` exception can be caught. - - ```cpp - --8<-- "examples/parse_error.cpp" - ``` - - Output: - - ```json - --8<-- "examples/parse_error.output" - ``` - -## See also - -- [List of parse errors](../../home/exceptions.md#parse-errors) -- [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators -- [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type -- [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range -- [`other_error`](other_error.md) for exceptions indicating other library errors - -## Version history - -- Since version 3.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/parse_event_t.md b/docs/mkdocs/docs/api/basic_json/parse_event_t.md deleted file mode 100644 index 1a7c39038d..0000000000 --- a/docs/mkdocs/docs/api/basic_json/parse_event_t.md +++ /dev/null @@ -1,29 +0,0 @@ -# nlohmann::basic_json::parse_event_t - -```cpp -enum class parse_event_t : std::uint8_t { - object_start, - object_end, - array_start, - array_end, - key, - value -}; -``` - -The parser callback distinguishes the following events: - -- `object_start`: the parser read `{` and started to process a JSON object -- `key`: the parser read a key of a value in an object -- `object_end`: the parser read `}` and finished processing a JSON object -- `array_start`: the parser read `[` and started to process a JSON array -- `array_end`: the parser read `]` and finished processing a JSON array -- `value`: the parser finished reading a JSON value - -## Examples - -![Example when certain parse events are triggered](../../images/callback_events.png) - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/parser_callback_t.md b/docs/mkdocs/docs/api/basic_json/parser_callback_t.md deleted file mode 100644 index e10402ea95..0000000000 --- a/docs/mkdocs/docs/api/basic_json/parser_callback_t.md +++ /dev/null @@ -1,73 +0,0 @@ -# nlohmann::basic_json::parser_callback_t - -```cpp -template -using parser_callback_t = - std::function; -``` - -With a parser callback function, the result of parsing a JSON text can be influenced. When passed to -[`parse`](parse.md), it is called on certain events (passed as [`parse_event_t`](parse_event_t.md) via parameter -`event`) with a set recursion depth `depth` and context JSON value `parsed`. The return value of the callback function -is a boolean indicating whether the element that emitted the callback shall be kept or not. - -We distinguish six scenarios (determined by the event type) in which the callback function can be called. The following -table describes the values of the parameters `depth`, `event`, and `parsed`. - -| parameter `event` | description | parameter `depth` | parameter `parsed` | -|-------------------------------|-----------------------------------------------------------|-------------------------------------------|----------------------------------| -| `parse_event_t::object_start` | the parser read `{` and started to process a JSON object | depth of the parent of the JSON object | a JSON value with type discarded | -| `parse_event_t::key` | the parser read a key of a value in an object | depth of the currently parsed JSON object | a JSON string containing the key | -| `parse_event_t::object_end` | the parser read `}` and finished processing a JSON object | depth of the parent of the JSON object | the parsed JSON object | -| `parse_event_t::array_start` | the parser read `[` and started to process a JSON array | depth of the parent of the JSON array | a JSON value with type discarded | -| `parse_event_t::array_end` | the parser read `]` and finished processing a JSON array | depth of the parent of the JSON array | the parsed JSON array | -| `parse_event_t::value` | the parser finished reading a JSON value | depth of the value | the parsed JSON value | - -![Example when certain parse events are triggered](../../images/callback_events.png) - -Discarding a value (i.e., returning `#!cpp false`) has different effects depending on the context in which function was -called: - -- Discarded values in structured types are skipped. That is, the parser will behave as if the discarded value was never - read. -- In case a value outside a structured type is skipped, it is replaced with `null`. This case happens if the top-level - element is skipped. - -## Parameters - -`depth` (in) -: the depth of the recursion during parsing - -`event` (in) -: an event of type [`parse_event_t`](parse_event_t.md) indicating the context in - the callback function has been called - -`parsed` (in, out) -: the current intermediate parse result; note that - writing to this value has no effect for `parse_event_t::key` events - -## Return value - -Whether the JSON value which called the function during parsing should be kept (`#!cpp true`) or not (`#!cpp false`). In -the latter case, it is either skipped completely or replaced by an empty discarded object. - -## Examples - -??? example - - The example below demonstrates the `parse()` function with - and without callback function. - - ```cpp - --8<-- "examples/parse__string__parser_callback_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/parse__string__parser_callback_t.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/patch.md b/docs/mkdocs/docs/api/basic_json/patch.md deleted file mode 100644 index deec47434c..0000000000 --- a/docs/mkdocs/docs/api/basic_json/patch.md +++ /dev/null @@ -1,73 +0,0 @@ -# nlohmann::basic_json::patch - -```cpp -basic_json patch(const basic_json& json_patch) const; -``` - -[JSON Patch](http://jsonpatch.com) defines a JSON document structure for expressing a sequence of operations to apply to -a JSON document. With this function, a JSON Patch is applied to the current JSON value by executing all operations from -the patch. - -## Parameters - -`json_patch` (in) -: JSON patch document - -## Return value - -patched document - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Exceptions - -- Throws [`parse_error.104`](../../home/exceptions.md#jsonexceptionparse_error104) if the JSON patch does not consist of - an array of objects. -- Throws [`parse_error.105`](../../home/exceptions.md#jsonexceptionparse_error105) if the JSON patch is malformed (e.g., - mandatory attributes are missing); example: `"operation add must have member path"`. -- Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) if an array index is out of range. -- Throws [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if a JSON pointer inside the patch - could not be resolved successfully in the current JSON value; example: `"key baz not found"`. -- Throws [`out_of_range.405`](../../home/exceptions.md#jsonexceptionout_of_range405) if JSON pointer has no parent - ("add", "remove", "move") -- Throws [`out_of_range.501`](../../home/exceptions.md#jsonexceptionother_error501) if "test" operation was - unsuccessful. - -## Complexity - -Linear in the size of the JSON value and the length of the JSON patch. As usually only a fraction of the JSON value is -affected by the patch, the complexity can usually be neglected. - -## Notes - -The application of a patch is atomic: Either all operations succeed and the patched document is returned or an exception -is thrown. In any case, the original value is not changed: the patch is applied to a copy of the value. - -## Examples - -??? example - - The following code shows how a JSON patch is applied to a value. - - ```cpp - --8<-- "examples/patch.cpp" - ``` - - Output: - - ```json - --8<-- "examples/patch.output" - ``` - -## See also - -- [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) -- [RFC 6901 (JSON Pointer)](https://tools.ietf.org/html/rfc6901) -- [patch_inplace](patch_inplace.md) applies a JSON Patch without creating a copy of the document -- [merge_patch](merge_patch.md) applies a JSON Merge Patch - -## Version history - -- Added in version 2.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/patch_inplace.md b/docs/mkdocs/docs/api/basic_json/patch_inplace.md deleted file mode 100644 index e8fd176c3a..0000000000 --- a/docs/mkdocs/docs/api/basic_json/patch_inplace.md +++ /dev/null @@ -1,70 +0,0 @@ -# nlohmann::basic_json::patch_inplace - -```cpp -void patch_inplace(const basic_json& json_patch) const; -``` - -[JSON Patch](http://jsonpatch.com) defines a JSON document structure for expressing a sequence of operations to apply to -a JSON document. With this function, a JSON Patch is applied to the current JSON value by executing all operations from -the patch. This function applies a JSON patch in place and returns void. - -## Parameters - -`json_patch` (in) -: JSON patch document - -## Exception safety - -No guarantees, value may be corrupted by an unsuccessful patch operation. - -## Exceptions - -- Throws [`parse_error.104`](../../home/exceptions.md#jsonexceptionparse_error104) if the JSON patch does not consist of - an array of objects. -- Throws [`parse_error.105`](../../home/exceptions.md#jsonexceptionparse_error105) if the JSON patch is malformed (e.g., - mandatory attributes are missing); example: `"operation add must have member path"`. -- Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) if an array index is out of range. -- Throws [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if a JSON pointer inside the patch - could not be resolved successfully in the current JSON value; example: `"key baz not found"`. -- Throws [`out_of_range.405`](../../home/exceptions.md#jsonexceptionout_of_range405) if JSON pointer has no parent - ("add", "remove", "move") -- Throws [`out_of_range.501`](../../home/exceptions.md#jsonexceptionother_error501) if "test" operation was - unsuccessful. - -## Complexity - -Linear in the size of the JSON value and the length of the JSON patch. As usually only a fraction of the JSON value is -affected by the patch, the complexity can usually be neglected. - -## Notes - -Unlike [`patch`](patch.md), `patch_inplace` applies the operation "in place" and no copy of the JSON value is created. -That makes it faster for large documents by avoiding the copy. However, the JSON value might be corrupted if the -function throws an exception. - -## Examples - -??? example - - The following code shows how a JSON patch is applied to a value. - - ```cpp - --8<-- "examples/patch_inplace.cpp" - ``` - - Output: - - ```json - --8<-- "examples/patch_inplace.output" - ``` - -## See also - -- [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) -- [RFC 6901 (JSON Pointer)](https://tools.ietf.org/html/rfc6901) -- [patch](patch.md) applies a JSON Merge Patch -- [merge_patch](merge_patch.md) applies a JSON Merge Patch - -## Version history - -- Added in version 3.11.0. diff --git a/docs/mkdocs/docs/api/basic_json/push_back.md b/docs/mkdocs/docs/api/basic_json/push_back.md deleted file mode 100644 index 5c7d20dd6a..0000000000 --- a/docs/mkdocs/docs/api/basic_json/push_back.md +++ /dev/null @@ -1,106 +0,0 @@ -# nlohmann::basic_json::push_back - -```cpp -// (1) -void push_back(basic_json&& val); -void push_back(const basic_json& val); - -// (2) -void push_back(const typename object_t::value_type& val); - -// (3) -void push_back(initializer_list_t init); -``` - -1. Appends the given element `val` to the end of the JSON array. If the function is called on a JSON null value, an - empty array is created before appending `val`. - -2. Inserts the given element `val` to the JSON object. If the function is called on a JSON null value, an empty object - is created before inserting `val`. - -3. This function allows using `push_back` with an initializer list. In case - - 1. the current value is an object, - 2. the initializer list `init` contains only two elements, and - 3. the first element of `init` is a string, - - `init` is converted into an object element and added using `push_back(const typename object_t::value_type&)`. - Otherwise, `init` is converted to a JSON value and added using `push_back(basic_json&&)`. - -## Parameters - -`val` (in) -: the value to add to the JSON array/object - -`init` (in) -: an initializer list - -## Exceptions - -All functions can throw the following exception: - - Throws [`type_error.308`](../../home/exceptions.md#jsonexceptiontype_error308) when called on a type other than - JSON array or null; example: `"cannot use push_back() with number"` - -## Complexity - -1. Amortized constant. -2. Logarithmic in the size of the container, O(log(`size()`)). -3. Linear in the size of the initializer list `init`. - -## Notes - -(3) This function is required to resolve an ambiguous overload error, because pairs like `{"key", "value"}` can be both - interpreted as `object_t::value_type` or `std::initializer_list`, see - [#235](https://github.com/nlohmann/json/issues/235) for more information. - -## Examples - -??? example "Example: (1) add element to array" - - The example shows how `push_back()` and `+=` can be used to add elements to a JSON array. Note how the `null` value - was silently converted to a JSON array. - - ```cpp - --8<-- "examples/push_back.cpp" - ``` - - Output: - - ```json - --8<-- "examples/push_back.output" - ``` - -??? example "Example: (2) add element to object" - - The example shows how `push_back()` and `+=` can be used to add elements to a JSON object. Note how the `null` value - was silently converted to a JSON object. - - ```cpp - --8<-- "examples/push_back__object_t__value.cpp" - ``` - - Output: - - ```json - --8<-- "examples/push_back__object_t__value.output" - ``` - -??? example "Example: (3) add to object from initializer list" - - The example shows how initializer lists are treated as objects when possible. - - ```cpp - --8<-- "examples/push_back__initializer_list.cpp" - ``` - - Output: - - ```json - --8<-- "examples/push_back__initializer_list.output" - ``` - -## Version history - -1. Since version 1.0.0. -2. Since version 1.0.0. -2. Since version 2.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/rbegin.md b/docs/mkdocs/docs/api/basic_json/rbegin.md deleted file mode 100644 index 126c47127c..0000000000 --- a/docs/mkdocs/docs/api/basic_json/rbegin.md +++ /dev/null @@ -1,42 +0,0 @@ -# nlohmann::basic_json::rbegin - -```cpp -reverse_iterator rbegin() noexcept; -const_reverse_iterator rbegin() const noexcept; -``` - -Returns an iterator to the reverse-beginning; that is, the last element. - -![Illustration from cppreference.com](../../images/range-rbegin-rend.svg) - -## Return value - -reverse iterator to the first element - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code shows an example for `rbegin()`. - - ```cpp - --8<-- "examples/rbegin.cpp" - ``` - - Output: - - ```json - --8<-- "examples/rbegin.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/rend.md b/docs/mkdocs/docs/api/basic_json/rend.md deleted file mode 100644 index 96da7a5f50..0000000000 --- a/docs/mkdocs/docs/api/basic_json/rend.md +++ /dev/null @@ -1,43 +0,0 @@ -# nlohmann::basic_json::rend - -```cpp -reverse_iterator rend() noexcept; -const_reverse_iterator rend() const noexcept; -``` - -Returns an iterator to the reverse-end; that is, one before the first element. This element acts as a placeholder, -attempting to access it results in undefined behavior. - -![Illustration from cppreference.com](../../images/range-rbegin-rend.svg) - -## Return value - -reverse iterator to the element following the last element - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code shows an example for `eend()`. - - ```cpp - --8<-- "examples/rend.cpp" - ``` - - Output: - - ```json - --8<-- "examples/rend.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/sax_parse.md b/docs/mkdocs/docs/api/basic_json/sax_parse.md deleted file mode 100644 index e2ac1b41d9..0000000000 --- a/docs/mkdocs/docs/api/basic_json/sax_parse.md +++ /dev/null @@ -1,115 +0,0 @@ -# nlohmann::basic_json::sax_parse - -```cpp -// (1) -template -static bool sax_parse(InputType&& i, - SAX* sax, - input_format_t format = input_format_t::json, - const bool strict = true, - const bool ignore_comments = false); - -// (2) -template -static bool sax_parse(IteratorType first, IteratorType last, - SAX* sax, - input_format_t format = input_format_t::json, - const bool strict = true, - const bool ignore_comments = false); -``` - -Read from input and generate SAX events - -1. Read from a compatible input. -2. Read from a pair of character iterators - - The value_type of the iterator must be an integral type with size of 1, 2 or 4 bytes, which will be interpreted - respectively as UTF-8, UTF-16 and UTF-32. - -The SAX event lister must follow the interface of [`json_sax`](../json_sax/index.md). - -## Template parameters - -`InputType` -: A compatible input, for instance: - - - an `std::istream` object - - a `FILE` pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of - iterators. - -`IteratorType` -: Description - -`SAX` -: Description - -## Parameters - -`i` (in) -: Input to parse from. - -`sax` (in) -: SAX event listener - -`format` (in) -: the format to parse (JSON, CBOR, MessagePack, or UBJSON) (optional, `input_format_t::json` by default), see - [`input_format_t`](input_format_t.md) for more information - -`strict` (in) -: whether the input has to be consumed completely (optional, `#!cpp true` by default) - -`ignore_comments` (in) -: whether comments should be ignored and treated like whitespace (`#!cpp true`) or yield a parse error - (`#!cpp false`); (optional, `#!cpp false` by default) - -`first` (in) -: iterator to start of character range - -`last` (in) -: iterator to end of character range - -## Return value - -return value of the last processed SAX event - -## Exception safety - -## Complexity - -Linear in the length of the input. The parser is a predictive LL(1) parser. The complexity can be higher if the SAX -consumer `sax` has a super-linear complexity. - -## Notes - -A UTF-8 byte order mark is silently ignored. - -## Examples - -??? example - - The example below demonstrates the `sax_parse()` function reading from string and processing the events with a - user-defined SAX event consumer. - - ```cpp - --8<-- "examples/sax_parse.cpp" - ``` - - Output: - - ```json - --8<-- "examples/sax_parse.output" - ``` - -## Version history - -- Added in version 3.2.0. -- Ignoring comments via `ignore_comments` added in version 3.9.0. - -!!! warning "Deprecation" - - Overload (2) replaces calls to `sax_parse` with a pair of iterators as their first parameter which has been - deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like - `#!cpp sax_parse({ptr, ptr+len});` with `#!cpp sax_parse(ptr, ptr+len);`. diff --git a/docs/mkdocs/docs/api/basic_json/size.md b/docs/mkdocs/docs/api/basic_json/size.md deleted file mode 100644 index 4ff582db21..0000000000 --- a/docs/mkdocs/docs/api/basic_json/size.md +++ /dev/null @@ -1,57 +0,0 @@ -# nlohmann::basic_json::size - -```cpp -size_type size() const noexcept; -``` - -Returns the number of elements in a JSON value. - -## Return value - -The return value depends on the different types and is defined as follows: - -| Value type | return value | -|------------|-------------------------------------| -| null | `0` | -| boolean | `1` | -| string | `1` | -| number | `1` | -| binary | `1` | -| object | result of function object_t::size() | -| array | result of function array_t::size() | - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Constant, as long as [`array_t`](array_t.md) and [`object_t`](object_t.md) satisfy the -[Container](https://en.cppreference.com/w/cpp/named_req/Container) concept; that is, their `size()` functions have -constant complexity. - -## Notes - -This function does not return the length of a string stored as JSON value -- it returns the number of elements in the -JSON value which is `1` in the case of a string. - -## Examples - -??? example - - The following code calls `size()` on the different value types. - - ```cpp - --8<-- "examples/size.cpp" - ``` - - Output: - - ```json - --8<-- "examples/size.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Extended to return `1` for binary types in version 3.8.0. diff --git a/docs/mkdocs/docs/api/basic_json/std_hash.md b/docs/mkdocs/docs/api/basic_json/std_hash.md deleted file mode 100644 index b9de74f8c5..0000000000 --- a/docs/mkdocs/docs/api/basic_json/std_hash.md +++ /dev/null @@ -1,34 +0,0 @@ -# std::hash - -```cpp -namespace std { - struct hash; -} -``` - -Return a hash value for a JSON object. The hash function tries to rely on `std::hash` where possible. Furthermore, the -type of the JSON value is taken into account to have different hash values for `#!json null`, `#!cpp 0`, `#!cpp 0U`, and -`#!cpp false`, etc. - -## Examples - -??? example - - The example shows how to calculate hash values for different JSON values. - - ```cpp - --8<-- "examples/std_hash.cpp" - ``` - - Output: - - ```json - --8<-- "examples/std_hash.output" - ``` - - Note the output is platform-dependent. - -## Version history - -- Added in version 1.0.0. -- Extended for arbitrary basic_json types in version 3.10.5. diff --git a/docs/mkdocs/docs/api/basic_json/std_swap.md b/docs/mkdocs/docs/api/basic_json/std_swap.md deleted file mode 100644 index d30f3bccd5..0000000000 --- a/docs/mkdocs/docs/api/basic_json/std_swap.md +++ /dev/null @@ -1,51 +0,0 @@ -# std::swap - -```cpp -namespace std { - void swap(nlohmann::basic_json& j1, nlohmann::basic_json& j2); -} -``` - -Exchanges the values of two JSON objects. - -## Parameters - -`j1` (in, out) -: value to be replaced by `j2` - -`j2` (in, out) -: value to be replaced by `j1` - -## Possible implementation - -```cpp -void swap(nlohmann::basic_json& j1, nlohmann::basic_json& j2) -{ - j1.swap(j2); -} -``` - -## Examples - -??? example - - The following code shows how two values are swapped with `std::swap`. - - ```cpp - --8<-- "examples/std_swap.cpp" - ``` - - Output: - - ```json - --8<-- "examples/std_swap.output" - ``` - -## See also - -- [swap](swap.md) - -## Version history - -- Added in version 1.0.0. -- Extended for arbitrary basic_json types in version 3.10.5. diff --git a/docs/mkdocs/docs/api/basic_json/string_t.md b/docs/mkdocs/docs/api/basic_json/string_t.md deleted file mode 100644 index 3ab4412dd0..0000000000 --- a/docs/mkdocs/docs/api/basic_json/string_t.md +++ /dev/null @@ -1,66 +0,0 @@ -# nlohmann::basic_json::string_t - -```cpp -using string_t = StringType; -``` - -The type used to store JSON strings. - -[RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON strings as follows: -> A string is a sequence of zero or more Unicode characters. - -To store objects in C++, a type is defined by the template parameter described below. Unicode values are split by the -JSON class into byte-sized characters during deserialization. - -## Template parameters - -`StringType` -: the container to store strings (e.g., `std::string`). Note this container is used for keys/names in objects, see - [object_t](object_t.md). - -## Notes - -#### Default type - -With the default values for `StringType` (`std::string`), the default value for `string_t` is `#!cpp std::string`. - -#### Encoding - -Strings are stored in UTF-8 encoding. Therefore, functions like `std::string::size()` or `std::string::length()` return -the number of bytes in the string rather than the number of characters or glyphs. - -#### String comparison - -[RFC 8259](https://tools.ietf.org/html/rfc8259) states: -> Software implementations are typically required to test names of object members for equality. Implementations that -> transform the textual representation into sequences of Unicode code units and then perform the comparison numerically, -> code unit by code unit, are interoperable in the sense that implementations will agree in all cases on equality or -> inequality of two strings. For example, implementations that compare strings with escaped characters unconverted may -> incorrectly find that `"a\\b"` and `"a\u005Cb"` are not equal. - -This implementation is interoperable as it does compare strings code unit by code unit. - -#### Storage - -String values are stored as pointers in a `basic_json` type. That is, for any access to string values, a pointer of type -`string_t*` must be dereferenced. - -## Examples - -??? example - - The following code shows that `string_t` is by default, a typedef to `#!cpp std::string`. - - ```cpp - --8<-- "examples/string_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/string_t.output" - ``` - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/swap.md b/docs/mkdocs/docs/api/basic_json/swap.md deleted file mode 100644 index a5730ffa7e..0000000000 --- a/docs/mkdocs/docs/api/basic_json/swap.md +++ /dev/null @@ -1,157 +0,0 @@ -# nlohmann::basic_json::swap - -```cpp -// (1) -void swap(reference other) noexcept; - -// (2) -void swap(reference left, reference right) noexcept; - -// (3) -void swap(array_t& other); - -// (4) -void swap(object_t& other); - -// (5) -void swap(string_t& other); - -// (6) -void swap(binary_t& other); - -// (7) -void swap(typename binary_t::container_type& other); -``` - -1. Exchanges the contents of the JSON value with those of `other`. Does not invoke any move, copy, or swap operations on - individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. -2. Exchanges the contents of the JSON value from `left` with those of `right`. Does not invoke any move, copy, or swap - operations on individual elements. All iterators and references remain valid. The past-the-end iterator is - invalidated. Implemented as a friend function callable via ADL. -3. Exchanges the contents of a JSON array with those of `other`. Does not invoke any move, copy, or swap operations on - individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. -4. Exchanges the contents of a JSON object with those of `other`. Does not invoke any move, copy, or swap operations on - individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. -5. Exchanges the contents of a JSON string with those of `other`. Does not invoke any move, copy, or swap operations on - individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. -6. Exchanges the contents of a binary value with those of `other`. Does not invoke any move, copy, or swap operations on - individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. -7. Exchanges the contents of a binary value with those of `other`. Does not invoke any move, copy, or swap operations on - individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated. Unlike - version (6), no binary subtype is involved. - -## Parameters - -`other` (in, out) -: value to exchange the contents with - -`left` (in, out) -: value to exchange the contents with - -`right` (in, out) -: value to exchange the contents with - -## Exceptions - -1. No-throw guarantee: this function never throws exceptions. -2. No-throw guarantee: this function never throws exceptions. -3. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than - arrays; example: `"cannot use swap() with boolean"` -4. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than - objects; example: `"cannot use swap() with boolean"` -5. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than - strings; example: `"cannot use swap() with boolean"` -6. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than - binaries; example: `"cannot use swap() with boolean"` -7. Throws [`type_error.310`](../../home/exceptions.md#jsonexceptiontype_error310) if called on JSON values other than - binaries; example: `"cannot use swap() with boolean"` - -## Complexity - -Constant. - -## Examples - -??? example "Example: Swap JSON value (1, 2)" - - The example below shows how JSON values can be swapped with `swap()`. - - ```cpp - --8<-- "examples/swap__reference.cpp" - ``` - - Output: - - ```json - --8<-- "examples/swap__reference.output" - ``` - -??? example "Example: Swap array (3)" - - The example below shows how arrays can be swapped with `swap()`. - - ```cpp - --8<-- "examples/swap__array_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/swap__array_t.output" - ``` - -??? example "Example: Swap object (4)" - - The example below shows how objects can be swapped with `swap()`. - - ```cpp - --8<-- "examples/swap__object_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/swap__object_t.output" - ``` - -??? example "Example: Swap string (5)" - - The example below shows how strings can be swapped with `swap()`. - - ```cpp - --8<-- "examples/swap__string_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/swap__string_t.output" - ``` - -??? example "Example: Swap string (6)" - - The example below shows how binary values can be swapped with `swap()`. - - ```cpp - --8<-- "examples/swap__binary_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/swap__binary_t.output" - ``` - -## See also - -- [std::swap](std_swap.md) - -## Version history - -1. Since version 1.0.0. -2. Since version 1.0.0. -3. Since version 1.0.0. -4. Since version 1.0.0. -5. Since version 1.0.0. -6. Since version 3.8.0. -7. Since version 3.8.0. \ No newline at end of file diff --git a/docs/mkdocs/docs/api/basic_json/to_bjdata.md b/docs/mkdocs/docs/api/basic_json/to_bjdata.md deleted file mode 100644 index 48598a5e61..0000000000 --- a/docs/mkdocs/docs/api/basic_json/to_bjdata.md +++ /dev/null @@ -1,70 +0,0 @@ -# nlohmann::basic_json::to_bjdata - -```cpp -// (1) -static std::vector to_bjdata(const basic_json& j, - const bool use_size = false, - const bool use_type = false); - -// (2) -static void to_bjdata(const basic_json& j, detail::output_adapter o, - const bool use_size = false, const bool use_type = false); -static void to_bjdata(const basic_json& j, detail::output_adapter o, - const bool use_size = false, const bool use_type = false); -``` - -Serializes a given JSON value `j` to a byte vector using the BJData (Binary JData) serialization format. BJData aims to -be more compact than JSON itself, yet more efficient to parse. - -1. Returns a byte vector containing the BJData serialization. -2. Writes the BJData serialization to an output adapter. - -The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/bjdata.md). - -## Parameters - -`j` (in) -: JSON value to serialize - -`o` (in) -: output adapter to write serialization to - -`use_size` (in) -: whether to add size annotations to container types; optional, `#!cpp false` by default. - -`use_type` (in) -: whether to add type annotations to container types (must be combined with `#!cpp use_size = true`); optional, -`#!cpp false` by default. - -## Return value - -1. BJData serialization as byte vector -2. (none) - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Complexity - -Linear in the size of the JSON value `j`. - -## Examples - -??? example - - The example shows the serialization of a JSON value to a byte vector in BJData format. - - ```cpp - --8<-- "examples/to_bjdata.cpp" - ``` - - Output: - - ```json - --8<-- "examples/to_bjdata.output" - ``` - -## Version history - -- Added in version 3.11.0. diff --git a/docs/mkdocs/docs/api/basic_json/to_bson.md b/docs/mkdocs/docs/api/basic_json/to_bson.md deleted file mode 100644 index 5c4324a3fd..0000000000 --- a/docs/mkdocs/docs/api/basic_json/to_bson.md +++ /dev/null @@ -1,59 +0,0 @@ -# nlohmann::basic_json::to_bson - -```cpp -// (1) -static std::vector to_bson(const basic_json& j); - -// (2) -static void to_bson(const basic_json& j, detail::output_adapter o); -static void to_bson(const basic_json& j, detail::output_adapter o); -``` - -BSON (Binary JSON) is a binary format in which zero or more ordered key/value pairs are stored as a single entity (a -so-called document). - -1. Returns a byte vector containing the BSON serialization. -2. Writes the BSON serialization to an output adapter. - -The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/bson.md). - -## Parameters - -`j` (in) -: JSON value to serialize - -`o` (in) -: output adapter to write serialization to - -## Return value - -1. BSON serialization as byte vector -2. (none) - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Complexity - -Linear in the size of the JSON value `j`. - -## Examples - -??? example - - The example shows the serialization of a JSON value to a byte vector in BSON format. - - ```cpp - --8<-- "examples/to_bson.cpp" - ``` - - Output: - - ```json - --8<-- "examples/to_bson.output" - ``` - -## Version history - -- Added in version 3.4.0. diff --git a/docs/mkdocs/docs/api/basic_json/to_cbor.md b/docs/mkdocs/docs/api/basic_json/to_cbor.md deleted file mode 100644 index 0f944c4810..0000000000 --- a/docs/mkdocs/docs/api/basic_json/to_cbor.md +++ /dev/null @@ -1,61 +0,0 @@ -# nlohmann::basic_json::to_cbor - -```cpp -// (1) -static std::vector to_cbor(const basic_json& j); - -// (2) -static void to_cbor(const basic_json& j, detail::output_adapter o); -static void to_cbor(const basic_json& j, detail::output_adapter o); -``` - -Serializes a given JSON value `j` to a byte vector using the CBOR (Concise Binary Object Representation) serialization -format. CBOR is a binary serialization format which aims to be more compact than JSON itself, yet more efficient to -parse. - -1. Returns a byte vector containing the CBOR serialization. -2. Writes the CBOR serialization to an output adapter. - -The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/cbor.md). - -## Parameters - -`j` (in) -: JSON value to serialize - -`o` (in) -: output adapter to write serialization to - -## Return value - -1. CBOR serialization as byte vector -2. (none) - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Complexity - -Linear in the size of the JSON value `j`. - -## Examples - -??? example - - The example shows the serialization of a JSON value to a byte vector in CBOR format. - - ```cpp - --8<-- "examples/to_cbor.cpp" - ``` - - Output: - - ```json - --8<-- "examples/to_cbor.output" - ``` - -## Version history - -- Added in version 2.0.9. -- Compact representation of floating-point numbers added in version 3.8.0. diff --git a/docs/mkdocs/docs/api/basic_json/to_msgpack.md b/docs/mkdocs/docs/api/basic_json/to_msgpack.md deleted file mode 100644 index 7d40981d5f..0000000000 --- a/docs/mkdocs/docs/api/basic_json/to_msgpack.md +++ /dev/null @@ -1,59 +0,0 @@ -# nlohmann::basic_json::to_msgpack - -```cpp -// (1) -static std::vector to_msgpack(const basic_json& j); - -// (2) -static void to_msgpack(const basic_json& j, detail::output_adapter o); -static void to_msgpack(const basic_json& j, detail::output_adapter o); -``` - -Serializes a given JSON value `j` to a byte vector using the MessagePack serialization format. MessagePack is a binary -serialization format which aims to be more compact than JSON itself, yet more efficient to parse. - -1. Returns a byte vector containing the MessagePack serialization. -2. Writes the MessagePack serialization to an output adapter. - -The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/messagepack.md). - -## Parameters - -`j` (in) -: JSON value to serialize - -`o` (in) -: output adapter to write serialization to - -## Return value - -1. MessagePack serialization as byte vector -2. (none) - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Complexity - -Linear in the size of the JSON value `j`. - -## Examples - -??? example - - The example shows the serialization of a JSON value to a byte vector in MessagePack format. - - ```cpp - --8<-- "examples/to_msgpack.cpp" - ``` - - Output: - - ```json - --8<-- "examples/to_msgpack.output" - ``` - -## Version history - -- Added in version 2.0.9. diff --git a/docs/mkdocs/docs/api/basic_json/to_string.md b/docs/mkdocs/docs/api/basic_json/to_string.md deleted file mode 100644 index 2b907e217d..0000000000 --- a/docs/mkdocs/docs/api/basic_json/to_string.md +++ /dev/null @@ -1,65 +0,0 @@ -# to_string(basic_json) - -```cpp -template -std::string to_string(const BasicJsonType& j); -``` - -This function implements a user-defined to_string for JSON objects. - -## Template parameters - -`BasicJsonType` -: a specialization of [`basic_json`](index.md) - -## Return value - -string containing the serialization of the JSON value - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes to any JSON value. - -## Exceptions - -Throws [`type_error.316`](../../home/exceptions.md#jsonexceptiontype_error316) if a string stored inside the JSON value -is not UTF-8 encoded - -## Complexity - -Linear. - -## Possible implementation - -```cpp -template -std::string to_string(const BasicJsonType& j) -{ - return j.dump(); -} -``` - -## Examples - -??? example - - The following code shows how the library's `to_string()` function integrates with others, allowing - argument-dependent lookup. - - ```cpp - --8<-- "examples/to_string.cpp" - ``` - - Output: - - ```json - --8<-- "examples/to_string.output" - ``` - -## See also - -- [dump](dump.md) - -## Version history - -Added in version 3.7.0. diff --git a/docs/mkdocs/docs/api/basic_json/to_ubjson.md b/docs/mkdocs/docs/api/basic_json/to_ubjson.md deleted file mode 100644 index e3cd5d62b9..0000000000 --- a/docs/mkdocs/docs/api/basic_json/to_ubjson.md +++ /dev/null @@ -1,70 +0,0 @@ -# nlohmann::basic_json::to_ubjson - -```cpp -// (1) -static std::vector to_ubjson(const basic_json& j, - const bool use_size = false, - const bool use_type = false); - -// (2) -static void to_ubjson(const basic_json& j, detail::output_adapter o, - const bool use_size = false, const bool use_type = false); -static void to_ubjson(const basic_json& j, detail::output_adapter o, - const bool use_size = false, const bool use_type = false); -``` - -Serializes a given JSON value `j` to a byte vector using the UBJSON (Universal Binary JSON) serialization format. UBJSON -aims to be more compact than JSON itself, yet more efficient to parse. - -1. Returns a byte vector containing the UBJSON serialization. -2. Writes the UBJSON serialization to an output adapter. - -The exact mapping and its limitations is described on a [dedicated page](../../features/binary_formats/ubjson.md). - -## Parameters - -`j` (in) -: JSON value to serialize - -`o` (in) -: output adapter to write serialization to - -`use_size` (in) -: whether to add size annotations to container types; optional, `#!cpp false` by default. - -`use_type` (in) -: whether to add type annotations to container types (must be combined with `#!cpp use_size = true`); optional, - `#!cpp false` by default. - -## Return value - -1. UBJSON serialization as byte vector -2. (none) - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no changes in the JSON value. - -## Complexity - -Linear in the size of the JSON value `j`. - -## Examples - -??? example - - The example shows the serialization of a JSON value to a byte vector in UBJSON format. - - ```cpp - --8<-- "examples/to_ubjson.cpp" - ``` - - Output: - - ```json - --8<-- "examples/to_ubjson.output" - ``` - -## Version history - -- Added in version 3.1.0. diff --git a/docs/mkdocs/docs/api/basic_json/type.md b/docs/mkdocs/docs/api/basic_json/type.md deleted file mode 100644 index deedd6b698..0000000000 --- a/docs/mkdocs/docs/api/basic_json/type.md +++ /dev/null @@ -1,54 +0,0 @@ -# nlohmann::basic_json::type - -```cpp -constexpr value_t type() const noexcept; -``` - -Return the type of the JSON value as a value from the [`value_t`](value_t.md) enumeration. - -## Return value - -the type of the JSON value - -| Value type | return value | -|---------------------------|----------------------------| -| `#!json null` | `value_t::null` | -| boolean | `value_t::boolean` | -| string | `value_t::string` | -| number (integer) | `value_t::number_integer` | -| number (unsigned integer) | `value_t::number_unsigned` | -| number (floating-point) | `value_t::number_float` | -| object | `value_t::object` | -| array | `value_t::array` | -| binary | `value_t::binary` | -| discarded | `value_t::discarded` | - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code exemplifies `type()` for all JSON types. - - ```cpp - --8<-- "examples/type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/type.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Added unsigned integer type in version 2.0.0. -- Added binary type in version 3.8.0. diff --git a/docs/mkdocs/docs/api/basic_json/type_error.md b/docs/mkdocs/docs/api/basic_json/type_error.md deleted file mode 100644 index cda54c089c..0000000000 --- a/docs/mkdocs/docs/api/basic_json/type_error.md +++ /dev/null @@ -1,68 +0,0 @@ -# nlohmann::basic_json::type_error - -```cpp -class type_error : public exception; -``` - -This exception is thrown in case of a type error; that is, a library function is executed on a JSON value whose type -does not match the expected semantics. - -Exceptions have ids 3xx (see [list of type errors](../../home/exceptions.md#type-errors)). - -```plantuml -std::exception <|-- basic_json::exception -basic_json::exception <|-- basic_json::parse_error -basic_json::exception <|-- basic_json::invalid_iterator -basic_json::exception <|-- basic_json::type_error -basic_json::exception <|-- basic_json::out_of_range -basic_json::exception <|-- basic_json::other_error - -interface std::exception {} - -class basic_json::exception { - + const int id - + const char* what() const -} - -class basic_json::parse_error { - + const std::size_t byte -} - -class basic_json::type_error #FFFF00 {} -``` - -## Member functions - -- **what** - returns explanatory string - -## Member variables - -- **id** - the id of the exception - -## Examples - -??? example - - The following code shows how a `type_error` exception can be caught. - - ```cpp - --8<-- "examples/type_error.cpp" - ``` - - Output: - - ```json - --8<-- "examples/type_error.output" - ``` - -## See also - -- [List of type errors](../../home/exceptions.md#type-errors) -- [`parse_error`](parse_error.md) for exceptions indicating a parse error -- [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators -- [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range -- [`other_error`](other_error.md) for exceptions indicating other library errors - -## Version history - -- Since version 3.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/type_name.md b/docs/mkdocs/docs/api/basic_json/type_name.md deleted file mode 100644 index 389c2b1dd5..0000000000 --- a/docs/mkdocs/docs/api/basic_json/type_name.md +++ /dev/null @@ -1,54 +0,0 @@ -# nlohmann::basic_json::type_name - -```cpp -const char* type_name() const noexcept; -``` - -Returns the type name as string to be used in error messages -- usually to indicate that a function was called on a -wrong JSON type. - -## Return value - -a string representation of the type ([`value_t`](value_t.md)): - -| Value type | return value | -|----------------------------------------------------|---------------| -| `#!json null` | `"null"` | -| boolean | `"boolean"` | -| string | `"string"` | -| number (integer, unsigned integer, floating-point) | `"number"` | -| object | `"object"` | -| array | `"array"` | -| binary | `"binary"` | -| discarded | `"discarded"` | - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The following code exemplifies `type_name()` for all JSON types. - - ```cpp - --8<-- "examples/type_name.cpp" - ``` - - Output: - - ```json - --8<-- "examples/type_name.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Part of the public API version since 2.1.0. -- Changed return value to `const char*` and added `noexcept` in version 3.0.0. -- Added support for binary type in version 3.8.0. diff --git a/docs/mkdocs/docs/api/basic_json/unflatten.md b/docs/mkdocs/docs/api/basic_json/unflatten.md deleted file mode 100644 index d9778036c2..0000000000 --- a/docs/mkdocs/docs/api/basic_json/unflatten.md +++ /dev/null @@ -1,61 +0,0 @@ -# nlohmann::basic_json::unflatten - -```cpp -basic_json unflatten() const; -``` - -The function restores the arbitrary nesting of a JSON value that has been flattened before using the -[`flatten()`](flatten.md) function. The JSON value must meet certain constraints: - -1. The value must be an object. -2. The keys must be JSON pointers (see [RFC 6901](https://tools.ietf.org/html/rfc6901)) -3. The mapped values must be primitive JSON types. - -## Return value - -the original JSON from a flattened version - -## Exception safety - -Strong exception safety: if an exception occurs, the original value stays intact. - -## Exceptions - -The function can throw the following exceptions: - -- Throws [`type_error.314`](../../home/exceptions.md#jsonexceptiontype_error314) if value is not an object -- Throws [`type_error.315`](../../home/exceptions.md#jsonexceptiontype_error315) if object values are not primitive - -## Complexity - -Linear in the size the JSON value. - -## Notes - -Empty objects and arrays are flattened by [`flatten()`](flatten.md) to `#!json null` values and can not unflattened to -their original type. Apart from this example, for a JSON value `j`, the following is always true: -`#!cpp j == j.flatten().unflatten()`. - -## Examples - -??? example - - The following code shows how a flattened JSON object is unflattened into the original nested JSON object. - - ```cpp - --8<-- "examples/unflatten.cpp" - ``` - - Output: - - ```json - --8<-- "examples/unflatten.output" - ``` - -## See also - -- [flatten](flatten.md) the reverse function - -## Version history - -- Added in version 2.0.0. diff --git a/docs/mkdocs/docs/api/basic_json/update.md b/docs/mkdocs/docs/api/basic_json/update.md deleted file mode 100644 index a594cf9d0f..0000000000 --- a/docs/mkdocs/docs/api/basic_json/update.md +++ /dev/null @@ -1,142 +0,0 @@ -# nlohmann::basic_json::update - -```cpp -// (1) -void update(const_reference j, bool merge_objects = false); - -// (2) -void update(const_iterator first, const_iterator last, bool merge_objects = false); -``` - -1. Inserts all values from JSON object `j`. -2. Inserts all values from range `[first, last)` - -When `merge_objects` is `#!c false` (default), existing keys are overwritten. When `merge_objects` is `#!c true`, -recursively merges objects with common keys. - -The function is motivated by Python's [dict.update](https://docs.python.org/3.6/library/stdtypes.html#dict.update) -function. - -## Parameters - -`j` (in) -: JSON object to read values from - -`merge_objects` (in) -: when `#!c true`, existing keys are not overwritten, but contents of objects are merged recursively (default: - `#!c false`) - -`first` (in) -: begin of the range of elements to insert - -`last` (in) -: end of the range of elements to insert - -## Exceptions - -1. The function can throw the following exceptions: - - Throws [`type_error.312`](../../home/exceptions.md#jsonexceptiontype_error312) if called on JSON values other than - objects; example: `"cannot use update() with string"` -2. The function can throw the following exceptions: - - Throws [`type_error.312`](../../home/exceptions.md#jsonexceptiontype_error312) if called on JSON values other than - objects; example: `"cannot use update() with string"` - - Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an - iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"` - - Throws [`invalid_iterator.210`](../../home/exceptions.md#jsonexceptioninvalid_iterator210) if `first` and `last` - do not belong to the same JSON value; example: `"iterators do not fit"` - -## Complexity - -1. O(N*log(size() + N)), where N is the number of elements to insert. -2. O(N*log(size() + N)), where N is the number of elements to insert. - -## Examples - -??? example - - The example shows how `update()` is used. - - ```cpp - --8<-- "examples/update.cpp" - ``` - - Output: - - ```json - --8<-- "examples/update.output" - ``` - -??? example - - The example shows how `update()` is used. - - ```cpp - --8<-- "examples/update__range.cpp" - ``` - - Output: - - ```json - --8<-- "examples/update__range.output" - ``` - -??? example - - One common use case for this function is the handling of user settings. Assume your application can be configured in - some aspects: - - ```json - { - "color": "red", - "active": true, - "name": {"de": "Maus", "en": "mouse"} - } - ``` - - The user may override the default settings selectively: - - ```json - { - "color": "blue", - "name": {"es": "ratón"}, - } - ``` - - Then `update` manages the merging of default settings and user settings: - - ```cpp - auto user_settings = json::parse("config.json"); - auto effective_settings = get_default_settings(); - effective_settings.update(user_settings); - ``` - - Now `effective_settings` contains the default settings, but those keys set by the user are overwritten: - - ```json - { - "color": "blue", - "active": true, - "name": {"es": "ratón"} - } - ``` - - Note existing keys were just overwritten. To merge objects, `merge_objects` setting should be set to `#!c true`: - - ```cpp - auto user_settings = json::parse("config.json"); - auto effective_settings = get_default_settings(); - effective_settings.update(user_settings, true); - ``` - - ```json - { - "color": "blue", - "active": true, - "name": {"de": "Maus", "en": "mouse", "es": "ratón"} - } - ``` - -## Version history - -- Added in version 3.0.0. -- Added `merge_objects` parameter in 3.10.4. diff --git a/docs/mkdocs/docs/api/basic_json/value.md b/docs/mkdocs/docs/api/basic_json/value.md deleted file mode 100644 index edb5406ba6..0000000000 --- a/docs/mkdocs/docs/api/basic_json/value.md +++ /dev/null @@ -1,159 +0,0 @@ -# nlohmann::basic_json::value - -```cpp -// (1) -template -ValueType value(const typename object_t::key_type& key, - ValueType&& default_value) const; - -// (2) -template -ValueType value(KeyType&& key, - ValueType&& default_value) const; - -// (3) -template -ValueType value(const json_pointer& ptr, - const ValueType& default_value) const; -``` - -1. Returns either a copy of an object's element at the specified key `key` or a given default value if no element with - key `key` exists. - - The function is basically equivalent to executing - ```cpp - try { - return at(key); - } catch(out_of_range) { - return default_value; - } - ``` - -2. See 1. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and - `#!cpp typename object_comparator_t::is_transparent` denotes a type. - -3. Returns either a copy of an object's element at the specified JSON pointer `ptr` or a given default value if no value - at `ptr` exists. - - The function is basically equivalent to executing - ```cpp - try { - return at(ptr); - } catch(out_of_range) { - return default_value; - } - ``` - -!!! note "Differences to `at` and `operator[]`" - - - Unlike [`at`](at.md), this function does not throw if the given `key`/`ptr` was not found. - - Unlike [`operator[]`](operator[].md), this function does not implicitly add an element to the position defined by - `key`/`ptr` key. This function is furthermore also applicable to const objects. - -## Template parameters - -`KeyType` -: A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with - [`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md). - This can also be a string view (C++17). -`ValueType` -: type compatible to JSON values, for instance `#!cpp int` for JSON integer numbers, `#!cpp bool` for JSON booleans, - or `#!cpp std::vector` types for JSON arrays. Note the type of the expected value at `key`/`ptr` and the default - value `default_value` must be compatible. - -## Parameters - -`key` (in) -: key of the element to access - -`default_value` (in) -: the value to return if `key`/`ptr` found no value - -`ptr` (in) -: a JSON pointer to the element to access - -## Return value - -1. copy of the element at key `key` or `default_value` if `key` is not found -2. copy of the element at key `key` or `default_value` if `key` is not found -3. copy of the element at JSON Pointer `ptr` or `default_value` if no value for `ptr` is found - -## Exception safety - -Strong guarantee: if an exception is thrown, there are no -changes to any JSON value. - -## Exceptions - -1. The function can throw the following exceptions: - - Throws [`type_error.302`](../../home/exceptions.md#jsonexceptiontype_error302) if `default_value` does not match - the type of the value at `key` - - Throws [`type_error.306`](../../home/exceptions.md#jsonexceptiontype_error306) if the JSON value is not an object; - in that case, using `value()` with a key makes no sense. -2. See 1. -3. The function can throw the following exceptions: - - Throws [`type_error.302`](../../home/exceptions.md#jsonexceptiontype_error302) if `default_value` does not match - the type of the value at `ptr` - - Throws [`type_error.306`](../../home/exceptions.md#jsonexceptiontype_error306) if the JSON value is not an object; - in that case, using `value()` with a key makes no sense. - -## Complexity - -1. Logarithmic in the size of the container. -2. Logarithmic in the size of the container. -3. Logarithmic in the size of the container. - -## Examples - -??? example "Example: (1) access specified object element with default value" - - The example below shows how object elements can be queried with a default value. - - ```cpp - --8<-- "examples/value__object_t_key_type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/value__object_t_key_type.output" - ``` - -??? example "Example: (2) access specified object element using string_view with default value" - - The example below shows how object elements can be queried with a default value. - - ```cpp - --8<-- "examples/value__keytype.c++17.cpp" - ``` - - Output: - - ```json - --8<-- "examples/value__keytype.c++17.output" - ``` - -??? example "Example: (3) access specified object element via JSON Pointer with default value" - - The example below shows how object elements can be queried with a default value. - - ```cpp - --8<-- "examples/value__json_ptr.cpp" - ``` - - Output: - - ```json - --8<-- "examples/value__json_ptr.output" - ``` - -## See also - -- see [`at`](at.md) for access by reference with range checking -- see [`operator[]`](operator%5B%5D.md) for unchecked access by reference - -## Version history - -1. Added in version 1.0.0. Changed parameter `default_value` type from `const ValueType&` to `ValueType&&` in version 3.11.0. -2. Added in version 3.11.0. Made `ValueType` the first template parameter in version 3.11.2. -3. Added in version 2.0.2. diff --git a/docs/mkdocs/docs/api/basic_json/value_t.md b/docs/mkdocs/docs/api/basic_json/value_t.md deleted file mode 100644 index 1505e02d08..0000000000 --- a/docs/mkdocs/docs/api/basic_json/value_t.md +++ /dev/null @@ -1,81 +0,0 @@ -# nlohmann::basic_json::value_t - -```cpp -enum class value_t : std::uint8_t { - null, - object, - array, - string, - boolean, - number_integer, - number_unsigned, - number_float, - binary, - discarded -}; -``` - -This enumeration collects the different JSON types. It is internally used to distinguish the stored values, and the -functions [`is_null`](is_null.md), [`is_object`](is_object.md), [`is_array`](is_array.md), [`is_string`](is_string.md), -[`is_boolean`](is_boolean.md), [`is_number`](is_number.md) (with [`is_number_integer`](is_number_integer.md), -[`is_number_unsigned`](is_number_unsigned.md), and [`is_number_float`](is_number_float.md)), -[`is_discarded`](is_discarded.md), [`is_binary`](is_binary.md), [`is_primitive`](is_primitive.md), and -[`is_structured`](is_structured.md) rely on it. - -## Notes - -!!! note "Ordering" - - The order of types is as follows: - - 1. `null` - 2. `boolean` - 3. `number_integer`, `number_unsigned`, `number_float` - 4. `object` - 5. `array` - 6. `string` - 7. `binary` - - `discarded` is unordered. - -!!! note "Types of numbers" - - There are three enumerators for numbers (`number_integer`, `number_unsigned`, and `number_float`) to distinguish - between different types of numbers: - - - [`number_unsigned_t`](number_unsigned_t.md) for unsigned integers - - [`number_integer_t`](number_integer_t.md) for signed integers - - [`number_float_t`](number_float_t.md) for floating-point numbers or to approximate integers which do not fit - into the limits of their respective type - -!!! warning "Comparison operators" - - `operator<` and `operator<=>` (since C++20) are overloaded and compare according to the ordering described above. - Until C++20 all other relational and equality operators yield results according to the integer value of each - enumerator. Since C++20 some compilers consider the _rewritten candidates_ generated from `operator<=>` during - overload resolution, while others do not. For predictable and portable behavior use: - - - `operator<` or `operator<=>` when wanting to compare according to the order described above - - `operator==` or `operator!=` when wanting to compare according to each enumerators integer value - -## Examples - -??? example - - The following code how `type()` queries the `value_t` for all JSON types. - - ```cpp - --8<-- "examples/type.cpp" - ``` - - Output: - - ```json - --8<-- "examples/type.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Added unsigned integer type in version 2.0.0. -- Added binary type in version 3.8.0. diff --git a/docs/mkdocs/docs/api/basic_json/~basic_json.md b/docs/mkdocs/docs/api/basic_json/~basic_json.md deleted file mode 100644 index 64e9440063..0000000000 --- a/docs/mkdocs/docs/api/basic_json/~basic_json.md +++ /dev/null @@ -1,21 +0,0 @@ -# nlohmann::basic_json::~basic_json - -```cpp -~basic_json() noexcept; -``` - -Destroys the JSON value and frees all allocated memory. - -## Exception safety - -No-throw guarantee: this member function never throws exceptions. - -## Complexity - -Linear. - - - -## Version history - -- Added in version 1.0.0. diff --git a/docs/mkdocs/docs/api/byte_container_with_subtype/byte_container_with_subtype.md b/docs/mkdocs/docs/api/byte_container_with_subtype/byte_container_with_subtype.md deleted file mode 100644 index 9913a9b5c9..0000000000 --- a/docs/mkdocs/docs/api/byte_container_with_subtype/byte_container_with_subtype.md +++ /dev/null @@ -1,46 +0,0 @@ -# nlohmann::byte_container_with_subtype::byte_container_with_subtype - -```cpp -// (1) -byte_container_with_subtype(); - -// (2) -byte_container_with_subtype(const container_type& container); -byte_container_with_subtype(container_type&& container); - -// (3) -byte_container_with_subtype(const container_type& container, subtype_type subtype); -byte_container_with_subtype(container_type&& container, subtype_type subtype); -``` - -1. Create empty binary container without subtype. -2. Create binary container without subtype. -3. Create binary container with subtype. - -## Parameters - -`container` (in) -: binary container - -`subtype` (in) -: subtype - -## Examples - -??? example - - The example below demonstrates how byte containers can be created. - - ```cpp - --8<-- "examples/byte_container_with_subtype__byte_container_with_subtype.cpp" - ``` - - Output: - - ```json - --8<-- "examples/byte_container_with_subtype__byte_container_with_subtype.output" - ``` - -## Version history - -Since version 3.8.0. diff --git a/docs/mkdocs/docs/api/byte_container_with_subtype/clear_subtype.md b/docs/mkdocs/docs/api/byte_container_with_subtype/clear_subtype.md deleted file mode 100644 index c62dead36b..0000000000 --- a/docs/mkdocs/docs/api/byte_container_with_subtype/clear_subtype.md +++ /dev/null @@ -1,36 +0,0 @@ -# nlohmann::byte_container_with_subtype::clear_subtype - -```cpp -void clear_subtype() noexcept; -``` - -Clears the binary subtype and flags the value as not having a subtype, which has implications for serialization; for -instance MessagePack will prefer the bin family over the ext family. - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The example below demonstrates how `clear_subtype` can remove subtypes. - - ```cpp - --8<-- "examples/byte_container_with_subtype__clear_subtype.cpp" - ``` - - Output: - - ```json - --8<-- "examples/byte_container_with_subtype__clear_subtype.output" - ``` - -## Version history - -Since version 3.8.0. diff --git a/docs/mkdocs/docs/api/byte_container_with_subtype/has_subtype.md b/docs/mkdocs/docs/api/byte_container_with_subtype/has_subtype.md deleted file mode 100644 index e06286e299..0000000000 --- a/docs/mkdocs/docs/api/byte_container_with_subtype/has_subtype.md +++ /dev/null @@ -1,39 +0,0 @@ -# nlohmann::byte_container_with_subtype::has_subtype - -```cpp -constexpr bool has_subtype() const noexcept; -``` - -Returns whether the value has a subtype. - -## Return value - -whether the value has a subtype - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The example below demonstrates how `has_subtype` can check whether a subtype was set. - - ```cpp - --8<-- "examples/byte_container_with_subtype__has_subtype.cpp" - ``` - - Output: - - ```json - --8<-- "examples/byte_container_with_subtype__has_subtype.output" - ``` - -## Version history - -Since version 3.8.0. diff --git a/docs/mkdocs/docs/api/byte_container_with_subtype/index.md b/docs/mkdocs/docs/api/byte_container_with_subtype/index.md deleted file mode 100644 index 277fffa345..0000000000 --- a/docs/mkdocs/docs/api/byte_container_with_subtype/index.md +++ /dev/null @@ -1,35 +0,0 @@ -# nlohmann::byte_container_with_subtype - -```cpp -template -class byte_container_with_subtype : public BinaryType; -``` - -This type extends the template parameter `BinaryType` provided to [`basic_json`](../basic_json/index.md) with a subtype -used by BSON and MessagePack. This type exists so that the user does not have to specify a type themselves with a -specific naming scheme in order to override the binary type. - -## Template parameters - -`BinaryType` -: container to store bytes (`#!cpp std::vector` by default) - -## Member types - -- **container_type** - the type of the underlying container (`BinaryType`) -- **subtype_type** - the type of the subtype (`#!cpp std::uint64_t`) - -## Member functions - -- [(constructor)](byte_container_with_subtype.md) -- **operator==** - comparison: equal -- **operator!=** - comparison: not equal -- [**set_subtype**](subtype.md) - sets the binary subtype -- [**subtype**](subtype.md) - return the binary subtype -- [**has_subtype**](has_subtype.md) - return whether the value has a subtype -- [**clear_subtype**](clear_subtype.md) - clears the binary subtype - -## Version history - -- Added in version 3.8.0. -- Changed type of subtypes to `#!cpp std::uint64_t` in 3.10.0. diff --git a/docs/mkdocs/docs/api/byte_container_with_subtype/set_subtype.md b/docs/mkdocs/docs/api/byte_container_with_subtype/set_subtype.md deleted file mode 100644 index cf21732b83..0000000000 --- a/docs/mkdocs/docs/api/byte_container_with_subtype/set_subtype.md +++ /dev/null @@ -1,41 +0,0 @@ -# nlohmann::byte_container_with_subtype::set_subtype - -```cpp -void set_subtype(subtype_type subtype) noexcept; -``` - -Sets the binary subtype of the value, also flags a binary JSON value as having a subtype, which has implications for -serialization. - -## Parameters - -`subtype` (in) -: subtype to set - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The example below demonstrates how a subtype can be set with `set_subtype`. - - ```cpp - --8<-- "examples/byte_container_with_subtype__set_subtype.cpp" - ``` - - Output: - - ```json - --8<-- "examples/byte_container_with_subtype__set_subtype.output" - ``` - -## Version history - -Since version 3.8.0. diff --git a/docs/mkdocs/docs/api/byte_container_with_subtype/subtype.md b/docs/mkdocs/docs/api/byte_container_with_subtype/subtype.md deleted file mode 100644 index 389241a796..0000000000 --- a/docs/mkdocs/docs/api/byte_container_with_subtype/subtype.md +++ /dev/null @@ -1,42 +0,0 @@ -# nlohmann::byte_container_with_subtype::subtype - -```cpp -constexpr subtype_type subtype() const noexcept; -``` - -Returns the numerical subtype of the value if it has a subtype. If it does not have a subtype, this function will return -`subtype_type(-1)` as a sentinel value. - -## Return value - -the numerical subtype of the binary value, or `subtype_type(-1)` if no subtype is set - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The example below demonstrates how the subtype can be retrieved with `subtype`. Note how `subtype_type(-1)` is - returned for container `c1`. - - ```cpp - --8<-- "examples/byte_container_with_subtype__subtype.cpp" - ``` - - Output: - - ```json - --8<-- "examples/byte_container_with_subtype__subtype.output" - ``` - -## Version history - -- Added in version 3.8.0 -- Fixed return value to properly return `subtype_type(-1)` as documented in version 3.10.0. diff --git a/docs/mkdocs/docs/api/json.md b/docs/mkdocs/docs/api/json.md deleted file mode 100644 index 36edcc2c12..0000000000 --- a/docs/mkdocs/docs/api/json.md +++ /dev/null @@ -1,28 +0,0 @@ -# nlohmann::json - -```cpp -using json = basic_json<>; -``` - -This type is the default specialization of the [basic_json](basic_json/index.md) class which uses the standard template -types. - -## Examples - -??? example - - The example below demonstrates how to use the type `nlohmann::json`. - - ```cpp - --8<-- "examples/README.cpp" - ``` - - Output: - - ```json - --8<-- "examples/README.output" - ``` - -## Version history - -Since version 1.0.0. diff --git a/docs/mkdocs/docs/api/json_pointer/back.md b/docs/mkdocs/docs/api/json_pointer/back.md deleted file mode 100644 index 240bc6e1e7..0000000000 --- a/docs/mkdocs/docs/api/json_pointer/back.md +++ /dev/null @@ -1,40 +0,0 @@ -# nlohmann::json_pointer::back - -```cpp -const string_t& back() const; -``` - -Return last reference token. - -## Return value - -Last reference token. - -## Exceptions - -Throws [out_of_range.405](../../home/exceptions.md#jsonexceptionout_of_range405) if JSON pointer has no parent. - -## Complexity - -Constant. - -## Examples - -??? example - - The example shows the usage of `back`. - - ```cpp - --8<-- "examples/json_pointer__back.cpp" - ``` - - Output: - - ```json - --8<-- "examples/json_pointer__back.output" - ``` - -## Version history - -- Added in version 3.6.0. -- Changed return type to `string_t` in version 3.11.0. diff --git a/docs/mkdocs/docs/api/json_pointer/empty.md b/docs/mkdocs/docs/api/json_pointer/empty.md deleted file mode 100644 index 346364ad50..0000000000 --- a/docs/mkdocs/docs/api/json_pointer/empty.md +++ /dev/null @@ -1,39 +0,0 @@ -# nlohmann::json_pointer::empty - -```cpp -bool empty() const noexcept; -``` - -Return whether pointer points to the root document. - -## Return value - -`#!cpp true` iff the JSON pointer points to the root document. - -## Exception safety - -No-throw guarantee: this function never throws exceptions. - -## Complexity - -Constant. - -## Examples - -??? example - - The example shows the result of `empty` for different JSON Pointers. - - ```cpp - --8<-- "examples/json_pointer__empty.cpp" - ``` - - Output: - - ```json - --8<-- "examples/json_pointer__empty.output" - ``` - -## Version history - -Added in version 3.6.0. diff --git a/docs/mkdocs/docs/api/json_pointer/index.md b/docs/mkdocs/docs/api/json_pointer/index.md deleted file mode 100644 index 22e2464053..0000000000 --- a/docs/mkdocs/docs/api/json_pointer/index.md +++ /dev/null @@ -1,52 +0,0 @@ -# nlohmann::json_pointer - -```cpp -template -class json_pointer; -``` - -A JSON pointer defines a string syntax for identifying a specific value within a JSON document. It can be used with -functions [`at`](../basic_json/at.md) and [`operator[]`](../basic_json/operator%5B%5D.md). Furthermore, JSON pointers -are the base for JSON patches. - -## Template parameters - -`RefStringType` -: the string type used for the reference tokens making up the JSON pointer - -!!! warning "Deprecation" - - For backwards compatibility `RefStringType` may also be a specialization of [`basic_json`](../basic_json/index.md) - in which case `string_t` will be deduced as [`basic_json::string_t`](../basic_json/string_t.md). This feature is - deprecated and may be removed in a future major version. - -## Member types - -- [**string_t**](string_t.md) - the string type used for the reference tokens - -## Member functions - -- [(constructor)](json_pointer.md) -- [**to_string**](to_string.md) - return a string representation of the JSON pointer -- [**operator string_t**](operator_string_t.md) - return a string representation of the JSON pointer -- [**operator==**](operator_eq.md) - compare: equal -- [**operator!=**](operator_ne.md) - compare: not equal -- [**operator/=**](operator_slasheq.md) - append to the end of the JSON pointer -- [**operator/**](operator_slash.md) - create JSON Pointer by appending -- [**parent_pointer**](parent_pointer.md) - returns the parent of this JSON pointer -- [**pop_back**](pop_back.md) - remove last reference token -- [**back**](back.md) - return last reference token -- [**push_back**](push_back.md) - append an unescaped token at the end of the pointer -- [**empty**](empty.md) - return whether pointer points to the root document - -## Literals - -- [**operator""_json_pointer**](../operator_literal_json_pointer.md) - user-defined string literal for JSON pointers -## See also - -- [RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901) - -## Version history - -- Added in version 2.0.0. -- Changed template parameter from `basic_json` to string type in version 3.11.0. diff --git a/docs/mkdocs/docs/api/json_pointer/json_pointer.md b/docs/mkdocs/docs/api/json_pointer/json_pointer.md deleted file mode 100644 index 5e7057fc9d..0000000000 --- a/docs/mkdocs/docs/api/json_pointer/json_pointer.md +++ /dev/null @@ -1,41 +0,0 @@ -# nlohmann::json_pointer::json_pointer - -```cpp -explicit json_pointer(const string_t& s = ""); -``` - -Create a JSON pointer according to the syntax described in -[Section 3 of RFC6901](https://tools.ietf.org/html/rfc6901#section-3). - -## Parameters - -`s` (in) -: string representing the JSON pointer; if omitted, the empty string is assumed which references the whole JSON value - -## Exceptions - -- Throws [parse_error.107](../../home/exceptions.md#jsonexceptionparse_error107) if the given JSON pointer `s` is - nonempty and does not begin with a slash (`/`); see example below. -- Throws [parse_error.108](../../home/exceptions.md#jsonexceptionparse_error108) if a tilde (`~`) in the given JSON - pointer `s` is not followed by `0` (representing `~`) or `1` (representing `/`); see example below. - -## Examples - -??? example - - The example shows the construction several valid JSON pointers as well as the exceptional behavior. - - ```cpp - --8<-- "examples/json_pointer.cpp" - ``` - - Output: - - ```json - --8<-- "examples/json_pointer.output" - ``` - -## Version history - -- Added in version 2.0.0. -- Changed type of `s` to `string_t` in version 3.11.0. diff --git a/docs/mkdocs/docs/api/json_pointer/operator_eq.md b/docs/mkdocs/docs/api/json_pointer/operator_eq.md deleted file mode 100644 index 807ae1d0ce..0000000000 --- a/docs/mkdocs/docs/api/json_pointer/operator_eq.md +++ /dev/null @@ -1,113 +0,0 @@ -# nlohmann::json_pointer::operator== - -```cpp -// until C++20 -template -bool operator==( - const json_pointer& lhs, - const json_pointer& rhs) noexcept; // (1) - -template -bool operator==( - const json_pointer& lhs, - const StringType& rhs); // (2) - -template -bool operator==( - const StringType& lhs, - const json_pointer& rhs); // (2) - -// since C++20 -class json_pointer { - template - bool operator==( - const json_pointer& rhs) const noexcept; // (1) - - bool operator==(const string_t& rhs) const; // (2) -}; -``` - -1. Compares two JSON pointers for equality by comparing their reference tokens. - -2. Compares a JSON pointer and a string or a string and a JSON pointer for equality by converting the string to a JSON - pointer and comparing the JSON pointers according to 1. - -## Template parameters - -`RefStringTypeLhs`, `RefStringTypeRhs` -: the string type of the left-hand side or right-hand side JSON pointer, respectively - -`StringType` -: the string type derived from the `json_pointer` operand ([`json_pointer::string_t`](string_t.md)) - -## Parameters - -`lhs` (in) -: first value to consider - -`rhs` (in) -: second value to consider - -## Return value - -whether the values `lhs`/`*this` and `rhs` are equal - -## Exception safety - -1. No-throw guarantee: this function never throws exceptions. -2. Strong exception safety: if an exception occurs, the original value stays intact. - -## Exceptions - -1. (none) -2. The function can throw the following exceptions: - - Throws [parse_error.107](../../home/exceptions.md#jsonexceptionparse_error107) if the given JSON pointer `s` is - nonempty and does not begin with a slash (`/`); see example below. - - Throws [parse_error.108](../../home/exceptions.md#jsonexceptionparse_error108) if a tilde (`~`) in the given JSON - pointer `s` is not followed by `0` (representing `~`) or `1` (representing `/`); see example below. - -## Complexity - -Constant if `lhs` and `rhs` differ in the number of reference tokens, otherwise linear in the number of reference -tokens. - -## Notes - -!!! warning "Deprecation" - - Overload 2 is deprecated and will be removed in a future major version release. - -## Examples - -??? example "Example: (1) Comparing JSON pointers" - - The example demonstrates comparing JSON pointers. - - ```cpp - --8<-- "examples/json_pointer__operator__equal.cpp" - ``` - - Output: - - ``` - --8<-- "examples/json_pointer__operator__equal.output" - ``` - -??? example "Example: (2) Comparing JSON pointers and strings" - - The example demonstrates comparing JSON pointers and strings, and when doing so may raise an exception. - - ```cpp - --8<-- "examples/json_pointer__operator__equal_stringtype.cpp" - ``` - - Output: - - ``` - --8<-- "examples/json_pointer__operator__equal_stringtype.output" - ``` - -## Version history - -1. Added in version 2.1.0. Added C++20 member functions in version 3.11.2. -2. Added for backward compatibility and deprecated in version 3.11.2. diff --git a/docs/mkdocs/docs/api/json_pointer/operator_ne.md b/docs/mkdocs/docs/api/json_pointer/operator_ne.md deleted file mode 100644 index 1f3e3247e0..0000000000 --- a/docs/mkdocs/docs/api/json_pointer/operator_ne.md +++ /dev/null @@ -1,109 +0,0 @@ -# nlohmann::json_pointer::operator!= - -```cpp -// until C++20 -template -bool operator!=( - const json_pointer& lhs, - const json_pointer& rhs) noexcept; // (1) - -template -bool operator!=( - const json_pointer& lhs, - const StringType& rhs); // (2) - -template -bool operator!=( - const StringType& lhs, - const json_pointer& rhs); // (2) -``` - -1. Compares two JSON pointers for inequality by comparing their reference tokens. - -2. Compares a JSON pointer and a string or a string and a JSON pointer for inequality by converting the string to a - JSON pointer and comparing the JSON pointers according to 1. - -## Template parameters - -`RefStringTypeLhs`, `RefStringTypeRhs` -: the string type of the left-hand side or right-hand side JSON pointer, respectively - -`StringType` -: the string type derived from the `json_pointer` operand ([`json_pointer::string_t`](string_t.md)) - -## Parameters - -`lhs` (in) -: first value to consider - -`rhs` (in) -: second value to consider - -## Return value - -whether the values `lhs`/`*this` and `rhs` are not equal - -## Exception safety - -1. No-throw guarantee: this function never throws exceptions. -2. Strong exception safety: if an exception occurs, the original value stays intact. - -## Exceptions - -1. (none) -2. The function can throw the following exceptions: - - Throws [parse_error.107](../../home/exceptions.md#jsonexceptionparse_error107) if the given JSON pointer `s` is - nonempty and does not begin with a slash (`/`); see example below. - - Throws [parse_error.108](../../home/exceptions.md#jsonexceptionparse_error108) if a tilde (`~`) in the given JSON - pointer `s` is not followed by `0` (representing `~`) or `1` (representing `/`); see example below. - -## Complexity - -Constant if `lhs` and `rhs` differ in the number of reference tokens, otherwise linear in the number of reference -tokens. - -## Notes - -!!! note "Operator overload resolution" - - Since C++20 overload resolution will consider the _rewritten candidate_ generated from - [`operator==`](operator_eq.md). - -!!! warning "Deprecation" - - Overload 2 is deprecated and will be removed in a future major version release. - -## Examples - -??? example "Example: (1) Comparing JSON pointers" - - The example demonstrates comparing JSON pointers. - - ```cpp - --8<-- "examples/json_pointer__operator__notequal.cpp" - ``` - - Output: - - ``` - --8<-- "examples/json_pointer__operator__notequal.output" - ``` - -??? example "Example: (2) Comparing JSON pointers and strings" - - The example demonstrates comparing JSON pointers and strings, and when doing so may raise an exception. - - ```cpp - --8<-- "examples/json_pointer__operator__notequal_stringtype.cpp" - ``` - - Output: - - ``` - --8<-- "examples/json_pointer__operator__notequal_stringtype.output" - ``` - -## Version history - -1. Added in version 2.1.0. -2. Added for backward compatibility and deprecated in version 3.11.2. diff --git a/docs/mkdocs/docs/api/json_pointer/operator_slash.md b/docs/mkdocs/docs/api/json_pointer/operator_slash.md deleted file mode 100644 index ed77b504bd..0000000000 --- a/docs/mkdocs/docs/api/json_pointer/operator_slash.md +++ /dev/null @@ -1,64 +0,0 @@ -# nlohmann::json_pointer::operator/ - -```cpp -// (1) -json_pointer operator/(const json_pointer& lhs, const json_pointer& rhs); - -// (2) -json_pointer operator/(const json_pointer& lhs, string_t token); - -// (3) -json_pointer operator/(const json_pointer& lhs, std::size_t array_idx); -``` - -1. create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer -2. create a new JSON pointer by appending the unescaped token at the end of the JSON pointer -3. create a new JSON pointer by appending the array-index-token at the end of the JSON pointer - -## Parameters - -`lhs` (in) -: JSON pointer - -`rhs` (in) -: JSON pointer to append - -`token` (in) -: reference token to append - -`array_idx` (in) -: array index to append - -## Return value - -1. a new JSON pointer with `rhs` appended to `lhs` -2. a new JSON pointer with unescaped `token` appended to `lhs` -3. a new JSON pointer with `array_idx` appended to `lhs` - -## Complexity - -1. Linear in the length of `lhs` and `rhs`. -2. Linear in the length of `lhs`. -3. Linear in the length of `lhs`. - -## Examples - -??? example - - The example shows the usage of `operator/`. - - ```cpp - --8<-- "examples/json_pointer__operator_add_binary.cpp" - ``` - - Output: - - ```json - --8<-- "examples/json_pointer__operator_add_binary.output" - ``` - -## Version history - -1. Added in version 3.6.0. -2. Added in version 3.6.0. Changed type of `token` to `string_t` in version 3.11.0. -3. Added in version 3.6.0. diff --git a/docs/mkdocs/docs/api/json_pointer/operator_slasheq.md b/docs/mkdocs/docs/api/json_pointer/operator_slasheq.md deleted file mode 100644 index 3518557d50..0000000000 --- a/docs/mkdocs/docs/api/json_pointer/operator_slasheq.md +++ /dev/null @@ -1,61 +0,0 @@ -# nlohmann::json_pointer::operator/= - -```cpp -// (1) -json_pointer& operator/=(const json_pointer& ptr); - -// (2) -json_pointer& operator/=(string_t token); - -// (3) -json_pointer& operator/=(std::size_t array_idx) -``` - -1. append another JSON pointer at the end of this JSON pointer -2. append an unescaped reference token at the end of this JSON pointer -3. append an array index at the end of this JSON pointer - -## Parameters - -`ptr` (in) -: JSON pointer to append - -`token` (in) -: reference token to append - -`array_idx` (in) -: array index to append - -## Return value - -1. JSON pointer with `ptr` appended -2. JSON pointer with `token` appended without escaping `token` -3. JSON pointer with `array_idx` appended - -## Complexity - -1. Linear in the length of `ptr`. -2. Amortized constant. -3. Amortized constant. - -## Examples - -??? example - - The example shows the usage of `operator/=`. - - ```cpp - --8<-- "examples/json_pointer__operator_add.cpp" - ``` - - Output: - - ```json - --8<-- "examples/json_pointer__operator_add.output" - ``` - -## Version history - -1. Added in version 3.6.0. -2. Added in version 3.6.0. Changed type of `token` to `string_t` in version 3.11.0. -3. Added in version 3.6.0. diff --git a/docs/mkdocs/docs/api/json_pointer/operator_string_t.md b/docs/mkdocs/docs/api/json_pointer/operator_string_t.md deleted file mode 100644 index 74105a4f1e..0000000000 --- a/docs/mkdocs/docs/api/json_pointer/operator_string_t.md +++ /dev/null @@ -1,48 +0,0 @@ -# nlohmann::json_pointer::operator string_t - -```cpp -operator string_t() const -``` - -Return a string representation of the JSON pointer. - -## Return value - -A string representation of the JSON pointer - -## Possible implementation - -```cpp -operator string_t() const -{ - return to_string(); -} -``` - -## Notes - -!!! warning "Deprecation" - - This function is deprecated in favor of [`to_string`](to_string.md) and will be removed in a future major version - release. - -## Examples - -??? example - - The example shows how JSON Pointers can be implicitly converted to strings. - - ```cpp - --8<-- "examples/json_pointer__operator_string_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/json_pointer__operator_string_t.output" - ``` - -## Version history - -- Since version 2.0.0. -- Changed type to `string_t` and deprecated in version 3.11.0. diff --git a/docs/mkdocs/docs/api/json_pointer/parent_pointer.md b/docs/mkdocs/docs/api/json_pointer/parent_pointer.md deleted file mode 100644 index 1398730720..0000000000 --- a/docs/mkdocs/docs/api/json_pointer/parent_pointer.md +++ /dev/null @@ -1,35 +0,0 @@ -# nlohmann::json_pointer::parent_pointer - -```cpp -json_pointer parent_pointer() const; -``` - -Returns the parent of this JSON pointer. - -## Return value - -Parent of this JSON pointer; in case this JSON pointer is the root, the root itself is returned. - -## Complexity - -Linear in the length of the JSON pointer. - -## Examples - -??? example - - The example shows the result of `parent_pointer` for different JSON Pointers. - - ```cpp - --8<-- "examples/json_pointer__parent_pointer.cpp" - ``` - - Output: - - ```json - --8<-- "examples/json_pointer__parent_pointer.output" - ``` - -## Version history - -Added in version 3.6.0. diff --git a/docs/mkdocs/docs/api/json_pointer/pop_back.md b/docs/mkdocs/docs/api/json_pointer/pop_back.md deleted file mode 100644 index 3c79f36383..0000000000 --- a/docs/mkdocs/docs/api/json_pointer/pop_back.md +++ /dev/null @@ -1,35 +0,0 @@ -# nlohmann::json_pointer::pop_back - -```cpp -void pop_back(); -``` - -Remove last reference token. - -## Exceptions - -Throws [out_of_range.405](../../home/exceptions.md#jsonexceptionout_of_range405) if JSON pointer has no parent. - -## Complexity - -Constant. - -## Examples - -??? example - - The example shows the usage of `pop_back`. - - ```cpp - --8<-- "examples/json_pointer__pop_back.cpp" - ``` - - Output: - - ```json - --8<-- "examples/json_pointer__pop_back.output" - ``` - -## Version history - -Added in version 3.6.0. diff --git a/docs/mkdocs/docs/api/json_pointer/push_back.md b/docs/mkdocs/docs/api/json_pointer/push_back.md deleted file mode 100644 index c1c19cb8d1..0000000000 --- a/docs/mkdocs/docs/api/json_pointer/push_back.md +++ /dev/null @@ -1,39 +0,0 @@ -# nlohmann::json_pointer::push_back - -```cpp -void push_back(const string_t& token); - -void push_back(string_t&& token); -``` - -Append an unescaped token at the end of the reference pointer. - -## Parameters - -`token` (in) -: token to add - -## Complexity - -Amortized constant. - -## Examples - -??? example - - The example shows the result of `push_back` for different JSON Pointers. - - ```cpp - --8<-- "examples/json_pointer__push_back.cpp" - ``` - - Output: - - ```json - --8<-- "examples/json_pointer__push_back.output" - ``` - -## Version history - -- Added in version 3.6.0. -- Changed type of `token` to `string_t` in version 3.11.0. diff --git a/docs/mkdocs/docs/api/json_pointer/string_t.md b/docs/mkdocs/docs/api/json_pointer/string_t.md deleted file mode 100644 index c8527bc9cd..0000000000 --- a/docs/mkdocs/docs/api/json_pointer/string_t.md +++ /dev/null @@ -1,28 +0,0 @@ -# nlohmann::json_pointer::string_t -```cpp -using string_t = RefStringType; -``` - -The string type used for the reference tokens making up the JSON pointer. - -See [`basic_json::string_t`](../basic_json/string_t.md) for more information. - -## Examples - -??? example - - The example shows the type `string_t` and its relation to `basic_json::string_t`. - - ```cpp - --8<-- "examples/json_pointer__string_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/json_pointer__string_t.output" - ``` - -## Version history - -- Added in version 3.11.0. diff --git a/docs/mkdocs/docs/api/json_pointer/to_string.md b/docs/mkdocs/docs/api/json_pointer/to_string.md deleted file mode 100644 index fae3abe5fc..0000000000 --- a/docs/mkdocs/docs/api/json_pointer/to_string.md +++ /dev/null @@ -1,40 +0,0 @@ -# nlohmann::json_pointer::to_string - -```cpp -string_t to_string() const; -``` - -Return a string representation of the JSON pointer. - -## Return value - -A string representation of the JSON pointer - -## Notes - -For each JSON pointer `ptr`, it holds: - -```cpp -ptr == json_pointer(ptr.to_string()); -``` - -## Examples - -??? example - - The example shows the result of `to_string`. - - ```cpp - --8<-- "examples/json_pointer__to_string.cpp" - ``` - - Output: - - ```json - --8<-- "examples/json_pointer__to_string.output" - ``` - -## Version history - -- Since version 2.0.0. -- Changed return type to `string_t` in version 3.11.0. diff --git a/docs/mkdocs/docs/api/json_sax/binary.md b/docs/mkdocs/docs/api/json_sax/binary.md deleted file mode 100644 index fc0980e20b..0000000000 --- a/docs/mkdocs/docs/api/json_sax/binary.md +++ /dev/null @@ -1,40 +0,0 @@ -# nlohmann::json_sax::binary - -```cpp -virtual bool binary(binary_t& val) = 0; -``` - -A binary value was read. - -## Parameters - -`val` (in) -: binary value - -## Return value - -Whether parsing should proceed. - -## Notes - -It is safe to move the passed binary value. - -## Examples - -??? example - - The example below shows how the SAX interface is used. - - ```cpp - --8<-- "examples/sax_parse__binary.cpp" - ``` - - Output: - - ```json - --8<-- "examples/sax_parse__binary.output" - ``` - -## Version history - -- Added in version 3.8.0. diff --git a/docs/mkdocs/docs/api/json_sax/boolean.md b/docs/mkdocs/docs/api/json_sax/boolean.md deleted file mode 100644 index fdf2945622..0000000000 --- a/docs/mkdocs/docs/api/json_sax/boolean.md +++ /dev/null @@ -1,36 +0,0 @@ -# nlohmann::json_sax::boolean - -```cpp -virtual bool boolean(bool val) = 0; -``` - -A boolean value was read. - -## Parameters - -`val` (in) -: boolean value - -## Return value - -Whether parsing should proceed. - -## Examples - -??? example - - The example below shows how the SAX interface is used. - - ```cpp - --8<-- "examples/sax_parse.cpp" - ``` - - Output: - - ```json - --8<-- "examples/sax_parse.output" - ``` - -## Version history - -- Added in version 3.2.0. diff --git a/docs/mkdocs/docs/api/json_sax/end_array.md b/docs/mkdocs/docs/api/json_sax/end_array.md deleted file mode 100644 index 9c12e40a5e..0000000000 --- a/docs/mkdocs/docs/api/json_sax/end_array.md +++ /dev/null @@ -1,31 +0,0 @@ -# nlohmann::json_sax::end_array - -```cpp -virtual bool end_array() = 0; -``` - -The end of an array was read. - -## Return value - -Whether parsing should proceed. - -## Examples - -??? example - - The example below shows how the SAX interface is used. - - ```cpp - --8<-- "examples/sax_parse.cpp" - ``` - - Output: - - ```json - --8<-- "examples/sax_parse.output" - ``` - -## Version history - -- Added in version 3.2.0. diff --git a/docs/mkdocs/docs/api/json_sax/end_object.md b/docs/mkdocs/docs/api/json_sax/end_object.md deleted file mode 100644 index 601c94a4ab..0000000000 --- a/docs/mkdocs/docs/api/json_sax/end_object.md +++ /dev/null @@ -1,31 +0,0 @@ -# nlohmann::json_sax::end_object - -```cpp -virtual bool end_object() = 0; -``` - -The end of an object was read. - -## Return value - -Whether parsing should proceed. - -## Examples - -??? example - - The example below shows how the SAX interface is used. - - ```cpp - --8<-- "examples/sax_parse.cpp" - ``` - - Output: - - ```json - --8<-- "examples/sax_parse.output" - ``` - -## Version history - -- Added in version 3.2.0. diff --git a/docs/mkdocs/docs/api/json_sax/index.md b/docs/mkdocs/docs/api/json_sax/index.md deleted file mode 100644 index f63e85c9a6..0000000000 --- a/docs/mkdocs/docs/api/json_sax/index.md +++ /dev/null @@ -1,44 +0,0 @@ -# nlohmann::json_sax - -```cpp -template -struct json_sax; -``` - -This class describes the SAX interface used by [sax_parse](../basic_json/sax_parse.md). Each function is called in -different situations while the input is parsed. The boolean return value informs the parser whether to continue -processing the input. - -## Template parameters - -`BasicJsonType` -: a specialization of [`basic_json`](../basic_json/index.md) - -## Member types - -- [**number_integer_t**](../basic_json/number_integer_t.md) - `BasicJsonType`'s type for numbers (integer) -- [**number_unsigned_t**](../basic_json/number_unsigned_t.md) - `BasicJsonType`'s type for numbers (unsigned) -- [**number_float_t**](../basic_json/number_float_t.md) - `BasicJsonType`'s type for numbers (floating-point) -- [**string_t**](../basic_json/string_t.md) - `BasicJsonType`'s type for strings -- [**binary_t**](../basic_json/binary_t.md) - `BasicJsonType`'s type for binary arrays - -## Member functions - -- [**binary**](binary.md) (_virtual_) - a binary value was read -- [**boolean**](boolean.md) (_virtual_) - a boolean value was read -- [**end_array**](end_array.md) (_virtual_) - the end of an array was read -- [**end_object**](end_object.md) (_virtual_) - the end of an object was read -- [**key**](key.md) (_virtual_) - an object key was read -- [**null**](null.md) (_virtual_) - a null value was read -- [**number_float**](number_float.md) (_virtual_) - a floating-point number was read -- [**number_integer**](number_integer.md) (_virtual_) - an integer number was read -- [**number_unsigned**](number_unsigned.md) (_virtual_) - an unsigned integer number was read -- [**parse_error**](parse_error.md) (_virtual_) - a parse error occurred -- [**start_array**](start_array.md) (_virtual_) - the beginning of an array was read -- [**start_object**](start_object.md) (_virtual_) - the beginning of an object was read -- [**string**](string.md) (_virtual_) - a string value was read - -## Version history - -- Added in version 3.2.0. -- Support for binary values (`binary_t`, `binary`) added in version 3.8.0. diff --git a/docs/mkdocs/docs/api/json_sax/key.md b/docs/mkdocs/docs/api/json_sax/key.md deleted file mode 100644 index 31fd6c1d12..0000000000 --- a/docs/mkdocs/docs/api/json_sax/key.md +++ /dev/null @@ -1,40 +0,0 @@ -# nlohmann::json_sax::key - -```cpp -virtual bool key(string_t& val) = 0; -``` - -An object key was read. - -## Parameters - -`val` (in) -: object key - -## Return value - -Whether parsing should proceed. - -## Notes - -It is safe to move the passed object key value. - -## Examples - -??? example - - The example below shows how the SAX interface is used. - - ```cpp - --8<-- "examples/sax_parse.cpp" - ``` - - Output: - - ```json - --8<-- "examples/sax_parse.output" - ``` - -## Version history - -- Added in version 3.2.0. diff --git a/docs/mkdocs/docs/api/json_sax/null.md b/docs/mkdocs/docs/api/json_sax/null.md deleted file mode 100644 index 9354ede6ca..0000000000 --- a/docs/mkdocs/docs/api/json_sax/null.md +++ /dev/null @@ -1,31 +0,0 @@ -# nlohmann::json_sax::null - -```cpp -virtual bool null() = 0; -``` - -A null value was read. - -## Return value - -Whether parsing should proceed. - -## Examples - -??? example - - The example below shows how the SAX interface is used. - - ```cpp - --8<-- "examples/sax_parse.cpp" - ``` - - Output: - - ```json - --8<-- "examples/sax_parse.output" - ``` - -## Version history - -- Added in version 3.2.0. diff --git a/docs/mkdocs/docs/api/json_sax/number_float.md b/docs/mkdocs/docs/api/json_sax/number_float.md deleted file mode 100644 index 17799401ee..0000000000 --- a/docs/mkdocs/docs/api/json_sax/number_float.md +++ /dev/null @@ -1,39 +0,0 @@ -# nlohmann::json_sax::number_float - -```cpp -virtual bool number_float(number_float_t val, const string_t& s) = 0; -``` - -A floating-point number was read. - -## Parameters - -`val` (in) -: floating-point value - -`s` (in) -: string representation of the original input - -## Return value - -Whether parsing should proceed. - -## Examples - -??? example - - The example below shows how the SAX interface is used. - - ```cpp - --8<-- "examples/sax_parse.cpp" - ``` - - Output: - - ```json - --8<-- "examples/sax_parse.output" - ``` - -## Version history - -- Added in version 3.2.0. diff --git a/docs/mkdocs/docs/api/json_sax/number_integer.md b/docs/mkdocs/docs/api/json_sax/number_integer.md deleted file mode 100644 index 5c3cb4f316..0000000000 --- a/docs/mkdocs/docs/api/json_sax/number_integer.md +++ /dev/null @@ -1,36 +0,0 @@ -# nlohmann::json_sax::number_integer - -```cpp -virtual bool number_integer(number_integer_t val) = 0; -``` - -An integer number was read. - -## Parameters - -`val` (in) -: integer value - -## Return value - -Whether parsing should proceed. - -## Examples - -??? example - - The example below shows how the SAX interface is used. - - ```cpp - --8<-- "examples/sax_parse.cpp" - ``` - - Output: - - ```json - --8<-- "examples/sax_parse.output" - ``` - -## Version history - -- Added in version 3.2.0. diff --git a/docs/mkdocs/docs/api/json_sax/number_unsigned.md b/docs/mkdocs/docs/api/json_sax/number_unsigned.md deleted file mode 100644 index 0ac2500373..0000000000 --- a/docs/mkdocs/docs/api/json_sax/number_unsigned.md +++ /dev/null @@ -1,36 +0,0 @@ -# nlohmann::json_sax::number_unsigned - -```cpp -virtual bool number_unsigned(number_unsigned_t val) = 0; -``` - -An unsigned integer number was read. - -## Parameters - -`val` (in) -: unsigned integer value - -## Return value - -Whether parsing should proceed. - -## Examples - -??? example - - The example below shows how the SAX interface is used. - - ```cpp - --8<-- "examples/sax_parse.cpp" - ``` - - Output: - - ```json - --8<-- "examples/sax_parse.output" - ``` - -## Version history - -- Added in version 3.2.0. diff --git a/docs/mkdocs/docs/api/json_sax/parse_error.md b/docs/mkdocs/docs/api/json_sax/parse_error.md deleted file mode 100644 index e41cb67ff2..0000000000 --- a/docs/mkdocs/docs/api/json_sax/parse_error.md +++ /dev/null @@ -1,44 +0,0 @@ -# nlohmann::json_sax::parse_error - -```cpp -virtual bool parse_error(std::size_t position, - const std::string& last_token, - const detail::exception& ex) = 0; -``` - -A parse error occurred. - -## Parameters - -`position` (in) -: the position in the input where the error occurs - -`last_token` (in) -: the last read token - -`ex` (in) -: an exception object describing the error - -## Return value - -Whether parsing should proceed (**must return `#!cpp false`**). - -## Examples - -??? example - - The example below shows how the SAX interface is used. - - ```cpp - --8<-- "examples/sax_parse.cpp" - ``` - - Output: - - ```json - --8<-- "examples/sax_parse.output" - ``` - -## Version history - -- Added in version 3.2.0. diff --git a/docs/mkdocs/docs/api/json_sax/start_array.md b/docs/mkdocs/docs/api/json_sax/start_array.md deleted file mode 100644 index cf2b8cf565..0000000000 --- a/docs/mkdocs/docs/api/json_sax/start_array.md +++ /dev/null @@ -1,40 +0,0 @@ -# nlohmann::json_sax::start_array - -```cpp -virtual bool start_array(std::size_t elements) = 0; -``` - -The beginning of an array was read. - -## Parameters - -`elements` (in) -: number of object elements or `#!cpp -1` if unknown - -## Return value - -Whether parsing should proceed. - -## Notes - -Binary formats may report the number of elements. - -## Examples - -??? example - - The example below shows how the SAX interface is used. - - ```cpp - --8<-- "examples/sax_parse.cpp" - ``` - - Output: - - ```json - --8<-- "examples/sax_parse.output" - ``` - -## Version history - -- Added in version 3.2.0. diff --git a/docs/mkdocs/docs/api/json_sax/start_object.md b/docs/mkdocs/docs/api/json_sax/start_object.md deleted file mode 100644 index 491815deb3..0000000000 --- a/docs/mkdocs/docs/api/json_sax/start_object.md +++ /dev/null @@ -1,40 +0,0 @@ -# nlohmann::json_sax::start_object - -```cpp -virtual bool start_object(std::size_t elements) = 0; -``` - -The beginning of an object was read. - -## Parameters - -`elements` (in) -: number of object elements or `#!cpp -1` if unknown - -## Return value - -Whether parsing should proceed. - -## Notes - -Binary formats may report the number of elements. - -## Examples - -??? example - - The example below shows how the SAX interface is used. - - ```cpp - --8<-- "examples/sax_parse.cpp" - ``` - - Output: - - ```json - --8<-- "examples/sax_parse.output" - ``` - -## Version history - -- Added in version 3.2.0. diff --git a/docs/mkdocs/docs/api/json_sax/string.md b/docs/mkdocs/docs/api/json_sax/string.md deleted file mode 100644 index dcffb5f612..0000000000 --- a/docs/mkdocs/docs/api/json_sax/string.md +++ /dev/null @@ -1,40 +0,0 @@ -# nlohmann::json_sax::string - -```cpp -virtual bool string(string_t& val) = 0; -``` - -A string value was read. - -## Parameters - -`val` (in) -: string value - -## Return value - -Whether parsing should proceed. - -## Notes - -It is safe to move the passed string value. - -## Examples - -??? example - - The example below shows how the SAX interface is used. - - ```cpp - --8<-- "examples/sax_parse.cpp" - ``` - - Output: - - ```json - --8<-- "examples/sax_parse.output" - ``` - -## Version history - -- Added in version 3.2.0. diff --git a/docs/mkdocs/docs/api/macros/index.md b/docs/mkdocs/docs/api/macros/index.md deleted file mode 100644 index 099dfa6712..0000000000 --- a/docs/mkdocs/docs/api/macros/index.md +++ /dev/null @@ -1,60 +0,0 @@ -# Macros - -Some aspects of the library can be configured by defining preprocessor macros **before** including the `json.hpp` -header. See also the [macro overview page](../../features/macros.md). - -## Runtime assertions - -- [**JSON_ASSERT(x)**](json_assert.md) - control behavior of runtime assertions - -## Exceptions - -- [**JSON_CATCH_USER(exception)**
**JSON_THROW_USER(exception)**
**JSON_TRY_USER**](json_throw_user.md) - control exceptions -- [**JSON_DIAGNOSTICS**](json_diagnostics.md) - control extended diagnostics -- [**JSON_NOEXCEPTION**](json_noexception.md) - switch off exceptions - -## Language support - -- [**JSON_HAS_CPP_11**
**JSON_HAS_CPP_14**
**JSON_HAS_CPP_17**
**JSON_HAS_CPP_20**](json_has_cpp_11.md) - set supported C++ standard -- [**JSON_HAS_FILESYSTEM**
**JSON_HAS_EXPERIMENTAL_FILESYSTEM**](json_has_filesystem.md) - control `std::filesystem` support -- [**JSON_HAS_RANGES**](json_has_ranges.md) - control `std::ranges` support -- [**JSON_HAS_THREE_WAY_COMPARISON**](json_has_three_way_comparison.md) - control 3-way comparison support -- [**JSON_NO_IO**](json_no_io.md) - switch off functions relying on certain C++ I/O headers -- [**JSON_SKIP_UNSUPPORTED_COMPILER_CHECK**](json_skip_unsupported_compiler_check.md) - do not warn about unsupported compilers -- [**JSON_USE_GLOBAL_UDLS**](json_use_global_udls.md) - place user-defined string literals (UDLs) into the global namespace - -## Library version - -- [**JSON_SKIP_LIBRARY_VERSION_CHECK**](json_skip_library_version_check.md) - skip library version check -- [**NLOHMANN_JSON_VERSION_MAJOR**
**NLOHMANN_JSON_VERSION_MINOR**
**NLOHMANN_JSON_VERSION_PATCH**](nlohmann_json_version_major.md) - \- library version information - -## Library namespace - -- [**NLOHMANN_JSON_NAMESPACE**](nlohmann_json_namespace.md) - full name of the `nlohmann` namespace -- [**NLOHMANN_JSON_NAMESPACE_BEGIN**
**NLOHMANN_JSON_NAMESPACE_END**](nlohmann_json_namespace_begin.md) - open and - close the library namespace -- [**NLOHMANN_JSON_NAMESPACE_NO_VERSION**](nlohmann_json_namespace_no_version.md) - disable the version component of - the inline namespace - -## Type conversions - -- [**JSON_DISABLE_ENUM_SERIALIZATION**](json_disable_enum_serialization.md) - switch off default serialization/deserialization functions for enums -- [**JSON_USE_IMPLICIT_CONVERSIONS**](json_use_implicit_conversions.md) - control implicit conversions - - -## Comparison behavior - -- [**JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON**](json_use_legacy_discarded_value_comparison.md) - - control comparison of discarded values - -## Serialization/deserialization macros - -- [**NLOHMANN_DEFINE_TYPE_INTRUSIVE(type, member...)**
**NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(type, member...)**][DefInt] - \- serialization/deserialization of types _with_ access to private variables -- [**NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(type, member...)**
**NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(type, member...)**][DefNonInt] - \- serialization/deserialization of types _without_ access to private variables -- [**NLOHMANN_JSON_SERIALIZE_ENUM(type, ...)**](nlohmann_json_serialize_enum.md) - serialization/deserialization of enum types - -[DefInt]: nlohmann_define_type_intrusive.md -[DefNonInt]: nlohmann_define_type_non_intrusive.md diff --git a/docs/mkdocs/docs/api/macros/json_assert.md b/docs/mkdocs/docs/api/macros/json_assert.md deleted file mode 100644 index a093341a1b..0000000000 --- a/docs/mkdocs/docs/api/macros/json_assert.md +++ /dev/null @@ -1,84 +0,0 @@ -# JSON_ASSERT - -```cpp -#define JSON_ASSERT(x) /* value */ -``` - -This macro controls which code is executed for [runtime assertions](../../features/assertions.md) of the library. - -## Parameters - -`x` (in) -: expression of scalar type - -## Default definition - -The default value is [`#!cpp assert(x)`](https://en.cppreference.com/w/cpp/error/assert). - -```cpp -#define JSON_ASSERT(x) assert(x) -``` - -Therefore, assertions can be switched off by defining `NDEBUG`. - -## Notes - -- The library uses numerous assertions to guarantee invariants and to abort in case of otherwise undefined behavior - (e.g., when calling [operator[]](../basic_json/operator%5B%5D.md) with a missing object key on a `const` object). See - page [runtime assertions](../../features/assertions.md) for more information. -- Defining the macro to code that does not call `std::abort` may leave the library in an undefined state. -- The macro is undefined outside the library. - -## Examples - -??? example "Example 1: default behavior" - - The following code will trigger an assertion at runtime: - - ```cpp - #include - - using json = nlohmann::json; - - int main() - { - const json j = {{"key", "value"}}; - auto v = j["missing"]; - } - ``` - - Output: - - ``` - Assertion failed: (m_value.object->find(key) != m_value.object->end()), function operator[], file json.hpp, line 2144. - ``` - -??? example "Example 2: user-defined behavior" - - The assertion reporting can be changed by defining `JSON_ASSERT(x)` differently. - - ```cpp - #include - #include - #define JSON_ASSERT(x) if(!(x)){fprintf(stderr, "assertion error in %s\n", __FUNCTION__); std::abort();} - - #include - - using json = nlohmann::json; - - int main() - { - const json j = {{"key", "value"}}; - auto v = j["missing"]; - } - ``` - - Output: - - ``` - assertion error in operator[] - ``` - -## Version history - -- Added in version 3.9.0. diff --git a/docs/mkdocs/docs/api/macros/json_diagnostics.md b/docs/mkdocs/docs/api/macros/json_diagnostics.md deleted file mode 100644 index 4fc0fc38e3..0000000000 --- a/docs/mkdocs/docs/api/macros/json_diagnostics.md +++ /dev/null @@ -1,76 +0,0 @@ -# JSON_DIAGNOSTICS - -```cpp -#define JSON_DIAGNOSTICS /* value */ -``` - -This macro enables [extended diagnostics for exception messages](../../home/exceptions.md#extended-diagnostic-messages). -Possible values are `1` to enable or `0` to disable (default). - -When enabled, exception messages contain a [JSON Pointer](../json_pointer/json_pointer.md) to the JSON value that -triggered the exception. Note that enabling this macro increases the size of every JSON value by one pointer and adds -some runtime overhead. - -## Default definition - -The default value is `0` (extended diagnostics are switched off). - -```cpp -#define JSON_DIAGNOSTICS 0 -``` - -When the macro is not defined, the library will define it to its default value. - -## Notes - -!!! note "ABI compatibility" - - As of version 3.11.0, this macro is no longer required to be defined consistently throughout a codebase to avoid - One Definition Rule (ODR) violations, as the value of this macro is encoded in the namespace, resulting in distinct - symbol names. - - This allows different parts of a codebase to use different versions or configurations of this library without - causing improper behavior. - - Where possible, it is still recommended that all code define this the same way for maximum interoperability. - -!!! hint "CMake option" - - Diagnostic messages can also be controlled with the CMake option - [`JSON_Diagnostics`](../../integration/cmake.md#json_diagnostics) (`OFF` by default) - which defines `JSON_DIAGNOSTICS` accordingly. - -## Examples - -??? example "Example 1: default behavior" - - ```cpp - --8<-- "examples/diagnostics_standard.cpp" - ``` - - Output: - - ``` - --8<-- "examples/diagnostics_standard.output" - ``` - - This exception can be hard to debug if storing the value `#!c "12"` and accessing it is further apart. - -??? example "Example 2: extended diagnostic messages" - - ```cpp - --8<-- "examples/diagnostics_extended.cpp" - ``` - - Output: - - ``` - --8<-- "examples/diagnostics_extended.output" - ``` - - Now the exception message contains a JSON Pointer `/address/housenumber` that indicates which value has the wrong type. - -## Version history - -- Added in version 3.10.0. -- As of version 3.11.0 the definition is allowed to vary between translation units. diff --git a/docs/mkdocs/docs/api/macros/json_disable_enum_serialization.md b/docs/mkdocs/docs/api/macros/json_disable_enum_serialization.md deleted file mode 100644 index 6440e34e32..0000000000 --- a/docs/mkdocs/docs/api/macros/json_disable_enum_serialization.md +++ /dev/null @@ -1,152 +0,0 @@ -# JSON_DISABLE_ENUM_SERIALIZATION - -```cpp -#define JSON_DISABLE_ENUM_SERIALIZATION /* value */ -``` - -When defined to `1`, default serialization and deserialization functions for enums are excluded and have to be provided -by the user, for example, using [`NLOHMANN_JSON_SERIALIZE_ENUM`](nlohmann_json_serialize_enum.md) (see -[arbitrary type conversions](../../features/arbitrary_types.md) for more details). - -Parsing or serializing an enum will result in a compiler error. - -This works for both unscoped and scoped enums. - -## Default definition - -The default value is `0`. - -```cpp -#define JSON_DISABLE_ENUM_SERIALIZATION 0 -``` - -## Notes - -!!! hint "CMake option" - - Enum serialization can also be controlled with the CMake option - [`JSON_DisableEnumSerialization`](../../integration/cmake.md#json_disableenumserialization) - (`OFF` by default) which defines `JSON_DISABLE_ENUM_SERIALIZATION` accordingly. - -## Examples - -??? example "Example 1: Disabled behavior" - - The code below forces the library **not** to create default serialization/deserialization functions `from_json` and `to_json`, meaning the code below - **does not** compile. - - ```cpp - #define JSON_DISABLE_ENUM_SERIALIZATION 1 - #include - - using json = nlohmann::json; - - enum class Choice - { - first, - second, - }; - - int main() - { - // normally invokes to_json serialization function but with JSON_DISABLE_ENUM_SERIALIZATION defined, it does not - const json j = Choice::first; - - // normally invokes from_json parse function but with JSON_DISABLE_ENUM_SERIALIZATION defined, it does not - Choice ch = j.template get(); - } - ``` - -??? example "Example 2: Serialize enum macro" - - The code below forces the library **not** to create default serialization/deserialization functions `from_json` and `to_json`, but uses - [`NLOHMANN_JSON_SERIALIZE_ENUM`](nlohmann_json_serialize_enum.md) to parse and serialize the enum. - - ```cpp - #define JSON_DISABLE_ENUM_SERIALIZATION 1 - #include - - using json = nlohmann::json; - - enum class Choice - { - first, - second, - }; - - NLOHMANN_JSON_SERIALIZE_ENUM(Choice, - { - { Choice::first, "first" }, - { Choice::second, "second" }, - }) - - int main() - { - // uses user-defined to_json function defined by macro - const json j = Choice::first; - - // uses user-defined from_json function defined by macro - Choice ch = j.template get(); - } - ``` - -??? example "Example 3: User-defined serialization/deserialization functions" - - The code below forces the library **not** to create default serialization/deserialization functions `from_json` and `to_json`, but uses user-defined - functions to parse and serialize the enum. - - ```cpp - #define JSON_DISABLE_ENUM_SERIALIZATION 1 - #include - - using json = nlohmann::json; - - enum class Choice - { - first, - second, - }; - - void from_json(const json& j, Choice& ch) - { - auto value = j.template get(); - if (value == "first") - { - ch = Choice::first; - } - else if (value == "second") - { - ch = Choice::second; - } - } - - void to_json(json& j, const Choice& ch) - { - auto value = j.template get(); - if (value == "first") - { - ch = Choice::first; - } - else if (value == "second") - { - ch = Choice::second; - } - } - - int main() - { - // uses user-defined to_json function - const json j = Choice::first; - - // uses user-defined from_json function - Choice ch = j.template get(); - } - ``` - -## See also - -- [`NLOHMANN_JSON_SERIALIZE_ENUM`](nlohmann_json_serialize_enum.md) - -## Version history - -- Added in version 3.11.0. diff --git a/docs/mkdocs/docs/api/macros/json_has_cpp_11.md b/docs/mkdocs/docs/api/macros/json_has_cpp_11.md deleted file mode 100644 index f3eaa585c8..0000000000 --- a/docs/mkdocs/docs/api/macros/json_has_cpp_11.md +++ /dev/null @@ -1,41 +0,0 @@ -# JSON_HAS_CPP_11, JSON_HAS_CPP_14, JSON_HAS_CPP_17, JSON_HAS_CPP_20 - -```cpp -#define JSON_HAS_CPP_11 -#define JSON_HAS_CPP_14 -#define JSON_HAS_CPP_17 -#define JSON_HAS_CPP_20 -``` - -The library targets C++11, but also supports some features introduced in later C++ versions (e.g., `std::string_view` -support for C++17). For these new features, the library implements some preprocessor checks to determine the C++ -standard. By defining any of these symbols, the internal check is overridden and the provided C++ version is -unconditionally assumed. This can be helpful for compilers that only implement parts of the standard and would be -detected incorrectly. - -## Default definition - -The default value is detected based on preprocessor macros such as `#!cpp __cplusplus`, `#!cpp _HAS_CXX17`, or -`#!cpp _MSVC_LANG`. - -## Notes - -- `#!cpp JSON_HAS_CPP_11` is always defined. -- All macros are undefined outside the library. - -## Examples - -??? example - - The code below forces the library to use the C++14 standard: - - ```cpp - #define JSON_HAS_CPP_14 1 - #include - - ... - ``` - -## Version history - -- Added in version 3.10.5. diff --git a/docs/mkdocs/docs/api/macros/json_has_filesystem.md b/docs/mkdocs/docs/api/macros/json_has_filesystem.md deleted file mode 100644 index 308aea2ace..0000000000 --- a/docs/mkdocs/docs/api/macros/json_has_filesystem.md +++ /dev/null @@ -1,43 +0,0 @@ -# JSON_HAS_FILESYSTEM / JSON_HAS_EXPERIMENTAL_FILESYSTEM - -```cpp -#define JSON_HAS_FILESYSTEM /* value */ -#define JSON_HAS_EXPERIMENTAL_FILESYSTEM /* value */ -``` - -When compiling with C++17, the library provides conversions from and to -[`std::filesystem::path`](https://en.cppreference.com/w/cpp/filesystem/path). As compiler support for filesystem is -limited, the library tries to detect whether -[``/`std::filesystem`](https://en.cppreference.com/w/cpp/header/filesystem) (`JSON_HAS_FILESYSTEM`) or -[``/`std::experimental::filesystem`](https://en.cppreference.com/w/cpp/header/experimental/filesystem) -(`JSON_HAS_EXPERIMENTAL_FILESYSTEM`) should be used. To override the built-in check, define `JSON_HAS_FILESYSTEM` or -`JSON_HAS_EXPERIMENTAL_FILESYSTEM` to `1`. - -## Default definition - -The default value is detected based on the preprocessor macros `#!cpp __cpp_lib_filesystem`, -`#!cpp __cpp_lib_experimental_filesystem`, `#!cpp __has_include()`, or -`#!cpp __has_include()`. - -## Notes - -- Note that older compilers or older versions of libstd++ also require the library `stdc++fs` to be linked to for - filesystem support. -- Both macros are undefined outside the library. - -## Examples - -??? example - - The code below forces the library to use the header ``. - - ```cpp - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 - #include - - ... - ``` - -## Version history - -- Added in version 3.10.5. diff --git a/docs/mkdocs/docs/api/macros/json_has_ranges.md b/docs/mkdocs/docs/api/macros/json_has_ranges.md deleted file mode 100644 index 96d51052d8..0000000000 --- a/docs/mkdocs/docs/api/macros/json_has_ranges.md +++ /dev/null @@ -1,31 +0,0 @@ -# JSON_HAS_RANGES - -```cpp -#define JSON_HAS_RANGES /* value */ -``` - -This macro indicates whether the standard library has any support for ranges. Implies support for concepts. -Possible values are `1` when supported or `0` when unsupported. - -## Default definition - -The default value is detected based on the preprocessor macro `#!cpp __cpp_lib_ranges`. - -When the macro is not defined, the library will define it to its default value. - -## Examples - -??? example - - The code below forces the library to enable support for ranges: - - ```cpp - #define JSON_HAS_RANGES 1 - #include - - ... - ``` - -## Version history - -- Added in version 3.11.0. diff --git a/docs/mkdocs/docs/api/macros/json_has_three_way_comparison.md b/docs/mkdocs/docs/api/macros/json_has_three_way_comparison.md deleted file mode 100644 index f52070ebf4..0000000000 --- a/docs/mkdocs/docs/api/macros/json_has_three_way_comparison.md +++ /dev/null @@ -1,32 +0,0 @@ -# JSON_HAS_THREE_WAY_COMPARISON - -```cpp -#define JSON_HAS_THREE_WAY_COMPARISON /* value */ -``` - -This macro indicates whether the compiler and standard library support 3-way comparison. -Possible values are `1` when supported or `0` when unsupported. - -## Default definition - -The default value is detected based on the preprocessor macros `#!cpp __cpp_impl_three_way_comparison` -and `#!cpp __cpp_lib_three_way_comparison`. - -When the macro is not defined, the library will define it to its default value. - -## Examples - -??? example - - The code below forces the library to use 3-way comparison: - - ```cpp - #define JSON_HAS_THREE_WAY_COMPARISON 1 - #include - - ... - ``` - -## Version history - -- Added in version 3.11.0. diff --git a/docs/mkdocs/docs/api/macros/json_no_io.md b/docs/mkdocs/docs/api/macros/json_no_io.md deleted file mode 100644 index ef37384a52..0000000000 --- a/docs/mkdocs/docs/api/macros/json_no_io.md +++ /dev/null @@ -1,35 +0,0 @@ -# JSON_NO_IO - -```cpp -#define JSON_NO_IO -``` - -When defined, headers ``, ``, ``, ``, and `` are not included and parse functions -relying on these headers are excluded. This is relevant for environments where these I/O functions are disallowed for -security reasons (e.g., Intel Software Guard Extensions (SGX)). - -## Default definition - -By default, `#!cpp JSON_NO_IO` is not defined. - -```cpp -#undef JSON_NO_IO -``` - -## Examples - -??? example - - The code below forces the library not to use the headers ``, ``, ``, ``, and - ``. - - ```cpp - #define JSON_NO_IO 1 - #include - - ... - ``` - -## Version history - -- Added in version 3.10.0. diff --git a/docs/mkdocs/docs/api/macros/json_noexception.md b/docs/mkdocs/docs/api/macros/json_noexception.md deleted file mode 100644 index c801b85675..0000000000 --- a/docs/mkdocs/docs/api/macros/json_noexception.md +++ /dev/null @@ -1,45 +0,0 @@ -# JSON_NOEXCEPTION - -```cpp -#define JSON_NOEXCEPTION -``` - -Exceptions can be switched off by defining the symbol `JSON_NOEXCEPTION`. When defining `JSON_NOEXCEPTION`, `#!cpp try` -is replaced by `#!cpp if (true)`, `#!cpp catch` is replaced by `#!cpp if (false)`, and `#!cpp throw` is replaced by -`#!cpp std::abort()`. - -The same effect is achieved by setting the compiler flag `-fno-exceptions`. - -## Default definition - -By default, the macro is not defined. - -```cpp -#undef JSON_NOEXCEPTION -``` - -## Notes - -The explanatory [`what()`](https://en.cppreference.com/w/cpp/error/exception/what) string of exceptions is not -available for MSVC if exceptions are disabled, see [#2824](https://github.com/nlohmann/json/discussions/2824). - -## Examples - -??? example - - The code below switches off exceptions in the library. - - ```cpp - #define JSON_NOEXCEPTION 1 - #include - - ... - ``` - -## See also - -- [Switch off exceptions](../../home/exceptions.md#switch-off-exceptions) for more information how to switch off exceptions - -## Version history - -Added in version 2.1.0. diff --git a/docs/mkdocs/docs/api/macros/json_skip_library_version_check.md b/docs/mkdocs/docs/api/macros/json_skip_library_version_check.md deleted file mode 100644 index c9a743c18d..0000000000 --- a/docs/mkdocs/docs/api/macros/json_skip_library_version_check.md +++ /dev/null @@ -1,37 +0,0 @@ -# JSON_SKIP_LIBRARY_VERSION_CHECK - -```cpp -#define JSON_SKIP_LIBRARY_VERSION_CHECK -``` - -When defined, the library will not create a compiler warning when a different version of the library was already -included. - -## Default definition - -By default, the macro is not defined. - -```cpp -#undef JSON_SKIP_LIBRARY_VERSION_CHECK -``` - -## Notes - -!!! danger "ABI compatibility" - - Mixing different library versions in the same code can be a problem as the different versions may not be ABI - compatible. - -## Examples - -!!! example - - The following warning will be shown in case a different version of the library was already included: - - ``` - Already included a different version of the library! - ``` - -## Version history - -Added in version 3.11.0. diff --git a/docs/mkdocs/docs/api/macros/json_skip_unsupported_compiler_check.md b/docs/mkdocs/docs/api/macros/json_skip_unsupported_compiler_check.md deleted file mode 100644 index 374fa4c27f..0000000000 --- a/docs/mkdocs/docs/api/macros/json_skip_unsupported_compiler_check.md +++ /dev/null @@ -1,33 +0,0 @@ -# JSON_SKIP_UNSUPPORTED_COMPILER_CHECK - -```cpp -#define JSON_SKIP_UNSUPPORTED_COMPILER_CHECK -``` - -When defined, the library will not create a compile error when a known unsupported compiler is detected. This allows to -use the library with compilers that do not fully support C++11 and may only work if unsupported features are not used. - -## Default definition - -By default, the macro is not defined. - -```cpp -#undef JSON_SKIP_UNSUPPORTED_COMPILER_CHECK -``` - -## Examples - -??? example - - The code below switches off the check whether the compiler is supported. - - ```cpp - #define JSON_SKIP_UNSUPPORTED_COMPILER_CHECK 1 - #include - - ... - ``` - -## Version history - -Added in version 3.2.0. diff --git a/docs/mkdocs/docs/api/macros/json_throw_user.md b/docs/mkdocs/docs/api/macros/json_throw_user.md deleted file mode 100644 index e10db90e46..0000000000 --- a/docs/mkdocs/docs/api/macros/json_throw_user.md +++ /dev/null @@ -1,75 +0,0 @@ -# JSON_CATCH_USER, JSON_THROW_USER, JSON_TRY_USER - -```cpp -// (1) -#define JSON_CATCH_USER(exception) /* value */ -// (2) -#define JSON_THROW_USER(exception) /* value */ -// (3) -#define JSON_TRY_USER /* value */ -``` - -Controls how exceptions are handled by the library. - -1. This macro overrides [`#!cpp catch`](https://en.cppreference.com/w/cpp/language/try_catch) calls inside the library. - The argument is the type of the exception to catch. As of version 3.8.0, the library only catches `std::out_of_range` - exceptions internally to rethrow them as [`json::out_of_range`](../../home/exceptions.md#out-of-range) exceptions. - The macro is always followed by a scope. -2. This macro overrides `#!cpp throw` calls inside the library. The argument is the exception to be thrown. Note that - `JSON_THROW_USER` should leave the current scope (e.g., by throwing or aborting), as continuing after it may yield - undefined behavior. -3. This macro overrides `#!cpp try` calls inside the library. It has no arguments and is always followed by a scope. - -## Parameters - -`exception` (in) -: an exception type - -## Default definition - -By default, the macros map to their respective C++ keywords: - -```cpp -#define JSON_CATCH_USER(exception) catch(exception) -#define JSON_THROW_USER(exception) throw exception -#define JSON_TRY_USER try -``` - -When exceptions are switched off, the `#!cpp try` block is executed unconditionally, and throwing exceptions is -replaced by calling [`std::abort`](https://en.cppreference.com/w/cpp/utility/program/abort) to make reaching the -`#!cpp throw` branch abort the process. - -```cpp -#define JSON_THROW_USER(exception) std::abort() -#define JSON_TRY_USER if (true) -#define JSON_CATCH_USER(exception) if (false) -``` - -## Examples - -??? example - - The code below switches off exceptions and creates a log entry with a detailed error message in case of errors. - - ```cpp - #include - - #define JSON_TRY_USER if(true) - #define JSON_CATCH_USER(exception) if(false) - #define JSON_THROW_USER(exception) \ - {std::clog << "Error in " << __FILE__ << ":" << __LINE__ \ - << " (function " << __FUNCTION__ << ") - " \ - << (exception).what() << std::endl; \ - std::abort();} - - #include - ``` - -## See also - -- [Switch off exceptions](../../home/exceptions.md#switch-off-exceptions) for more information how to switch off exceptions -- [JSON_NOEXCEPTION](JSON_NOEXCEPTION) - switch off exceptions - -## Version history - -- Added in version 3.1.0. diff --git a/docs/mkdocs/docs/api/macros/json_use_global_udls.md b/docs/mkdocs/docs/api/macros/json_use_global_udls.md deleted file mode 100644 index 69db9e77c3..0000000000 --- a/docs/mkdocs/docs/api/macros/json_use_global_udls.md +++ /dev/null @@ -1,98 +0,0 @@ -# JSON_USE_GLOBAL_UDLS - -```cpp -#define JSON_USE_GLOBAL_UDLS /* value */ -``` - -When defined to `1`, the user-defined string literals (UDLs) are placed into the global namespace instead of -`nlohmann::literals::json_literals`. - -## Default definition - -The default value is `1`. - -```cpp -#define JSON_USE_GLOBAL_UDLS 1 -``` - -When the macro is not defined, the library will define it to its default value. - -## Notes - -!!! info "Future behavior change" - - The user-defined string literals will be removed from the global namespace in the next major release of the library. - - To prepare existing code, define `JSON_USE_GLOBAL_UDLS` to `0` and bring the string literals into scope where - needed. Refer to any of the [string literals](#see-also) for details. - -!!! hint "CMake option" - - The placement of user-defined string literals can also be controlled with the CMake option - [`JSON_GlobalUDLs`](../../integration/cmake.md#json_globaludls) (`ON` by default) which defines - `JSON_USE_GLOBAL_UDLS` accordingly. - -## Examples - -??? example "Example 1: Default behavior" - - The code below shows the default behavior using the `_json` UDL. - - ```cpp - #include - - #include - - int main() - { - auto j = "42"_json; - - std::cout << j << std::endl; - } - ``` - - Output: - - ```json - 42 - ``` - -??? example "Example 2: Namespaced UDLs" - - The code below shows how UDLs need to be brought into scope before using `_json` when `JSON_USE_GLOBAL_UDLS` is - defined to `0`. - - ```cpp - #define JSON_USE_GLOBAL_UDLS 0 - #include - - #include - - int main() - { - // auto j = "42"_json; // This line would fail to compile, - // because the UDLs are not in the global namespace - - // Bring the UDLs into scope - using namespace nlohmann::json_literals; - - auto j = "42"_json; - - std::cout << j << std::endl; - } - ``` - - Output: - - ```json - 42 - ``` - -## See also - -- [`operator""_json`](../operator_literal_json.md) -- [`operator""_json_pointer`](../operator_literal_json_pointer.md) - -## Version history - -- Added in version 3.11.0. diff --git a/docs/mkdocs/docs/api/macros/json_use_implicit_conversions.md b/docs/mkdocs/docs/api/macros/json_use_implicit_conversions.md deleted file mode 100644 index 557dfa299e..0000000000 --- a/docs/mkdocs/docs/api/macros/json_use_implicit_conversions.md +++ /dev/null @@ -1,59 +0,0 @@ -# JSON_USE_IMPLICIT_CONVERSIONS - -```cpp -#define JSON_USE_IMPLICIT_CONVERSIONS /* value */ -``` - -When defined to `0`, implicit conversions are switched off. By default, implicit conversions are switched on. The -value directly affects [`operator ValueType`](../basic_json/operator_ValueType.md). - -## Default definition - -By default, implicit conversions are enabled. - -```cpp -#define JSON_USE_IMPLICIT_CONVERSIONS 1 -``` - -## Notes - -!!! info "Future behavior change" - - Implicit conversions will be switched off by default in the next major release of the library. - - You can prepare existing code by already defining `JSON_USE_IMPLICIT_CONVERSIONS` to `0` and replace any implicit - conversions with calls to [`get`](../basic_json/get.md). - -!!! hint "CMake option" - - Implicit conversions can also be controlled with the CMake option - [`JSON_ImplicitConversions`](../../integration/cmake.md#json_legacydiscardedvaluecomparison) - (`ON` by default) which defines `JSON_USE_IMPLICIT_CONVERSIONS` accordingly. - -## Examples - -??? example - - This is an example for an implicit conversion: - - ```cpp - json j = "Hello, world!"; - std::string s = j; - ``` - - When `JSON_USE_IMPLICIT_CONVERSIONS` is defined to `0`, the code above does no longer compile. Instead, it must be - written like this: - - ```cpp - json j = "Hello, world!"; - auto s = j.template get(); - ``` - -## See also - -- [**operator ValueType**](../basic_json/operator_ValueType.md) - get a value (implicit) -- [**get**](../basic_json/get.md) - get a value (explicit) - -## Version history - -- Added in version 3.9.0. diff --git a/docs/mkdocs/docs/api/macros/json_use_legacy_discarded_value_comparison.md b/docs/mkdocs/docs/api/macros/json_use_legacy_discarded_value_comparison.md deleted file mode 100644 index bc1d1434a7..0000000000 --- a/docs/mkdocs/docs/api/macros/json_use_legacy_discarded_value_comparison.md +++ /dev/null @@ -1,77 +0,0 @@ -# JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON - -```cpp -#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON /* value */ -``` - -This macro enables the (incorrect) legacy comparison behavior of discarded JSON values. Possible values are `1` to -enable or `0` to disable (default). - -When enabled, comparisons involving at least one discarded JSON value yield results as follows: - -| **Operator** | **Result** | -|--------------|---------------| -| `==` | `#!cpp false` | -| `!=` | `#!cpp true` | -| `<` | `#!cpp false` | -| `<=` | `#!cpp true` | -| `>=` | `#!cpp true` | -| `>` | `#!cpp false` | - -Otherwise, comparisons involving at least one discarded JSON value always yield `#!cpp false`. - -## Default definition - -The default value is `0`. - -```cpp -#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0 -``` - -When the macro is not defined, the library will define it to its default value. - -## Notes - -!!! warning "Inconsistent behavior in C++20 and beyond" - - When targeting C++20 or above, enabling the legacy comparison behavior is _strongly_ - discouraged. - - - The 3-way comparison operator (`<=>`) will always give the correct result - (`#!cpp std::partial_ordering::unordered`) regardless of the value of - `JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON`. - - Overloads for the equality and relational operators emulate the legacy behavior. - - Code outside your control may use either 3-way comparison or the equality and relational operators, resulting in - inconsistent and unpredictable behavior. - - See [`operator<=>`](../basic_json/operator_spaceship.md) for more information on 3-way comparison. - -!!! warning "Deprecation" - - The legacy comparison behavior is deprecated and may be removed in a future major version release. - - New code should not depend on it and existing code should try to remove or rewrite expressions relying on it. - -!!! hint "CMake option" - - Legacy comparison can also be controlled with the CMake option - [`JSON_LegacyDiscardedValueComparison`](../../integration/cmake.md#json_legacydiscardedvaluecomparison) - (`OFF` by default) which defines `JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON` accordingly. - -## Examples - -??? example - - The code below switches on the legacy discarded value comparison behavior in the library. - - ```cpp - #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 1 - #include - - ... - ``` - -## Version history - -- Added in version 3.11.0. diff --git a/docs/mkdocs/docs/api/macros/nlohmann_define_type_intrusive.md b/docs/mkdocs/docs/api/macros/nlohmann_define_type_intrusive.md deleted file mode 100644 index afd09c6db3..0000000000 --- a/docs/mkdocs/docs/api/macros/nlohmann_define_type_intrusive.md +++ /dev/null @@ -1,126 +0,0 @@ -# NLOHMANN_DEFINE_TYPE_INTRUSIVE, NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT - -```cpp -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(type, member...) // (1) -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(type, member...) // (2) -``` - -These macros can be used to simplify the serialization/deserialization of types if you want to use a JSON object as -serialization and want to use the member variable names as object keys in that object. The macro is to be defined -**inside** the class/struct to create code for. Unlike -[`NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`](nlohmann_define_type_non_intrusive.md), it can access private members. The first -parameter is the name of the class/struct, and all remaining parameters name the members. - -1. Will use [`at`](../basic_json/at.md) during deserialization and will throw - [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if a key is missing in the JSON object. -2. Will use [`value`](../basic_json/value.md) during deserialization and fall back to the default value for the - respective type of the member variable if a key in the JSON object is missing. The generated `from_json()` function - default constructs an object and uses its values as the defaults when calling the `value` function. - -## Parameters - -`type` (in) -: name of the type (class, struct) to serialize/deserialize - -`member` (in) -: name of the member variable to serialize/deserialize; up to 64 members can be given as comma-separated list - -## Default definition - -The macros add two friend functions to the class which take care of the serialization and deserialization: - -```cpp -friend void to_json(nlohmann::json&, const type&); -friend void from_json(const nlohmann::json&, type&); -``` - -See examples below for the concrete generated code. - -## Notes - -!!! info "Prerequisites" - - 1. The type `type` must be default constructible. See [How can I use `get()` for non-default - constructible/non-copyable types?][GetNonDefNonCopy] for how to overcome this limitation. - 2. The macro must be used inside the type (class/struct). - -[GetNonDefNonCopy]: ../../features/arbitrary_types.md#how-can-i-use-get-for-non-default-constructiblenon-copyable-types - -!!! warning "Implementation limits" - - - The current implementation is limited to at most 64 member variables. If you want to serialize/deserialize types - with more than 64 member variables, you need to define the `to_json`/`from_json` functions manually. - - The macros only work for the [`nlohmann::json`](../json.md) type; other specializations such as - [`nlohmann::ordered_json`](../ordered_json.md) are currently unsupported. - -## Examples - -??? example "Example (1): NLOHMANN_DEFINE_TYPE_INTRUSIVE" - - Consider the following complete example: - - ```cpp hl_lines="21" - --8<-- "examples/nlohmann_define_type_intrusive_macro.cpp" - ``` - - Output: - - ```json - --8<-- "examples/nlohmann_define_type_intrusive_macro.output" - ``` - - Notes: - - - `ns::person` is default-constructible. This is a requirement for using the macro. - - `ns::person` has private member variables. This makes `NLOHMANN_DEFINE_TYPE_INTRUSIVE` applicable, but not - `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`. - - The macro `NLOHMANN_DEFINE_TYPE_INTRUSIVE` is used _inside_ the class. - - A missing key "age" in the deserialization yields an exception. To fall back to the default value, - `NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT` can be used. - - The macro is equivalent to: - - ```cpp hl_lines="21 22 23 24 25 26 27 28 29 30 31 32 33" - --8<-- "examples/nlohmann_define_type_intrusive_explicit.cpp" - ``` - -??? example "Example (2): NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT" - - Consider the following complete example: - - ```cpp hl_lines="21" - --8<-- "examples/nlohmann_define_type_intrusive_with_default_macro.cpp" - ``` - - Output: - - ```json - --8<-- "examples/nlohmann_define_type_intrusive_with_default_macro.output" - ``` - - Notes: - - - `ns::person` is default-constructible. This is a requirement for using the macro. - - `ns::person` has private member variables. This makes `NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT` applicable, - but not `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT`. - - The macro `NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT` is used _inside_ the class. - - A missing key "age" in the deserialization does not yield an exception. Instead, the default value `-1` is used. - - The macro is equivalent to: - - ```cpp hl_lines="21 22 23 24 25 26 27 28 29 30 31 32 33 34" - --8<-- "examples/nlohmann_define_type_intrusive_with_default_explicit.cpp" - ``` - - Note how a default-initialized `person` object is used in the `from_json` to fill missing values. - -## See also - -- [NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE / NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT](nlohmann_define_type_non_intrusive.md) - for a similar macro that can be defined _outside_ the type. -- [Arbitrary Type Conversions](../../features/arbitrary_types.md) for an overview. - -## Version history - -1. Added in version 3.9.0. -2. Added in version 3.11.0. diff --git a/docs/mkdocs/docs/api/macros/nlohmann_define_type_non_intrusive.md b/docs/mkdocs/docs/api/macros/nlohmann_define_type_non_intrusive.md deleted file mode 100644 index 70cf934fcc..0000000000 --- a/docs/mkdocs/docs/api/macros/nlohmann_define_type_non_intrusive.md +++ /dev/null @@ -1,127 +0,0 @@ -# NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE, NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT - -```cpp -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(type, member...) // (1) -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(type, member...) // (2) -``` - -These macros can be used to simplify the serialization/deserialization of types if you want to use a JSON object as -serialization and want to use the member variable names as object keys in that object. The macro is to be defined -**outside** the class/struct to create code for, but **inside** its namespace. Unlike -[`NLOHMANN_DEFINE_TYPE_INTRUSIVE`](nlohmann_define_type_intrusive.md), it **cannot** access private members. The first -parameter is the name of the class/struct, and all remaining parameters name the members. - -1. Will use [`at`](../basic_json/at.md) during deserialization and will throw - [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if a key is missing in the JSON object. -2. Will use [`value`](../basic_json/value.md) during deserialization and fall back to the default value for the - respective type of the member variable if a key in the JSON object is missing. The generated `from_json()` function - default constructs an object and uses its values as the defaults when calling the `value` function. - -## Parameters - -`type` (in) -: name of the type (class, struct) to serialize/deserialize - -`member` (in) -: name of the (public) member variable to serialize/deserialize; up to 64 members can be given as comma-separated list - -## Default definition - -The macros add two functions to the namespace which take care of the serialization and deserialization: - -```cpp -void to_json(nlohmann::json&, const type&); -void from_json(const nlohmann::json&, type&); -``` - -See examples below for the concrete generated code. - -## Notes - -!!! info "Prerequisites" - - 1. The type `type` must be default constructible. See [How can I use `get()` for non-default constructible/non-copyable types?][GetNonDefNonCopy] - for how to overcome this limitation. - 2. The macro must be used outside the type (class/struct). - 3. The passed members must be public. - -[GetNonDefNonCopy]: ../../features/arbitrary_types.md#how-can-i-use-get-for-non-default-constructiblenon-copyable-types - -!!! warning "Implementation limits" - - - The current implementation is limited to at most 64 member variables. If you want to serialize/deserialize types - with more than 64 member variables, you need to define the `to_json`/`from_json` functions manually. - - The macros only work for the [`nlohmann::json`](../json.md) type; other specializations such as - [`nlohmann::ordered_json`](../ordered_json.md) are currently unsupported. - -## Examples - -??? example "Example (1): NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE" - - Consider the following complete example: - - ```cpp hl_lines="15" - --8<-- "examples/nlohmann_define_type_non_intrusive_macro.cpp" - ``` - - Output: - - ```json - --8<-- "examples/nlohmann_define_type_non_intrusive_macro.output" - ``` - - Notes: - - - `ns::person` is default-constructible. This is a requirement for using the macro. - - `ns::person` has only public member variables. This makes `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE` applicable. - - The macro `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE` is used _outside_ the class, but _inside_ its namespace `ns`. - - A missing key "age" in the deserialization yields an exception. To fall back to the default value, - `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT` can be used. - - The macro is equivalent to: - - ```cpp hl_lines="15 16 17 18 19 20 21 22 23 24 25 26 27" - --8<-- "examples/nlohmann_define_type_non_intrusive_explicit.cpp" - ``` - -??? example "Example (2): NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT" - - Consider the following complete example: - - ```cpp hl_lines="20" - --8<-- "examples/nlohmann_define_type_non_intrusive_with_default_macro.cpp" - ``` - - Output: - - ```json - --8<-- "examples/nlohmann_define_type_non_intrusive_with_default_macro.output" - ``` - - Notes: - - - `ns::person` is default-constructible. This is a requirement for using the macro. - - `ns::person` has only public member variables. This makes `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT` - applicable. - - The macro `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT` is used _outside_ the class, but _inside_ its - namespace `ns`. - - A missing key "age" in the deserialization does not yield an exception. Instead, the default value `-1` is used. - - The macro is equivalent to: - - ```cpp hl_lines="20 21 22 23 24 25 26 27 28 29 30 31 32 33" - --8<-- "examples/nlohmann_define_type_non_intrusive_with_default_explicit.cpp" - ``` - - Note how a default-initialized `person` object is used in the `from_json` to fill missing values. - -## See also - -- [NLOHMANN_DEFINE_TYPE_INTRUSIVE / NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT](nlohmann_define_type_intrusive.md) - for a similar macro that can be defined _inside_ the type. -- [Arbitrary Type Conversions](../../features/arbitrary_types.md) for an overview. - -## Version history - -1. Added in version 3.9.0. -2. Added in version 3.11.0. diff --git a/docs/mkdocs/docs/api/macros/nlohmann_json_namespace.md b/docs/mkdocs/docs/api/macros/nlohmann_json_namespace.md deleted file mode 100644 index 5c54dba52e..0000000000 --- a/docs/mkdocs/docs/api/macros/nlohmann_json_namespace.md +++ /dev/null @@ -1,41 +0,0 @@ -# NLOHMANN_JSON_NAMESPACE - -```cpp -#define NLOHMANN_JSON_NAMESPACE /* value */ -``` - -This macro evaluates to the full name of the `nlohmann` namespace. - -## Default definition - -The default value consists of the root namespace (`nlohmann`) and an inline ABI namespace. See -[`nlohmann` Namespace](../../features/namespace.md#structure) for details. - -When the macro is not defined, the library will define it to its default value. Overriding this value has no effect on -the library. - -## Examples - -??? example - - The example shows how to use `NLOHMANN_JSON_NAMESPACE` instead of just `nlohmann`, as well as how to output the value - of `NLOHMANN_JSON_NAMESPACE`. - - ```cpp - --8<-- "examples/nlohmann_json_namespace.cpp" - ``` - - Output: - - ```json - --8<-- "examples/nlohmann_json_namespace.output" - ``` - -## See also - -- [`NLOHMANN_JSON_NAMESPACE_BEGIN, NLOHMANN_JSON_NAMESPACE_END`](nlohmann_json_namespace_begin.md) -- [`NLOHMANN_JSON_NAMESPACE_NO_VERSION`](nlohmann_json_namespace_no_version.md) - -## Version history - -- Added in version 3.11.0. Changed inline namespace name in version 3.11.2. diff --git a/docs/mkdocs/docs/api/macros/nlohmann_json_namespace_begin.md b/docs/mkdocs/docs/api/macros/nlohmann_json_namespace_begin.md deleted file mode 100644 index 1374264a3b..0000000000 --- a/docs/mkdocs/docs/api/macros/nlohmann_json_namespace_begin.md +++ /dev/null @@ -1,61 +0,0 @@ -# NLOHMANN_JSON_NAMESPACE_BEGIN, NLOHMANN_JSON_NAMESPACE_END - -```cpp -#define NLOHMANN_JSON_NAMESPACE_BEGIN /* value */ // (1) -#define NLOHMANN_JSON_NAMESPACE_END /* value */ // (2) -``` - -These macros can be used to open and close the `nlohmann` namespace. See -[`nlohmann` Namespace](../../features/namespace.md#structure) for details. - -1. Opens the namespace. -2. Closes the namespace. - -## Default definition - -The default definitions open and close the `nlohmann` namespace. The precise definition of -[`NLOHMANN_JSON_NAMESPACE_BEGIN`] varies as described [here](../../features/namespace.md#structure). - -1. Default definition of `NLOHMANN_JSON_NAMESPACE_BEGIN`: - - ```cpp - namespace nlohmann - { - inline namespace json_abi_v3_11_2 - { - ``` - -2. Default definition of `NLOHMANN_JSON_NAMESPACE_END`: - ```cpp - } // namespace json_abi_v3_11_2 - } // namespace nlohmann - ``` - -When these macros are not defined, the library will define them to their default definitions. - -## Examples - -??? example - - The example shows how to use `NLOHMANN_JSON_NAMESPACE_BEGIN`/`NLOHMANN_JSON_NAMESPACE_END` from the - [How do I convert third-party types?](../../features/arbitrary_types.md#how-do-i-convert-third-party-types) page. - - ```cpp - --8<-- "examples/nlohmann_json_namespace_begin.c++17.cpp" - ``` - - Output: - - ```json - --8<-- "examples/nlohmann_json_namespace_begin.c++17.output" - ``` - -## See also - -- [`nlohmann` Namespace](../../features/namespace.md) -- [NLOHMANN_JSON_NAMESPACE](nlohmann_json_namespace.md) -- [`NLOHMANN_JSON_NAMESPACE_NO_VERSION`](nlohmann_json_namespace_no_version.md) - -## Version history - -- Added in version 3.11.0. Changed inline namespace name in version 3.11.2. diff --git a/docs/mkdocs/docs/api/macros/nlohmann_json_namespace_no_version.md b/docs/mkdocs/docs/api/macros/nlohmann_json_namespace_no_version.md deleted file mode 100644 index 9e2a52d042..0000000000 --- a/docs/mkdocs/docs/api/macros/nlohmann_json_namespace_no_version.md +++ /dev/null @@ -1,45 +0,0 @@ -# NLOHMANN_JSON_NAMESPACE_NO_VERSION - -```cpp -#define NLOHMANN_JSON_NAMESPACE_NO_VERSION /* value */ -``` - -If defined to `1`, the version component is omitted from the inline namespace. See -[`nlohmann` Namespace](../../features/namespace.md#structure) for details. - -## Default definition - -The default value is `0`. - -```cpp -#define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0 -``` - -When the macro is not defined, the library will define it to its default value. - -## Examples - -??? example - - The example shows how to use `NLOHMANN_JSON_NAMESPACE_NO_VERSION` to disable the version component of the inline - namespace. - - ```cpp - --8<-- "examples/nlohmann_json_namespace_no_version.cpp" - ``` - - Output: - - ```json - --8<-- "examples/nlohmann_json_namespace_no_version.output" - ``` - -## See also - -- [`nlohmann` Namespace](../../features/namespace.md) -- [`NLOHMANN_JSON_NAMESPACE`](nlohmann_json_namespace.md) -- [`NLOHMANN_JSON_NAMESPACE_BEGIN, NLOHMANN_JSON_NAMESPACE_END`](nlohmann_json_namespace_begin.md) - -## Version history - -- Added in version 3.11.2. diff --git a/docs/mkdocs/docs/api/macros/nlohmann_json_serialize_enum.md b/docs/mkdocs/docs/api/macros/nlohmann_json_serialize_enum.md deleted file mode 100644 index dc2cc8ecb8..0000000000 --- a/docs/mkdocs/docs/api/macros/nlohmann_json_serialize_enum.md +++ /dev/null @@ -1,85 +0,0 @@ -# NLOHMANN_JSON_SERIALIZE_ENUM - -```cpp -#define NLOHMANN_JSON_SERIALIZE_ENUM(type, conversion...) -``` - -By default, enum values are serialized to JSON as integers. In some cases this could result in undesired behavior. If an -enum is modified or re-ordered after data has been serialized to JSON, the later de-serialized JSON data may be -undefined or a different enum value than was originally intended. - -The `NLOHMANN_JSON_SERIALIZE_ENUM` allows to define a user-defined serialization for every enumerator. - -## Parameters - -`type` (in) -: name of the enum to serialize/deserialize - -`conversion` (in) -: a pair of an enumerator and a JSON serialization; arbitrary pairs can be given as a comma-separated list - -## Default definition - -The macros add two friend functions to the class which take care of the serialization and deserialization: - -```cpp -template -inline void to_json(BasicJsonType& j, const type& e); -template -inline void from_json(const BasicJsonType& j, type& e); -``` - -## Notes - -!!! info "Prerequisites" - - The macro must be used inside the namespace of the enum. - -!!! important "Important notes" - - - When using [`template get()`](../basic_json/get.md), undefined JSON values will default to the first specified - conversion. Select this default pair carefully. See example 1 below. - - If an enum or JSON value is specified in multiple conversions, the first matching conversion from the top of the - list will be returned when converting to or from JSON. See example 2 below. - -## Examples - -??? example "Example 1: Basic usage" - - The example shows how `NLOHMANN_JSON_SERIALIZE_ENUM` can be used to serialize/deserialize both classical enums and - C++11 enum classes: - - ```cpp hl_lines="16 17 18 19 20 21 22 29 30 31 32 33" - --8<-- "examples/nlohmann_json_serialize_enum.cpp" - ``` - - Output: - - ```json - --8<-- "examples/nlohmann_json_serialize_enum.output" - ``` - -??? example "Example 2: Multiple conversions for one enumerator" - - The example shows how to use multiple conversions for a single enumerator. In the example, `Color::red` will always - be *serialized* to `"red"`, because the first occurring conversion. The second conversion, however, offers an - alternative *deserialization* from `"rot"` to `Color::red`. - - ```cpp hl_lines="17" - --8<-- "examples/nlohmann_json_serialize_enum_2.cpp" - ``` - - Output: - - ```json - --8<-- "examples/nlohmann_json_serialize_enum_2.output" - ``` - -## See also - -- [Specializing enum conversion](../../features/enum_conversion.md) -- [`JSON_DISABLE_ENUM_SERIALIZATION`](json_disable_enum_serialization.md) - -## Version history - -Added in version 3.4.0. diff --git a/docs/mkdocs/docs/api/macros/nlohmann_json_version_major.md b/docs/mkdocs/docs/api/macros/nlohmann_json_version_major.md deleted file mode 100644 index d7a314276e..0000000000 --- a/docs/mkdocs/docs/api/macros/nlohmann_json_version_major.md +++ /dev/null @@ -1,40 +0,0 @@ -# NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, NLOHMANN_JSON_VERSION_PATCH - -```cpp -#define NLOHMANN_JSON_VERSION_MAJOR /* value */ -#define NLOHMANN_JSON_VERSION_MINOR /* value */ -#define NLOHMANN_JSON_VERSION_PATCH /* value */ -``` - -These macros are defined by the library and contain the version numbers according to -[Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html). - -## Default definition - -The macros are defined according to the current library version. - -## Examples - -??? example - - The example below shows how `NLOHMANN_JSON_VERSION_MAJOR`, `NLOHMANN_JSON_VERSION_MINOR`, and - `NLOHMANN_JSON_VERSION_PATCH` are defined by the library. - - ```cpp - --8<-- "examples/nlohmann_json_version.cpp" - ``` - - Output: - - ```json - --8<-- "examples/nlohmann_json_version.output" - ``` - -## See also - -- [meta](../basic_json/meta.md) - returns version information on the library -- [JSON_SKIP_LIBRARY_VERSION_CHECK](json_skip_library_version_check.md) - skip library version check - -## Version history - -- Added in version 3.1.0. diff --git a/docs/mkdocs/docs/api/operator_gtgt.md b/docs/mkdocs/docs/api/operator_gtgt.md deleted file mode 100644 index e76cc0db7f..0000000000 --- a/docs/mkdocs/docs/api/operator_gtgt.md +++ /dev/null @@ -1,64 +0,0 @@ -# nlohmann::operator>>(basic_json) - -```cpp -std::istream& operator>>(std::istream& i, basic_json& j); -``` - -Deserializes an input stream to a JSON value. - -## Parameters - -`i` (in, out) -: input stream to read a serialized JSON value from - -`j` (in, out) -: JSON value to write the deserialized input to - -## Return value - -the stream `i` - -## Exceptions - -- Throws [`parse_error.101`](../home/exceptions.md#jsonexceptionparse_error101) in case of an unexpected token. -- Throws [`parse_error.102`](../home/exceptions.md#jsonexceptionparse_error102) if to_unicode fails or surrogate error. -- Throws [`parse_error.103`](../home/exceptions.md#jsonexceptionparse_error103) if to_unicode fails. - -## Complexity - -Linear in the length of the input. The parser is a predictive LL(1) parser. - -## Notes - -A UTF-8 byte order mark is silently ignored. - -!!! warning "Deprecation" - - This function replaces function `#!cpp std::istream& operator<<(basic_json& j, std::istream& i)` which has - been deprecated in version 3.0.0. It will be removed in version 4.0.0. Please replace calls like `#!cpp j << i;` - with `#!cpp i >> j;`. - -## Examples - -??? example - - The example below shows how a JSON value is constructed by reading a serialization from a stream. - - ```cpp - --8<-- "examples/operator_deserialize.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator_deserialize.output" - ``` - -## See also - -- [accept](basic_json/accept.md) - check if the input is valid JSON -- [parse](basic_json/parse.md) - deserialize from a compatible input - -## Version history - -- Added in version 1.0.0. Deprecated in version 3.0.0. diff --git a/docs/mkdocs/docs/api/operator_literal_json.md b/docs/mkdocs/docs/api/operator_literal_json.md deleted file mode 100644 index cda00215c5..0000000000 --- a/docs/mkdocs/docs/api/operator_literal_json.md +++ /dev/null @@ -1,61 +0,0 @@ -# nlohmann::operator""_json - -```cpp -json operator "" _json(const char* s, std::size_t n); -``` - -This operator implements a user-defined string literal for JSON objects. It can be used by adding `#!cpp _json` to a -string literal and returns a [`json`](json.md) object if no parse error occurred. - -It is recommended to bring the operator into scope using any of the following lines: -```cpp -using nlohmann::literals::operator "" _json; -using namespace nlohmann::literals; -using namespace nlohmann::json_literals; -using namespace nlohmann::literals::json_literals; -using namespace nlohmann; -``` - -This is suggested to ease migration to the next major version release of the library. See -['JSON_USE_GLOBAL_UDLS`](macros/json_use_global_udls.md#notes) for details. - -## Parameters - -`s` (in) -: a string representation of a JSON object - -`n` (in) -: length of string `s` - -## Return value - -[`json`](json.md) value parsed from `s` - -## Exceptions - -The function can throw anything that [`parse(s, s+n)`](basic_json/parse.md) would throw. - -## Complexity - -Linear. - -## Examples - -??? example - - The following code shows how to create JSON values from string literals. - - ```cpp - --8<-- "examples/operator_literal_json.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator_literal_json.output" - ``` - -## Version history - -- Added in version 1.0.0. -- Moved to namespace `nlohmann::literals::json_literals` in 3.11.0. diff --git a/docs/mkdocs/docs/api/operator_literal_json_pointer.md b/docs/mkdocs/docs/api/operator_literal_json_pointer.md deleted file mode 100644 index 14d5378bcb..0000000000 --- a/docs/mkdocs/docs/api/operator_literal_json_pointer.md +++ /dev/null @@ -1,64 +0,0 @@ -# nlohmann::operator""_json_pointer - -```cpp -json_pointer operator "" _json_pointer(const char* s, std::size_t n); -``` - -This operator implements a user-defined string literal for JSON Pointers. It can be used by adding `#!cpp _json_pointer` -to a string literal and returns a [`json_pointer`](json_pointer/index.md) object if no parse error occurred. - -It is recommended to bring the operator into scope using any of the following lines: -```cpp -using nlohmann::literals::operator "" _json_pointer; -using namespace nlohmann::literals; -using namespace nlohmann::json_literals; -using namespace nlohmann::literals::json_literals; -using namespace nlohmann; -``` -This is suggested to ease migration to the next major version release of the library. See -['JSON_USE_GLOBAL_UDLS`](macros/json_use_global_udls.md#notes) for details. - -## Parameters - -`s` (in) -: a string representation of a JSON Pointer - -`n` (in) -: length of string `s` - -## Return value - -[`json_pointer`](json_pointer/index.md) value parsed from `s` - -## Exceptions - -The function can throw anything that [`json_pointer::json_pointer`](json_pointer/index.md) would throw. - -## Complexity - -Linear. - -## Examples - -??? example - - The following code shows how to create JSON Pointers from string literals. - - ```cpp - --8<-- "examples/operator_literal_json_pointer.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator_literal_json_pointer.output" - ``` - -## See also - -- [json_pointer](json_pointer/index.md) - type to represent JSON Pointers - -## Version history - -- Added in version 2.0.0. -- Moved to namespace `nlohmann::literals::json_literals` in 3.11.0. diff --git a/docs/mkdocs/docs/api/operator_ltlt.md b/docs/mkdocs/docs/api/operator_ltlt.md deleted file mode 100644 index 1718b3c9e8..0000000000 --- a/docs/mkdocs/docs/api/operator_ltlt.md +++ /dev/null @@ -1,87 +0,0 @@ -# nlohmann::operator<<(basic_json), nlohmann::operator<<(json_pointer) - -```cpp -std::ostream& operator<<(std::ostream& o, const basic_json& j); // (1) - -std::ostream& operator<<(std::ostream& o, const json_pointer& ptr); // (2) -``` - -1. Serialize the given JSON value `j` to the output stream `o`. The JSON value will be serialized using the - [`dump`](basic_json/dump.md) member function. - - The indentation of the output can be controlled with the member variable `width` of the output stream `o`. For - instance, using the manipulator `std::setw(4)` on `o` sets the indentation level to `4` and the serialization - result is the same as calling `dump(4)`. - - The indentation character can be controlled with the member variable `fill` of the output stream `o`. - For instance, the manipulator `std::setfill('\\t')` sets indentation to use a tab character rather than the - default space character. -2. Write a string representation of the given JSON pointer `ptr` to the output stream `o`. The string representation is - obtained using the [`to_string`](json_pointer/to_string.md) member function. - -## Parameters - -`o` (in, out) -: stream to write to - -`j` (in) -: JSON value to serialize - -`ptr` (in) -: JSON pointer to write - -## Return value - -the stream `o` - -## Exceptions - -1. Throws [`type_error.316`](../home/exceptions.md#jsonexceptiontype_error316) if a string stored inside the JSON - value is not UTF-8 encoded. Note that unlike the [`dump`](basic_json/dump.md) member functions, no `error_handler` - can be set. -2. None. - -## Complexity - -Linear. - -## Notes - -!!! warning "Deprecation" - - Function `#!cpp std::ostream& operator<<(std::ostream& o, const basic_json& j)` replaces function - `#!cpp std::ostream& operator>>(const basic_json& j, std::ostream& o)` which has been deprecated in version 3.0.0. - It will be removed in version 4.0.0. Please replace calls like `#!cpp j >> o;` with `#!cpp o << j;`. - -## Examples - -??? example "Example: (1) serialize JSON value to stream" - - The example below shows the serialization with different parameters to `width` to adjust the indentation level. - - ```cpp - --8<-- "examples/operator_ltlt__basic_json.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator_ltlt__basic_json.output" - ``` - -??? example "Example: (2) write JSON pointer to stream" - - The example below shows how to write a JSON pointer to a stream. - - ```cpp - --8<-- "examples/operator_ltlt__json_pointer.cpp" - ``` - - Output: - - ```json - --8<-- "examples/operator_ltlt__json_pointer.output" - ``` -## Version history - -1. Added in version 1.0.0. Added support for indentation character and deprecated - `#!cpp std::ostream& operator>>(const basic_json& j, std::ostream& o)` in version 3.0.0. -3. Added in version 3.11.0. diff --git a/docs/mkdocs/docs/api/ordered_json.md b/docs/mkdocs/docs/api/ordered_json.md deleted file mode 100644 index 7cfd9f4dde..0000000000 --- a/docs/mkdocs/docs/api/ordered_json.md +++ /dev/null @@ -1,32 +0,0 @@ -# nlohmann::ordered_json - -```cpp -using ordered_json = basic_json; -``` - -This type preserves the insertion order of object keys. - -## Examples - -??? example - - The example below demonstrates how `ordered_json` preserves the insertion order of object keys. - - ```cpp - --8<-- "examples/ordered_json.cpp" - ``` - - Output: - - ```json - --8<-- "examples/ordered_json.output" - ``` - -## See also - -- [ordered_map](ordered_map.md) -- [Object Order](../features/object_order.md) - -## Version history - -Since version 3.9.0. diff --git a/docs/mkdocs/docs/api/ordered_map.md b/docs/mkdocs/docs/api/ordered_map.md deleted file mode 100644 index 160b85c28b..0000000000 --- a/docs/mkdocs/docs/api/ordered_map.md +++ /dev/null @@ -1,77 +0,0 @@ -# nlohmann::ordered_map - -```cpp -template, - class Allocator = std::allocator>> -struct ordered_map : std::vector, Allocator>; -``` - -A minimal map-like container that preserves insertion order for use within [`nlohmann::ordered_json`](ordered_json.md) -(`nlohmann::basic_json`). - -## Template parameters - -`Key` -: key type - -`T` -: mapped type - -`IgnoredLess` -: comparison function (ignored and only added to ensure compatibility with `#!cpp std::map`) - -`Allocator` -: allocator type - -## Member types - -- **key_type** - key type (`Key`) -- **mapped_type** - mapped type (`T`) -- **Container** - base container type (`#!cpp std::vector, Allocator>`) -- **iterator** -- **const_iterator** -- **size_type** -- **value_type** -- **key_compare** - key comparison function -```cpp -std::equal_to // until C++14 - -std::equal_to<> // since C++14 -``` - -## Member functions - -- (constructor) -- (destructor) -- **emplace** -- **operator\[\]** -- **at** -- **erase** -- **count** -- **find** -- **insert** - -## Examples - -??? example - - The example shows the different behavior of `std::map` and `nlohmann::ordered_map`. - - ```cpp - --8<-- "examples/ordered_map.cpp" - ``` - - Output: - - ```json - --8<-- "examples/ordered_map.output" - ``` - -## See also - -- [ordered_json](ordered_json.md) - -## Version history - -- Added in version 3.9.0 to implement [`nlohmann::ordered_json`](ordered_json.md). -- Added **key_compare** member in version 3.11.0. diff --git a/docs/mkdocs/docs/css/custom.css b/docs/mkdocs/docs/css/custom.css deleted file mode 100644 index 7a1008b0bb..0000000000 --- a/docs/mkdocs/docs/css/custom.css +++ /dev/null @@ -1,4 +0,0 @@ -/* disable ligatures in code and preformatted blocks */ -code, pre { - font-variant-ligatures: none; -} diff --git a/docs/mkdocs/docs/features/arbitrary_types.md b/docs/mkdocs/docs/features/arbitrary_types.md deleted file mode 100644 index 9b54fcb3e8..0000000000 --- a/docs/mkdocs/docs/features/arbitrary_types.md +++ /dev/null @@ -1,274 +0,0 @@ -# Arbitrary Type Conversions - -Every type can be serialized in JSON, not just STL containers and scalar types. Usually, you would do something along those lines: - -```cpp -namespace ns { - // a simple struct to model a person - struct person { - std::string name; - std::string address; - int age; - }; -} // namespace ns - -ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60}; - -// convert to JSON: copy each value into the JSON object -json j; -j["name"] = p.name; -j["address"] = p.address; -j["age"] = p.age; - -// ... - -// convert from JSON: copy each value from the JSON object -ns::person p { - j["name"].template get(), - j["address"].template get(), - j["age"].template get() -}; -``` - -It works, but that's quite a lot of boilerplate... Fortunately, there's a better way: - -```cpp -// create a person -ns::person p {"Ned Flanders", "744 Evergreen Terrace", 60}; - -// conversion: person -> json -json j = p; - -std::cout << j << std::endl; -// {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"} - -// conversion: json -> person -auto p2 = j.template get(); - -// that's it -assert(p == p2); -``` - -## Basic usage - -To make this work with one of your types, you only need to provide two functions: - -```cpp -using json = nlohmann::json; - -namespace ns { - void to_json(json& j, const person& p) { - j = json{ {"name", p.name}, {"address", p.address}, {"age", p.age} }; - } - - void from_json(const json& j, person& p) { - j.at("name").get_to(p.name); - j.at("address").get_to(p.address); - j.at("age").get_to(p.age); - } -} // namespace ns -``` - -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()` 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` **MUST** be [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). (There is a way to bypass this requirement described later.) -* In function `from_json`, use function [`at()`](../api/basic_json/at.md) to access the object values rather than `operator[]`. In case a key does not exist, `at` throws an exception that you can handle, whereas `operator[]` exhibits undefined behavior. -* You do not need to add serializers or deserializers for STL types like `std::vector`: the library already implements these. - - -## Simplify your life with macros - -If you just want to serialize/deserialize some structs, the `to_json`/`from_json` functions can be a lot of boilerplate. - -There are four macros to make your life easier as long as you (1) want to use a JSON object as serialization and (2) want to use the member variable names as object keys in that object: - -- [`NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(name, member1, member2, ...)`](../api/macros/nlohmann_define_type_non_intrusive.md) is to be defined inside the namespace of the class/struct to create code for. It will throw an exception in `from_json()` due to a missing value in the JSON object. -- [`NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(name, member1, member2, ...)`](../api/macros/nlohmann_define_type_non_intrusive.md) is to be defined inside the namespace of the class/struct to create code for. It will not throw an exception in `from_json()` due to a missing value in the JSON object, but fills in values from object which is default-constructed by the type. -- [`NLOHMANN_DEFINE_TYPE_INTRUSIVE(name, member1, member2, ...)`](../api/macros/nlohmann_define_type_intrusive.md) is to be defined inside the class/struct to create code for. This macro can also access private members. It will throw an exception in `from_json()` due to a missing value in the JSON object. -- [`NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(name, member1, member2, ...)`](../api/macros/nlohmann_define_type_intrusive.md) is to be defined inside the class/struct to create code for. This macro can also access private members. It will not throw an exception in `from_json()` due to a missing value in the JSON object, but fills in values from object which is default-constructed by the type. - -In all macros, the first parameter is the name of the class/struct, and all remaining parameters name the members. You can read more docs about them starting from [here](macros.md#nlohmann_define_type_intrusivetype-member). - -!!! info "Implementation limits" - - - The current macro implementations are limited to at most 64 member variables. If you want to serialize/deserialize - types with more than 64 member variables, you need to define the `to_json`/`from_json` functions manually. - - The macros only work for the [`nlohmann::json`](../api/json.md) type; other specializations such as - [`nlohmann::ordered_json`](../api/ordered_json.md) are currently unsupported. - -??? example - - The `to_json`/`from_json` functions for the `person` struct above can be created with: - - ```cpp - namespace ns { - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(person, name, address, age) - } - ``` - - Here is an example with private members, where `NLOHMANN_DEFINE_TYPE_INTRUSIVE` is needed: - - ```cpp - namespace ns { - class address { - private: - std::string street; - int housenumber; - int postcode; - - public: - NLOHMANN_DEFINE_TYPE_INTRUSIVE(address, street, housenumber, postcode) - }; - } - ``` - -## How do I convert third-party types? - -This requires a bit more advanced technique. But first, let's see how this conversion mechanism works: - -The library uses **JSON Serializers** to convert types to json. -The default serializer for `nlohmann::json` is `nlohmann::adl_serializer` (ADL means [Argument-Dependent Lookup](https://en.cppreference.com/w/cpp/language/adl)). - -It is implemented like this (simplified): - -```cpp -template -struct adl_serializer { - static void to_json(json& j, const T& value) { - // calls the "to_json" method in T's namespace - } - - static void from_json(const json& j, T& value) { - // same thing, but with the "from_json" method - } -}; -``` - -This serializer works fine when you have control over the type's namespace. However, what about `boost::optional` or `std::filesystem::path` (C++17)? Hijacking the `boost` namespace is pretty bad, and it's illegal to add something other than template specializations to `std`... - -To solve this, you need to add a specialization of `adl_serializer` to the `nlohmann` namespace, here's an example: - -```cpp -// partial specialization (full specialization works too) -NLOHMANN_JSON_NAMESPACE_BEGIN -template -struct adl_serializer> { - static void to_json(json& j, const boost::optional& opt) { - if (opt == boost::none) { - j = nullptr; - } else { - j = *opt; // this will call adl_serializer::to_json which will - // find the free function to_json in T's namespace! - } - } - - static void from_json(const json& j, boost::optional& opt) { - if (j.is_null()) { - opt = boost::none; - } else { - opt = j.template get(); // same as above, but with - // adl_serializer::from_json - } - } -}; -NLOHMANN_JSON_NAMESPACE_END -``` - -!!! note "ABI compatibility" - - Use [`NLOHMANN_JSON_NAMESPACE_BEGIN`](../api/macros/nlohmann_json_namespace_begin.md) and `NLOHMANN_JSON_NAMESPACE_END` - instead of `#!cpp namespace nlohmann { }` in code which may be linked with different versions of this library. - -## How can I use `get()` for non-default constructible/non-copyable types? - -There is a way, if your type is [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible). You will need to specialize the `adl_serializer` as well, but with a special `from_json` overload: - -```cpp -struct move_only_type { - move_only_type() = delete; - move_only_type(int ii): i(ii) {} - move_only_type(const move_only_type&) = delete; - move_only_type(move_only_type&&) = default; - - int i; -}; - -namespace nlohmann { - template <> - struct adl_serializer { - // 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()}; - } - - // Here's the catch! You must provide a to_json method! Otherwise, you - // will not be able to convert move_only_type to json, since you fully - // specialized adl_serializer on that type - static void to_json(json& j, move_only_type t) { - j = t.i; - } - }; -} -``` - -## Can I write my own serializer? (Advanced use) - -Yes. You might want to take a look at [`unit-udt.cpp`](https://github.com/nlohmann/json/blob/develop/tests/src/unit-udt.cpp) in the test suite, to see a few examples. - -If you write your own serializer, you'll need to do a few things: - -- use a different `basic_json` alias than `nlohmann::json` (the last template parameter of `basic_json` is the `JSONSerializer`) -- use your `basic_json` alias (or a template parameter) in all your `to_json`/`from_json` methods -- use `nlohmann::to_json` and `nlohmann::from_json` when you need ADL - -Here is an example, without simplifications, that only accepts types with a size <= 32, and uses ADL. - -```cpp -// You should use void as a second template argument -// if you don't need compile-time checks on T -template::type> -struct less_than_32_serializer { - template - static void to_json(BasicJsonType& j, T value) { - // we want to use ADL, and call the correct to_json overload - using nlohmann::to_json; // this method is called by adl_serializer, - // this is where the magic happens - to_json(j, value); - } - - template - static void from_json(const BasicJsonType& j, T& value) { - // same thing here - using nlohmann::from_json; - from_json(j, value); - } -}; -``` - -Be **very** careful when reimplementing your serializer, you can stack overflow if you don't pay attention: - -```cpp -template -struct bad_serializer -{ - template - static void to_json(BasicJsonType& j, const T& value) { - // this calls BasicJsonType::json_serializer::to_json(j, value); - // if BasicJsonType::json_serializer == bad_serializer ... oops! - j = value; - } - - template - static void to_json(const BasicJsonType& j, T& value) { - // this calls BasicJsonType::json_serializer::from_json(j, value); - // if BasicJsonType::json_serializer == bad_serializer ... oops! - value = j.template template get(); // oops! - } -}; -``` diff --git a/docs/mkdocs/docs/features/assertions.md b/docs/mkdocs/docs/features/assertions.md deleted file mode 100644 index 2bad62e81d..0000000000 --- a/docs/mkdocs/docs/features/assertions.md +++ /dev/null @@ -1,131 +0,0 @@ -# Runtime Assertions - -The code contains numerous debug assertions to ensure class invariants are valid or to detect undefined behavior. -Whereas the former class invariants are nothing to be concerned of, the latter checks for undefined behavior are to -detect bugs in client code. - -## Switch off runtime assertions - -Runtime assertions can be switched off by defining the preprocessor macro `NDEBUG` (see the -[documentation of assert](https://en.cppreference.com/w/cpp/error/assert)) which is the default for release builds. - -## Change assertion behavior - -The behavior of runtime assertions can be changes by defining macro [`JSON_ASSERT(x)`](../api/macros/json_assert.md) -before including the `json.hpp` header. - -## Function with runtime assertions - -### Unchecked object access to a const value - -Function [`operator[]`](../api/basic_json/operator%5B%5D.md) implements unchecked access for objects. Whereas a missing -key is added in case of non-const objects, accessing a const object with a missing key is undefined behavior (think of a -dereferenced null pointer) and yields a runtime assertion. - -If you are not sure whether an element in an object exists, use checked access with the -[`at` function](../api/basic_json/at.md) or call the [`contains` function](../api/basic_json/contains.md) before. - -See also the documentation on [element access](element_access/index.md). - -??? example "Example 1: Missing object key" - - The following code will trigger an assertion at runtime: - - ```cpp - #include - - using json = nlohmann::json; - - int main() - { - const json j = {{"key", "value"}}; - auto v = j["missing"]; - } - ``` - - Output: - - ``` - Assertion failed: (m_value.object->find(key) != m_value.object->end()), function operator[], file json.hpp, line 2144. - ``` - -### Constructing from an uninitialized iterator range - -Constructing a JSON value from an iterator range (see [constructor](../api/basic_json/basic_json.md)) with an -uninitialized iterator is undefined behavior and yields a runtime assertion. - -??? example "Example 2: Uninitialized iterator range" - - The following code will trigger an assertion at runtime: - - ```cpp - #include - - using json = nlohmann::json; - - int main() - { - json::iterator it1, it2; - json j(it1, it2); - } - ``` - - Output: - - ``` - Assertion failed: (m_object != nullptr), function operator++, file iter_impl.hpp, line 368. - ``` - -### Operations on uninitialized iterators - -Any operation on uninitialized iterators (i.e., iterators that are not associated with any JSON value) is undefined -behavior and yields a runtime assertion. - -??? example "Example 3: Uninitialized iterator" - - The following code will trigger an assertion at runtime: - - ```cpp - #include - - using json = nlohmann::json; - - int main() - { - json::iterator it; - ++it; - } - ``` - - Output: - - ``` - Assertion failed: (m_object != nullptr), function operator++, file iter_impl.hpp, line 368. - ``` - -### Reading from a null `FILE` pointer - -Reading from a null `#!cpp FILE` pointer is undefined behavior and yields a runtime assertion. This can happen when -calling `#!cpp std::fopen` on a nonexistent file. - -??? example "Example 4: Uninitialized iterator" - - The following code will trigger an assertion at runtime: - - ```cpp - #include - - using json = nlohmann::json; - - int main() - { - std::FILE* f = std::fopen("nonexistent_file.json", "r"); - json j = json::parse(f); - } - ``` - - Output: - - ``` - Assertion failed: (m_file != nullptr), function file_input_adapter, file input_adapters.hpp, line 55. - ``` diff --git a/docs/mkdocs/docs/features/binary_formats/bjdata.md b/docs/mkdocs/docs/features/binary_formats/bjdata.md deleted file mode 100644 index a89a228858..0000000000 --- a/docs/mkdocs/docs/features/binary_formats/bjdata.md +++ /dev/null @@ -1,194 +0,0 @@ -# BJData - -The [BJData format](https://neurojson.org) was derived from and improved upon -[Universal Binary JSON(UBJSON)](https://ubjson.org) specification (Draft 12). Specifically, it introduces an optimized -array container for efficient storage of N-dimensional packed arrays (**ND-arrays**); it also adds 4 new type markers - -`[u] - uint16`, `[m] - uint32`, `[M] - uint64` and `[h] - float16` - to unambiguously map common binary numeric types; -furthermore, it uses little-endian (LE) to store all numerics instead of big-endian (BE) as in UBJSON to avoid -unnecessary conversions on commonly available platforms. - -Compared to other binary JSON-like formats such as MessagePack and CBOR, both BJData and UBJSON demonstrate a rare -combination of being both binary and **quasi-human-readable**. This is because all semantic elements in BJData and -UBJSON, including the data-type markers and name/string types are directly human-readable. Data stored in the -BJData/UBJSON format are not only compact in size, fast to read/write, but also can be directly searched or read using -simple processing. - -!!! abstract "References" - - - [BJData Specification](https://neurojson.org/bjdata/draft2) - -## Serialization - -The library uses the following mapping from JSON values types to BJData types according to the BJData specification: - -| JSON value type | value/range | BJData type | marker | -|-----------------|-------------------------------------------|----------------|--------| -| null | `null` | null | `Z` | -| boolean | `true` | true | `T` | -| boolean | `false` | false | `F` | -| number_integer | -9223372036854775808..-2147483649 | int64 | `L` | -| number_integer | -2147483648..-32769 | int32 | `l` | -| number_integer | -32768..-129 | int16 | `I` | -| number_integer | -128..127 | int8 | `i` | -| number_integer | 128..255 | uint8 | `U` | -| number_integer | 256..32767 | int16 | `I` | -| number_integer | 32768..65535 | uint16 | `u` | -| number_integer | 65536..2147483647 | int32 | `l` | -| number_integer | 2147483648..4294967295 | uint32 | `m` | -| number_integer | 4294967296..9223372036854775807 | int64 | `L` | -| number_integer | 9223372036854775808..18446744073709551615 | uint64 | `M` | -| number_unsigned | 0..127 | int8 | `i` | -| number_unsigned | 128..255 | uint8 | `U` | -| number_unsigned | 256..32767 | int16 | `I` | -| number_unsigned | 32768..65535 | uint16 | `u` | -| number_unsigned | 65536..2147483647 | int32 | `l` | -| number_unsigned | 2147483648..4294967295 | uint32 | `m` | -| number_unsigned | 4294967296..9223372036854775807 | int64 | `L` | -| number_unsigned | 9223372036854775808..18446744073709551615 | uint64 | `M` | -| number_float | *any value* | float64 | `D` | -| string | *with shortest length indicator* | string | `S` | -| array | *see notes on optimized format/ND-array* | array | `[` | -| object | *see notes on optimized format* | map | `{` | - -!!! success "Complete mapping" - - The mapping is **complete** in the sense that any JSON value type can be converted to a BJData value. - - Any BJData output created by `to_bjdata` can be successfully parsed by `from_bjdata`. - -!!! warning "Size constraints" - - The following values can **not** be converted to a BJData value: - - - strings with more than 18446744073709551615 bytes, i.e., $2^{64}-1$ bytes (theoretical) - -!!! info "Unused BJData markers" - - The following markers are not used in the conversion: - - - `Z`: no-op values are not created. - - `C`: single-byte strings are serialized with `S` markers. - -!!! info "NaN/infinity handling" - - If NaN or Infinity are stored inside a JSON number, they are serialized properly. This behavior differs from the - `dump()` function which serializes NaN or Infinity to `#!json null`. - -!!! info "Endianness" - - A breaking difference between BJData and UBJSON is the endianness of numerical values. In BJData, all numerical data - types (integers `UiuImlML` and floating-point values `hdD`) are stored in the little-endian (LE) byte order as - opposed to big-endian as used by UBJSON. Adopting LE to store numeric records avoids unnecessary byte swapping on - most modern computers where LE is used as the default byte order. - -!!! info "Optimized formats" - - Optimized formats for containers are supported via two parameters of - [`to_bjdata`](../../api/basic_json/to_bjdata.md): - - - Parameter `use_size` adds size information to the beginning of a container and removes the closing marker. - - Parameter `use_type` further checks whether all elements of a container have the same type and adds the type - marker to the beginning of the container. The `use_type` parameter must only be used together with - `use_size = true`. - - Note that `use_size = true` alone may result in larger representations - the benefit of this parameter is that the - receiving side is immediately informed of the number of elements in the container. - -!!! info "ND-array optimized format" - - BJData extends UBJSON's optimized array **size** marker to support ND-arrays of uniform numerical data types - (referred to as *packed arrays*). For example, the 2-D `uint8` integer array `[[1,2],[3,4],[5,6]]`, stored as nested - optimized array in UBJSON `[ [$U#i2 1 2 [$U#i2 3 4 [$U#i2 5 6 ]`, can be further compressed in BJData to - `[$U#[$i#i2 2 3 1 2 3 4 5 6` or `[$U#[i2 i3] 1 2 3 4 5 6`. - - To maintain type and size information, ND-arrays are converted to JSON objects following the **annotated array - format** (defined in the [JData specification (Draft 3)][JDataAAFmt]), when parsed using - [`from_bjdata`](../../api/basic_json/from_bjdata.md). For example, the above 2-D `uint8` array can be parsed and - accessed as - - ```json - { - "_ArrayType_": "uint8", - "_ArraySize_": [2,3], - "_ArrayData_": [1,2,3,4,5,6] - } - ``` - - Likewise, when a JSON object in the above form is serialzed using - [`to_bjdata`](../../api/basic_json/to_bjdata.md), it is automatically converted into a compact BJData ND-array. The - only exception is, that when the 1-dimensional vector stored in `"_ArraySize_"` contains a single integer or two - integers with one being 1, a regular 1-D optimized array is generated. - - The current version of this library does not yet support automatic detection of and conversion from a nested JSON - array input to a BJData ND-array. - - [JDataAAFmt]: https://github.com/NeuroJSON/jdata/blob/master/JData_specification.md#annotated-storage-of-n-d-arrays) - -!!! info "Restrictions in optimized data types for arrays and objects" - - Due to diminished space saving, hampered readability, and increased security risks, in BJData, the allowed data - types following the `$` marker in an optimized array and object container are restricted to - **non-zero-fixed-length** data types. Therefore, the valid optimized type markers can only be one of `UiuImlMLhdDC`. - This also means other variable (`[{SH`) or zero-length types (`TFN`) can not be used in an optimized array or object - in BJData. - -!!! info "Binary values" - - If the JSON data contains the binary type, the value stored is a list of integers, as suggested by the BJData - documentation. In particular, this means that the serialization and the deserialization of JSON containing binary - values into BJData and back will result in a different JSON object. - -??? example - - ```cpp - --8<-- "examples/to_bjdata.cpp" - ``` - - Output: - - ```c - --8<-- "examples/to_bjdata.output" - ``` - -## Deserialization - -The library maps BJData types to JSON value types as follows: - -| BJData type | JSON value type | marker | -|-------------|-----------------------------------------|--------| -| no-op | *no value, next value is read* | `N` | -| null | `null` | `Z` | -| false | `false` | `F` | -| true | `true` | `T` | -| float16 | number_float | `h` | -| float32 | number_float | `d` | -| float64 | number_float | `D` | -| uint8 | number_unsigned | `U` | -| int8 | number_integer | `i` | -| uint16 | number_unsigned | `u` | -| int16 | number_integer | `I` | -| uint32 | number_unsigned | `m` | -| int32 | number_integer | `l` | -| uint64 | number_unsigned | `M` | -| int64 | number_integer | `L` | -| string | string | `S` | -| char | string | `C` | -| array | array (optimized values are supported) | `[` | -| ND-array | object (in JData annotated array format)|`[$.#[.`| -| object | object (optimized values are supported) | `{` | - -!!! success "Complete mapping" - - The mapping is **complete** in the sense that any BJData value can be converted to a JSON value. - -??? example - - ```cpp - --8<-- "examples/from_bjdata.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_bjdata.output" - ``` diff --git a/docs/mkdocs/docs/features/binary_formats/bson.md b/docs/mkdocs/docs/features/binary_formats/bson.md deleted file mode 100644 index f3b8cf18d0..0000000000 --- a/docs/mkdocs/docs/features/binary_formats/bson.md +++ /dev/null @@ -1,96 +0,0 @@ -# BSON - -BSON, short for Binary JSON, is a binary-encoded serialization of JSON-like documents. Like JSON, BSON supports the -embedding of documents and arrays within other documents and arrays. BSON also contains extensions that allow -representation of data types that are not part of the JSON spec. For example, BSON has a Date type and a BinData type. - -!!! abstract "References" - - - [BSON Website](http://bsonspec.org) - the main source on BSON - - [BSON Specification](http://bsonspec.org/spec.html) - the specification - - -## Serialization - -The library uses the following mapping from JSON values types to BSON types: - -| JSON value type | value/range | BSON type | marker | -|-----------------|-------------------------------------------|-----------|--------| -| null | `null` | null | 0x0A | -| boolean | `true`, `false` | boolean | 0x08 | -| number_integer | -9223372036854775808..-2147483649 | int64 | 0x12 | -| number_integer | -2147483648..2147483647 | int32 | 0x10 | -| number_integer | 2147483648..9223372036854775807 | int64 | 0x12 | -| number_unsigned | 0..2147483647 | int32 | 0x10 | -| number_unsigned | 2147483648..9223372036854775807 | int64 | 0x12 | -| number_unsigned | 9223372036854775808..18446744073709551615 | -- | -- | -| number_float | *any value* | double | 0x01 | -| string | *any value* | string | 0x02 | -| array | *any value* | document | 0x04 | -| object | *any value* | document | 0x03 | -| binary | *any value* | binary | 0x05 | - -!!! warning "Incomplete mapping" - - The mapping is **incomplete**, since only JSON-objects (and things - contained therein) can be serialized to BSON. - Also, integers larger than 9223372036854775807 cannot be serialized to BSON, - and the keys may not contain U+0000, since they are serialized a - zero-terminated c-strings. - -??? example - - ```cpp - --8<-- "examples/to_bson.cpp" - ``` - - Output: - - ```c - --8<-- "examples/to_bson.output" - ``` - - -## Deserialization - -The library maps BSON record types to JSON value types as follows: - -| BSON type | BSON marker byte | JSON value type | -|-----------------------|------------------|-----------------| -| double | 0x01 | number_float | -| string | 0x02 | string | -| document | 0x03 | object | -| array | 0x04 | array | -| binary | 0x05 | binary | -| undefined | 0x06 | *unsupported* | -| ObjectId | 0x07 | *unsupported* | -| boolean | 0x08 | boolean | -| UTC Date-Time | 0x09 | *unsupported* | -| null | 0x0A | null | -| Regular Expr. | 0x0B | *unsupported* | -| DB Pointer | 0x0C | *unsupported* | -| JavaScript Code | 0x0D | *unsupported* | -| Symbol | 0x0E | *unsupported* | -| JavaScript Code | 0x0F | *unsupported* | -| int32 | 0x10 | number_integer | -| Timestamp | 0x11 | *unsupported* | -| 128-bit decimal float | 0x13 | *unsupported* | -| Max Key | 0x7F | *unsupported* | -| Min Key | 0xFF | *unsupported* | - -!!! warning "Incomplete mapping" - - The mapping is **incomplete**. The unsupported mappings are indicated in the table above. - - -??? example - - ```cpp - --8<-- "examples/from_bson.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_bson.output" - ``` diff --git a/docs/mkdocs/docs/features/binary_formats/cbor.md b/docs/mkdocs/docs/features/binary_formats/cbor.md deleted file mode 100644 index 2d0a1dae10..0000000000 --- a/docs/mkdocs/docs/features/binary_formats/cbor.md +++ /dev/null @@ -1,181 +0,0 @@ -# CBOR - -The Concise Binary Object Representation (CBOR) is a data format whose design goals include the possibility of extremely -small code size, fairly small message size, and extensibility without the need for version negotiation. - -!!! abstract "References" - - - [CBOR Website](http://cbor.io) - the main source on CBOR - - [CBOR Playground](http://cbor.me) - an interactive webpage to translate between JSON and CBOR - - [RFC 7049](https://tools.ietf.org/html/rfc7049) - the CBOR specification - -## Serialization - -The library uses the following mapping from JSON values types to CBOR types according to the CBOR specification -([RFC 7049](https://www.rfc-editor.org/rfc/rfc7049.html)): - -| JSON value type | value/range | CBOR type | first byte | -|-----------------|--------------------------------------------|-----------------------------------|------------| -| null | `null` | Null | 0xF6 | -| boolean | `true` | True | 0xF5 | -| boolean | `false` | False | 0xF4 | -| number_integer | -9223372036854775808..-2147483649 | Negative integer (8 bytes follow) | 0x3B | -| number_integer | -2147483648..-32769 | Negative integer (4 bytes follow) | 0x3A | -| number_integer | -32768..-129 | Negative integer (2 bytes follow) | 0x39 | -| number_integer | -128..-25 | Negative integer (1 byte follow) | 0x38 | -| number_integer | -24..-1 | Negative integer | 0x20..0x37 | -| number_integer | 0..23 | Integer | 0x00..0x17 | -| number_integer | 24..255 | Unsigned integer (1 byte follow) | 0x18 | -| number_integer | 256..65535 | Unsigned integer (2 bytes follow) | 0x19 | -| number_integer | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A | -| number_integer | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B | -| number_unsigned | 0..23 | Integer | 0x00..0x17 | -| number_unsigned | 24..255 | Unsigned integer (1 byte follow) | 0x18 | -| number_unsigned | 256..65535 | Unsigned integer (2 bytes follow) | 0x19 | -| number_unsigned | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A | -| number_unsigned | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B | -| number_float | *any value representable by a float* | Single-Precision Float | 0xFA | -| number_float | *any value NOT representable by a float* | Double-Precision Float | 0xFB | -| string | *length*: 0..23 | UTF-8 string | 0x60..0x77 | -| string | *length*: 23..255 | UTF-8 string (1 byte follow) | 0x78 | -| string | *length*: 256..65535 | UTF-8 string (2 bytes follow) | 0x79 | -| string | *length*: 65536..4294967295 | UTF-8 string (4 bytes follow) | 0x7A | -| string | *length*: 4294967296..18446744073709551615 | UTF-8 string (8 bytes follow) | 0x7B | -| array | *size*: 0..23 | array | 0x80..0x97 | -| array | *size*: 23..255 | array (1 byte follow) | 0x98 | -| array | *size*: 256..65535 | array (2 bytes follow) | 0x99 | -| array | *size*: 65536..4294967295 | array (4 bytes follow) | 0x9A | -| array | *size*: 4294967296..18446744073709551615 | array (8 bytes follow) | 0x9B | -| object | *size*: 0..23 | map | 0xA0..0xB7 | -| object | *size*: 23..255 | map (1 byte follow) | 0xB8 | -| object | *size*: 256..65535 | map (2 bytes follow) | 0xB9 | -| object | *size*: 65536..4294967295 | map (4 bytes follow) | 0xBA | -| object | *size*: 4294967296..18446744073709551615 | map (8 bytes follow) | 0xBB | -| binary | *size*: 0..23 | byte string | 0x40..0x57 | -| binary | *size*: 23..255 | byte string (1 byte follow) | 0x58 | -| binary | *size*: 256..65535 | byte string (2 bytes follow) | 0x59 | -| binary | *size*: 65536..4294967295 | byte string (4 bytes follow) | 0x5A | -| binary | *size*: 4294967296..18446744073709551615 | byte string (8 bytes follow) | 0x5B | - -Binary values with subtype are mapped to tagged values (0xD8..0xDB) depending on the subtype, followed by a byte string, -see "binary" cells in the table above. - -!!! success "Complete mapping" - - The mapping is **complete** in the sense that any JSON value type can be converted to a CBOR value. - -!!! info "NaN/infinity handling" - - If NaN or Infinity are stored inside a JSON number, they are serialized properly. This behavior differs from the normal JSON serialization which serializes NaN or Infinity to `null`. - -!!! info "Unused CBOR types" - - The following CBOR types are not used in the conversion: - - - UTF-8 strings terminated by "break" (0x7F) - - arrays terminated by "break" (0x9F) - - maps terminated by "break" (0xBF) - - byte strings terminated by "break" (0x5F) - - date/time (0xC0..0xC1) - - bignum (0xC2..0xC3) - - decimal fraction (0xC4) - - bigfloat (0xC5) - - expected conversions (0xD5..0xD7) - - simple values (0xE0..0xF3, 0xF8) - - undefined (0xF7) - - half-precision floats (0xF9) - - break (0xFF) - -!!! info "Tagged items" - - Binary subtypes will be serialized as tagged items. See [binary values](../binary_values.md#cbor) for an example. - -??? example - - ```cpp - --8<-- "examples/to_cbor.cpp" - ``` - - Output: - - ```c - --8<-- "examples/to_cbor.output" - ``` - -## Deserialization - -The library maps CBOR types to JSON value types as follows: - -| CBOR type | JSON value type | first byte | -|------------------------|-----------------|------------| -| Integer | number_unsigned | 0x00..0x17 | -| Unsigned integer | number_unsigned | 0x18 | -| Unsigned integer | number_unsigned | 0x19 | -| Unsigned integer | number_unsigned | 0x1A | -| Unsigned integer | number_unsigned | 0x1B | -| Negative integer | number_integer | 0x20..0x37 | -| Negative integer | number_integer | 0x38 | -| Negative integer | number_integer | 0x39 | -| Negative integer | number_integer | 0x3A | -| Negative integer | number_integer | 0x3B | -| Byte string | binary | 0x40..0x57 | -| Byte string | binary | 0x58 | -| Byte string | binary | 0x59 | -| Byte string | binary | 0x5A | -| Byte string | binary | 0x5B | -| UTF-8 string | string | 0x60..0x77 | -| UTF-8 string | string | 0x78 | -| UTF-8 string | string | 0x79 | -| UTF-8 string | string | 0x7A | -| UTF-8 string | string | 0x7B | -| UTF-8 string | string | 0x7F | -| array | array | 0x80..0x97 | -| array | array | 0x98 | -| array | array | 0x99 | -| array | array | 0x9A | -| array | array | 0x9B | -| array | array | 0x9F | -| map | object | 0xA0..0xB7 | -| map | object | 0xB8 | -| map | object | 0xB9 | -| map | object | 0xBA | -| map | object | 0xBB | -| map | object | 0xBF | -| False | `false` | 0xF4 | -| True | `true` | 0xF5 | -| Null | `null` | 0xF6 | -| Half-Precision Float | number_float | 0xF9 | -| Single-Precision Float | number_float | 0xFA | -| Double-Precision Float | number_float | 0xFB | - -!!! warning "Incomplete mapping" - - The mapping is **incomplete** in the sense that not all CBOR types can be converted to a JSON value. The following CBOR types are not supported and will yield parse errors: - - - date/time (0xC0..0xC1) - - bignum (0xC2..0xC3) - - decimal fraction (0xC4) - - bigfloat (0xC5) - - expected conversions (0xD5..0xD7) - - simple values (0xE0..0xF3, 0xF8) - - undefined (0xF7) - -!!! warning "Object keys" - - CBOR allows map keys of any type, whereas JSON only allows strings as keys in object values. Therefore, CBOR maps with keys other than UTF-8 strings are rejected. - -!!! warning "Tagged items" - - Tagged items will throw a parse error by default. They can be ignored by passing `cbor_tag_handler_t::ignore` to function `from_cbor`. They can be stored by passing `cbor_tag_handler_t::store` to function `from_cbor`. - -??? example - - ```cpp - --8<-- "examples/from_cbor.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_cbor.output" - ``` diff --git a/docs/mkdocs/docs/features/binary_formats/index.md b/docs/mkdocs/docs/features/binary_formats/index.md deleted file mode 100644 index e74290b097..0000000000 --- a/docs/mkdocs/docs/features/binary_formats/index.md +++ /dev/null @@ -1,52 +0,0 @@ -# Binary Formats - -Though JSON is a ubiquitous data format, it is not a very compact format suitable for data exchange, for instance over -a network. Hence, the library supports - -- [BJData](bjdata.md) (Binary JData), -- [BSON](bson.md) (Binary JSON), -- [CBOR](cbor.md) (Concise Binary Object Representation), -- [MessagePack](messagepack.md), and -- [UBJSON](ubjson.md) (Universal Binary JSON) - -to efficiently encode JSON values to byte vectors and to decode such vectors. - -## Comparison - -### Completeness - -| Format | Serialization | Deserialization | -|-------------|-----------------------------------------------|----------------------------------------------| -| BJData | complete | complete | -| BSON | incomplete: top-level value must be an object | incomplete, but all JSON types are supported | -| CBOR | complete | incomplete, but all JSON types are supported | -| MessagePack | complete | complete | -| UBJSON | complete | complete | - -### Binary values - -| Format | Binary values | Binary subtypes | -|-------------|---------------|-----------------| -| BJData | not supported | not supported | -| BSON | supported | supported | -| CBOR | supported | supported | -| MessagePack | supported | supported | -| UBJSON | not supported | not supported | - -See [binary values](../binary_values.md) for more information. - -### Sizes - -| Format | canada.json | twitter.json | citm_catalog.json | jeopardy.json | -|--------------------|-------------|--------------|-------------------|---------------| -| BJData | 53.2 % | 91.1 % | 78.1 % | 96.6 % | -| BJData (size) | 58.6 % | 92.1 % | 86.7 % | 97.4 % | -| BJData (size+tyoe) | 58.6 % | 92.1 % | 86.5 % | 97.4 % | -| BSON | 85.8 % | 95.2 % | 95.8 % | 106.7 % | -| CBOR | 50.5 % | 86.3 % | 68.4 % | 88.0 % | -| MessagePack | 50.5 % | 86.0 % | 68.5 % | 87.9 % | -| UBJSON | 53.2 % | 91.3 % | 78.2 % | 96.6 % | -| UBJSON (size) | 58.6 % | 92.3 % | 86.8 % | 97.4 % | -| UBJSON (size+type) | 55.9 % | 92.3 % | 85.0 % | 95.0 % | - -Sizes compared to minified JSON value. diff --git a/docs/mkdocs/docs/features/binary_formats/messagepack.md b/docs/mkdocs/docs/features/binary_formats/messagepack.md deleted file mode 100644 index b2f69f174d..0000000000 --- a/docs/mkdocs/docs/features/binary_formats/messagepack.md +++ /dev/null @@ -1,143 +0,0 @@ -# MessagePack - -MessagePack is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON. -But it's faster and smaller. Small integers are encoded into a single byte, and typical short strings require only one -extra byte in addition to the strings themselves. - -!!! abstract "References" - - - [MessagePack website](https://msgpack.org) - - [MessagePack specification](https://github.com/msgpack/msgpack/blob/master/spec.md) - -## Serialization - -The library uses the following mapping from JSON values types to MessagePack types according to the MessagePack -specification: - -| JSON value type | value/range | MessagePack type | first byte | -|-----------------|------------------------------------------|------------------|------------| -| null | `null` | nil | 0xC0 | -| boolean | `true` | true | 0xC3 | -| boolean | `false` | false | 0xC2 | -| number_integer | -9223372036854775808..-2147483649 | int64 | 0xD3 | -| number_integer | -2147483648..-32769 | int32 | 0xD2 | -| number_integer | -32768..-129 | int16 | 0xD1 | -| number_integer | -128..-33 | int8 | 0xD0 | -| number_integer | -32..-1 | negative fixint | 0xE0..0xFF | -| number_integer | 0..127 | positive fixint | 0x00..0x7F | -| number_integer | 128..255 | uint 8 | 0xCC | -| number_integer | 256..65535 | uint 16 | 0xCD | -| number_integer | 65536..4294967295 | uint 32 | 0xCE | -| number_integer | 4294967296..18446744073709551615 | uint 64 | 0xCF | -| number_unsigned | 0..127 | positive fixint | 0x00..0x7F | -| number_unsigned | 128..255 | uint 8 | 0xCC | -| number_unsigned | 256..65535 | uint 16 | 0xCD | -| number_unsigned | 65536..4294967295 | uint 32 | 0xCE | -| number_unsigned | 4294967296..18446744073709551615 | uint 64 | 0xCF | -| number_float | *any value representable by a float* | float 32 | 0xCA | -| number_float | *any value NOT representable by a float* | float 64 | 0xCB | -| string | *length*: 0..31 | fixstr | 0xA0..0xBF | -| string | *length*: 32..255 | str 8 | 0xD9 | -| string | *length*: 256..65535 | str 16 | 0xDA | -| string | *length*: 65536..4294967295 | str 32 | 0xDB | -| array | *size*: 0..15 | fixarray | 0x90..0x9F | -| array | *size*: 16..65535 | array 16 | 0xDC | -| array | *size*: 65536..4294967295 | array 32 | 0xDD | -| object | *size*: 0..15 | fix map | 0x80..0x8F | -| object | *size*: 16..65535 | map 16 | 0xDE | -| object | *size*: 65536..4294967295 | map 32 | 0xDF | -| binary | *size*: 0..255 | bin 8 | 0xC4 | -| binary | *size*: 256..65535 | bin 16 | 0xC5 | -| binary | *size*: 65536..4294967295 | bin 32 | 0xC6 | - -!!! success "Complete mapping" - - The mapping is **complete** in the sense that any JSON value type can be converted to a MessagePack value. - - Any MessagePack output created by `to_msgpack` can be successfully parsed by `from_msgpack`. - -!!! warning "Size constraints" - - The following values can **not** be converted to a MessagePack value: - - - strings with more than 4294967295 bytes - - byte strings with more than 4294967295 bytes - - arrays with more than 4294967295 elements - - objects with more than 4294967295 elements - -!!! info "NaN/infinity handling" - - If NaN or Infinity are stored inside a JSON number, they are serialized properly in contrast to the - [dump](../../api/basic_json/dump.md) function which serializes NaN or Infinity to `null`. - -??? example - - ```cpp - --8<-- "examples/to_msgpack.cpp" - ``` - - Output: - - ```c - --8<-- "examples/to_msgpack.output" - ``` - -## Deserialization - -The library maps MessagePack types to JSON value types as follows: - -| MessagePack type | JSON value type | first byte | -|------------------|-----------------|------------| -| positive fixint | number_unsigned | 0x00..0x7F | -| fixmap | object | 0x80..0x8F | -| fixarray | array | 0x90..0x9F | -| fixstr | string | 0xA0..0xBF | -| nil | `null` | 0xC0 | -| false | `false` | 0xC2 | -| true | `true` | 0xC3 | -| float 32 | number_float | 0xCA | -| float 64 | number_float | 0xCB | -| uint 8 | number_unsigned | 0xCC | -| uint 16 | number_unsigned | 0xCD | -| uint 32 | number_unsigned | 0xCE | -| uint 64 | number_unsigned | 0xCF | -| int 8 | number_integer | 0xD0 | -| int 16 | number_integer | 0xD1 | -| int 32 | number_integer | 0xD2 | -| int 64 | number_integer | 0xD3 | -| str 8 | string | 0xD9 | -| str 16 | string | 0xDA | -| str 32 | string | 0xDB | -| array 16 | array | 0xDC | -| array 32 | array | 0xDD | -| map 16 | object | 0xDE | -| map 32 | object | 0xDF | -| bin 8 | binary | 0xC4 | -| bin 16 | binary | 0xC5 | -| bin 32 | binary | 0xC6 | -| ext 8 | binary | 0xC7 | -| ext 16 | binary | 0xC8 | -| ext 32 | binary | 0xC9 | -| fixext 1 | binary | 0xD4 | -| fixext 2 | binary | 0xD5 | -| fixext 4 | binary | 0xD6 | -| fixext 8 | binary | 0xD7 | -| fixext 16 | binary | 0xD8 | -| negative fixint | number_integer | 0xE0-0xFF | - -!!! info - - Any MessagePack output created by `to_msgpack` can be successfully parsed by `from_msgpack`. - - -??? example - - ```cpp - --8<-- "examples/from_msgpack.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_msgpack.output" - ``` diff --git a/docs/mkdocs/docs/features/binary_formats/ubjson.md b/docs/mkdocs/docs/features/binary_formats/ubjson.md deleted file mode 100644 index 76956d60a7..0000000000 --- a/docs/mkdocs/docs/features/binary_formats/ubjson.md +++ /dev/null @@ -1,126 +0,0 @@ -# UBJSON - -Universal Binary JSON (UBJSON) is a binary form directly imitating JSON, but requiring fewer bytes of data. It aims to -achieve the generality of JSON, combined with being much easier to process than JSON. - -!!! abstract "References" - - - [UBJSON Website](http://ubjson.org) - -## Serialization - -The library uses the following mapping from JSON values types to UBJSON types according to the UBJSON specification: - -| JSON value type | value/range | UBJSON type | marker | -|-----------------|-----------------------------------|----------------|--------| -| null | `null` | null | `Z` | -| boolean | `true` | true | `T` | -| boolean | `false` | false | `F` | -| number_integer | -9223372036854775808..-2147483649 | int64 | `L` | -| number_integer | -2147483648..-32769 | int32 | `l` | -| number_integer | -32768..-129 | int16 | `I` | -| number_integer | -128..127 | int8 | `i` | -| number_integer | 128..255 | uint8 | `U` | -| number_integer | 256..32767 | int16 | `I` | -| number_integer | 32768..2147483647 | int32 | `l` | -| number_integer | 2147483648..9223372036854775807 | int64 | `L` | -| number_unsigned | 0..127 | int8 | `i` | -| number_unsigned | 128..255 | uint8 | `U` | -| number_unsigned | 256..32767 | int16 | `I` | -| number_unsigned | 32768..2147483647 | int32 | `l` | -| number_unsigned | 2147483648..9223372036854775807 | int64 | `L` | -| number_unsigned | 2147483649..18446744073709551615 | high-precision | `H` | -| number_float | *any value* | float64 | `D` | -| string | *with shortest length indicator* | string | `S` | -| array | *see notes on optimized format* | array | `[` | -| object | *see notes on optimized format* | map | `{` | - -!!! success "Complete mapping" - - The mapping is **complete** in the sense that any JSON value type can be converted to a UBJSON value. - - Any UBJSON output created by `to_ubjson` can be successfully parsed by `from_ubjson`. - -!!! warning "Size constraints" - - The following values can **not** be converted to a UBJSON value: - - - strings with more than 9223372036854775807 bytes (theoretical) - -!!! info "Unused UBJSON markers" - - The following markers are not used in the conversion: - - - `Z`: no-op values are not created. - - `C`: single-byte strings are serialized with `S` markers. - -!!! info "NaN/infinity handling" - - If NaN or Infinity are stored inside a JSON number, they are serialized properly. This behavior differs from the - `dump()` function which serializes NaN or Infinity to `null`. - -!!! info "Optimized formats" - - The optimized formats for containers are supported: Parameter `use_size` adds size information to the beginning of a - container and removes the closing marker. Parameter `use_type` further checks whether all elements of a container - have the same type and adds the type marker to the beginning of the container. The `use_type` parameter must only be - used together with `use_size = true`. - - Note that `use_size = true` alone may result in larger representations - the benefit of this parameter is that the - receiving side is immediately informed on the number of elements of the container. - -!!! info "Binary values" - - If the JSON data contains the binary type, the value stored is a list of integers, as suggested by the UBJSON - documentation. In particular, this means that serialization and the deserialization of a JSON containing binary - values into UBJSON and back will result in a different JSON object. - -??? example - - ```cpp - --8<-- "examples/to_ubjson.cpp" - ``` - - Output: - - ```c - --8<-- "examples/to_ubjson.output" - ``` - -## Deserialization - -The library maps UBJSON types to JSON value types as follows: - -| UBJSON type | JSON value type | marker | -|-------------|-----------------------------------------|--------| -| no-op | *no value, next value is read* | `N` | -| null | `null` | `Z` | -| false | `false` | `F` | -| true | `true` | `T` | -| float32 | number_float | `d` | -| float64 | number_float | `D` | -| uint8 | number_unsigned | `U` | -| int8 | number_integer | `i` | -| int16 | number_integer | `I` | -| int32 | number_integer | `l` | -| int64 | number_integer | `L` | -| string | string | `S` | -| char | string | `C` | -| array | array (optimized values are supported) | `[` | -| object | object (optimized values are supported) | `{` | - -!!! success "Complete mapping" - - The mapping is **complete** in the sense that any UBJSON value can be converted to a JSON value. - -??? example - - ```cpp - --8<-- "examples/from_ubjson.cpp" - ``` - - Output: - - ```json - --8<-- "examples/from_ubjson.output" - ``` diff --git a/docs/mkdocs/docs/features/binary_values.md b/docs/mkdocs/docs/features/binary_values.md deleted file mode 100644 index 5ad6433cff..0000000000 --- a/docs/mkdocs/docs/features/binary_values.md +++ /dev/null @@ -1,372 +0,0 @@ -# Binary Values - -The library implements several [binary formats](binary_formats/index.md) that encode JSON in an efficient way. Most of -these formats support binary values; that is, values that have semantics define outside the library and only define a -sequence of bytes to be stored. - -JSON itself does not have a binary value. As such, binary values are an extension that this library implements to store -values received by a binary format. Binary values are never created by the JSON parser, and are only part of a -serialized JSON text if they have been created manually or via a binary format. - -## API for binary values - -```plantuml -class json::binary_t { - -- setters -- - +void set_subtype(std::uint64_t subtype) - +void clear_subtype() - -- getters -- - +std::uint64_t subtype() const - +bool has_subtype() const -} - -"std::vector" <|-- json::binary_t -``` - -By default, binary values are stored as `std::vector`. This type can be changed by providing a template -parameter to the `basic_json` type. To store binary subtypes, the storage type is extended and exposed as -`json::binary_t`: - -```cpp -auto binary = json::binary_t({0xCA, 0xFE, 0xBA, 0xBE}); -auto binary_with_subtype = json::binary_t({0xCA, 0xFE, 0xBA, 0xBE}, 42); -``` - -There are several convenience functions to check and set the subtype: - -```cpp -binary.has_subtype(); // returns false -binary_with_subtype.has_subtype(); // returns true - -binary_with_subtype.clear_subtype(); -binary_with_subtype.has_subtype(); // returns true - -binary_with_subtype.set_subtype(42); -binary.set_subtype(23); - -binary.subtype(); // returns 23 -``` - -As `json::binary_t` is subclassing `std::vector`, all member functions are available: - -```cpp -binary.size(); // returns 4 -binary[1]; // returns 0xFE -``` - -JSON values can be constructed from `json::binary_t`: - -```cpp -json j = binary; -``` - -Binary values are primitive values just like numbers or strings: - -```cpp -j.is_binary(); // returns true -j.is_primitive(); // returns true -``` - -Given a binary JSON value, the `binary_t` can be accessed by reference as via `get_binary()`: - -```cpp -j.get_binary().has_subtype(); // returns true -j.get_binary().size(); // returns 4 -``` - -For convenience, binary JSON values can be constructed via `json::binary`: - -```cpp -auto j2 = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 23); -auto j3 = json::binary({0xCA, 0xFE, 0xBA, 0xBE}); - -j2 == j; // returns true -j3.get_binary().has_subtype(); // returns false -j3.get_binary().subtype(); // returns std::uint64_t(-1) as j3 has no subtype -``` - - - -## Serialization - -Binary values are serialized differently according to the formats. - -### JSON - -JSON does not have a binary type, and this library does not introduce a new type as this would break conformance. -Instead, binary values are serialized as an object with two keys: `bytes` holds an array of integers, and `subtype` -is an integer or `null`. - -??? example - - Code: - - ```cpp - // create a binary value of subtype 42 - json j; - j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42); - - // serialize to standard output - std::cout << j.dump(2) << std::endl; - ``` - - Output: - - ```json - { - "binary": { - "bytes": [202, 254, 186, 190], - "subtype": 42 - } - } - ``` - -!!! warning "No roundtrip for binary values" - - The JSON parser will not parse the objects generated by binary values back to binary values. This is by design to - remain standards compliant. Serializing binary values to JSON is only implemented for debugging purposes. - -### BJData - -[BJData](binary_formats/bjdata.md) neither supports binary values nor subtypes, and proposes to serialize binary values -as array of uint8 values. This translation is implemented by the library. - -??? example - - Code: - - ```cpp - // create a binary value of subtype 42 (will be ignored in BJData) - json j; - j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42); - - // convert to BJData - auto v = json::to_bjdata(j); - ``` - - `v` is a `std::vector` with the following 20 elements: - - ```c - 0x7B // '{' - 0x69 0x06 // i 6 (length of the key) - 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary" - 0x5B // '[' - 0x55 0xCA 0x55 0xFE 0x55 0xBA 0x55 0xBE // content (each byte prefixed with 'U') - 0x5D // ']' - 0x7D // '}' - ``` - - The following code uses the type and size optimization for UBJSON: - - ```cpp - // convert to UBJSON using the size and type optimization - auto v = json::to_bjdata(j, true, true); - ``` - - The resulting vector has 22 elements; the optimization is not effective for examples with few values: - - ```c - 0x7B // '{' - 0x23 0x69 0x01 // '#' 'i' type of the array elements: unsigned integers - 0x69 0x06 // i 6 (length of the key) - 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary" - 0x5B // '[' array - 0x24 0x55 // '$' 'U' type of the array elements: unsigned integers - 0x23 0x69 0x04 // '#' i 4 number of array elements - 0xCA 0xFE 0xBA 0xBE // content - ``` - - Note that subtype (42) is **not** serialized and that UBJSON has **no binary type**, and deserializing `v` would - yield the following value: - - ```json - { - "binary": [202, 254, 186, 190] - } - ``` - -### BSON - -[BSON](binary_formats/bson.md) supports binary values and subtypes. If a subtype is given, it is used and added as -unsigned 8-bit integer. If no subtype is given, the generic binary subtype 0x00 is used. - -??? example - - Code: - - ```cpp - // create a binary value of subtype 42 - json j; - j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42); - - // convert to BSON - auto v = json::to_bson(j); - ``` - - `v` is a `std::vector` with the following 22 elements: - - ```c - 0x16 0x00 0x00 0x00 // number of bytes in the document - 0x05 // binary value - 0x62 0x69 0x6E 0x61 0x72 0x79 0x00 // key "binary" + null byte - 0x04 0x00 0x00 0x00 // number of bytes - 0x2a // subtype - 0xCA 0xFE 0xBA 0xBE // content - 0x00 // end of the document - ``` - - Note that the serialization preserves the subtype, and deserializing `v` would yield the following value: - - ```json - { - "binary": { - "bytes": [202, 254, 186, 190], - "subtype": 42 - } - } - ``` - -### CBOR - -[CBOR](binary_formats/cbor.md) supports binary values, but no subtypes. Subtypes will be serialized as tags. Any binary -value will be serialized as byte strings. The library will choose the smallest representation using the length of the -byte array. - -??? example - - Code: - - ```cpp - // create a binary value of subtype 42 - json j; - j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42); - - // convert to CBOR - auto v = json::to_cbor(j); - ``` - - `v` is a `std::vector` with the following 15 elements: - - ```c - 0xA1 // map(1) - 0x66 // text(6) - 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary" - 0xD8 0x2A // tag(42) - 0x44 // bytes(4) - 0xCA 0xFE 0xBA 0xBE // content - ``` - - Note that the subtype is serialized as tag. However, parsing tagged values yield a parse error unless - `json::cbor_tag_handler_t::ignore` or `json::cbor_tag_handler_t::store` is passed to `json::from_cbor`. - - ```json - { - "binary": { - "bytes": [202, 254, 186, 190], - "subtype": null - } - } - ``` - -### MessagePack - -[MessagePack](binary_formats/messagepack.md) supports binary values and subtypes. If a subtype is given, the ext family -is used. The library will choose the smallest representation among fixext1, fixext2, fixext4, fixext8, ext8, ext16, and -ext32. The subtype is then added as signed 8-bit integer. - -If no subtype is given, the bin family (bin8, bin16, bin32) is used. - -??? example - - Code: - - ```cpp - // create a binary value of subtype 42 - json j; - j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42); - - // convert to MessagePack - auto v = json::to_msgpack(j); - ``` - - `v` is a `std::vector` with the following 14 elements: - - ```c - 0x81 // fixmap1 - 0xA6 // fixstr6 - 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary" - 0xD6 // fixext4 - 0x2A // subtype - 0xCA 0xFE 0xBA 0xBE // content - ``` - - Note that the serialization preserves the subtype, and deserializing `v` would yield the following value: - - ```json - { - "binary": { - "bytes": [202, 254, 186, 190], - "subtype": 42 - } - } - ``` - -### UBJSON - -[UBJSON](binary_formats/ubjson.md) neither supports binary values nor subtypes, and proposes to serialize binary values -as array of uint8 values. This translation is implemented by the library. - -??? example - - Code: - - ```cpp - // create a binary value of subtype 42 (will be ignored in UBJSON) - json j; - j["binary"] = json::binary({0xCA, 0xFE, 0xBA, 0xBE}, 42); - - // convert to UBJSON - auto v = json::to_ubjson(j); - ``` - - `v` is a `std::vector` with the following 20 elements: - - ```c - 0x7B // '{' - 0x69 0x06 // i 6 (length of the key) - 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary" - 0x5B // '[' - 0x55 0xCA 0x55 0xFE 0x55 0xBA 0x55 0xBE // content (each byte prefixed with 'U') - 0x5D // ']' - 0x7D // '}' - ``` - - The following code uses the type and size optimization for UBJSON: - - ```cpp - // convert to UBJSON using the size and type optimization - auto v = json::to_ubjson(j, true, true); - ``` - - The resulting vector has 23 elements; the optimization is not effective for examples with few values: - - ```c - 0x7B // '{' - 0x24 // '$' type of the object elements - 0x5B // '[' array - 0x23 0x69 0x01 // '#' i 1 number of object elements - 0x69 0x06 // i 6 (length of the key) - 0x62 0x69 0x6E 0x61 0x72 0x79 // "binary" - 0x24 0x55 // '$' 'U' type of the array elements: unsigned integers - 0x23 0x69 0x04 // '#' i 4 number of array elements - 0xCA 0xFE 0xBA 0xBE // content - ``` - - Note that subtype (42) is **not** serialized and that UBJSON has **no binary type**, and deserializing `v` would - yield the following value: - - ```json - { - "binary": [202, 254, 186, 190] - } - ``` diff --git a/docs/mkdocs/docs/features/comments.md b/docs/mkdocs/docs/features/comments.md deleted file mode 100644 index 61266d9caf..0000000000 --- a/docs/mkdocs/docs/features/comments.md +++ /dev/null @@ -1,83 +0,0 @@ -# Comments - -This library does not support comments *by default*. It does so for three reasons: - -1. Comments are not part of the [JSON specification](https://tools.ietf.org/html/rfc8259). You may argue that `//` or `/* */` are allowed in JavaScript, but JSON is not JavaScript. -2. This was not an oversight: Douglas Crockford [wrote on this](https://plus.google.com/118095276221607585885/posts/RK8qyGVaGSr) in May 2012: - - > I removed comments from JSON because I saw people were using them to hold parsing directives, a practice which would have destroyed interoperability. I know that the lack of comments makes some people sad, but it shouldn't. - - > Suppose you are using JSON to keep configuration files, which you would like to annotate. Go ahead and insert all the comments you like. Then pipe it through JSMin before handing it to your JSON parser. - -3. It is dangerous for interoperability if some libraries would add comment support while others don't. Please check [The Harmful Consequences of the Robustness Principle](https://tools.ietf.org/html/draft-iab-protocol-maintenance-01) on this. - -However, you can pass set parameter `ignore_comments` to `#!c true` in the parse function to ignore `//` or `/* */` comments. Comments will then be treated as whitespace. - -!!! example - - Consider the following JSON with comments. - - ```json - { - // update in 2006: removed Pluto - "planets": ["Mercury", "Venus", "Earth", "Mars", - "Jupiter", "Uranus", "Neptune" /*, "Pluto" */] - } - ``` - - When calling `parse` without additional argument, a parse error exception is thrown. If `ignore_comments` is set to `#! true`, the comments are ignored during parsing: - - ```cpp - #include - #include "json.hpp" - - using json = nlohmann::json; - - int main() - { - std::string s = R"( - { - // update in 2006: removed Pluto - "planets": ["Mercury", "Venus", "Earth", "Mars", - "Jupiter", "Uranus", "Neptune" /*, "Pluto" */] - } - )"; - - try - { - json j = json::parse(s); - } - catch (json::exception &e) - { - std::cout << e.what() << std::endl; - } - - json j = json::parse(s, - /* callback */ nullptr, - /* allow exceptions */ true, - /* ignore_comments */ true); - std::cout << j.dump(2) << '\n'; - } - ``` - - Output: - - ``` - [json.exception.parse_error.101] parse error at line 3, column 9: - syntax error while parsing object key - invalid literal; - last read: ' { /'; expected string literal - ``` - - ```json - { - "planets": [ - "Mercury", - "Venus", - "Earth", - "Mars", - "Jupiter", - "Uranus", - "Neptune" - ] - } - ``` diff --git a/docs/mkdocs/docs/features/element_access/checked_access.md b/docs/mkdocs/docs/features/element_access/checked_access.md deleted file mode 100644 index c4023cce58..0000000000 --- a/docs/mkdocs/docs/features/element_access/checked_access.md +++ /dev/null @@ -1,91 +0,0 @@ -# Checked access: at - -## Overview - -The [`at`](../../api/basic_json/at.md) member function performs checked access; that is, it returns a reference to the -desired value if it exists and throws a [`basic_json::out_of_range` exception](../../home/exceptions.md#out-of-range) -otherwise. - -??? example "Read access" - - Consider the following JSON value: - - ```json - { - "name": "Mary Smith", - "age": 42, - "hobbies": ["hiking", "reading"] - } - ``` - - Assume the value is parsed to a `json` variable `j`. - - | expression | value | - |-------------------------------|------------------------------------------------------------------------------| - | `#!cpp j` | `#!json {"name": "Mary Smith", "age": 42, "hobbies": ["hiking", "reading"]}` | - | `#!cpp j.at("name")` | `#!json "Mary Smith"` | - | `#!cpp j.at("age")` | `#!json 42` | - | `#!cpp j.at("hobbies")` | `#!json ["hiking", "reading"]` | - | `#!cpp j.at("hobbies").at(0)` | `#!json "hiking"` | - | `#!cpp j.at("hobbies").at(1)` | `#!json "reading"` | - -The return value is a reference, so it can be modified by the original value. - -??? example "Write access" - - ```cpp - j.at("name") = "John Smith"; - ``` - - This code produces the following JSON value: - - ```json - { - "name": "John Smith", - "age": 42, - "hobbies": ["hiking", "reading"] - } - ``` - -When accessing an invalid index (i.e., an index greater than or equal to the array size) or the passed object key is -non-existing, an exception is thrown. - -??? example "Accessing via invalid index or missing key" - - ```cpp - j.at("hobbies").at(3) = "cooking"; - ``` - - This code produces the following exception: - - ``` - [json.exception.out_of_range.401] array index 3 is out of range - ``` - - When you [extended diagnostic messages](../../home/exceptions.md#extended-diagnostic-messages) are enabled by - defining [`JSON_DIAGNOSTICS`](../../api/macros/json_diagnostics.md), the exception further gives information where - the key or index is missing or out of range. - - ``` - [json.exception.out_of_range.401] (/hobbies) array index 3 is out of range - ``` - -## Notes - - -!!! failure "Exceptions" - - - [`at`](../../api/basic_json/at.md) can only be used with objects (with a string argument) or with arrays (with a - numeric argument). For other types, a [`basic_json::type_error`](../../home/exceptions.md#jsonexceptiontype_error304) - is thrown. - - [`basic_json::out_of_range` exception](../../home/exceptions.md#out-of-range) exceptions are thrown if the - provided key is not found in an object or the provided index is invalid. - -## Summary - -| scenario | non-const value | const value | -|-----------------------------------|------------------------------------------------|------------------------------------------------| -| access to existing object key | reference to existing value is returned | const reference to existing value is returned | -| access to valid array index | reference to existing value is returned | const reference to existing value is returned | -| access to non-existing object key | `basic_json::out_of_range` exception is thrown | `basic_json::out_of_range` exception is thrown | -| access to invalid array index | `basic_json::out_of_range` exception is thrown | `basic_json::out_of_range` exception is thrown | diff --git a/docs/mkdocs/docs/features/element_access/default_value.md b/docs/mkdocs/docs/features/element_access/default_value.md deleted file mode 100644 index 02b4fea3ff..0000000000 --- a/docs/mkdocs/docs/features/element_access/default_value.md +++ /dev/null @@ -1,32 +0,0 @@ -# Access with default value: value - -## Overview - -In many situations such as configuration files, missing values are not exceptional, but may be treated as if a default value was present. - -??? example - - Consider the following JSON value: - - ```json - { - "logOutput": "result.log", - "append": true - } - ``` - - Assume the value is parsed to a `json` variable `j`. - - | expression | value | - | ---------- | ----- | - | `#!cpp j` | `#!json {"logOutput": "result.log", "append": true}` | - | `#!cpp j.value("logOutput", "logfile.log")` | `#!json "result.log"` | - | `#!cpp j.value("append", true)` | `#!json true` | - | `#!cpp j.value("append", false)` | `#!json true` | - | `#!cpp j.value("logLevel", "verbose")` | `#!json "verbose"` | - -## Note - -!!! failure "Exceptions" - - - `value` can only be used with objects. For other types, a [`basic_json::type_error`](../../home/exceptions.md#jsonexceptiontype_error306) is thrown. diff --git a/docs/mkdocs/docs/features/element_access/index.md b/docs/mkdocs/docs/features/element_access/index.md deleted file mode 100644 index 0b39547ecf..0000000000 --- a/docs/mkdocs/docs/features/element_access/index.md +++ /dev/null @@ -1,9 +0,0 @@ -# Element Access - -There are many ways elements in a JSON value can be accessed: - -- unchecked access via [`operator[]`](unchecked_access.md) -- checked access via [`at`](checked_access.md) -- access with default value via [`value`](default_value.md) -- iterators -- JSON pointers diff --git a/docs/mkdocs/docs/features/element_access/unchecked_access.md b/docs/mkdocs/docs/features/element_access/unchecked_access.md deleted file mode 100644 index 39f06dc9f2..0000000000 --- a/docs/mkdocs/docs/features/element_access/unchecked_access.md +++ /dev/null @@ -1,112 +0,0 @@ -# Unchecked access: operator[] - -## Overview - -Elements in a JSON object and a JSON array can be accessed via [`operator[]`](../../api/basic_json/operator%5B%5D.md) -similar to a `#!cpp std::map` and a `#!cpp std::vector`, respectively. - -??? example "Read access" - - Consider the following JSON value: - - ```json - { - "name": "Mary Smith", - "age": 42, - "hobbies": ["hiking", "reading"] - } - ``` - - Assume the value is parsed to a `json` variable `j`. - - | expression | value | - |-------------------------|------------------------------------------------------------------------------| - | `#!cpp j` | `#!json {"name": "Mary Smith", "age": 42, "hobbies": ["hiking", "reading"]}` | - | `#!cpp j["name"]` | `#!json "Mary Smith"` | - | `#!cpp j["age"]` | `#!json 42` | - | `#!cpp j["hobbies"]` | `#!json ["hiking", "reading"]` | - | `#!cpp j["hobbies"][0]` | `#!json "hiking"` | - | `#!cpp j["hobbies"][1]` | `#!json "reading"` | - -The return value is a reference, so it can modify the original value. In case the passed object key is non-existing, a -`#!json null` value is inserted which can be immediately be overwritten. - -??? example "Write access" - - ```cpp - j["name"] = "John Smith"; - j["maidenName"] = "Jones"; - ``` - - This code produces the following JSON value: - - ```json - { - "name": "John Smith", - "maidenName": "Jones", - "age": 42, - "hobbies": ["hiking", "reading"] - } - ``` - -When accessing an invalid index (i.e., an index greater than or equal to the array size), the JSON array is resized such -that the passed index is the new maximal index. Intermediate values are filled with `#!json null`. - -??? example "Filling up arrays with `#!json null` values" - - ```cpp - j["hobbies"][0] = "running"; - j["hobbies"][3] = "cooking"; - ``` - - This code produces the following JSON value: - - ```json - { - "name": "John Smith", - "maidenName": "Jones", - "age": 42, - "hobbies": ["running", "reading", null, "cooking"] - } - ``` - -## Notes - -!!! info "Design rationale" - - The library behaves differently to `#!cpp std::vector` and `#!cpp std::map`: - - - `#!cpp std::vector::operator[]` never inserts a new element. - - `#!cpp std::map::operator[]` is not available for const values. - - The type `#!cpp json` wraps all JSON value types. It would be impossible to remove - [`operator[]`](../../api/basic_json/operator%5B%5D.md) for const objects. At the same time, inserting elements for - non-const objects is really convenient as it avoids awkward `insert` calls. To this end, we decided to have an - inserting non-const behavior for both arrays and objects. - -!!! info - - The access is unchecked. In case the passed object key does not exist or the passed array index is invalid, no - exception is thrown. - -!!! danger - - - It is **undefined behavior** to access a const object with a non-existing key. - - It is **undefined behavior** to access a const array with an invalid index. - - In debug mode, an **assertion** will fire in both cases. You can disable assertions by defining the preprocessor - symbol `#!cpp NDEBUG` or redefine the macro [`JSON_ASSERT(x)`](../macros.md#json_assertx). See the documentation - on [runtime assertions](../assertions.md) for more information. - -!!! failure "Exceptions" - - `operator[]` can only be used with objects (with a string argument) or with arrays (with a numeric argument). For - other types, a [`basic_json::type_error`](../../home/exceptions.md#jsonexceptiontype_error305) is thrown. - -## Summary - -| scenario | non-const value | const value | -|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------| -| access to existing object key | reference to existing value is returned | const reference to existing value is returned | -| access to valid array index | reference to existing value is returned | const reference to existing value is returned | -| access to non-existing object key | reference to newly inserted `#!json null` value is returned | **undefined behavior**; [runtime assertion](../assertions.md) in debug mode | -| access to invalid array index | reference to newly inserted `#!json null` value is returned; any index between previous maximal index and passed index are filled with `#!json null` | **undefined behavior**; [runtime assertion](../assertions.md) in debug mode | diff --git a/docs/mkdocs/docs/features/enum_conversion.md b/docs/mkdocs/docs/features/enum_conversion.md deleted file mode 100644 index 1755bca2ad..0000000000 --- a/docs/mkdocs/docs/features/enum_conversion.md +++ /dev/null @@ -1,61 +0,0 @@ -# Specializing enum conversion - -By default, enum values are serialized to JSON as integers. In some cases this could result in undesired behavior. If an -enum is modified or re-ordered after data has been serialized to JSON, the later de-serialized JSON data may be -undefined or a different enum value than was originally intended. - -It is possible to more precisely specify how a given enum is mapped to and from JSON as shown below: - -```cpp -// example enum type declaration -enum TaskState { - TS_STOPPED, - TS_RUNNING, - TS_COMPLETED, - TS_INVALID=-1, -}; - -// map TaskState values to JSON as strings -NLOHMANN_JSON_SERIALIZE_ENUM( TaskState, { - {TS_INVALID, nullptr}, - {TS_STOPPED, "stopped"}, - {TS_RUNNING, "running"}, - {TS_COMPLETED, "completed"}, -}) -``` - -The [`NLOHMANN_JSON_SERIALIZE_ENUM()` macro](../api/macros/nlohmann_json_serialize_enum.md) declares a set of -`to_json()` / `from_json()` functions for type `TaskState` while avoiding repetition and boilerplate serialization code. - -## Usage - -```cpp -// enum to JSON as string -json j = TS_STOPPED; -assert(j == "stopped"); - -// json string to enum -json j3 = "running"; -assert(j3.template get() == TS_RUNNING); - -// undefined json value to enum (where the first map entry above is the default) -json jPi = 3.14; -assert(jPi.template get() == TS_INVALID ); -``` - -## Notes - -Just as in [Arbitrary Type Conversions](arbitrary_types.md) above, - -- [`NLOHMANN_JSON_SERIALIZE_ENUM()`](../api/macros/nlohmann_json_serialize_enum.md) MUST be declared in your enum type's - namespace (which can be the global namespace), or the library will not be able to locate it, and it will default to - integer serialization. -- It MUST be available (e.g., proper headers must be included) everywhere you use the conversions. - -Other Important points: - -- When using `template get()`, 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. -- To disable the default serialization of enumerators as integers and force a compiler error instead, see [`JSON_DISABLE_ENUM_SERIALIZATION`](../api/macros/json_disable_enum_serialization.md). diff --git a/docs/mkdocs/docs/features/iterators.md b/docs/mkdocs/docs/features/iterators.md deleted file mode 100644 index ce627e0126..0000000000 --- a/docs/mkdocs/docs/features/iterators.md +++ /dev/null @@ -1,155 +0,0 @@ -# Iterators - -## Overview - -A `basic_json` value is a container and allows access via iterators. Depending on the value type, `basic_json` stores zero or more values. - -As for other containers, `begin()` returns an iterator to the first value and `end()` returns an iterator to the value following the last value. The latter iterator is a placeholder and cannot be dereferenced. In case of null values, empty arrays, or empty objects, `begin()` will return `end()`. - -![Illustration from cppreference.com](../images/range-begin-end.svg) - -### Iteration order for objects - -When iterating over objects, values are ordered with respect to the `object_comparator_t` type which defaults to `std::less`. See the [types documentation](types/index.md#key-order) for more information. - -??? example - - ```cpp - // create JSON object {"one": 1, "two": 2, "three": 3} - json j; - j["one"] = 1; - j["two"] = 2; - j["three"] = 3; - - for (auto it = j.begin(); it != j.end(); ++it) - { - std::cout << *it << std::endl; - } - ``` - - Output: - - ```json - 1 - 3 - 2 - ``` - - The reason for the order is the lexicographic ordering of the object keys "one", "three", "two". - -### Access object key during iteration - -The JSON iterators have two member functions, `key()` and `value()` to access the object key and stored value, respectively. When calling `key()` on a non-object iterator, an [invalid_iterator.207](../home/exceptions.md#jsonexceptioninvalid_iterator207) exception is thrown. - -??? example - - ```cpp - // create JSON object {"one": 1, "two": 2, "three": 3} - json j; - j["one"] = 1; - j["two"] = 2; - j["three"] = 3; - - for (auto it = j.begin(); it != j.end(); ++it) - { - std::cout << it.key() << " : " << it.value() << std::endl; - } - ``` - - Output: - - ```json - one : 1 - three : 3 - two : 2 - ``` - -### Range-based for loops - -C++11 allows using range-based for loops to iterate over a container. - -```cpp -for (auto it : j_object) -{ - // "it" is of type json::reference and has no key() member - std::cout << "value: " << it << '\n'; -} -``` - -For this reason, the `items()` function allows accessing `iterator::key()` and `iterator::value()` during range-based for loops. In these loops, a reference to the JSON values is returned, so there is no access to the underlying iterator. - -```cpp -for (auto& el : j_object.items()) -{ - std::cout << "key: " << el.key() << ", value:" << el.value() << '\n'; -} -``` - -The items() function also allows using structured bindings (C++17): - -```cpp -for (auto& [key, val] : j_object.items()) -{ - std::cout << "key: " << key << ", value:" << val << '\n'; -} -``` - -!!! note - - When iterating over an array, `key()` will return the index of the element as string. For primitive types (e.g., numbers), `key()` returns an empty string. - -!!! warning - - Using `items()` on temporary objects is dangerous. Make sure the object's lifetime exceeds the iteration. See for more information. - -### Reverse iteration order - -`rbegin()` and `rend()` return iterators in the reverse sequence. - -![Illustration from cppreference.com](../images/range-rbegin-rend.svg) - -??? example - - ```cpp - json j = {1, 2, 3, 4}; - - for (auto it = j.rbegin(); it != j.rend(); ++it) - { - std::cout << *it << std::endl; - } - ``` - - Output: - - ```json - 4 - 3 - 2 - 1 - ``` - -### Iterating strings and binary values - -Note that "value" means a JSON value in this setting, not values stored in the underlying containers. That is, `*begin()` returns the complete string or binary array and is also safe the underlying string or binary array is empty. - -??? example - - ```cpp - json j = "Hello, world"; - for (auto it = j.begin(); it != j.end(); ++it) - { - std::cout << *it << std::endl; - } - ``` - - Output: - - ```json - "Hello, world" - ``` - -## Iterator invalidation - -| Operations | invalidated iterators | -|------------|-----------------------| -| `clear` | all | diff --git a/docs/mkdocs/docs/features/json_patch.md b/docs/mkdocs/docs/features/json_patch.md deleted file mode 100644 index 88c731a2ca..0000000000 --- a/docs/mkdocs/docs/features/json_patch.md +++ /dev/null @@ -1,47 +0,0 @@ -# JSON Patch and Diff - -## Patches - -JSON Patch ([RFC 6902](https://tools.ietf.org/html/rfc6902)) defines a JSON document structure for expressing a sequence -of operations to apply to a JSON document. With the `patch` function, a JSON Patch is applied to the current JSON value -by executing all operations from the patch. - -??? example - - The following code shows how a JSON patch is applied to a value. - - ```cpp - --8<-- "examples/patch.cpp" - ``` - - Output: - - ```json - --8<-- "examples/patch.output" - ``` - -## Diff - -The library can also calculate a JSON patch (i.e., a **diff**) given two JSON values. - -!!! success "Invariant" - - For two JSON values *source* and *target*, the following code yields always true: - - ```cüü - source.patch(diff(source, target)) == target; - ``` - -??? example - - The following code shows how a JSON patch is created as a diff for two JSON values. - - ```cpp - --8<-- "examples/diff.cpp" - ``` - - Output: - - ```json - --8<-- "examples/diff.output" - ``` diff --git a/docs/mkdocs/docs/features/json_pointer.md b/docs/mkdocs/docs/features/json_pointer.md deleted file mode 100644 index 04aeca504d..0000000000 --- a/docs/mkdocs/docs/features/json_pointer.md +++ /dev/null @@ -1,126 +0,0 @@ -# JSON Pointer - -## Introduction - -The library supports **JSON Pointer** ([RFC 6901](https://tools.ietf.org/html/rfc6901)) as alternative means to address -structured values. A JSON Pointer is a string that identifies a specific value within a JSON document. - -Consider the following JSON document - -```json -{ - "array": ["A", "B", "C"], - "nested": { - "one": 1, - "two": 2, - "three": [true, false] - } -} -``` - -Then every value inside the JSON document can be identified as follows: - -| JSON Pointer | JSON value | -|-------------------|----------------------------------------------------------------------------------| -| `` | `#!json {"array":["A","B","C"],"nested":{"one":1,"two":2,"three":[true,false]}}` | -| `/array` | `#!json ["A","B","C"]` | -| `/array/0` | `#!json A` | -| `/array/1` | `#!json B` | -| `/array/2` | `#!json C` | -| `/nested` | `#!json {"one":1,"two":2,"three":[true,false]}` | -| `/nested/one` | `#!json 1` | -| `/nested/two` | `#!json 2` | -| `/nested/three` | `#!json [true,false]` | -| `/nested/three/0` | `#!json true` | -| `/nested/three/1` | `#!json false` | - -Note `/` does not identify the root (i.e., the whole document), but an object entry with empty key `""`. See -[RFC 6901](https://tools.ietf.org/html/rfc6901) for more information. - -## JSON Pointer creation - -JSON Pointers can be created from a string: - -```cpp -json::json_pointer p = "/nested/one"; -``` - -Furthermore, a user-defined string literal can be used to achieve the same result: - -```cpp -auto p = "/nested/one"_json_pointer; -``` - -The escaping rules of [RFC 6901](https://tools.ietf.org/html/rfc6901) are implemented. See the -[constructor documentation](../api/json_pointer/json_pointer.md) for more information. - -## Value access - -JSON Pointers can be used in the [`at`](../api/basic_json/at.md), [`operator[]`](../api/basic_json/operator%5B%5D.md), -and [`value`](../api/basic_json/value.md) functions just like object keys or array indices. - -```cpp -// the JSON value from above -auto j = json::parse(R"({ - "array": ["A", "B", "C"], - "nested": { - "one": 1, - "two": 2, - "three": [true, false] - } -})"); - -// access values -auto val = j["/"_json_pointer]; // {"array":["A","B","C"],...} -auto val1 = j["/nested/one"_json_pointer]; // 1 -auto val2 = j.at[json::json_pointer("/nested/three/1")]; // false -auto val3 = j.value[json::json_pointer("/nested/four", 0)]; // 0 -``` - -## Flatten / unflatten - -The library implements a function [`flatten`](../api/basic_json/flatten.md) to convert any JSON document into a JSON -object where each key is a JSON Pointer and each value is a primitive JSON value (i.e., a string, boolean, number, or -null). - -```cpp -// the JSON value from above -auto j = json::parse(R"({ - "array": ["A", "B", "C"], - "nested": { - "one": 1, - "two": 2, - "three": [true, false] - } -})"); - -// create flattened value -auto j_flat = j.flatten(); -``` - -The resulting value `j_flat` is: - -```json -{ - "/array/0": "A", - "/array/1": "B", - "/array/2": "C", - "/nested/one": 1, - "/nested/two": 2, - "/nested/three/0": true, - "/nested/three/1": false -} -``` - -The reverse function, [`unflatten`](../api/basic_json/unflatten.md) recreates the original value. - -```cpp -auto j_original = j_flat.unflatten(); -``` - -## See also - -- Class [`json_pointer`](../api/json_pointer/index.md) -- Function [`flatten`](../api/basic_json/flatten.md) -- Function [`unflatten`](../api/basic_json/unflatten.md) -- [JSON Patch](json_patch.md) diff --git a/docs/mkdocs/docs/features/macros.md b/docs/mkdocs/docs/features/macros.md deleted file mode 100644 index 1be95d35d5..0000000000 --- a/docs/mkdocs/docs/features/macros.md +++ /dev/null @@ -1,153 +0,0 @@ -# Supported Macros - -Some aspects of the library can be configured by defining preprocessor macros before including the `json.hpp` header. -See also the [API documentation for macros](../api/macros/index.md) for examples and more information. - -## `JSON_ASSERT(x)` - -This macro controls which code is executed for [runtime assertions](assertions.md) of the library. - -See [full documentation of `JSON_ASSERT(x)`](../api/macros/json_assert.md). - -## `JSON_CATCH_USER(exception)` - -This macro overrides [`#!cpp catch`](https://en.cppreference.com/w/cpp/language/try_catch) calls inside the library. - -See [full documentation of `JSON_CATCH_USER(exception)`](../api/macros/json_throw_user.md). - -## `JSON_DIAGNOSTICS` - -This macro enables extended diagnostics for exception messages. Possible values are `1` to enable or `0` to disable -(default). - -When enabled, exception messages contain a [JSON Pointer](json_pointer.md) to the JSON value that triggered the -exception, see [Extended diagnostic messages](../home/exceptions.md#extended-diagnostic-messages) for an example. Note -that enabling this macro increases the size of every JSON value by one pointer and adds some runtime overhead. - -The diagnostics messages can also be controlled with the CMake option `JSON_Diagnostics` (`OFF` by default) which sets -`JSON_DIAGNOSTICS` accordingly. - -See [full documentation of `JSON_DIAGNOSTICS`](../api/macros/json_diagnostics.md). - -## `JSON_HAS_CPP_11`, `JSON_HAS_CPP_14`, `JSON_HAS_CPP_17`, `JSON_HAS_CPP_20` - -The library targets C++11, but also supports some features introduced in later C++ versions (e.g., `std::string_view` -support for C++17). For these new features, the library implements some preprocessor checks to determine the C++ -standard. By defining any of these symbols, the internal check is overridden and the provided C++ version is -unconditionally assumed. This can be helpful for compilers that only implement parts of the standard and would be -detected incorrectly. - -See [full documentation of `JSON_HAS_CPP_11`, `JSON_HAS_CPP_14`, `JSON_HAS_CPP_17`, and `JSON_HAS_CPP_20`](../api/macros/json_has_cpp_11.md). - -## `JSON_HAS_FILESYSTEM`, `JSON_HAS_EXPERIMENTAL_FILESYSTEM` - -When compiling with C++17, the library provides conversions from and to `std::filesystem::path`. As compiler support -for filesystem is limited, the library tries to detect whether ``/`std::filesystem` (`JSON_HAS_FILESYSTEM`) -or ``/`std::experimental::filesystem` (`JSON_HAS_EXPERIMENTAL_FILESYSTEM`) should be used. -To override the built-in check, define `JSON_HAS_FILESYSTEM` or `JSON_HAS_EXPERIMENTAL_FILESYSTEM` to `1`. - -See [full documentation of `JSON_HAS_FILESYSTEM` and `JSON_HAS_EXPERIMENTAL_FILESYSTEM`](../api/macros/json_has_filesystem.md). - -## `JSON_NOEXCEPTION` - -Exceptions can be switched off by defining the symbol `JSON_NOEXCEPTION`. - -See [full documentation of `JSON_NOEXCEPTION`](../api/macros/json_noexception.md). - -## `JSON_DISABLE_ENUM_SERIALIZATION` - -When defined, default parse and serialize functions for enums are excluded and have to be provided by the user, for example, using [`NLOHMANN_JSON_SERIALIZE_ENUM`](../api/macros/nlohmann_json_serialize_enum.md). - -See [full documentation of `JSON_DISABLE_ENUM_SERIALIZATION`](../api/macros/json_disable_enum_serialization.md). - -## `JSON_NO_IO` - -When defined, headers ``, ``, ``, ``, and `` are not included and parse functions -relying on these headers are excluded. This is relevant for environment where these I/O functions are disallowed for -security reasons (e.g., Intel Software Guard Extensions (SGX)). - -See [full documentation of `JSON_NO_IO`](../api/macros/json_no_io.md). - -## `JSON_SKIP_LIBRARY_VERSION_CHECK` - -When defined, the library will not create a compiler warning when a different version of the library was already -included. - -See [full documentation of `JSON_SKIP_LIBRARY_VERSION_CHECK`](../api/macros/json_skip_library_version_check.md). - -## `JSON_SKIP_UNSUPPORTED_COMPILER_CHECK` - -When defined, the library will not create a compile error when a known unsupported compiler is detected. This allows to -use the library with compilers that do not fully support C++11 and may only work if unsupported features are not used. - -See [full documentation of `JSON_SKIP_UNSUPPORTED_COMPILER_CHECK`](../api/macros/json_skip_unsupported_compiler_check.md). - -## `JSON_THROW_USER(exception)` - -This macro overrides `#!cpp throw` calls inside the library. The argument is the exception to be thrown. - -See [full documentation of `JSON_THROW_USER(exception)`](../api/macros/json_throw_user.md). - -## `JSON_TRY_USER` - -This macro overrides `#!cpp try` calls inside the library. - -See [full documentation of `JSON_TRY_USER`](../api/macros/json_throw_user.md). - -## `JSON_USE_IMPLICIT_CONVERSIONS` - -When defined to `0`, implicit conversions are switched off. By default, implicit conversions are switched on. - -See [full documentation of `JSON_USE_IMPLICIT_CONVERSIONS`](../api/macros/json_use_implicit_conversions.md). - -## `NLOHMANN_DEFINE_TYPE_INTRUSIVE(type, member...)` - -This macro can be used to simplify the serialization/deserialization of types if (1) want to use a JSON object as -serialization and (2) want to use the member variable names as object keys in that object. - -The macro is to be defined inside the class/struct to create code for. Unlike -[`NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`](#nlohmann_define_type_non_intrusivetype-member), it can access private members. -The first parameter is the name of the class/struct, and all remaining parameters name the members. - -See [full documentation of `NLOHMANN_DEFINE_TYPE_INTRUSIVE`](../api/macros/nlohmann_define_type_intrusive.md). - -## `NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(type, member...)` - -This macro is similar to `NLOHMANN_DEFINE_TYPE_INTRUSIVE`. It will not throw an exception in `from_json()` due to a -missing value in the JSON object, but can throw due to a mismatched type. The `from_json()` function default constructs -an object and uses its values as the defaults when calling the [`value`](../api/basic_json/value.md) function. - -See [full documentation of `NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT`](../api/macros/nlohmann_define_type_intrusive.md). - -## `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(type, member...)` - -This macro can be used to simplify the serialization/deserialization of types if (1) want to use a JSON object as -serialization and (2) want to use the member variable names as object keys in that object. - -The macro is to be defined inside the namespace of the class/struct to create code for. Private members cannot be -accessed. Use [`NLOHMANN_DEFINE_TYPE_INTRUSIVE`](#nlohmann_define_type_intrusivetype-member) in these scenarios. The -first parameter is the name of the class/struct, and all remaining parameters name the members. - -See [full documentation of `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`](../api/macros/nlohmann_define_type_non_intrusive.md). - -## `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(type, member...)` - -This macro is similar to `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`. It will not throw an exception in `from_json()` due to a -missing value in the JSON object, but can throw due to a mismatched type. The `from_json()` function default constructs -an object and uses its values as the defaults when calling the [`value`](../api/basic_json/value.md) function. - -See [full documentation of `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT`](../api/macros/nlohmann_define_type_non_intrusive.md). - -## `NLOHMANN_JSON_SERIALIZE_ENUM(type, ...)` - -This macro simplifies the serialization/deserialization of enum types. See -[Specializing enum conversion](enum_conversion.md) for more information. - -See [full documentation of `NLOHMANN_JSON_SERIALIZE_ENUM`](../api/macros/nlohmann_json_serialize_enum.md). - -## `NLOHMANN_JSON_VERSION_MAJOR`, `NLOHMANN_JSON_VERSION_MINOR`, `NLOHMANN_JSON_VERSION_PATCH` - -These macros are defined by the library and contain the version numbers according to -[Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html). - -See [full documentation of `NLOHMANN_JSON_VERSION_MAJOR`, `NLOHMANN_JSON_VERSION_MINOR`, and `NLOHMANN_JSON_VERSION_PATCH`](../api/macros/nlohmann_json_version_major.md). diff --git a/docs/mkdocs/docs/features/merge_patch.md b/docs/mkdocs/docs/features/merge_patch.md deleted file mode 100644 index 84e0ab02fd..0000000000 --- a/docs/mkdocs/docs/features/merge_patch.md +++ /dev/null @@ -1,20 +0,0 @@ -# JSON Merge Patch - -The library supports JSON Merge Patch ([RFC 7386](https://tools.ietf.org/html/rfc7386)) as a patch format. -The merge patch format is primarily intended for use with the HTTP PATCH method as a means of describing a set of modifications to a target resource's content. This function applies a merge patch to the current JSON value. - -Instead of using [JSON Pointer](json_pointer.md) to specify values to be manipulated, it describes the changes using a syntax that closely mimics the document being modified. - -??? example - - The following code shows how a JSON Merge Patch is applied to a JSON document. - - ```cpp - --8<-- "examples/merge_patch.cpp" - ``` - - Output: - - ```json - --8<-- "examples/merge_patch.output" - ``` diff --git a/docs/mkdocs/docs/features/namespace.md b/docs/mkdocs/docs/features/namespace.md deleted file mode 100644 index 8cee2ccfe7..0000000000 --- a/docs/mkdocs/docs/features/namespace.md +++ /dev/null @@ -1,93 +0,0 @@ -# `nlohmann` Namespace - -The 3.11.0 release introduced an -[inline namespace](https://en.cppreference.com/w/cpp/language/namespace#Inline_namespaces) to allow different parts of -a codebase to safely use different versions of the JSON library as long as they never exchange instances of library -types. - -## Structure - -The complete default namespace name is derived as follows: - -- The root namespace is always `nlohmann`. -- The inline namespace starts with `json_abi` and is followed by serveral optional ABI tags according to the value of - these ABI-affecting macros, in order: - - [`JSON_DIAGNOSTICS`](../api/macros/json_diagnostics.md) defined non-zero appends `_diag`. - - [`JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON`](../api/macros/json_use_legacy_discarded_value_comparison.md) - defined non-zero appends `_ldvcmp`. -- The inline namespace ends with the suffix `_v` followed by the 3 components of the version number separated by - underscores. To omit the version component, see [Disabling the version component](#disabling-the-version-component) - below. - -For example, the namespace name for version 3.11.2 with `JSON_DIAGNOSTICS` defined to `1` is: - -```cpp -nlohmann::json_abi_diag_v3_11_2 -``` - -## Purpose - -Several incompatibilities have been observed. Amongst the most common ones is linking code compiled with different -definitions of [`JSON_DIAGNOSTICS`](../api/macros/json_diagnostics.md). This is illustrated in the diagram below. - -```plantuml -[**nlohmann_json (v3.10.5)**\nJSON_DIAGNOSTICS=0] as [json] -[**nlohmann_json (v3.10.5)**\nJSON_DIAGNOSTICS=1] as [json_diag] -[**some_library**] as [library] -[**application**] as [app] - -[library] ..|> [json] -[app] ..|> [json_diag] -[app] ..|>[library] -``` - -In releases prior to 3.11.0, mixing any version of the JSON library with different `JSON_DIAGNOSTICS` settings would -result in a crashing application. If `some_library` never passes instances of JSON library types to the application, -this scenario became safe in version 3.11.0 and above due to the inline namespace yielding distinct symbol names. - -## Limitations - -Neither the compiler nor the linker will issue as much as a warning when translation units – intended to be linked -together and that include different versions and/or configurations of the JSON library – exchange and use library -types. - -There is an exception when forward declarations are used (i.e., when including `json_fwd.hpp`) in which case the linker -may complain about undefined references. - -## Disabling the version component - -Different versions are not necessarily ABI-incompatible, but the project does not actively track changes in the ABI and -recommends that all parts of a codebase exchanging library types be built with the same version. Users can, **at their -own risk**, disable the version component of the linline namespace, allowing different versions – but not -configurations – to be used in cases where the linker would otherwise output undefined reference errors. - -To do so, define [`NLOHMANN_JSON_NAMESPACE_NO_VERSION`](../api/macros/nlohmann_json_namespace_no_version.md) to `1`. - -This applies to version 3.11.2 and above only, versions 3.11.0 and 3.11.1 can apply the technique described in the next -section to emulate the effect of the `NLOHMANN_JSON_NAMESPACE_NO_VERSION` macro. - -!!! danger "Use at your own risk" - - Disabling the namespace version component and mixing ABI-incompatible versions will result in crashes or incorrect - behavior. You have been warned! -## Disabling the inline namespace completely - -When interoperability with code using a pre-3.11.0 version of the library is required, users can, **at their own risk** -restore the old namespace layout by redefining -[`NLOHMANN_JSON_NAMESPACE_BEGIN, NLOHMANN_JSON_NAMESPACE_END`](../api/macros/nlohmann_json_namespace_begin.md) as -follows: - -```cpp -#define NLOHMANN_JSON_NAMESPACE_BEGIN namespace nlohmann { -#define NLOHMANN_JSON_NAMESPACE_END } -``` - -!!! danger "Use at your own risk" - - Overriding the namespace and mixing ABI-incompatible versions will result in crashes or incorrect behavior. You - have been warned! - -## Version history - -- Introduced inline namespace (`json_v3_11_0[_abi-tag]*`) in version 3.11.0. -- Changed structure of inline namespace in version 3.11.2. diff --git a/docs/mkdocs/docs/features/object_order.md b/docs/mkdocs/docs/features/object_order.md deleted file mode 100644 index 3ee16a90e4..0000000000 --- a/docs/mkdocs/docs/features/object_order.md +++ /dev/null @@ -1,109 +0,0 @@ -# Object Order - -The [JSON standard](https://tools.ietf.org/html/rfc8259.html) defines objects as "an unordered collection of zero or more name/value pairs". As such, an implementation does not need to preserve any specific order of object keys. - -## Default behavior: sort keys - -The default type `nlohmann::json` uses a `std::map` to store JSON objects, and thus stores object keys **sorted alphabetically**. - -??? example - - ```cpp - #include - #include "json.hpp" - - using json = nlohmann::json; - - int main() - { - json j; - j["one"] = 1; - j["two"] = 2; - j["three"] = 3; - - std::cout << j.dump(2) << '\n'; - } - ``` - - Output: - - ```json - { - "one": 1, - "three": 3, - "two": 2 - } - ``` - -## Alternative behavior: preserve insertion order - -If you do want to preserve the **insertion order**, you can try the type [`nlohmann::ordered_json`](https://github.com/nlohmann/json/issues/2179). - -??? example - - ```cpp - --8<-- "examples/ordered_json.cpp" - ``` - - Output: - - ```json - --8<-- "examples/ordered_json.output" - ``` - -Alternatively, you can use a more sophisticated ordered map like [`tsl::ordered_map`](https://github.com/Tessil/ordered-map) ([integration](https://github.com/nlohmann/json/issues/546#issuecomment-304447518)) or [`nlohmann::fifo_map`](https://github.com/nlohmann/fifo_map) ([integration](https://github.com/nlohmann/json/issues/485#issuecomment-333652309)). - -### Notes on parsing - -Note that you also need to call the right [`parse`](../api/basic_json/parse.md) function when reading from a file. -Assume file `input.json` contains the JSON object above: - -```json -{ - "one": 1, - "two": 2, - "three": 3 -} -``` - -!!! success "Right way" - - The following code correctly calls the `parse` function from `nlohmann::ordered_json`: - - ```cpp - std::ifstream i("input.json"); - auto j = nlohmann::ordered_json::parse(i); - std::cout << j.dump(2) << std::endl; - ``` - - The output will be: - - ```json - { - "one": 1, - "two": 2, - "three": 3 - } - ``` - -??? failure "Wrong way" - - The following code incorrectly calls the `parse` function from `nlohmann::json` which does not preserve the - insertion order, but sorts object keys. Assigning the result to `nlohmann::ordered_json` compiles, but does not - restore the order from the input file. - - ```cpp - std::ifstream i("input.json"); - nlohmann::ordered_json j = nlohmann::json::parse(i); - std::cout << j.dump(2) << std::endl; - ``` - - The output will be: - - ```json - { - "one": 1, - "three": 3 - "two": 2, - } - ``` diff --git a/docs/mkdocs/docs/features/parsing/index.md b/docs/mkdocs/docs/features/parsing/index.md deleted file mode 100644 index 29493520e1..0000000000 --- a/docs/mkdocs/docs/features/parsing/index.md +++ /dev/null @@ -1,13 +0,0 @@ -# Parsing - -!!! note - - This page is under construction. - -## Input - -## SAX vs. DOM parsing - -## Exceptions - -See [parsing and exceptions](parse_exceptions.md). diff --git a/docs/mkdocs/docs/features/parsing/json_lines.md b/docs/mkdocs/docs/features/parsing/json_lines.md deleted file mode 100644 index 659d317927..0000000000 --- a/docs/mkdocs/docs/features/parsing/json_lines.md +++ /dev/null @@ -1,49 +0,0 @@ -# JSON Lines - -The [JSON Lines](https://jsonlines.org) format is a text format of newline-delimited JSON. In particular: - -1. The input must be UTF-8 encoded. -2. Every line must be a valid JSON value. -3. The line separator must be `\n`. As `\r` is silently ignored, `\r\n` is also supported. -4. The final character may be `\n`, but is not required to be one. - -!!! example "JSON Text example" - - ```json - {"name": "Gilbert", "wins": [["straight", "7♣"], ["one pair", "10♥"]]} - {"name": "Alexa", "wins": [["two pair", "4♠"], ["two pair", "9♠"]]} - {"name": "May", "wins": []} - {"name": "Deloise", "wins": [["three of a kind", "5♣"]]} - ``` - -JSON Lines input with more than one value is treated as invalid JSON by the [`parse`](../../api/basic_json/parse.md) or -[`accept`](../../api/basic_json/accept.md) functions. To process it line by line, functions like -[`std::getline`](https://en.cppreference.com/w/cpp/string/basic_string/getline) can be used: - -!!! example "Example: Parse JSON Text input line by line" - - The example below demonstrates how JSON Lines can be processed. - - ```cpp - --8<-- "examples/json_lines.cpp" - ``` - - Output: - - ```json - --8<-- "examples/json_lines.output" - ``` - -!!! warning "Note" - - Using [`operator>>`](../../api/operator_gtgt.md) like - - ```cpp - json j; - while (input >> j) - { - std::cout << j << std::endl; - } - ``` - - with a JSON Lines input does not work, because the parser will try to parse one value after the last one. diff --git a/docs/mkdocs/docs/features/parsing/parse_exceptions.md b/docs/mkdocs/docs/features/parsing/parse_exceptions.md deleted file mode 100644 index 61c0ff2902..0000000000 --- a/docs/mkdocs/docs/features/parsing/parse_exceptions.md +++ /dev/null @@ -1,121 +0,0 @@ -# Parsing and Exceptions - -When the input is not valid JSON, an exception of type [`parse_error`](../../home/exceptions.md#parse-errors) is thrown. -This exception contains the position in the input where the error occurred, together with a diagnostic message and the -last read input token. The exceptions page contains a -[list of examples for parse error exceptions](../../home/exceptions.md#parse-errors). In case you process untrusted -input, always enclose your code with a `#!cpp try`/`#!cpp catch` block, like - -```cpp -json j; -try -{ - j = json::parse(my_input); -} -catch (json::parse_error& ex) -{ - std::cerr << "parse error at byte " << ex.byte << std::endl; -} -``` - -In case exceptions are undesired or not supported by the environment, there are different ways to proceed: - - -## Switch off exceptions - -The `parse()` function accepts a `#!cpp bool` parameter `allow_exceptions` which controls whether an exception is -thrown when a parse error occurs (`#!cpp true`, default) or whether a discarded value should be returned -(`#!cpp false`). - -```cpp -json j = json::parse(my_input, nullptr, false); -if (j.is_discarded()) -{ - std::cerr << "parse error" << std::endl; -} -``` - -Note there is no diagnostic information available in this scenario. - -## Use accept() function - -Alternatively, function `accept()` can be used which does not return a `json` value, but a `#!cpp bool` indicating -whether the input is valid JSON. - -```cpp -if (!json::accept(my_input)) -{ - std::cerr << "parse error" << std::endl; -} -``` - -Again, there is no diagnostic information available. - - -## User-defined SAX interface - -Finally, you can implement the [SAX interface](sax_interface.md) and decide what should happen in case of a parse error. - -This function has the following interface: - -```cpp -bool parse_error(std::size_t position, - const std::string& last_token, - const json::exception& ex); -``` - -The return value indicates whether the parsing should continue, so the function should usually return `#!cpp false`. - -??? example - - ```cpp - #include - #include "json.hpp" - - using json = nlohmann::json; - - class sax_no_exception : public nlohmann::detail::json_sax_dom_parser - { - public: - sax_no_exception(json& j) - : nlohmann::detail::json_sax_dom_parser(j, false) - {} - - bool parse_error(std::size_t position, - const std::string& last_token, - const json::exception& ex) - { - std::cerr << "parse error at input byte " << position << "\n" - << ex.what() << "\n" - << "last read: \"" << last_token << "\"" - << std::endl; - return false; - } - }; - - int main() - { - std::string myinput = "[1,2,3,]"; - - json result; - sax_no_exception sax(result); - - bool parse_result = json::sax_parse(myinput, &sax); - if (!parse_result) - { - std::cerr << "parsing unsuccessful!" << std::endl; - } - - std::cout << "parsed value: " << result << std::endl; - } - ``` - - Output: - - ``` - parse error at input byte 8 - [json.exception.parse_error.101] parse error at line 1, column 8: syntax error while parsing value - unexpected ']'; expected '[', '{', or a literal - last read: "3,]" - parsing unsuccessful! - parsed value: [1,2,3] - ``` diff --git a/docs/mkdocs/docs/features/parsing/parser_callbacks.md b/docs/mkdocs/docs/features/parsing/parser_callbacks.md deleted file mode 100644 index ef076d126c..0000000000 --- a/docs/mkdocs/docs/features/parsing/parser_callbacks.md +++ /dev/null @@ -1,83 +0,0 @@ -# Parser Callbacks - -## Overview - -With a parser callback function, the result of parsing a JSON text can be influenced. When passed to `parse`, it is -called on certain events (passed as `parse_event_t` via parameter `event`) with a set recursion depth `depth` and -context JSON value `parsed`. The return value of the callback function is a boolean indicating whether the element that -emitted the callback shall be kept or not. - -The type of the callback function is: - -```cpp -template -using parser_callback_t = - std::function; -``` - - -## Callback event types - -We distinguish six scenarios (determined by the event type) in which the callback function can be called. The following -table describes the values of the parameters `depth`, `event`, and `parsed`. - -| parameter `event` | description | parameter `depth` | parameter `parsed` | -|-------------------------------|-----------------------------------------------------------|-------------------------------------------|----------------------------------| -| `parse_event_t::object_start` | the parser read `{` and started to process a JSON object | depth of the parent of the JSON object | a JSON value with type discarded | -| `parse_event_t::key` | the parser read a key of a value in an object | depth of the currently parsed JSON object | a JSON string containing the key | -| `parse_event_t::object_end` | the parser read `}` and finished processing a JSON object | depth of the parent of the JSON object | the parsed JSON object | -| `parse_event_t::array_start` | the parser read `[` and started to process a JSON array | depth of the parent of the JSON array | a JSON value with type discarded | -| `parse_event_t::array_end` | the parser read `]` and finished processing a JSON array | depth of the parent of the JSON array | the parsed JSON array | -| `parse_event_t::value` | the parser finished reading a JSON value | depth of the value | the parsed JSON value | - -??? example - - When parsing the following JSON text, - - ```json - { - "name": "Berlin", - "location": [ - 52.519444, - 13.406667 - ] - } - ``` - - these calls are made to the callback function: - - | event | depth | parsed | - | -------------- | ----- | ------ | - | `object_start` | 0 | *discarded* | - | `key` | 1 | `#!json "name"` | - | `value` | 1 | `#!json "Berlin"` | - | `key` | 1 | `#!json "location"` | - | `array_start` | 1 | *discarded* | - | `value` | 2 | `#!json 52.519444` | - | `value` | 2 | `#!json 13.406667` | - | `array_end` | 1 | `#!json [52.519444,13.406667]` | - | `object_end` | 0 | `#!json {"location":[52.519444,13.406667],"name":"Berlin"}` | - -## Return value - -Discarding a value (i.e., returning `#!c false`) has different effects depending on the context in which the function -was called: - -- Discarded values in structured types are skipped. That is, the parser will behave as if the discarded value was never - read. -- In case a value outside a structured type is skipped, it is replaced with `#!json null`. This case happens if the - top-level element is skipped. - -??? example - - The example below demonstrates the `parse()` function with and without callback function. - - ```cpp - --8<-- "examples/parse__string__parser_callback_t.cpp" - ``` - - Output: - - ```json - --8<-- "examples/parse__string__parser_callback_t.output" - ``` diff --git a/docs/mkdocs/docs/features/parsing/sax_interface.md b/docs/mkdocs/docs/features/parsing/sax_interface.md deleted file mode 100644 index 0796a55f52..0000000000 --- a/docs/mkdocs/docs/features/parsing/sax_interface.md +++ /dev/null @@ -1,73 +0,0 @@ -# SAX Interface - -The library uses a SAX-like interface with the following functions: - -```plantuml -interface json::sax_t { - + {abstract} bool null() - - + {abstract} bool boolean(bool val) - - + {abstract} bool number_integer(number_integer_t val) - + {abstract} bool number_unsigned(number_unsigned_t val) - - + {abstract} bool number_float(number_float_t val, const string_t& s) - - + {abstract} bool string(string_t& val) - + {abstract} bool binary(binary_t& val) - - + {abstract} bool start_object(std::size_t elements) - + {abstract} bool end_object() - + {abstract} bool start_array(std::size_t elements) - + {abstract} bool end_array() - + {abstract} bool key(string_t& val) - - + {abstract} bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) -} -``` - -```cpp -// called when null is parsed -bool null(); - -// called when a boolean is parsed; value is passed -bool boolean(bool val); - -// called when a signed or unsigned integer number is parsed; value is passed -bool number_integer(number_integer_t val); -bool number_unsigned(number_unsigned_t val); - -// called when a floating-point number is parsed; value and original string is passed -bool number_float(number_float_t val, const string_t& s); - -// called when a string is parsed; value is passed and can be safely moved away -bool string(string_t& val); -// called when a binary value is parsed; value is passed and can be safely moved away -bool binary(binary& val); - -// called when an object or array begins or ends, resp. The number of elements is passed (or -1 if not known) -bool start_object(std::size_t elements); -bool end_object(); -bool start_array(std::size_t elements); -bool end_array(); -// called when an object key is parsed; value is passed and can be safely moved away -bool key(string_t& val); - -// called when a parse error occurs; byte position, the last token, and an exception is passed -bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex); -``` - -The return value of each function determines whether parsing should proceed. - -To implement your own SAX handler, proceed as follows: - -1. Implement the SAX interface in a class. You can use class `nlohmann::json_sax` as base class, but you can also use any class where the functions described above are implemented and public. -2. Create an object of your SAX interface class, e.g. `my_sax`. -3. Call `#!cpp bool json::sax_parse(input, &my_sax);` where the first parameter can be any input like a string or an input stream and the second parameter is a pointer to your SAX interface. - -Note the `sax_parse` function only returns a `#!cpp bool` indicating the result of the last executed SAX event. It does not return `json` value - it is up to you to decide what to do with the SAX events. Furthermore, no exceptions are thrown in case of a parse error - it is up to you what to do with the exception object passed to your `parse_error` implementation. Internally, the SAX interface is used for the DOM parser (class `json_sax_dom_parser`) as well as the acceptor (`json_sax_acceptor`), see file `json_sax.hpp`. - -## See also - -- [json_sax](../../api/json_sax/index.md) - documentation of the SAX interface -- [sax_parse](../../api/basic_json/sax_parse.md) - SAX parser diff --git a/docs/mkdocs/docs/features/types/index.md b/docs/mkdocs/docs/features/types/index.md deleted file mode 100644 index d9dfcc29a0..0000000000 --- a/docs/mkdocs/docs/features/types/index.md +++ /dev/null @@ -1,269 +0,0 @@ -# Types - -This page gives an overview how JSON values are stored and how this can be configured. - -## Overview - -By default, JSON values are stored as follows: - -| JSON type | C++ type | -|-----------|-----------------------------------------------| -| object | `std::map` | -| array | `std::vector` | -| null | `std::nullptr_t` | -| string | `std::string` | -| boolean | `bool` | -| number | `std::int64_t`, `std::uint64_t`, and `double` | - -Note there are three different types for numbers - when parsing JSON text, the best fitting type is chosen. - -## Storage - -```plantuml -enum value_t { - null - object - array - string - boolean - number_integer - number_unsigned - number_float - binary - discarded -} - -class json_value << (U,orchid) >> { - object_t* object - array_t* array - string_t* string - binary_t* binary - boolean_t boolean - number_integer_t number_integer - number_unsigned_t number_unsigned - number_float_t number_float -} - -class basic_json { - -- type and value -- - value_t m_type - json_value m_value - -- derived types -- - + typedef object_t - + typedef array_t - + typedef binary_t - + typedef boolean_t - + typedef number_integer_t - + typedef number_unsigned_t - + typedef number_float_t -} - -basic_json .. json_value -basic_json .. value_t -``` - -## Template arguments - -The data types to store a JSON value are derived from the template arguments passed to class `basic_json`: - -```cpp -template< - template class ObjectType = std::map, - template class ArrayType = std::vector, - class StringType = std::string, - class BooleanType = bool, - class NumberIntegerType = std::int64_t, - class NumberUnsignedType = std::uint64_t, - class NumberFloatType = double, - template class AllocatorType = std::allocator, - template class JSONSerializer = adl_serializer, - class BinaryType = std::vector -> -class basic_json; -``` - -Type `json` is an alias for `basic_json<>` and uses the default types. - -From the template arguments, the following types are derived: - -```cpp -using object_comparator_t = std::less<>; -using object_t = ObjectType>>; - -using array_t = ArrayType>; - -using string_t = StringType; - -using boolean_t = BooleanType; - -using number_integer_t = NumberIntegerType; -using number_unsigned_t = NumberUnsignedType; -using number_float_t = NumberFloatType; - -using binary_t = nlohmann::byte_container_with_subtype; -``` - - -## Objects - -[RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON objects as follows: - -> An object is an unordered collection of zero or more name/value pairs, where a name is a string and a value is a string, number, boolean, null, object, or array. - -### Default type - -With the default values for *ObjectType* (`std::map`), *StringType* (`std::string`), and *AllocatorType* (`std::allocator`), the default value for `object_t` is: - -```cpp -std::map< - std::string, // key_type - basic_json, // value_type - std::less<>, // key_compare - std::allocator> // allocator_type -> -``` - -### Behavior - -The choice of `object_t` influences the behavior of the JSON class. With the default type, objects have the following behavior: - -- When all names are unique, objects will be interoperable in the sense that all software implementations receiving that object will agree on the name-value mappings. -- When the names within an object are not unique, it is unspecified which one of the values for a given key will be chosen. For instance, `#!json {"key": 2, "key": 1}` could be equal to either `#!json {"key": 1}` or `#!json {"key": 2}`. -- Internally, name/value pairs are stored in lexicographical order of the names. Objects will also be serialized (see `dump`) in this order. For instance, both `#!json {"b": 1, "a": 2}` and `#!json {"a": 2, "b": 1}` will be stored and serialized as `#!json {"a": 2, "b": 1}`. -- When comparing objects, the order of the name/value pairs is irrelevant. This makes objects interoperable in the sense that they will not be affected by these differences. For instance, `#!json {"b": 1, "a": 2}` and `#!json {"a": 2, "b": 1}` will be treated as equal. - -### Key order - -The order name/value pairs are added to the object is *not* preserved by the library. Therefore, iterating an object may return name/value pairs in a different order than they were originally stored. In fact, keys will be traversed in alphabetical order as `std::map` with `std::less` is used by default. Please note this behavior conforms to [RFC 8259](https://tools.ietf.org/html/rfc8259), because any order implements the specified "unordered" nature of JSON objects. - -### Limits - -[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: - -> An implementation may set limits on the maximum depth of nesting. - -In this class, the object's limit of nesting is not explicitly constrained. However, a maximum depth of nesting may be introduced by the compiler or runtime environment. A theoretical limit can be queried by calling the `max_size` function of a JSON object. - -### Storage - -Objects are stored as pointers in a `basic_json` type. That is, for any access to object values, a pointer of type `object_t*` must be dereferenced. - - -## Arrays - -[RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON arrays as follows: - -> An array is an ordered sequence of zero or more values. - -### Default type - -With the default values for *ArrayType* (`std::vector`) and *AllocatorType* (`std::allocator`), the default value for `array_t` is: - -```cpp -std::vector< - basic_json, // value_type - std::allocator // allocator_type -> -``` - -### Limits - -[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: - -> An implementation may set limits on the maximum depth of nesting. - -In this class, the array's limit of nesting is not explicitly constrained. However, a maximum depth of nesting may be introduced by the compiler or runtime environment. A theoretical limit can be queried by calling the `max_size` function of a JSON array. - -### Storage - -Arrays are stored as pointers in a `basic_json` type. That is, for any access to array values, a pointer of type `array_t*` must be dereferenced. - - -## Strings - -[RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON strings as follows: - -> A string is a sequence of zero or more Unicode characters. - -Unicode values are split by the JSON class into byte-sized characters during deserialization. - -### Default type - -With the default values for *StringType* (`std::string`), the default value for `string_t` is `#!cpp std::string`. - -### Encoding - -Strings are stored in UTF-8 encoding. Therefore, functions like `std::string::size()` or `std::string::length()` return the number of **bytes** in the string rather than the number of characters or glyphs. - -### String comparison - -[RFC 8259](https://tools.ietf.org/html/rfc8259) states: - -> Software implementations are typically required to test names of object members for equality. Implementations that transform the textual representation into sequences of Unicode code units and then perform the comparison numerically, code unit by code unit, are interoperable in the sense that implementations will agree in all cases on equality or inequality of two strings. For example, implementations that compare strings with escaped characters unconverted may incorrectly find that `"a\\b"` and `"a\u005Cb"` are not equal. - -This implementation is interoperable as it does compare strings code unit by code unit. - -### Storage - -String values are stored as pointers in a `basic_json` type. That is, for any access to string values, a pointer of type `string_t*` must be dereferenced. - - -## Booleans - -[RFC 8259](https://tools.ietf.org/html/rfc8259) implicitly describes a boolean as a type which differentiates the two literals `true` and `false`. - -### Default type - -With the default values for *BooleanType* (`#!cpp bool`), the default value for `boolean_t` is `#!cpp bool`. - -### Storage - -Boolean values are stored directly inside a `basic_json` type. - -## Numbers - -See the [number handling](number_handling.md) article for a detailed discussion on how numbers are handled by this library. - -[RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows: - -> The representation of numbers is similar to that used in most programming languages. A number is represented in base 10 using decimal digits. It contains an integer component that may be prefixed with an optional minus sign, which may be followed by a fraction part and/or an exponent part. Leading zeros are not allowed. (...) Numeric values that cannot be represented in the grammar below (such as Infinity and NaN) are not permitted. - -This description includes both integer and floating-point numbers. However, C++ allows more precise storage if it is known whether the number is a signed integer, an unsigned integer or a floating-point number. Therefore, three different types, `number_integer_t`, `number_unsigned_t`, and `number_float_t` are used. - -### Default types - -With the default values for *NumberIntegerType* (`std::int64_t`), the default value for `number_integer_t` is `std::int64_t`. -With the default values for *NumberUnsignedType* (`std::uint64_t`), the default value for `number_unsigned_t` is `std::uint64_t`. -With the default values for *NumberFloatType* (`#!cpp double`), the default value for `number_float_t` is `#!cpp double`. - -### Default behavior - -- The restrictions about leading zeros is not enforced in C++. Instead, leading zeros in integer literals lead to an interpretation as octal number. Internally, the value will be stored as decimal number. For instance, the C++ integer literal `#!c 010` will be serialized to `#!c 8`. During deserialization, leading zeros yield an error. -- Not-a-number (NaN) values will be serialized to `#!json null`. - -### Limits - -[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: - -> An implementation may set limits on the range and precision of numbers. - -When the default type is used, the maximal integer number that can be stored is `#!c 9223372036854775807` (`INT64_MAX`) and the minimal integer number that can be stored is `#!c -9223372036854775808` (`INT64_MIN`). Integer numbers that are out of range will yield over/underflow when used in a constructor. During deserialization, too large or small integer numbers will be automatically be stored as `number_unsigned_t` or `number_float_t`. - -When the default type is used, the maximal unsigned integer number that can be stored is `#!c 18446744073709551615` (`UINT64_MAX`) and the minimal integer number that can be stored is `#!c 0`. Integer numbers that are out of range will yield over/underflow when used in a constructor. During deserialization, too large or small integer numbers will be automatically be stored as `number_integer_t` or `number_float_t`. - -[RFC 8259](https://tools.ietf.org/html/rfc8259) further states: - -> Note that when such software is used, numbers that are integers and are in the range $[-2^{53}+1, 2^{53}-1]$ are interoperable in the sense that implementations will agree exactly on their numeric values. - -As this range is a subrange of the exactly supported range [`INT64_MIN`, `INT64_MAX`], this class's integer type is interoperable. - -[RFC 8259](https://tools.ietf.org/html/rfc8259) states: - -> This specification allows implementations to set limits on the range and precision of numbers accepted. Since software that implements IEEE 754-2008 binary64 (double precision) numbers is generally available and widely used, good interoperability can be achieved by implementations that expect no more precision or range than these provide, in the sense that implementations will approximate JSON numbers within the expected precision. - -This implementation does exactly follow this approach, as it uses double precision floating-point numbers. Note values smaller than `#!c -1.79769313486232e+308` and values greater than `#!c 1.79769313486232e+308` will be stored as NaN internally and be serialized to `#!json null`. - -### Storage - -Integer number values, unsigned integer number values, and floating-point number values are stored directly inside a `basic_json` type. diff --git a/docs/mkdocs/docs/features/types/number_handling.md b/docs/mkdocs/docs/features/types/number_handling.md deleted file mode 100644 index c457ae07c0..0000000000 --- a/docs/mkdocs/docs/features/types/number_handling.md +++ /dev/null @@ -1,328 +0,0 @@ -# Number Handling - -This document describes how the library is handling numbers. - -## Background - -This section briefly summarizes how the JSON specification describes how numbers should be handled. - -### JSON number syntax - -JSON defines the syntax of numbers as follows: - -!!! quote "[RFC 8259](https://tools.ietf.org/html/rfc8259#section-6), Section 6" - - The representation of numbers is similar to that used in most - programming languages. A number is represented in base 10 using - decimal digits. It contains an integer component that may be - prefixed with an optional minus sign, which may be followed by a - fraction part and/or an exponent part. Leading zeros are not - allowed. - - A fraction part is a decimal point followed by one or more digits. - - An exponent part begins with the letter E in uppercase or lowercase, - which may be followed by a plus or minus sign. The E and optional - sign are followed by one or more digits. - -The following railroad diagram from [json.org](https://json.org) visualizes the number syntax: - -![Syntax for JSON numbers](../../images/json_syntax_number.png) - -### Number interoperability - -On number interoperability, the following remarks are made: - -!!! quote "[RFC 8259](https://tools.ietf.org/html/rfc8259#section-6), Section 6" - - This specification allows implementations to set limits on the range - and precision of numbers accepted. Since software that implements - IEEE 754 binary64 (double precision) numbers [IEEE754] is generally - available and widely used, good interoperability can be achieved by - implementations that expect no more precision or range than these - provide, in the sense that implementations will approximate JSON - numbers within the expected precision. A JSON number such as 1E400 - or 3.141592653589793238462643383279 may indicate potential - interoperability problems, since it suggests that the software that - created it expects receiving software to have greater capabilities - for numeric magnitude and precision than is widely available. - - Note that when such software is used, numbers that are integers and - are in the range $[-2^{53}+1, 2^{53}-1]$ are interoperable in the - sense that implementations will agree exactly on their numeric - values. - -## Library implementation - -This section describes how the above number specification is implemented by this library. - -### Number storage - -In the default [`json`](../../api/json.md) type, numbers are stored as `#!c std::uint64_t`, `#!c std::int64_t`, and -`#!c double`, respectively. Thereby, `#!c std::uint64_t` and `#!c std::int64_t` are used only if they can store the -number without loss of precision. If this is impossible (e.g., if the number is too large), the number is stored as -`#!c double`. - -!!! info "Notes" - - - Numbers with a decimal digit or scientific notation are always stored as `#!c double`. - - The number types can be changed, see [Template number types](#template-number-types). - - As of version 3.9.1, the conversion is realized by - [`std::strtoull`](https://en.cppreference.com/w/cpp/string/byte/strtoul), - [`std::strtoll`](https://en.cppreference.com/w/cpp/string/byte/strtol), and - [`std::strtod`](https://en.cppreference.com/w/cpp/string/byte/strtof), respectively. - -!!! example "Examples" - - - Integer `#!c -12345678912345789123456789` is smaller than `#!c INT64_MIN` and will be stored as floating-point - number `#!c -1.2345678912345788e+25`. - - Integer `#!c 1E3` will be stored as floating-point number `#!c 1000.0`. - -### Number limits - -- Any 64-bit signed or unsigned integer can be stored without loss of precision. -- Numbers exceeding the limits of `#!c double` (i.e., numbers that after conversion via -[`std::strtod`](https://en.cppreference.com/w/cpp/string/byte/strtof) are not satisfying -[`std::isfinite`](https://en.cppreference.com/w/cpp/numeric/math/isfinite) such as `#!c 1E400`) will throw exception -[`json.exception.out_of_range.406`](../../home/exceptions.md#jsonexceptionout_of_range406) during parsing. -- Floating-point numbers are rounded to the next number representable as `double`. For instance -`#!c 3.141592653589793238462643383279` is stored as [`0x400921fb54442d18`](https://float.exposed/0x400921fb54442d18). -This is the same behavior as the code `#!c double x = 3.141592653589793238462643383279;`. - -!!! success "Interoperability" - - - The library interoperable with respect to the specification, because its supported range $[-2^{63}, 2^{64}-1]$ is - larger than the described range $[-2^{53}+1, 2^{53}-1]$. - - All integers outside the range $[-2^{63}, 2^{64}-1]$, as well as floating-point numbers are stored as `double`. - This also concurs with the specification above. - -### Zeros - -The JSON number grammar allows for different ways to express zero, and this library will store zeros differently: - -| Literal | Stored value and type | Serialization | -|---------|------------------------|---------------| -| `0` | `#!c std::uint64_t(0)` | `0` | -| `-0` | `#!c std::int64_t(0)` | `0` | -| `0.0` | `#!c double(0.0)` | `0.0` | -| `-0.0` | `#!c double(-0.0)` | `-0.0` | -| `0E0` | `#!c double(0.0)` | `0.0` | -| `-0E0` | `#!c double(-0.0)` | `-0.0` | - -That is, `-0` is stored as a signed integer, but the serialization does not reproduce the `-`. - -### Number serialization - -- Integer numbers are serialized as is; that is, no scientific notation is used. -- Floating-point numbers are serialized as specified by the `#!c %g` printf modifier with - [`std::numeric_limits::max_digits10`](https://en.cppreference.com/w/cpp/types/numeric_limits/max_digits10) - significant digits. The rationale is to use the shortest representation while still allow round-tripping. - -!!! hint "Notes regarding precision of floating-point numbers" - - As described above, floating-point numbers are rounded to the nearest double and serialized with the shortest - representation to allow round-tripping. This can yield confusing examples: - - - The serialization can have fewer decimal places than the input: `#!c 2555.5599999999999` will be serialized as - `#!c 2555.56`. The reverse can also be true. - - The serialization can be in scientific notation even if the input is not: `#!c 0.0000972439793401814` will be - serialized as `#!c 9.72439793401814e-05`. The reverse can also be true: `#!c 12345E-5` will be serialized as - `#!c 0.12345`. - - Conversions from `#!c float` to `#!c double` can also introduce rounding errors: - ```cpp - float f = 0.3; - json j = f; - std::cout << j << '\n'; - ``` - yields `#!c 0.30000001192092896`. - - All examples here can be reproduced by passing the original double value to - - ```cpp - std::printf("%.*g\n", std::numeric_limits::max_digits10, double_value); - ``` - -#### NaN handling - -NaN (not-a-number) cannot be expressed with the number syntax described above and are in fact explicitly excluded: - -!!! quote "[RFC 8259](https://tools.ietf.org/html/rfc8259#section-6), Section 6" - - Numeric values that cannot be represented in the grammar below (such - as Infinity and NaN) are not permitted. - -That is, there is no way to *parse* a NaN value. However, NaN values can be stored in a JSON value by assignment. - -This library serializes NaN values as `#!js null`. This corresponds to the behavior of JavaScript's -[`JSON.stringify`](https://www.w3schools.com/js/js_json_stringify.asp) function. - -!!! example - - The following example shows how a NaN value is stored in a `json` value. - - ```cpp - int main() - { - double val = std::numeric_limits::quiet_NaN(); - std::cout << "val=" << val << std::endl; - json j = val; - std::cout << "j=" << j.dump() << std::endl; - val = j; - std::cout << "val=" << val << std::endl; - } - ``` - - output: - - ``` - val=nan - j=null - val=nan - ``` - -### Number comparison - -Floating-point inside JSON values numbers are compared with `#!c json::number_float_t::operator==` which is -`#!c double::operator==` by default. - -!!! example "Alternative comparison functions" - - To compare floating-point while respecting an epsilon, an alternative - [comparison function](https://github.com/mariokonrad/marnav/blob/master/include/marnav/math/floatingpoint.hpp#L34-#L39) - could be used, for instance - - ```cpp - template::value, T>::type> - inline bool is_same(T a, T b, T epsilon = std::numeric_limits::epsilon()) noexcept - { - return std::abs(a - b) <= epsilon; - } - ``` - Or you can self-define an operator equal function like this: - - ```cpp - bool my_equal(const_reference lhs, const_reference rhs) - { - const auto lhs_type lhs.type(); - const auto rhs_type rhs.type(); - if (lhs_type == rhs_type) - { - switch(lhs_type) - { - // self_defined case - case value_t::number_float: - return std::abs(lhs - rhs) <= std::numeric_limits::epsilon(); - - // other cases remain the same with the original - ... - } - } - ... - } - ``` - - (see [#703](https://github.com/nlohmann/json/issues/703) for more information.) - -!!! note - - NaN values never compare equal to themselves or to other NaN values. See [#514](https://github.com/nlohmann/json/issues/514). - -### Number conversion - -Just like the C++ language itself, the `get` family of functions allows conversions between unsigned and signed -integers, and between integers and floating-point values to integers. This behavior may be surprising. - -!!! warning "Unconditional number conversions" - - ```cpp hl_lines="3" - double d = 42.3; // non-integer double value 42.3 - json jd = d; // stores double value 42.3 - std::int64_t i = jd.template get(); // now i==42; no warning or error is produced - ``` - - Note the last line with throw a [`json.exception.type_error.302`](../../home/exceptions.md#jsonexceptiontype_error302) - exception if `jd` is not a numerical type, for instance a string. - -The rationale is twofold: - -1. JSON does not define a number type or precision (see [#json-specification](above)). -2. C++ also allows to silently convert between number types. - -!!! success "Conditional number conversion" - - The code above can be solved by explicitly checking the nature of the value with members such as - [`is_number_integer()`](../../api/basic_json/is_number_integer.md) or - [`is_number_unsigned()`](../../api/basic_json/is_number_unsigned.md): - - ```cpp hl_lines="2" - // check if jd is really integer-valued - if (jd.is_number_integer()) - { - // if so, do the conversion and use i - std::int64_t i = jd.template get(); - // ... - } - else - { - // otherwise, take appropriate action - // ... - } - ``` - - Note this approach also has the advantage that it can react on non-numerical JSON value types such as strings. - - (Example taken from [#777](https://github.com/nlohmann/json/issues/777#issuecomment-459968458).) - -### Determine number types - -As the example in [Number conversion](#number-conversion) shows, there are different functions to determine the type of -the stored number: - -- [`is_number()`](../../api/basic_json/is_number.md) returns `#!c true` for any number type -- [`is_number_integer()`](../../api/basic_json/is_number_integer.md) returns `#!c true` for signed and unsigned integers -- [`is_number_unsigned()`](../../api/basic_json/is_number_unsigned.md) returns `#!c true` for unsigned integers only -- [`is_number_float()`](../../api/basic_json/is_number_float.md) returns `#!c true` for floating-point numbers -- [`type_name()`](../../api/basic_json/type_name.md) returns `#!c "number"` for any number type -- [`type()`](../../api/basic_json/type.md) returns a different enumerator of - [`value_t`](../../api/basic_json/value_t.md) for all number types - -| function | unsigned integer | signed integer | floating-point | string | -|----------------------------------------------------------------------|-------------------|------------------|----------------|----------------| -| [`is_number()`](../../api/basic_json/is_number.md) | `#!c true` | `#!c true` | `#!c true` | `#!c false` | -| [`is_number_integer()`](../../api/basic_json/is_number_integer.md) | `#!c true` | `#!c true` | `#!c false` | `#!c false` | -| [`is_number_unsigned()`](../../api/basic_json/is_number_unsigned.md) | `#!c true` | `#!c false` | `#!c false` | `#!c false` | -| [`is_number_float()`](../../api/basic_json/is_number_float.md) | `#!c false` | `#!c false` | `#!c true` | `#!c false` | -| [`type_name()`](../../api/basic_json/type_name.md) | `#!c "number"` | `#!c "number"` | `#!c "number"` | `#!c "string"` | -| [`type()`](../../api/basic_json/type.md) | `number_unsigned` | `number_integer` | `number_float` | `string` | - -### Template number types - -The number types can be changed with template parameters. - -| position | number type | default type | possible values | -|----------|-------------------|---------------------|------------------------------------------------| -| 5 | signed integers | `#!c std::int64_t` | `#!c std::int32_t`, `#!c std::int16_t`, etc. | -| 6 | unsigned integers | `#!c std::uint64_t` | `#!c std::uint32_t`, `#!c std::uint16_t`, etc. | -| 7 | floating-point | `#!c double` | `#!c float`, `#!c long double` | - -!!! info "Constraints on number types" - - - The type for signed integers must be convertible from `#!c long long`. The type for floating-point numbers is used - in case of overflow. - - The type for unsigned integers must be convertible from `#!c unsigned long long`. The type for floating-point - numbers is used in case of overflow. - - The types for signed and unsigned integers must be distinct, see - [#2573](https://github.com/nlohmann/json/issues/2573). - - Only `#!c double`, `#!c float`, and `#!c long double` are supported for floating-point numbers. - -!!! example - - A `basic_json` type that uses `#!c long double` as floating-point type. - - ```cpp hl_lines="2" - using json_ld = nlohmann::basic_json; - ``` - - Note values should then be parsed with `json_ld::parse` rather than `json::parse` as the latter would parse - floating-point values to `#!c double` before then converting them to `#!c long double`. diff --git a/docs/mkdocs/docs/home/code_of_conduct.md b/docs/mkdocs/docs/home/code_of_conduct.md deleted file mode 100644 index 770b8173e1..0000000000 --- a/docs/mkdocs/docs/home/code_of_conduct.md +++ /dev/null @@ -1,46 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at mail@nlohmann.me. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] - -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ diff --git a/docs/mkdocs/docs/home/design_goals.md b/docs/mkdocs/docs/home/design_goals.md deleted file mode 100644 index b80551fe97..0000000000 --- a/docs/mkdocs/docs/home/design_goals.md +++ /dev/null @@ -1,17 +0,0 @@ -# Design goals - -There are myriads of [JSON](https://json.org) libraries out there, and each may even have its reason to exist. Our class had these design goals: - -- **Intuitive syntax**. In languages such as Python, JSON feels like a first class data type. We used all the operator magic of modern C++ to achieve the same feeling in your code. Check out the [examples below](#examples), and you'll know what I mean. - -- **Trivial integration**. Our whole code consists of a single header file [`json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp). That's it. No library, no subproject, no dependencies, no complex build system. The class is written in vanilla C++11. All in all, everything should require no adjustment of your compiler flags or project settings. - -- **Serious testing**. Our class is heavily [unit-tested](https://github.com/nlohmann/json/tree/develop/test/src) and covers [100%](https://coveralls.io/r/nlohmann/json) of the code, including all exceptional behavior. Furthermore, we checked with [Valgrind](http://valgrind.org) and the [Clang Sanitizers](https://clang.llvm.org/docs/index.html) that there are no memory leaks. [Google OSS-Fuzz](https://github.com/google/oss-fuzz/tree/master/projects/json) additionally runs fuzz tests against all parsers 24/7, effectively executing billions of tests so far. To maintain high quality, the project is following the [Core Infrastructure Initiative (CII) best practices](https://bestpractices.coreinfrastructure.org/projects/289). - -Other aspects were not so important to us: - -- **Memory efficiency**. Each JSON object has an overhead of one pointer (the maximal size of a union) and one enumeration element (1 byte). The default generalization uses the following C++ data types: `std::string` for strings, `int64_t`, `uint64_t` or `double` for numbers, `std::map` for objects, `std::vector` for arrays, and `bool` for Booleans. However, you can template the generalized class `basic_json` to your needs. - -- **Speed**. There are certainly [faster JSON libraries](https://github.com/miloyip/nativejson-benchmark#parsing-time) out there. However, if your goal is to speed up your development by adding JSON support with a single header, then this library is the way to go. If you know how to use a `std::vector` or `std::map`, you are already set. - -See the [contribution guidelines](https://github.com/nlohmann/json/blob/master/.github/CONTRIBUTING.md#please-dont) for more information. diff --git a/docs/mkdocs/docs/home/exceptions.md b/docs/mkdocs/docs/home/exceptions.md deleted file mode 100644 index 0ecf8557ca..0000000000 --- a/docs/mkdocs/docs/home/exceptions.md +++ /dev/null @@ -1,896 +0,0 @@ -# Exceptions - -## Overview - -### Base type - -All exceptions inherit from class `json::exception` (which in turn inherits from `std::exception`). It is used as the base class for all exceptions thrown by the `basic_json` class. This class can hence be used as "wildcard" to catch exceptions. - -```plantuml -std::exception <|-- json::exception -json::exception <|-- json::parse_error -json::exception <|-- json::invalid_iterator -json::exception <|-- json::type_error -json::exception <|-- json::out_of_range -json::exception <|-- json::other_error - -interface std::exception {} - -class json::exception { - + const int id - + const char* what() const -} - -class json::parse_error { - + const std::size_t byte -} -``` - -### Switch off exceptions - -Exceptions are used widely within the library. They can, however, be switched off with either using the compiler flag `-fno-exceptions` or by defining the symbol [`JSON_NOEXCEPTION`](../api/macros/json_noexception.md). In this case, exceptions are replaced by `abort()` calls. You can further control this behavior by defining `JSON_THROW_USER` (overriding `#!cpp throw`), `JSON_TRY_USER` (overriding `#!cpp try`), and `JSON_CATCH_USER` (overriding `#!cpp catch`). - -Note that [`JSON_THROW_USER`](../api/macros/json_throw_user.md) should leave the current scope (e.g., by throwing or aborting), as continuing after it may yield undefined behavior. - -??? example - - The code below switches off exceptions and creates a log entry with a detailed error message in case of errors. - - ```cpp - #include - - #define JSON_TRY_USER if(true) - #define JSON_CATCH_USER(exception) if(false) - #define JSON_THROW_USER(exception) \ - {std::clog << "Error in " << __FILE__ << ":" << __LINE__ \ - << " (function " << __FUNCTION__ << ") - " \ - << (exception).what() << std::endl; \ - std::abort();} - - #include - ``` - -Note the explanatory [`what()`](https://en.cppreference.com/w/cpp/error/exception/what) string of exceptions is not available for MSVC if exceptions are disabled, see [#2824](https://github.com/nlohmann/json/discussions/2824). - -See [documentation of `JSON_TRY_USER`, `JSON_CATCH_USER` and `JSON_THROW_USER`](../api/macros/json_throw_user.md) for more information. - -### Extended diagnostic messages - -Exceptions in the library are thrown in the local context of the JSON value they are detected. This makes detailed diagnostics messages, and hence debugging, difficult. - -??? example - - ```cpp - --8<-- "examples/diagnostics_standard.cpp" - ``` - - Output: - - ``` - --8<-- "examples/diagnostics_standard.output" - ``` - - This exception can be hard to debug if storing the value `#!c "12"` and accessing it is further apart. - -To create better diagnostics messages, each JSON value needs a pointer to its parent value such that a global context (i.e., a path from the root value to the value that lead to the exception) can be created. That global context is provided as [JSON Pointer](../features/json_pointer.md). - -As this global context comes at the price of storing one additional pointer per JSON value and runtime overhead to maintain the parent relation, extended diagnostics are disabled by default. They can, however, be enabled by defining the preprocessor symbol [`JSON_DIAGNOSTICS`](../api/macros/json_diagnostics.md) to `1` before including `json.hpp`. - -??? example - - ```cpp - --8<-- "examples/diagnostics_extended.cpp" - ``` - - Output: - - ``` - --8<-- "examples/diagnostics_extended.output" - ``` - - Now the exception message contains a JSON Pointer `/address/housenumber` that indicates which value has the wrong type. - -See [documentation of `JSON_DIAGNOSTICS`](../api/macros/json_diagnostics.md) for more information. - -## Parse errors - -This exception is thrown by the library when a parse error occurs. Parse errors -can occur during the deserialization of JSON text, CBOR, MessagePack, as well -as when using JSON Patch. - -Exceptions have ids 1xx. - -!!! info "Byte index" - - Member `byte` holds the byte index of the last read character in the input - file. - - For an input with n bytes, 1 is the index of the first character and n+1 - is the index of the terminating null byte or the end of file. This also - holds true when reading a byte vector (CBOR or MessagePack). - -??? example - - The following code shows how a `parse_error` exception can be caught. - - ```cpp - --8<-- "examples/parse_error.cpp" - ``` - - Output: - - ``` - --8<-- "examples/parse_error.output" - ``` - - -### json.exception.parse_error.101 - -This error indicates a syntax error while deserializing a JSON text. The error message describes that an unexpected token (character) was encountered, and the member `byte` indicates the error position. - -!!! failure "Example message" - - Input ended prematurely: - - ``` - [json.exception.parse_error.101] parse error at 2: unexpected end of input; expected string literal - ``` - - No input: - - ``` - [json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal - ``` - - Control character was not escaped: - - ``` - [json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0009 (HT) must be escaped to \u0009 or \\; last read: '"'" - ``` - - String was not closed: - - ``` - [json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: missing closing quote; last read: '"' - ``` - - Invalid number format: - - ``` - [json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid number; expected '+', '-', or digit after exponent; last read: '1E' - ``` - - `\u` was not be followed by four hex digits: - - ``` - [json.exception.parse_error.101] parse error at line 1, column 6: syntax error while parsing value - invalid string: '\u' must be followed by 4 hex digits; last read: '"\u01"' - ``` - - Invalid UTF-8 surrogate pair: - - ``` - [json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF; last read: '"\uD7FF\uDC00'" - ``` - - Invalid UTF-8 byte: - - ``` - [json.exception.parse_error.101] parse error at line 3, column 24: syntax error while parsing value - invalid string: ill-formed UTF-8 byte; last read: '"vous \352t' - ``` - -!!! tip - - - Make sure the input is correctly read. Try to write the input to standard output to check if, for instance, the input file was successfully opened. - - Paste the input to a JSON validator like or a tool like [jq](https://stedolan.github.io/jq/). - -### json.exception.parse_error.102 - -JSON uses the `\uxxxx` format to describe Unicode characters. Code points above 0xFFFF are split into two `\uxxxx` entries ("surrogate pairs"). This error indicates that the surrogate pair is incomplete or contains an invalid code point. - -!!! failure "Example message" - - ``` - parse error at 14: missing or wrong low surrogate - ``` - -!!! note - - This exception is not used any more. Instead [json.exception.parse_error.101](#jsonexceptionparse_error101) with a more detailed description is used. - -### json.exception.parse_error.103 - -Unicode supports code points up to 0x10FFFF. Code points above 0x10FFFF are invalid. - -!!! failure "Example message" - - ``` - parse error: code points above 0x10FFFF are invalid - ``` - -!!! note - - This exception is not used any more. Instead [json.exception.parse_error.101](#jsonexceptionparse_error101) with a more detailed description is used. - -### json.exception.parse_error.104 - -[RFC 6902](https://tools.ietf.org/html/rfc6902) requires a JSON Patch document to be a JSON document that represents an array of objects. - -!!! failure "Example message" - - ``` - [json.exception.parse_error.104] parse error: JSON patch must be an array of objects - ``` - -### json.exception.parse_error.105 - -An operation of a JSON Patch document must contain exactly one "op" member, whose value indicates the operation to perform. Its value must be one of "add", "remove", "replace", "move", "copy", or "test"; other values are errors. - -!!! failure "Example message" - - ``` - [json.exception.parse_error.105] parse error: operation 'add' must have member 'value' - ``` - ``` - [json.exception.parse_error.105] parse error: operation 'copy' must have string member 'from' - ``` - ``` - [json.exception.parse_error.105] parse error: operation value 'foo' is invalid - ``` - -### json.exception.parse_error.106 - -An array index in a JSON Pointer ([RFC 6901](https://tools.ietf.org/html/rfc6901)) may be `0` or any number without a leading `0`. - -!!! failure "Example message" - - ``` - [json.exception.parse_error.106] parse error: array index '01' must not begin with '0' - ``` - -### json.exception.parse_error.107 - -A JSON Pointer must be a Unicode string containing a sequence of zero or more reference tokens, each prefixed by a `/` character. - -!!! failure "Example message" - - ``` - [json.exception.parse_error.107] parse error at byte 1: JSON pointer must be empty or begin with '/' - was: 'foo' - ``` - -### json.exception.parse_error.108 - -In a JSON Pointer, only `~0` and `~1` are valid escape sequences. - -!!! failure "Example message" - - ``` - [json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1' - ``` - -### json.exception.parse_error.109 - -A JSON Pointer array index must be a number. - -!!! failure "Example messages" - - ``` - [json.exception.parse_error.109] parse error: array index 'one' is not a number - ``` - ``` - [json.exception.parse_error.109] parse error: array index '+1' is not a number - ``` - -### json.exception.parse_error.110 - -When parsing CBOR or MessagePack, the byte vector ends before the complete value has been read. - -!!! failure "Example message" - - ``` - [json.exception.parse_error.110] parse error at byte 5: syntax error while parsing CBOR string: unexpected end of input - ``` - ``` - [json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON value: expected end of input; last byte: 0x5A - ``` - -### json.exception.parse_error.112 - -An unexpected byte was read in a [binary format](../features/binary_formats/index.md) or length information is invalid ([BSON](../features/binary_formats/bson.md)). - -!!! failure "Example messages" - - ``` - [json.exception.parse_error.112] parse error at byte 1: syntax error while parsing CBOR value: invalid byte: 0x1C - ``` - ``` - [json.exception.parse_error.112] parse error at byte 1: syntax error while parsing MessagePack value: invalid byte: 0xC1 - ``` - ``` - [json.exception.parse_error.112] parse error at byte 4: syntax error while parsing BJData size: expected '#' after type information; last byte: 0x02 - ``` - ``` - [json.exception.parse_error.112] parse error at byte 4: syntax error while parsing UBJSON size: expected '#' after type information; last byte: 0x02 - ``` - ``` - [json.exception.parse_error.112] parse error at byte 10: syntax error while parsing BSON string: string length must be at least 1, is -2147483648 - ``` - ``` - [json.exception.parse_error.112] parse error at byte 15: syntax error while parsing BSON binary: byte array length cannot be negative, is -1 - ``` - -### json.exception.parse_error.113 - -While parsing a map key, a value that is not a string has been read. - -!!! failure "Example messages" - - ``` - [json.exception.parse_error.113] parse error at byte 2: syntax error while parsing CBOR string: expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0xFF - ``` - ``` - [json.exception.parse_error.113] parse error at byte 2: syntax error while parsing MessagePack string: expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0xFF - ``` - ``` - [json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON char: byte after 'C' must be in range 0x00..0x7F; last byte: 0x82 - ``` - -### json.exception.parse_error.114 - -The parsing of the corresponding BSON record type is not implemented (yet). - -!!! failure "Example message" - - ``` - [json.exception.parse_error.114] parse error at byte 5: Unsupported BSON record type 0xFF - ``` - -### json.exception.parse_error.115 - -A UBJSON high-precision number could not be parsed. - -!!! failure "Example message" - - ``` - [json.exception.parse_error.115] parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A - ``` - -## Iterator errors - -This exception is thrown if iterators passed to a library function do not match -the expected semantics. - -Exceptions have ids 2xx. - -??? example - - The following code shows how an `invalid_iterator` exception can be caught. - - ```cpp - --8<-- "examples/invalid_iterator.cpp" - ``` - - Output: - - ``` - --8<-- "examples/invalid_iterator.output" - ``` - -### json.exception.invalid_iterator.201 - -The iterators passed to constructor `basic_json(InputIT first, InputIT last)` are not compatible, meaning they do not belong to the same container. Therefore, the range (`first`, `last`) is invalid. - -!!! failure "Example message" - - ``` - [json.exception.invalid_iterator.201] iterators are not compatible - ``` - -### json.exception.invalid_iterator.202 - -In the [erase](../api/basic_json/erase.md) or insert function, the passed iterator `pos` does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion. - -!!! failure "Example messages" - - ``` - [json.exception.invalid_iterator.202] iterator does not fit current value - ``` - ``` - [json.exception.invalid_iterator.202] iterators first and last must point to objects - ``` - -### json.exception.invalid_iterator.203 - -Either iterator passed to function [`erase(IteratorType first, IteratorType last`)](../api/basic_json/erase.md) does not belong to the JSON value from which values shall be erased. It hence does not define a valid range to delete values from. - -!!! failure "Example message" - - ``` - [json.exception.invalid_iterator.203] iterators do not fit current value - ``` - -### json.exception.invalid_iterator.204 - -When an iterator range for a primitive type (number, boolean, or string) is passed to a constructor or an [erase](../api/basic_json/erase.md) function, this range has to be exactly (`begin(),` `end()),` because this is the only way the single stored value is expressed. All other ranges are invalid. - -!!! failure "Example message" - - ``` - [json.exception.invalid_iterator.204] iterators out of range - ``` - -### json.exception.invalid_iterator.205 - -When an iterator for a primitive type (number, boolean, or string) is passed to an [erase](../api/basic_json/erase.md) function, the iterator has to be the `begin()` iterator, because it is the only way to address the stored value. All other iterators are invalid. - -!!! failure "Example message" - - ``` - [json.exception.invalid_iterator.205] iterator out of range - ``` - -### json.exception.invalid_iterator.206 - -The iterators passed to constructor `basic_json(InputIT first, InputIT last)` belong to a JSON null value and hence to not define a valid range. - -!!! failure "Example message" - - ``` - [json.exception.invalid_iterator.206] cannot construct with iterators from null - ``` - -### json.exception.invalid_iterator.207 - -The `key()` member function can only be used on iterators belonging to a JSON object, because other types do not have a concept of a key. - -!!! failure "Example message" - - ``` - [json.exception.invalid_iterator.207] cannot use key() for non-object iterators - ``` - - -### json.exception.invalid_iterator.208 - -The `operator[]` to specify a concrete offset cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. - -!!! failure "Example message" - - ``` - [json.exception.invalid_iterator.208] cannot use operator[] for object iterators - ``` - -### json.exception.invalid_iterator.209 - -The offset operators (`+`, `-`, `+=`, `-=`) cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. - -!!! failure "Example message" - - ``` - [json.exception.invalid_iterator.209] cannot use offsets with object iterators - ``` - -### json.exception.invalid_iterator.210 - -The iterator range passed to the insert function are not compatible, meaning they do not belong to the same container. Therefore, the range (`first`, `last`) is invalid. - -!!! failure "Example message" - - ``` - [json.exception.invalid_iterator.210] iterators do not fit - ``` - -### json.exception.invalid_iterator.211 - -The iterator range passed to the insert function must not be a subrange of the container to insert to. - -!!! failure "Example message" - - ``` - [json.exception.invalid_iterator.211] passed iterators may not belong to container - ``` - -### json.exception.invalid_iterator.212 - -When two iterators are compared, they must belong to the same container. - -!!! failure "Example message" - - ``` - [json.exception.invalid_iterator.212] cannot compare iterators of different containers - ``` - -### json.exception.invalid_iterator.213 - -The order of object iterators cannot be compared, because JSON objects are unordered. - -!!! failure "Example message" - - ``` - [json.exception.invalid_iterator.213] cannot compare order of object iterators - ``` - -### json.exception.invalid_iterator.214 - -Cannot get value for iterator: Either the iterator belongs to a null value or it is an iterator to a primitive type (number, boolean, or string), but the iterator is different to `begin()`. - -!!! failure "Example message" - - ``` - [json.exception.invalid_iterator.214] cannot get value - ``` - -## Type errors - -This exception is thrown in case of a type error; that is, a library function is executed on a JSON value whose type does not match the expected semantics. - -Exceptions have ids 3xx. - -??? example - - The following code shows how a `type_error` exception can be caught. - - ```cpp - --8<-- "examples/type_error.cpp" - ``` - - Output: - - ``` - --8<-- "examples/type_error.output" - ``` - -### json.exception.type_error.301 - -To create an object from an initializer list, the initializer list must consist only of a list of pairs whose first element is a string. When this constraint is violated, an array is created instead. - -!!! failure "Example message" - - ``` - [json.exception.type_error.301] cannot create object from initializer list - ``` - -### json.exception.type_error.302 - -During implicit or explicit value conversion, the JSON type must be compatible to the target type. For instance, a JSON string can only be converted into string types, but not into numbers or boolean types. - -!!! failure "Example messages" - - ``` - [json.exception.type_error.302] type must be object, but is null - ``` - ``` - [json.exception.type_error.302] type must be string, but is object - ``` - -### json.exception.type_error.303 - -To retrieve a reference to a value stored in a `basic_json` object with `get_ref`, the type of the reference must match the value type. For instance, for a JSON array, the `ReferenceType` must be `array_t &`. - -!!! failure "Example messages" - - ``` - [json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object - ``` - ``` - [json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number" - ``` - -### json.exception.type_error.304 - -The `at()` member functions can only be executed for certain JSON types. - -!!! failure "Example messages" - - ``` - [json.exception.type_error.304] cannot use at() with string - ``` - ``` - [json.exception.type_error.304] cannot use at() with number - ``` - -### json.exception.type_error.305 - -The `operator[]` member functions can only be executed for certain JSON types. - -!!! failure "Example messages" - - ``` - [json.exception.type_error.305] cannot use operator[] with a string argument with array - ``` - ``` - [json.exception.type_error.305] cannot use operator[] with a numeric argument with object - ``` - -### json.exception.type_error.306 - -The `value()` member functions can only be executed for certain JSON types. - -!!! failure "Example message" - - ``` - [json.exception.type_error.306] cannot use value() with number - ``` - -### json.exception.type_error.307 - -The [`erase()`](../api/basic_json/erase.md) member functions can only be executed for certain JSON types. - -!!! failure "Example message" - - ``` - [json.exception.type_error.307] cannot use erase() with string - ``` - -### json.exception.type_error.308 - -The `push_back()` and `operator+=` member functions can only be executed for certain JSON types. - -!!! failure "Example message" - - ``` - [json.exception.type_error.308] cannot use push_back() with string - ``` - -### json.exception.type_error.309 - -The `insert()` member functions can only be executed for certain JSON types. - -!!! failure "Example messages" - - ``` - [json.exception.type_error.309] cannot use insert() with array - ``` - ``` - [json.exception.type_error.309] cannot use insert() with number - ``` - -### json.exception.type_error.310 - -The `swap()` member functions can only be executed for certain JSON types. - -!!! failure "Example message" - - ``` - [json.exception.type_error.310] cannot use swap() with number - ``` - -### json.exception.type_error.311 - -The `emplace()` and `emplace_back()` member functions can only be executed for certain JSON types. - -!!! failure "Example messages" - - ``` - [json.exception.type_error.311] cannot use emplace() with number - ``` - ``` - [json.exception.type_error.311] cannot use emplace_back() with number - ``` - -### json.exception.type_error.312 - -The `update()` member functions can only be executed for certain JSON types. - -!!! failure "Example message" - - ``` - [json.exception.type_error.312] cannot use update() with array - ``` - -### json.exception.type_error.313 - -The `unflatten` function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well-defined. - -!!! failure "Example message" - - ``` - [json.exception.type_error.313] invalid value to unflatten - ``` - -### json.exception.type_error.314 - -The `unflatten` function only works for an object whose keys are JSON Pointers. - -!!! failure "Example message" - - Calling `unflatten()` on an array `#!json [1,2,3]`: - - ``` - [json.exception.type_error.314] only objects can be unflattened - ``` - -### json.exception.type_error.315 - -The `unflatten()` function only works for an object whose keys are JSON Pointers and whose values are primitive. - -!!! failure "Example message" - - Calling `unflatten()` on an object `#!json {"/1", [1,2,3]}`: - - ``` - [json.exception.type_error.315] values in object must be primitive - ``` - -### json.exception.type_error.316 - -The `dump()` function only works with UTF-8 encoded strings; that is, if you assign a `std::string` to a JSON value, make sure it is UTF-8 encoded. - -!!! failure "Example message" - - Calling `dump()` on a JSON value containing an ISO 8859-1 encoded string: - ``` - [json.exception.type_error.316] invalid UTF-8 byte at index 15: 0x6F - ``` - -!!! tip - - - Store the source file with UTF-8 encoding. - - Pass an error handler as last parameter to the `dump()` function to avoid this exception: - - `json::error_handler_t::replace` will replace invalid bytes sequences with `U+FFFD` - - `json::error_handler_t::ignore` will silently ignore invalid byte sequences - -### json.exception.type_error.317 - -The dynamic type of the object cannot be represented in the requested serialization format (e.g. a raw `true` or `null` JSON object cannot be serialized to BSON) - -!!! failure "Example messages" - - Serializing `#!json null` to BSON: - ``` - [json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is null - ``` - Serializing `#!json [1,2,3]` to BSON: - ``` - [json.exception.type_error.317] to serialize to BSON, top-level type must be object, but is array - ``` - -!!! tip - - Encapsulate the JSON value in an object. That is, instead of serializing `#!json true`, serialize `#!json {"value": true}` - -## Out of range - -This exception is thrown in case a library function is called on an input parameter that exceeds the expected range, for instance in case of array indices or nonexisting object keys. - -Exceptions have ids 4xx. - -??? example - - The following code shows how an `out_of_range` exception can be caught. - - ```cpp - --8<-- "examples/out_of_range.cpp" - ``` - - Output: - - ``` - --8<-- "examples/out_of_range.output" - ``` - -### json.exception.out_of_range.401 - -The provided array index `i` is larger than `size-1`. - -!!! failure "Example message" - - ``` - array index 3 is out of range - ``` - -### json.exception.out_of_range.402 - -The special array index `-` in a JSON Pointer never describes a valid element of the array, but the index past the end. That is, it can only be used to add elements at this position, but not to read it. - -!!! failure "Example message" - - ``` - array index '-' (3) is out of range - ``` - -### json.exception.out_of_range.403 - -The provided key was not found in the JSON object. - -!!! failure "Example message" - - ``` - key 'foo' not found - ``` - -### json.exception.out_of_range.404 - -A reference token in a JSON Pointer could not be resolved. - -!!! failure "Example message" - - ``` - unresolved reference token 'foo' - ``` - -### json.exception.out_of_range.405 - -The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value. - -!!! failure "Example message" - - ``` - JSON pointer has no parent - ``` - -### json.exception.out_of_range.406 - -A parsed number could not be stored as without changing it to NaN or INF. - -!!! failure "Example message" - - ``` - number overflow parsing '10E1000' - ``` - -### json.exception.out_of_range.407 - -UBJSON and BSON only support integer numbers up to 9223372036854775807. - -!!! failure "Example message" - - ``` - number overflow serializing '9223372036854775808' - ``` - -!!! note - - Since version 3.9.0, integer numbers beyond int64 are serialized as high-precision UBJSON numbers, and this exception does not further occur. - -### json.exception.out_of_range.408 - -The size (following `#`) of an UBJSON array or object exceeds the maximal capacity. - -!!! failure "Example message" - - ``` - excessive array size: 8658170730974374167 - ``` - -### json.exception.out_of_range.409 - -Key identifiers to be serialized to BSON cannot contain code point U+0000, since the key is stored as zero-terminated c-string. - -!!! failure "Example message" - - ``` - BSON key cannot contain code point U+0000 (at byte 2) - ``` - -## Further exceptions - -This exception is thrown in case of errors that cannot be classified with the -other exception types. - -Exceptions have ids 5xx. - -??? example - - The following code shows how an `other_error` exception can be caught. - - ```cpp - --8<-- "examples/other_error.cpp" - ``` - - Output: - - ``` - --8<-- "examples/other_error.output" - ``` - -### json.exception.other_error.501 - -A JSON Patch operation 'test' failed. The unsuccessful operation is also printed. - -!!! failure "Example message" - - Executing `#!json {"op":"test", "path":"/baz", "value":"bar"}` on `#!json {"baz": "qux"}`: - - ``` - [json.exception.other_error.501] unsuccessful: {"op":"test","path":"/baz","value":"bar"} - ``` diff --git a/docs/mkdocs/docs/home/faq.md b/docs/mkdocs/docs/home/faq.md deleted file mode 100644 index dd426e073f..0000000000 --- a/docs/mkdocs/docs/home/faq.md +++ /dev/null @@ -1,180 +0,0 @@ -# Frequently Asked Questions (FAQ) - -## Known bugs - -### Brace initialization yields arrays - -!!! question - - Why does - - ```cpp - json j{true}; - ``` - - and - - ```cpp - json j(true); - ``` - - yield different results (`#!json [true]` vs. `#!json true`)? - -This is a known issue, and -- even worse -- the behavior differs between GCC and Clang. The "culprit" for this is the library's constructor overloads for initializer lists to allow syntax like - -```cpp -json array = {1, 2, 3, 4}; -``` - -for arrays and - -```cpp -json object = {{"one", 1}, {"two", 2}}; -``` - -for objects. - -!!! tip - - To avoid any confusion and ensure portable code, **do not** use brace initialization with the types `basic_json`, `json`, or `ordered_json` unless you want to create an object or array as shown in the examples above. - -## Limitations - -### Relaxed parsing - -!!! question - - Can you add an option to ignore trailing commas? - -This library does not support any feature which would jeopardize interoperability. - - -### Parse errors reading non-ASCII characters - -!!! question "Questions" - - - Why is the parser complaining about a Chinese character? - - Does the library support Unicode? - - I get an exception `[json.exception.parse_error.101] parse error at line 1, column 53: syntax error while parsing value - invalid string: ill-formed UTF-8 byte; last read: '"Testé$')"` - -The library supports **Unicode input** as follows: - -- Only **UTF-8** encoded input is supported which is the default encoding for JSON according to [RFC 8259](https://tools.ietf.org/html/rfc8259.html#section-8.1). -- `std::u16string` and `std::u32string` can be parsed, assuming UTF-16 and UTF-32 encoding, respectively. These encodings are not supported when reading from files or other input containers. -- Other encodings such as Latin-1 or ISO 8859-1 are **not** supported and will yield parse or serialization errors. -- [Unicode noncharacters](http://www.unicode.org/faq/private_use.html#nonchar1) will not be replaced by the library. -- Invalid surrogates (e.g., incomplete pairs such as `\uDEAD`) will yield parse errors. -- The strings stored in the library are UTF-8 encoded. When using the default string type (`std::string`), note that its length/size functions return the number of stored bytes rather than the number of characters or glyphs. -- When you store strings with different encodings in the library, calling [`dump()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a50ec80b02d0f3f51130d4abb5d1cfdc5.html#a50ec80b02d0f3f51130d4abb5d1cfdc5) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers. - -In most cases, the parser is right to complain, because the input is not UTF-8 encoded. This is especially true for Microsoft Windows where Latin-1 or ISO 8859-1 is often the standard encoding. - - -### Wide string handling - -!!! question - - Why are wide strings (e.g., `std::wstring`) dumped as arrays of numbers? - -As described [above](#parse-errors-reading-non-ascii-characters), the library assumes UTF-8 as encoding. To store a wide string, you need to change the encoding. - -!!! example - - ```cpp - #include // codecvt_utf8 - #include // wstring_convert - - // encoding function - std::string to_utf8(std::wstring& wide_string) - { - static std::wstring_convert> utf8_conv; - return utf8_conv.to_bytes(wide_string); - } - - json j; - std::wstring ws = L"車B1234 こんにちは"; - - j["original"] = ws; - j["encoded"] = to_utf8(ws); - - std::cout << j << std::endl; - ``` - - The result is: - - ```json - { - "encoded": "車B1234 こんにちは", - "original": [36554, 66, 49, 50, 51, 52, 32, 12371, 12435, 12395, 12385, 12399] - } - ``` - -## Exceptions - -### Parsing without exceptions - -!!! question - - Is it possible to indicate a parse error without throwing an exception? - -Yes, see [Parsing and exceptions](../features/parsing/parse_exceptions.md). - - -### Key name in exceptions - -!!! question - - Can I get the key of the object item that caused an exception? - -Yes, you can. Please define the symbol [`JSON_DIAGNOSTICS`](../api/macros/json_diagnostics.md) to get [extended diagnostics messages](exceptions.md#extended-diagnostic-messages). - - -## Serialization issues - - -### Number precision - -!!! question - - - It seems that precision is lost when serializing a double. - - Can I change the precision for floating-point serialization? - -The library uses `std::numeric_limits::digits10` (15 for IEEE `double`s) digits for serialization. This value is sufficient to guarantee roundtripping. If one uses more than this number of digits of precision, then string -> value -> string is not guaranteed to round-trip. - -!!! quote "[cppreference.com](https://en.cppreference.com/w/cpp/types/numeric_limits/digits10)" - - The value of `std::numeric_limits::digits10` is the number of base-10 digits that can be represented by the type T without change, that is, any number with this many significant decimal digits can be converted to a value of type T and back to decimal form, without change due to rounding or overflow. - -!!! tip - - The website https://float.exposed gives a good insight into the internal storage of floating-point numbers. - -See [this section](../features/types/number_handling.md#number-serialization) on the library's number handling for more information. - -## Compilation issues - -### Android SDK - -!!! question - - Why does the code not compile with Android SDK? - -Android defaults to using very old compilers and C++ libraries. To fix this, add the following to your `Application.mk`. This will switch to the LLVM C++ library, the Clang compiler, and enable C++11 and other features disabled by default. - -```ini -APP_STL := c++_shared -NDK_TOOLCHAIN_VERSION := clang3.6 -APP_CPPFLAGS += -frtti -fexceptions -``` - -The code compiles successfully with [Android NDK](https://developer.android.com/ndk/index.html?hl=ml), Revision 9 - 11 (and possibly later) and [CrystaX's Android NDK](https://www.crystax.net/en/android/ndk) version 10. - - -### Missing STL function - -!!! question "Questions" - - - Why do I get a compilation error `'to_string' is not a member of 'std'` (or similarly, for `strtod` or `strtof`)? - - Why does the code not compile with MinGW or Android SDK? - -This is not an issue with the code, but rather with the compiler itself. On Android, see above to build with a newer environment. For MinGW, please refer to [this site](http://tehsausage.com/mingw-to-string) and [this discussion](https://github.com/nlohmann/json/issues/136) for information on how to fix this bug. For Android NDK using `APP_STL := gnustl_static`, please refer to [this discussion](https://github.com/nlohmann/json/issues/219). diff --git a/docs/mkdocs/docs/home/license.md b/docs/mkdocs/docs/home/license.md deleted file mode 100644 index baef2f51b9..0000000000 --- a/docs/mkdocs/docs/home/license.md +++ /dev/null @@ -1,21 +0,0 @@ -# License - - - -The class is licensed under the [MIT License](https://opensource.org/licenses/MIT): - -Copyright © 2013-2022 [Niels Lohmann](https://nlohmann.me) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -* * * - -The class contains the UTF-8 Decoder from Bjoern Hoehrmann which is licensed under the [MIT License](https://opensource.org/licenses/MIT) (see above). Copyright © 2008-2009 [Björn Hoehrmann](http://bjoern.hoehrmann.de/) - -The class contains a slightly modified version of the Grisu2 algorithm from Florian Loitsch which is licensed under the [MIT License](https://opensource.org/licenses/MIT) (see above). Copyright © 2009 [Florian Loitsch](https://florian.loitsch.com/) - -The class contains a copy of [Hedley](https://nemequ.github.io/hedley/) from Evan Nemerson which is licensed as [CC0-1.0](https://creativecommons.org/publicdomain/zero/1.0/). diff --git a/docs/mkdocs/docs/home/releases.md b/docs/mkdocs/docs/home/releases.md deleted file mode 100644 index 5237c42592..0000000000 --- a/docs/mkdocs/docs/home/releases.md +++ /dev/null @@ -1,1225 +0,0 @@ -# Releases - -## v3.7.3 - -!!! summary "Files" - - - [include.zip](https://github.com/nlohmann/json/releases/download/v3.7.3/include.zip) (274 KB) - - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.7.3/include.zip.asc) (1 KB) - - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.7.3/json.hpp) (791 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.7.3/json.hpp.asc) (1 KB) - -Release date: 2019-11-17 -SHA-256: 3b5d2b8f8282b80557091514d8ab97e27f9574336c804ee666fda673a9b59926 (json.hpp), 87b5884741427220d3a33df1363ae0e8b898099fbc59f1c451113f6732891014 (include.zip) - -### Summary - -This release fixes a bug introduced in release 3.7.2 which could yield quadratic complexity in destructor calls. All changes are backward-compatible. - -### :bug: Bug Fixes - -- Removed `reserve()` calls from the destructor which could lead to quadratic complexity. #1837 #1838 - -### :fire: Deprecated functions - -This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0): - -- Function [`iterator_wrapper`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_af1592a06bc63811886ade4f9d965045e.html#af1592a06bc63811886ade4f9d965045e) are deprecated. Please use the member function [`items()`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_afe3e137ace692efa08590d8df40f58dd.html#afe3e137ace692efa08590d8df40f58dd) instead. -- Functions [`friend std::istream& operator<<(basic_json&, std::istream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_ab7285a92514fcdbe6de505ebaba92ea3.html#ab7285a92514fcdbe6de505ebaba92ea3) and [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9e06deabe69262c3ffc5533d32856983.html#a9e06deabe69262c3ffc5533d32856983) are deprecated. Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead. - - -## v3.7.2 - -!!! summary "Files" - - - [include.zip](https://github.com/nlohmann/json/releases/download/v3.7.2/include.zip) (274 KB) - - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.7.2/include.zip.asc) (1 KB) - - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.7.2/json.hpp) (791 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.7.2/json.hpp.asc) (1 KB) - -Release date: 2019-11-10 -SHA-256: 0a65fcbbe1b334d3f45c9498e5ee28c3f3b2428aea98557da4a3ff12f0f14ad6 (json.hpp), 67f69c9a93b7fa0612dc1b6273119d2c560317333581845f358aaa68bff8f087 (include.zip) - -### Summary - -Project [bad_json_parsers](https://github.com/lovasoa/bad_json_parsers) tested how JSON parser libraries react on **deeply nested inputs**. It turns out that this library segfaulted at a certain nesting depth. This bug was fixed with this release. **Now the parsing is only bounded by the available memory.** All changes are backward-compatible. - -### :bug: Bug Fixes - -* Fixed a bug that lead to stack overflow for deeply nested JSON values (objects, array) by changing the implementation of the destructor from a recursive to an iterative approach. #832, #1419, #1835 - -### :hammer: Further Changes - -* Added WhiteStone Bolt. #1830 - -### :fire: Deprecated functions - -This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0): - -- Function [`iterator_wrapper`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_af1592a06bc63811886ade4f9d965045e.html#af1592a06bc63811886ade4f9d965045e) are deprecated. Please use the member function [`items()`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_afe3e137ace692efa08590d8df40f58dd.html#afe3e137ace692efa08590d8df40f58dd) instead. -- Functions [`friend std::istream& operator<<(basic_json&, std::istream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_ab7285a92514fcdbe6de505ebaba92ea3.html#ab7285a92514fcdbe6de505ebaba92ea3) and [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9e06deabe69262c3ffc5533d32856983.html#a9e06deabe69262c3ffc5533d32856983) are deprecated. Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead. - -## v3.7.1 - -!!! summary "Files" - - - [include.zip](https://github.com/nlohmann/json/releases/download/v3.7.1/include.zip) (273 KB) - - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.7.1/include.zip.asc) (1 KB) - - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.7.1/json.hpp) (789 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.7.1/json.hpp.asc) (1 KB) - -Release date: 2019-11-06 -SHA-256: b5ba7228f3c22a882d379e93d08eab4349458ee16fbf45291347994eac7dc7ce (json.hpp), 77b9f54b34e7989e6f402afb516f7ff2830df551c3a36973085e2c7a6b1045fe (include.zip) - -### Summary - -This release fixes several small bugs in the library. All changes are backward-compatible. - -### :bug: Bug Fixes - -- Fixed a segmentation fault when serializing `std::int64_t` minimum value. #1708 #1722 -- Fixed the [`contains()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_ab23b04802eb9da97dc3f664e54e09cb3.html#ab23b04802eb9da97dc3f664e54e09cb3) function for JSON Pointers. #1727 #1741 -- Fixed too lax SFINAE guard for conversion from `std::pair` and `std::tuple` to `json`. #1805 #1806 #1825 #1826 -- Fixed some regressions detected by UBSAN. Updated CI to use Clang-Tidy 7.1.0. #1716 #1728 -- Fixed integer truncation in `iteration_proxy`. #1797 -- Updated [Hedley](https://github.com/nemequ/hedley) to v11 to [fix a E2512 error](https://github.com/nemequ/hedley/issues/28) in MSVC. #1799 -- Fixed a compile error in enum deserialization of non non-default-constructible types. #1647 #1821 -- Fixed the conversion from `json` to `std::valarray`. - -### :zap: Improvements - -- The [`items()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_afe3e137ace692efa08590d8df40f58dd.html#afe3e137ace692efa08590d8df40f58dd) function can now be used with a custom string type. #1765 -- Made [`json_pointer::back`](https://nlohmann.github.io/json/classnlohmann_1_1json__pointer_a213bc67c32a30c68ac6bf06f5195d482.html#a213bc67c32a30c68ac6bf06f5195d482) `const`. #1764 #1769 -- Meson is part of the release archive. #1672 #1694 -- Improved documentation on the Meson and Spack package manager. #1694 #1720 - -### :hammer: Further Changes - -- Added GitHub Workflow with `ubuntu-latest`/GCC 7.4.0 as CI step. -- Added GCC 9 to Travis CI to compile with C++20 support. #1724 -- Added MSVC 2019 to the AppVeyor CI. #1780 -- Added badge to [fuzzing status](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:json). -- Fixed some cppcheck warnings. #1760 -- Fixed several typos in the documentation. #1720 #1767 #1803 -- Added documentation on the `JSON_THROW_USER`, `JSON_TRY_USER`, and `JSON_CATCH_USER` macros to control user-defined exception handling. -- Used GitHub's [CODEOWNERS](https://github.com/nlohmann/json/blob/develop/.github/CODEOWNERS) and [SECURITY](https://github.com/nlohmann/json/blob/develop/.github/SECURITY.md) feature. -- Removed `GLOB` from CMake files. #1779 -- Updated to [Doctest](https://github.com/onqtam/doctest) 2.3.5. - -### :fire: Deprecated functions - -This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0): - -- Function [`iterator_wrapper`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_af1592a06bc63811886ade4f9d965045e.html#af1592a06bc63811886ade4f9d965045e) are deprecated. Please use the member function [`items()`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_afe3e137ace692efa08590d8df40f58dd.html#afe3e137ace692efa08590d8df40f58dd) instead. -- Functions [`friend std::istream& operator<<(basic_json&, std::istream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_ab7285a92514fcdbe6de505ebaba92ea3.html#ab7285a92514fcdbe6de505ebaba92ea3) and [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9e06deabe69262c3ffc5533d32856983.html#a9e06deabe69262c3ffc5533d32856983) are deprecated. Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead. - -## v3.7.0 - -!!! summary "Files" - - - [include.zip](https://github.com/nlohmann/json/releases/download/v3.7.0/include.zip) (143 KB) - - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.7.0/include.zip.asc) (1 KB) - - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.7.0/json.hpp) (782 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.7.0/json.hpp.asc) (1 KB) - -Release date: 2019-07-28 -SHA-256: a503214947952b69f0062f572cb74c17582a495767446347ce2e452963fc2ca4 (json.hpp), 541c34438fd54182e9cdc68dd20c898d766713ad6d901fb2c6e28ff1f1e7c10d (include.zip) - -### Summary - -This release introduces a few convenience functions and performs a lot of house keeping (bug fixes and small improvements). All changes are backward-compatible. - -### :sparkles: New Features - -- Add overload of the **[`contains`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_ab23b04802eb9da97dc3f664e54e09cb3.html#ab23b04802eb9da97dc3f664e54e09cb3) function** to check if a JSON pointer is valid without throwing exceptions, just like its [counterpart for object keys](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9286acdc0578fc66e9346323e69fc0e3.html#a9286acdc0578fc66e9346323e69fc0e3). #1600 -- Add a function **[`to_string`](http://nlohmann.github.io/json/doxygen/namespacenlohmann_a6ce645a0b8717757e096a5b5773b7a16.html#a6ce645a0b8717757e096a5b5773b7a16)** to allow for generic conversion to strings. #916 #1585 -- Add **return value for the [`emplace_back`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_abf29131f898b05aad2c01a9c80e7a002.html#abf29131f898b05aad2c01a9c80e7a002) function**, returning a reference to the added element just like C++17 is [introducing this](https://en.cppreference.com/w/cpp/container/vector/emplace_back) for `std::vector`. #1609 -- Add info how to use the library with the **[pacman](https://wiki.archlinux.org/index.php/pacman) package manager** on MSYS2. #1670 - -### :bug: Bug Fixes - -- Fix an issue where typedefs with certain names yielded a compilation error. #1642 #1643 -- Fix a conversion to `std::string_view` in the unit tests. #1634 #1639 -- Fix MSVC Debug build. #1536 #1570 #1608 -- Fix [`get_to`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a65753c68f06639eda0d355f919564e01.html#a65753c68f06639eda0d355f919564e01) method to clear existing content before writing. #1511 #1555 -- Fix a `-Wc++17-extensions` warning. `nodiscard` attributes are now only used with Clang when `-std=c++17` is used. #1535 #1551 - -### :zap: Improvements - -- Switch from [Catch](https://github.com/philsquared/Catch) to **[doctest](https://github.com/onqtam/doctest)** for the unit tests which speeds up compilation and runtime of the 112,112,308 tests. -- Add an explicit section to the [README](https://github.com/nlohmann/json/blob/develop/README.md) about the **frequently addressed topics** [character encoding](https://github.com/nlohmann/json#character-encoding), [comments in JSON](https://github.com/nlohmann/json#comments-in-json), and the [order of object keys](https://github.com/nlohmann/json#order-of-object-keys). - -### :hammer: Further Changes - -- Use [`GNUInstallDirs`](https://cmake.org/cmake/help/v3.0/module/GNUInstallDirs.html) to set library install directories. #1673 -- Fix links in the [README](https://github.com/nlohmann/json/blob/develop/README.md). #1620 #1621 #1622 #1623 #1625 -- Mention [`json` type](http://nlohmann.github.io/json/doxygen/namespacenlohmann_a2bfd99e845a2e5cd90aeaf1b1431f474.html#a2bfd99e845a2e5cd90aeaf1b1431f474) on the [documentation start page](http://nlohmann.github.io/json/doxygen/index.html). #1616 -- Complete documentation of [`value()` function](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_adcf8ca5079f5db993820bf50036bf45d.html#adcf8ca5079f5db993820bf50036bf45d) with respect to `type_error.302` exception. #1601 -- Fix links in the documentation. #1598 -- Add regression tests for MSVC. #1543 #1570 -- Use **[CircleCI](http://circleci.com)** for [continuous integration](https://circleci.com/gh/nlohmann/json). -- Use **[Doozer](https://doozer.io)** for [continuous integration](https://doozer.io/nlohmann/json) on Linux (CentOS, Raspbian, Fedora) -- Add tests to check each CMake flag (`JSON_BuildTests`, `JSON_Install`, `JSON_MultipleHeaders`, `JSON_Sanitizer`, `JSON_Valgrind`, `JSON_NoExceptions`, `JSON_Coverage`). -- Use [Hedley](https://nemequ.github.io/hedley/) to avoid re-inventing several compiler-agnostic feature macros like `JSON_DEPRECATED`, `JSON_NODISCARD`, `JSON_LIKELY`, `JSON_UNLIKELY`, `JSON_HAS_CPP_14`, or `JSON_HAS_CPP_17`. Functions taking or returning pointers are annotated accordingly when a pointer will not be null. -- Build and run tests on [AppVeyor](https://ci.appveyor.com/project/nlohmann/json) in DEBUG and RELEASE mode. - -### :fire: Deprecated functions - -This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0): - -- Function [`iterator_wrapper`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_af1592a06bc63811886ade4f9d965045e.html#af1592a06bc63811886ade4f9d965045e) are deprecated. Please use the member function [`items()`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_afe3e137ace692efa08590d8df40f58dd.html#afe3e137ace692efa08590d8df40f58dd) instead. -- Functions [`friend std::istream& operator<<(basic_json&, std::istream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_ab7285a92514fcdbe6de505ebaba92ea3.html#ab7285a92514fcdbe6de505ebaba92ea3) and [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9e06deabe69262c3ffc5533d32856983.html#a9e06deabe69262c3ffc5533d32856983) are deprecated. Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead. - -## v3.6.1 - -!!! summary "Files" - - - [include.zip](https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip) (136 KB) - - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip.asc) (1 KB) - - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.6.1/json.hpp) (711 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.6.1/json.hpp.asc) (1 KB) - -Release date: 2019-03-20 -SHA-256: d2eeb25d2e95bffeb08ebb7704cdffd2e8fca7113eba9a0b38d60a5c391ea09a (json.hpp), 69cc88207ce91347ea530b227ff0776db82dcb8de6704e1a3d74f4841bc651cf (include.zip) - -### Summary - -This release **fixes a regression and a bug** introduced by the earlier 3.6.0 release. All changes are backward-compatible. - -### :bug: Bug Fixes - -- Fixed regression of #590 which could lead to compilation errors with GCC 7 and GCC 8. #1530 -- Fixed a compilation error when `` was included. #1531 - -### :hammer: Further Changes - -- Fixed a warning for missing field initializers. #1527 - -### :fire: Deprecated functions - -This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0): - -- Function [`iterator_wrapper`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_af1592a06bc63811886ade4f9d965045e.html#af1592a06bc63811886ade4f9d965045e) are deprecated. Please use the member function [`items()`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_afe3e137ace692efa08590d8df40f58dd.html#afe3e137ace692efa08590d8df40f58dd) instead. -- Functions [`friend std::istream& operator<<(basic_json&, std::istream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_ab7285a92514fcdbe6de505ebaba92ea3.html#ab7285a92514fcdbe6de505ebaba92ea3) and [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9e06deabe69262c3ffc5533d32856983.html#a9e06deabe69262c3ffc5533d32856983) are deprecated. Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead. - -## v3.6.0 - -!!! summary "Files" - - - [include.zip](https://github.com/nlohmann/json/releases/download/v3.6.0/include.zip) (136 KB) - - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.6.0/include.zip.asc) (1 KB) - - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.6.0/json.hpp) (711 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.6.0/json.hpp.asc) (1 KB) - -Release date: 2019-03-20 -SHA-256: ce9839370f28094c71107c405affb3b08c4a098154988014cbb0800b1c44a831 (json.hpp), 237c5e66e7f8186a02804ce9dbd5f69ce89fe7424ef84adf6142e973bd9532f4 (include.zip) - -ℹ️ **This release introduced a regression. Please update to [version 3.6.1](https://github.com/nlohmann/json/releases/tag/v3.6.1)!** - -### Summary - -This release adds some **convenience functions for JSON Pointers**, introduces a [`contains`]( -http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a0a45fc740637123fdf05fef970f8be47.html#a0a45fc740637123fdf05fef970f8be47) function to check if a key is present in an object, and improves the **performance of integer serialization**. Furthermore, a lot of small bug fixes and improvements have been made. All changes are backward-compatible. - -### :sparkles: New Features - -- Overworked the public interface for JSON Pointers. The creation of JSON Pointers is simplified with [`operator/`]( -http://nlohmann.github.io/json/doxygen/classnlohmann_1_1json__pointer_a90a11fe6c7f37b1746a3ff9cb24b0d53.html#a90a11fe6c7f37b1746a3ff9cb24b0d53) and [`operator/=`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1json__pointer_a7395bd0af29ac23fd3f21543c935cdfa.html#a7395bd0af29ac23fd3f21543c935cdfa). JSON Pointers can be inspected with [`empty`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1json__pointer_a649252bda4a2e75a0915b11a25d8bcc3.html#a649252bda4a2e75a0915b11a25d8bcc3), [`back`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1json__pointer_a6bd5b554c10f15672135c216893eef31.html#a6bd5b554c10f15672135c216893eef31), and [`parent_pointer`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1json__pointer_afdaacce1edb7145e0434e014f0e8685a.html#afdaacce1edb7145e0434e014f0e8685a), and manipulated with [`push_back`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1json__pointer_a697d12b5bd6205f8866691b166b7c7dc.html#a697d12b5bd6205f8866691b166b7c7dc) and [`pop_back`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1json__pointer_a4b1ee4d511ca195bed896a3da47e264c.html#a4b1ee4d511ca195bed896a3da47e264c). #1434 -- Added a boolean method [`contains`]( -http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a0a45fc740637123fdf05fef970f8be47.html#a0a45fc740637123fdf05fef970f8be47) to check whether an element exists in a JSON object with a given key. Returns false when called on non-object types. #1471 #1474 - -### :bug: Bug Fixes - -- Fixed a compilation issues with libc 2.12. #1483 #1514 -- Fixed endian conversion on PPC64. #1489 -- Fixed library to compile with GCC 9. #1472 #1492 -- Fixed a compilation issue with GCC 7 on CentOS. #1496 -- Fixed an integer overflow. #1447 -- Fixed buffer flushing in serializer. #1445 #1446 - -### :zap: Improvements - -- The performance of dumping integers has been greatly improved. #1411 -- Added CMake parameter `JSON_Install` to control whether the library should be installed (default: on). #1330 -- Fixed a lot of compiler and linter warnings. #1400 #1435 #1502 -- Reduced required CMake version from 3.8 to 3.1. #1409 #1428 #1441 #1498 -- Added `nodiscard` attribute to `meta()`, `array()`, `object()`, `from_cbor`, `from_msgpack`, `from_ubjson`, `from_bson`, and `parse`. #1433 - -### :hammer: Further Changes - -- Added missing headers. #1500 -- Fixed typos and broken links in README. #1417 #1423 #1425 #1451 #1455 #1491 -- Fixed documentation of parse function. #1473 -- Suppressed warning that cannot be fixed inside the library. #1401 #1468 -- Imroved package manager suppert: - - Updated Buckaroo instructions. #1495 - - Improved Meson support. #1463 - - Added Conda package manager documentation. #1430 - - Added NuGet package manager documentation. #1132 -- Continuous Integration - - Removed unstable or deprecated Travis builders (Xcode 6.4 - 8.2) and added Xcode 10.1 builder. - - Added Clang 7 to Travis CI. - - Fixed AppVeyor x64 builds. #1374 #1414 -- Updated thirdparty libraries: - - Catch 1.12.0 -> 1.12.2 - - Google Benchmark 1.3.0 -> 1.4.1 - - Doxygen 1.8.15 -> 1.8.16 - -### :fire: Deprecated functions - -This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0): - -- Function [`iterator_wrapper`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_af1592a06bc63811886ade4f9d965045e.html#af1592a06bc63811886ade4f9d965045e) are deprecated. Please use the member function [`items()`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_afe3e137ace692efa08590d8df40f58dd.html#afe3e137ace692efa08590d8df40f58dd) instead. -- Functions [`friend std::istream& operator<<(basic_json&, std::istream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_ab7285a92514fcdbe6de505ebaba92ea3.html#ab7285a92514fcdbe6de505ebaba92ea3) and [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9e06deabe69262c3ffc5533d32856983.html#a9e06deabe69262c3ffc5533d32856983) are deprecated. Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead. - -## v3.5.0 - -!!! summary "Files" - - - [include.zip](https://github.com/nlohmann/json/releases/download/v3.5.0/include.zip) (133 KB) - - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.5.0/include.zip.asc) (1 KB) - - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.5.0/json.hpp) (693 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.5.0/json.hpp.asc) (1 KB) - -Release date: 2018-12-22 -SHA-256: 8a6dbf3bf01156f438d0ca7e78c2971bca50eec4ca6f0cf59adf3464c43bb9d5 (json.hpp), 3564da9c5b0cf2e032f97c69baedf10ddbc98030c337d0327a215ea72259ea21 (include.zip) - -### Summary - -This release introduces the support for **structured bindings** and reading from **`FILE*`**. Besides, a few bugs have been fixed. All changes are backward-compatible. - -### :sparkles: New Features - -- **Structured bindings** are now supported for JSON objects and arrays via the [`items()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_afe3e137ace692efa08590d8df40f58dd.html#afe3e137ace692efa08590d8df40f58dd) member function, so finally this code is possible: - ```cpp - for (auto& [key, val] : j.items()) { - std::cout << key << ':' << val << '\n'; - } - ``` - #1388 #1391 - -- Added support for **reading from `FILE*`** to support situations in which streams are nit available or would require too much RAM. #1370 #1392 - -### :bug: Bug Fixes - -- The `eofbit` was not set for input streams when the end of a stream was reached while parsing. #1340 #1343 -- Fixed a bug in the SAX parser for BSON arrays. - -### :zap: Improvements - -- Added support for Clang 5.0.1 (PS4 version). #1341 #1342 - -### :hammer: Further Changes - -- Added a warning for implicit conversions to the documentation: It is not recommended to use implicit conversions when reading **from** a JSON value. Details about this recommendation can be found [here](https://www.github.com/nlohmann/json/issues/958). #1363 -- Fixed typos in the documentation. #1329 #1380 #1382 -- Fixed a C4800 warning. #1364 -- Fixed a `-Wshadow` warning #1346 -- Wrapped `std::snprintf` calls to avoid error in MSVC. #1337 -- Added code to allow installation via Meson. #1345 - -### :fire: Deprecated functions - -This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0): - -- Function [`iterator_wrapper`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_af1592a06bc63811886ade4f9d965045e.html#af1592a06bc63811886ade4f9d965045e) are deprecated. Please use the member function [`items()`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_afe3e137ace692efa08590d8df40f58dd.html#afe3e137ace692efa08590d8df40f58dd) instead. -- Functions [`friend std::istream& operator<<(basic_json&, std::istream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_ab7285a92514fcdbe6de505ebaba92ea3.html#ab7285a92514fcdbe6de505ebaba92ea3) and [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9e06deabe69262c3ffc5533d32856983.html#a9e06deabe69262c3ffc5533d32856983) are deprecated. Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead. - -## v3.4.0 - -!!! summary "Files" - - - [include.zip](https://github.com/nlohmann/json/releases/download/v3.4.0/include.zip) (132 KB) - - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.4.0/include.zip.asc) (1 KB) - - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.4.0/json.hpp) (689 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.4.0/json.hpp.asc) (1 KB) - -Release date: 2018-10-30 -SHA-256: 63da6d1f22b2a7bb9e4ff7d6b255cf691a161ff49532dcc45d398a53e295835f (json.hpp), bfec46fc0cee01c509cf064d2254517e7fa80d1e7647fea37cf81d97c5682bdc (include.zip) - -### Summary - -This release introduces three new features: - -- **BSON (Binary JSON)** is next to CBOR, MessagePack, and UBJSON the fourth binary (de)serialization format supported by the library. -- **Adjustable error handlers for invalid Unicode** allows to specify the behavior when invalid byte sequences are serialized. -- **Simplified enum/JSON mapping** with a macro in case the default mapping to integers is not desired. - -Furthermore, some effort has been invested in improving the **parse error messages**. Besides, a few bugs have been fixed. All changes are backward-compatible. - -### :sparkles: New Features - -- The library can read and write a subset of **[BSON](http://bsonspec.org/) (Binary JSON)**. All data types known from JSON are supported, whereas other types more tied to MongoDB such as timestamps, object ids, or binary data are currently not implemented. See [the README](https://github.com/nlohmann/json#binary-formats-bson-cbor-messagepack-and-ubjson) for examples. #1244 #1320 -- The behavior when the library encounters an invalid Unicode sequence during serialization can now be controlled by defining one of three **Unicode error handlers**: (1) throw an exception (default behavior), (2) replace invalid sequences by the Unicode replacement character (U+FFFD), or (3) ignore/filter invalid sequences. See the [documentation of the `dump` function](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a50ec80b02d0f3f51130d4abb5d1cfdc5.html#a50ec80b02d0f3f51130d4abb5d1cfdc5) for examples. #1198 #1314 -- To easily specify a user-defined **enum/JSON mapping**, a macro `NLOHMANN_JSON_SERIALIZE_ENUM` has been introduced. See the [README section](https://github.com/nlohmann/json#specializing-enum-conversion) for more information. #1208 #1323 - -### :bug: Bug Fixes - -- fixed truncation #1286 #1315 -- fixed an issue with std::pair #1299 #1301 -- fixed an issue with std::variant #1292 #1294 -- fixed a bug in the JSON Pointer parser - -### :zap: Improvements - -- The **diagnosis messages for parse errors** have been improved: error messages now indicated line/column positions where possible (in addition to a byte count) and also the context in which the error occurred (e.g., "while parsing a JSON string"). Example: error `parse error at 2: syntax error - invalid string: control character must be escaped; last read: ''` is now reported as `parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0009 (HT) must be escaped to \u0009 or \t; last read: ''`. #1280 #1288 #1303 - -### :hammer: Further Changes - -- improved Meson documentation #1305 -- fixed some more linter warnings #1280 -- fixed Clang detection for third-party Google Benchmark library #1277 - -### :fire: Deprecated functions - -This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0): - -- Function [`iterator_wrapper`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_af1592a06bc63811886ade4f9d965045e.html#af1592a06bc63811886ade4f9d965045e) are deprecated. Please use the member function [`items()`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_afe3e137ace692efa08590d8df40f58dd.html#afe3e137ace692efa08590d8df40f58dd) instead. -- Functions [`friend std::istream& operator<<(basic_json&, std::istream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_ab7285a92514fcdbe6de505ebaba92ea3.html#ab7285a92514fcdbe6de505ebaba92ea3) and [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9e06deabe69262c3ffc5533d32856983.html#a9e06deabe69262c3ffc5533d32856983) are deprecated. Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead. - -## v3.3.0 - -!!! summary "Files" - - - [include.zip](https://github.com/nlohmann/json/releases/download/v3.3.0/include.zip) (123 KB) - - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.3.0/include.zip.asc) (1 KB) - - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.3.0/json.hpp) (635 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.3.0/json.hpp.asc) (1 KB) - -Release date: 2018-10-05 -SHA-256: f1327bb60c58757a3dd2b0c9c45d49503d571337681d950ec621f8374bcc14d4 (json.hpp), 9588d63557333aaa485e92221ec38014a85a6134e7486fe3441e0541a5a89576 (include.zip) - -### Summary - -This release adds support for **GCC 4.8**. Furthermore, it adds a function [**`get_to`**](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a8a3db7d78f74232d3a6fb8f1abf69709.html#a8a3db7d78f74232d3a6fb8f1abf69709) to write a JSON value to a passed reference. Another topic of this release was the **CMake support** which has been overworked and documented. - -Besides, a lot of bugs have been fixed and slight improvements have been made. All changes are backward-compatible. - -### :sparkles: New Features - -- The library can now also built with **GCC 4.8**. Though this compiler does not fully support C++11, it can successfully compile and run the test suite. Note that bug [57824](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57824) in GCC 4.8 still forbids to use multiline raw strings in arguments to macros. #1257 -- Added new function [**`get_to`**](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a8a3db7d78f74232d3a6fb8f1abf69709.html#a8a3db7d78f74232d3a6fb8f1abf69709) to write a JSON value to a passed reference. The destination type is automatically derived which allows more succinct code compared to the `get` function. #1227 #1231 - -### :bug: Bug Fixes - -- Fixed a bug in the CMake file that made `target_link_libraries` to not properly include `nlohmann_json`. #1243 #1245 #1260 -- Fixed a warning in MSVC 2017 complaining about a constexpr if. #1204 #1268 #1272 -- Fixed a bug that prevented compilation with ICPC. #755 #1222 -- Improved the SFINAE correctness to fix a bug in the conversion operator. #1237 #1238 -- Fixed a `-Wctor-dtor-privacy` warning. #1224 -- Fixed a warning on a lambda in unevaluated context. #1225 #1230 -- Fixed a bug introduced in version 3.2.0 where defining `JSON_CATCH_USER` led to duplicate macro definition of `JSON_INTERNAL_CATCH`. #1213 #1214 -- Fixed a bug that prevented compilation with Clang 3.4.2 in RHEL 7. #1179 #1249 - -### :zap: Improvements - -- Added [documentation on CMake integration](https://github.com/nlohmann/json#cmake) of the library. #1270 -- Changed the CMake file to use `find_package(nlohmann_json)` without installing the library. #1202 -- Improved error messages in case `operator[]` is used with the wrong combination (json.exception.type_error.305) of JSON container type and argument type. Example: "cannot use operator[] with a string argument". #1220 #1221 -- Added a license and version information to the Meson build file. #1252 -- Removed static assertions to indicated missing `to_json` or `from_json` functions as such assertions do not play well with SFINAE. These assertions also led to problems with GMock. #960 #1212 #1228 -- The test suite now does not wait forever if run in a wrong directory and input files are not found. #1262 -- The test suite does not show deprecation warnings for deprecated functions which frequently led to confusion. #1271 - -### :hammer: Further Changes - -- GCC 4.8 and Xcode 10 were added to the [continuous integration suite](https://travis-ci.org/nlohmann/json) at Travis. -- Added [lgtm](https://lgtm.com/projects/g/nlohmann/json/context:cpp) checks to pull requests. -- Added tests for CMake integration. #1260 - -### :fire: Deprecated functions - -This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0): - -- Function [`iterator_wrapper`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_af1592a06bc63811886ade4f9d965045e.html#af1592a06bc63811886ade4f9d965045e) are deprecated. Please use the member function [`items()`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_afe3e137ace692efa08590d8df40f58dd.html#afe3e137ace692efa08590d8df40f58dd) instead. -- Functions [`friend std::istream& operator<<(basic_json&, std::istream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_ab7285a92514fcdbe6de505ebaba92ea3.html#ab7285a92514fcdbe6de505ebaba92ea3) and [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9e06deabe69262c3ffc5533d32856983.html#a9e06deabe69262c3ffc5533d32856983) are deprecated. Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead. - - -## v3.2.0 - -!!! summary "Files" - - - [include.zip](https://github.com/nlohmann/json/releases/download/v3.2.0/include.zip) (124 KB) - - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.2.0/include.zip.asc) (1 KB) - - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.2.0/json.hpp) (636 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.2.0/json.hpp.asc) (1 KB) - -Release date: 2018-08-20 -SHA-256: ce6b5610a051ec6795fa11c33854abebb086f0fd67c311f5921c3c07f9531b44 (json.hpp), 35ee642558b90e2f9bc758995c4788c4b4d4dec54eef95fb8f38cb4d49c8fc7c (include.zip) - -### Summary - -This release introduces a [**SAX interface**](https://nlohmann.github.io/json/structnlohmann_1_1json__sax.html) to the library. While this may be a very special feature used by only few people, it allowed to unify all functions that consumed input and created some kind of JSON value. Internally, now all existing functions like `parse`, `accept`, `from_cbor`, `from_msgpack`, and `from_ubjson` use the SAX interface with different event processors. This allowed to separate the input processing from the value generation. Furthermore, throwing an exception in case of a parse error is now optional and up to the event processor. Finally, the JSON parser is now non-recursive (meaning it does not use the call stack, but `std::vector` to track the hierarchy of structured values) which allows to process nested input more efficiently. - -Furthermore, the library finally is able to parse from **wide string types**. This is the first step toward opening the library from UTF-8 to UTF-16 and UTF-32. - -This release further fixes several bugs in the library. All changes are backward-compatible. - -### :sparkles: New Features - -- added a parser with a **SAX interface** (#971, #1153) -- support to parse from **wide string types** `std::wstring`, `std::u16string`, and `std::u32string`; the input will be converted to UTF-8 (#1031) -- added support for **`std::string_view`** when using C++17 (#1028) -- allow to **roundtrip `std::map` and `std::unordered_map`** from JSON if key type is not convertible to string; in these cases, values are serialized to arrays of pairs (#1079, #1089, #1133, #1138) - -### :bug: Bug Fixes - -- allow to create `nullptr_t` from JSON allowing to properly roundtrip `null` values (#1169) -- allow compare user-defined string types (#1130) -- better support for algorithms using iterators from `items()` (#1045, #1134) -- added parameter to avoid compilation error with MSVC 2015 debug builds (#1114) -- re-added accidentally skipped unit tests (#1176) -- fixed MSVC issue with `std::swap` (#1168) - -### :zap: Improvements - -- `key()` function for iterators returns a const reference rather than a string copy (#1098) -- binary formats CBOR, MessagePack, and UBJSON now supports `float` as type for floating-point numbers (#1021) - -### :hammer: Further Changes - -- changed issue templates -- improved continuous integration: added builders for Xcode 9.3 and 9.4, added builders for GCC 8 and Clang 6, added builder for MinGW, added builders for MSVC targeting x86 -- required CMake version is now at least 3.8 (#1040) -- overworked CMake file wrt. packaging (#1048) -- added package managers: Spack (#1041) and CocoaPods (#1148) -- fixed Meson include directory (#1142) -- preprocessor macro `JSON_SKIP_UNSUPPORTED_COMPILER_CHECK` can skip the rejection of unsupported compilers - use at your own risk! (#1128) -- preprocessor macro `JSON_INTERNAL_CATCH`/`JSON_INTERNAL_CATCH_USER` allows to control the behavior of exception handling inside the library (#1187) -- added note on `char` to JSON conversion -- added note how to send security-related issue via encrypted email -- removed dependency to `std::stringstream` (#1117) -- added SPDX-License-Identifier -- added updated JSON Parsing Test Suite, described in [Parsing JSON is a Minefield 💣](http://seriot.ch/parsing_json.php) -- updated to Catch 1.12.0 - -### :fire: Deprecated functions - -This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0): - -- Function [`iterator_wrapper`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_af1592a06bc63811886ade4f9d965045e.html#af1592a06bc63811886ade4f9d965045e) are deprecated. Please use the member function [`items()`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_afe3e137ace692efa08590d8df40f58dd.html#afe3e137ace692efa08590d8df40f58dd) instead. -- Functions [`friend std::istream& operator<<(basic_json&, std::istream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_ab7285a92514fcdbe6de505ebaba92ea3.html#ab7285a92514fcdbe6de505ebaba92ea3) and [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9e06deabe69262c3ffc5533d32856983.html#a9e06deabe69262c3ffc5533d32856983) are deprecated. Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead. - - - -## v3.1.2 - -!!! summary "Files" - - - [include.zip](https://github.com/nlohmann/json/releases/download/v3.1.2/include.zip) (115 KB) - - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.1.2/include.zip.asc) (1 KB) - - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.1.2/json.hpp) (582 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.1.2/json.hpp.asc) (1 KB) - -Release date: 2018-03-14 -SHA-256: fbdfec4b4cf63b3b565d09f87e6c3c183bdd45c5be1864d3fcb338f6f02c1733 (json.hpp), 495362ee1b9d03d9526ba9ccf1b4a9c37691abe3a642ddbced13e5778c16660c (include.zip) - -### Summary - -This release fixes several bugs in the library. All changes are backward-compatible. - -### :bug: Bug Fixes - -- Fixed a **memory leak** occurring in the parser callback (#1001). -- Different **specializations of `basic_json`** (e.g., using different template arguments for strings or objects) can now be used in assignments (#972, #977, #986). -- Fixed a logical error in an iterator range check (#992). - -### :zap: Improvements - -- The parser and the serialization now support **user-defined string types** (#1006, #1009). - -### :hammer: Further Changes - -- **[Clang Analyzer](http://clang-analyzer.llvm.org)** is now used as additional static analyzer; see `make clang_analyze`. -- Overworked [README](https://github.com/nlohmann/json/blob/develop/README.md) by adding links to the [documentation](https://nlohmann.github.io/json/) (#981). - -### :fire: Deprecated functions - -This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0): - -- Function [`iterator_wrapper`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_af1592a06bc63811886ade4f9d965045e.html#af1592a06bc63811886ade4f9d965045e) are deprecated. Please use the member function [`items()`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_afe3e137ace692efa08590d8df40f58dd.html#afe3e137ace692efa08590d8df40f58dd) instead. -- Functions [`friend std::istream& operator<<(basic_json&, std::istream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_ab7285a92514fcdbe6de505ebaba92ea3.html#ab7285a92514fcdbe6de505ebaba92ea3) and [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9e06deabe69262c3ffc5533d32856983.html#a9e06deabe69262c3ffc5533d32856983) are deprecated. Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead. - - -## v3.1.1 - -!!! summary "Files" - - - [include.zip](https://github.com/nlohmann/json/releases/download/v3.1.1/include.zip) (114 KB) - - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.1.1/include.zip.asc) (1 KB) - - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.1.1/json.hpp) (577 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.1.1/json.hpp.asc) (1 KB) - -Release date: 2018-02-13 -SHA-256: e14ce5e33d6a2daf748026bd4947f3d9686ca4cfd53d10c3da46a0a9aceb7f2e (json.hpp), fde771d4b9e4f222965c00758a2bdd627d04fb7b59e09b7f3d1965abdc848505 (include.zip) - -### Summary - -This release fixes several bugs in the library. All changes are backward-compatible. - -### :bug: Bug Fixes - -- Fixed parsing of **CBOR strings with indefinite length** (#961). Earlier versions of this library misinterpreted the CBOR standard and rejected input with the `0x7F` start byte. -- Fixed user-defined **conversion to vector type** (#924, #969). A wrong SFINAE check rejected code though a user-defined conversion was provided. -- Fixed documentation of the parser behavior for **objects with duplicate keys** (#963). The exact behavior is not specified by [RFC 8259](https://tools.ietf.org/html/rfc8259) and the library now also provides no guarantee which object key is stored. -- Added check to detect memory **overflow when parsing UBJSON containers** (#962). The optimized UBJSON format allowed for specifying an array with billions of `null` elements with a few bytes and the library did not check whether this size exceeded `max_size()`. - -### :hammer: Further Changes - -- [Code coverage](https://coveralls.io/github/nlohmann/json) is now calculated for the individual header files, allowing to find uncovered lines more quickly than by browsing through the single header version (#953, #957). -- A Makefile target `run_benchmarks` was added to quickly build and run the benchmark suite. -- The documentation was harmonized with respect to the header inclusion (#955). Now all examples and the README use `#include ` to allow for selecting `single_include` or `include` or whatever installation folder as include directory. -- Added note on how to use the library with the [cget](http://cget.readthedocs.io/en/latest/) package manager (#954). - -### :fire: Deprecated functions - -This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0): - -- Function [`iterator_wrapper`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_af1592a06bc63811886ade4f9d965045e.html#af1592a06bc63811886ade4f9d965045e) are deprecated. Please use the member function [`items()`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_afe3e137ace692efa08590d8df40f58dd.html#afe3e137ace692efa08590d8df40f58dd) instead. -- Functions [`friend std::istream& operator<<(basic_json&, std::istream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_ab7285a92514fcdbe6de505ebaba92ea3.html#ab7285a92514fcdbe6de505ebaba92ea3) and [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9e06deabe69262c3ffc5533d32856983.html#a9e06deabe69262c3ffc5533d32856983) are deprecated. Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead. - -## v3.1.0 - -!!! summary "Files" - - - [include.zip](https://github.com/nlohmann/json/releases/download/v3.1.0/include.zip) (114 KB) - - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.1.0/include.zip.asc) (1 KB) - - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.1.0/json.hpp) (577 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.1.0/json.hpp.asc) (1 KB) - -Release date: 2018-02-01 -SHA-256: d40f614d10a6e4e4e80dca9463da905285f20e93116c36d97d4dc1aa63d10ba4 (json.hpp), 2b7234fca394d1e27b7e017117ed80b7518fafbb4f4c13a7c069624f6f924673 (include.zip) - -### Summary - -This release adds support for the [**UBJSON**](http://ubjson.org) format and [**JSON Merge Patch**](https://tools.ietf.org/html/rfc7386). It also contains some minor changes and bug fixes. All changes are backward-compatible. - -### :sparkles: New features - -- The library now supports [**UBJSON**](http://ubjson.org) (Universal Binary JSON Specification) as binary format to read and write JSON values space-efficiently. See the [documentation overview](https://github.com/nlohmann/json/blob/develop/doc/binary_formats.md) for a comparison of the different formats CBOR, MessagePack, and UBJSON. -- [**JSON Merge Patch**](https://tools.ietf.org/html/rfc7386) (RFC 7386) offers an intuitive means to describe patches between JSON values (#876, #877). See the documentation of [`merge_patch`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a0ec0cd19cce42ae6071f3cc6870ea295.html#a0ec0cd19cce42ae6071f3cc6870ea295) for more information. - -### :zap: Improvements - -- The library now uses the **Grisu2 algorithm** for printing floating-point numbers (based on the reference implementation by Florian Loitsch) which produces a short representation which is guaranteed to round-trip (#360, #935, #936). -- The **UTF-8 handling** was further simplified by using the decoder of Björn Hoehrmann in more scenarios. - -### :truck: Reorganization - -- Though the library is released as a single header, its development got more and more complicated. With this release, the header is **split into several files** and the single-header file `json.hpp` can be generated from these development sources. In the repository, folder `include` contains the development sources and `single_include` contains the single `json.hpp` header (#700, #906, #907, #910, #911, #915, #920, #924, #925, #928, #944). -- The split further allowed for a **forward declaration header** `include/nlohmann/json_fwd.hpp` to speed up compilation times (#314). - -### :hammer: Further changes - -- [Google Benchmark](https://github.com/google/benchmark) is now used for micro benchmarks (see `benchmarks` folder, #921). -- The serialization (JSON and binary formats) now properly work with the libraries string template parameter, allowing for optimized string implementations to be used in constraint environments such as embedded software (#941, #950). -- The exceptional behavior can now be overridden by defining macros `JSON_THROW_USER`, `JSON_TRY_USER`, and `JSON_CATCH_USER`, defining the behavior of `throw`, `try` and `catch`, respectively. This allows to switch off C++'s exception mechanism yet still execute user-defined code in case an error condition occurs (#938). -- To facilitate the interplay with [flex](https://github.com/westes/flex) and [Bison](https://www.gnu.org/software/bison/), the library does not use the variable name `yytext` any more as it could clash with macro definitions (#933). -- The library now defines `NLOHMANN_JSON_VERSION_MAJOR`, `NLOHMANN_JSON_VERSION_MINOR`, and `NLOHMANN_JSON_VERSION_PATCH` to allow for conditional compilation based on the included library version (#943, #948). -- A compilation error with ICC has been fixed (#947). -- Typos and links in the documentation have been fixed (#900, #930). -- A compiler error related to incomplete types has been fixed (#919). -- The tests form the [UTF-8 decoder stress test](http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt) have been added to the test suite. - -### :fire: Deprecated functions - -- Function [`iterator_wrapper`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_af1592a06bc63811886ade4f9d965045e.html#af1592a06bc63811886ade4f9d965045e) has been deprecated (#874). Since its introduction, the name was up for discussion, as it was too technical. We now introduced the member function [`items()`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_afe3e137ace692efa08590d8df40f58dd.html#afe3e137ace692efa08590d8df40f58dd) with the same semantics. `iterator_wrapper` will be removed in the next major version (i.e., 4.0.0). - -Furthermore, the following functions are deprecated since version 3.0.0 and will be removed in the next major version (i.e., 4.0.0): - -- [`friend std::istream& operator<<(basic_json&, std::istream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_ab7285a92514fcdbe6de505ebaba92ea3.html#ab7285a92514fcdbe6de505ebaba92ea3) -- [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9e06deabe69262c3ffc5533d32856983.html#a9e06deabe69262c3ffc5533d32856983) - -Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead. - -## v3.0.1 - -!!! summary "Files" - - - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.0.1/json.hpp) (502 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.0.1/json.hpp.asc) (1 KB) - -Release date: 2017-12-29 -SHA-256: c9b3591f1bb94e723a0cd7be861733a3a555b234ef132be1e9027a0364118c4c - -### Summary - -This release fixes small issues in the implementation of **JSON Pointer** and **JSON Patch**. All changes are backward-compatible. - -### Changes - -- :bug: The **"copy" operation of JSON Patch** ([RFC 6902](https://tools.ietf.org/html/rfc6902)) requests that it is an error if the target path points into a non-existing array or object (see #894 for a detailed description). This release fixes the implementation to detect such invalid target paths and throw an exception. -- :bug: An **array index in a JSON Pointer** ([RFC 6901](https://tools.ietf.org/html/rfc6901)) must be an integer. This release fixes the implementation to throw an exception in case invalid array indices such as `10e2` are used. -- :white_check_mark: Added the [JSON Patch tests](https://github.com/json-patch/json-patch-tests) from Byron Ruth and Mike McCabe. -- :memo: Fixed the documentation of the [`at(ptr)` function with JSON Pointers](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a8ab61397c10f18b305520da7073b2b45.html#a8ab61397c10f18b305520da7073b2b45) to list all possible exceptions (see #888). -- :memo: Updated the [container overview documentation](https://nlohmann.github.io/json/) (see #883). -- :wrench: The CMake files now respect the [`BUILD_TESTING`](https://cmake.org/cmake/help/latest/module/CTest.html?highlight=build_testing) option (see #846, #885) -- :rotating_light: Fixed some compiler warnings (see #858, #882). - -### Deprecated functions - -:fire: To unify the interfaces and to improve similarity with the STL, the following functions are deprecated since version 3.0.0 and will be removed in the next major version (i.e., 4.0.0): - -- [`friend std::istream& operator<<(basic_json&, std::istream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_ab7285a92514fcdbe6de505ebaba92ea3.html#ab7285a92514fcdbe6de505ebaba92ea3) -- [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9e06deabe69262c3ffc5533d32856983.html#a9e06deabe69262c3ffc5533d32856983) - -Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead. - -## v3.0.0 - -!!! summary "Files" - - - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.0.0/json.hpp) (501 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.0.0/json.hpp.asc) (1 KB) - -Release date: 2017-12-17 -SHA-256: 076d4a0cb890a3c3d389c68421a11c3d77c64bd788e85d50f1b77ed252f2a462 - -### Summary - - - -After almost a year, here is finally a new release of JSON for Modern C++, and it is a major one! As we adhere to [semantic versioning](https://semver.org), this means the release includes some breaking changes, so please read the next section carefully before you update. But don't worry, we also added a few new features and put a lot of effort into fixing a lot of bugs and straighten out a few inconsistencies. - -### :boom: Breaking changes - -This section describes changes that change the public API of the library and may require changes in code using a previous version of the library. In section "Moving from 2.x.x to 3.0.0" at the end of the release notes, we describe in detail how existing code needs to be changed. - -- The library now uses [**user-defined exceptions**](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9a0aced019cb1d65bb49703406c84970.html#a9a0aced019cb1d65bb49703406c84970) instead of re-using those defined in `` (#244). This not only allows to add more information to the exceptions (every exception now has an identifier, and parse errors contain the position of the error), but also to easily catch all library exceptions with a single `catch(json::exception)`. -- When strings with a different encoding as UTF-8 were stored in JSON values, their serialization could not be parsed by the library itself, as only UTF-8 is supported. To enforce this library limitation and improve consistency, **non-UTF-8 encoded strings now yield a `json::type_error` exception during serialization** (#838). The check for valid UTF-8 is realized with code from [Björn Hoehrmann](http://bjoern.hoehrmann.de/). -- **NaN and infinity values can now be stored inside the JSON value** without throwing an exception. They are, however, still serialized as `null` (#388). -- The library's iterator tag was changed from RandomAccessIterator to **[BidirectionalIterator](http://en.cppreference.com/w/cpp/concept/BidirectionalIterator)** (#593). Supporting RandomAccessIterator was incorrect as it assumed an ordering of values in a JSON objects which are unordered by definition. -- The library does not include the standard headers ``, ``, and `` any more. You may need to add these headers to code relying on them. -- Removed constructor `explicit basic_json(std::istream& i, const parser_callback_t cb = nullptr)` which was deprecated in version 2.0.0 (#480). - -### :fire: Deprecated functions - -To unify the interfaces and to improve similarity with the STL, the following functions are now deprecated and will be removed in the next major version (i.e., 4.0.0): - -- [`friend std::istream& operator<<(basic_json&, std::istream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_ab7285a92514fcdbe6de505ebaba92ea3.html#ab7285a92514fcdbe6de505ebaba92ea3) -- [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9e06deabe69262c3ffc5533d32856983.html#a9e06deabe69262c3ffc5533d32856983) - -Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead. - -### :sparkles: New features - -With all this breaking and deprecation out of the way, let's talk about features! - -- We improved the **diagnostic information for syntax errors** (#301). Now, an exception [`json::parse_error`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_af1efc2468e6022be6e35fc2944cabe4d.html#af1efc2468e6022be6e35fc2944cabe4d) is thrown which contains a detailed message on the error, but also a member `byte` to indicate the byte offset in the input where the error occurred. -- We added a **non-throwing syntax check** (#458): The new `accept` function returns a Boolean indicating whether the input is proper JSON. We also added a Boolean parameter `allow_exceptions` to the existing [`parse`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aa9676414f2e36383c4b181fe856aa3c0.html#aa9676414f2e36383c4b181fe856aa3c0) functions to return a `discarded` value in case a syntax error occurs instead of throwing an exception. -- An [`update`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a1cfa9ae5e7c2434cab4cfe69bffffe11.html#a1cfa9ae5e7c2434cab4cfe69bffffe11) function was added to **merge two JSON objects** (#428). In case you are wondering: the name was inspired by [Python](https://docs.python.org/2/library/stdtypes.html#dict.update). -- The [`insert`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a1b0a4e60d56f1fe80501ed941e122892.html#a1b0a4e60d56f1fe80501ed941e122892) function now also supports an iterator range to add elements to an object. -- The binary exchange formats **CBOR and MessagePack can now be parsed from input streams and written to output streams** (#477). -- Input streams are now only read until the end of a JSON value instead of the end of the input (#367). -- The serialization function [`dump`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5adea76fedba9898d404fef8598aa663.html#a5adea76fedba9898d404fef8598aa663) now has two optional parameters `ensure_ascii` to **escape all non-ASCII characters** with `\uxxxx` and an `indent_char` parameter to choose whether to **indent with spaces or tabs** (#654). -- Added **built-in type support** for C arrays (#502), `std::pair` and `std::tuple` (#563, #614), `enum` and `enum class` (#545), `std::vector` (#494). Fixed support for `std::valarray` (#702), `std::array` (#553), and `std::map` (#600, #607). - -### :hammer: Further changes - -Furthermore, there have been a lot of changes under the hood: - -- Replaced the [re2c](http://re2c.org) generated scanner by a self-coded version which allows for a better modularization of the parser and better diagnostics. To test the new scanner, we added millions (8,860,608 to be exact) of unit tests to check all valid and invalid byte sequences of the Unicode standard. -- Google's OSS-Fuzz is still constantly fuzz-testing the library and found several issues that were fixed in this release (#497, #504, #514, #516, #518, #519, #575). -- We now also ignore UTF-8 byte order marks when parsing from an iterator range (#602). -- Values can be now moved from initializer lists (#663). -- Updated to [Catch](https://github.com/catchorg/Catch2) 1.9.7. Unfortunately, Catch2 currently has some performance issues. -- The non-exceptional paths of the library are now annotated with `__builtin_expect` to optimize branch prediction as long as no error occurs. -- MSVC now produces a stack trace in MSVC if a `from_json` or `to_json` function was not found for a user-defined type. We also added a debug visualizer [`nlohmann_json.natvis`](https://github.com/nlohmann/json/blob/develop/nlohmann_json.natvis) for better debugging in MSVC (#844). -- Overworked the documentation and added even more examples. -- The build workflow now relies on CMake and CTest. Special flags can be chosen with CMake, including coverage (`JSON_Coverage`), compilation without exceptions (`JSON_NoExceptions`), LLVM sanitizers (`JSON_Sanitizer`), or execution with Valgrind (`JSON_Valgrind`). -- Added support for package managers Meson (#576), Conan (#566), Hunter (#671, #829), and vcpkg (#753). -- Added CI builders: Xcode 8.3, 9.0, 9.1, and 9.2; GCC 7.2; Clang 3.8, 3.9, 4.0, and 5.0; Visual Studio 2017. The library is further built with C++17 settings on the latest Clang, GCC, and MSVC version to quickly detect new issues. - -### Moving from 2.x.x to 3.0.0 - -#### User-defined Exceptions - -There are five different exceptions inheriting from [`json::exception`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a9a0aced019cb1d65bb49703406c84970.html#a9a0aced019cb1d65bb49703406c84970): - -- [`json::parse_error`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_af1efc2468e6022be6e35fc2944cabe4d.html#af1efc2468e6022be6e35fc2944cabe4d) for syntax errors (including the binary formats), -- [`json::invalid_iterator`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_ac13d32f7cbd02d616e71d8dc30dadcbf.html#ac13d32f7cbd02d616e71d8dc30dadcbf) for errors related to iterators, -- [`json::type_error`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a4010e8e268fefd86da773c10318f2902.html#a4010e8e268fefd86da773c10318f2902) for errors where functions were called with the wrong JSON type, -- [`json::out_of_range`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a28f7c2f087274a0012eb7a2333ee1580.html#a28f7c2f087274a0012eb7a2333ee1580) for range errors, and -- [`json::other_error`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a3333a5a8714912adda33a35b369f7b3d.html#a3333a5a8714912adda33a35b369f7b3d) for miscellaneous errors. - -To support these exception, the `try`/`catch` blocks of your code need to be adjusted: - -| new exception | previous exception | -|:--|:--| -| parse_error.101 | invalid_argument | -| parse_error.102 | invalid_argument | -| parse_error.103 | invalid_argument | -| parse_error.104 | invalid_argument | -| parse_error.105 | invalid_argument | -| parse_error.106 | domain_error | -| parse_error.107 | domain_error | -| parse_error.108 | domain_error | -| parse_error.109 | invalid_argument | -| parse_error.110 | out_of_range | -| parse_error.111 | invalid_argument | -| parse_error.112 | invalid_argument | -| invalid_iterator.201 | domain_error | -| invalid_iterator.202 | domain_error | -| invalid_iterator.203 | domain_error | -| invalid_iterator.204 | out_of_range | -| invalid_iterator.205 | out_of_range | -| invalid_iterator.206 | domain_error | -| invalid_iterator.207 | domain_error | -| invalid_iterator.208 | domain_error | -| invalid_iterator.209 | domain_error | -| invalid_iterator.210 | domain_error | -| invalid_iterator.211 | domain_error | -| invalid_iterator.212 | domain_error | -| invalid_iterator.213 | domain_error | -| invalid_iterator.214 | out_of_range | -| type_error.301 | domain_error | -| type_error.302 | domain_error | -| type_error.303 | domain_error | -| type_error.304 | domain_error | -| type_error.305 | domain_error | -| type_error.306 | domain_error | -| type_error.307 | domain_error | -| type_error.308 | domain_error | -| type_error.309 | domain_error | -| type_error.310 | domain_error | -| type_error.311 | domain_error | -| type_error.313 | domain_error | -| type_error.314 | domain_error | -| type_error.315 | domain_error | -| out_of_range.401 | out_of_range | -| out_of_range.402 | out_of_range | -| out_of_range.403 | out_of_range | -| out_of_range.404 | out_of_range | -| out_of_range.405 | domain_error | -| other_error.501 | domain_error | - -#### Handling of NaN and INF - -- If an overflow occurs during parsing a number from a JSON text, an exception [`json::out_of_range`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a28f7c2f087274a0012eb7a2333ee1580.html#a28f7c2f087274a0012eb7a2333ee1580) is thrown so that the overflow is detected early and roundtripping is guaranteed. - -- NaN and INF floating-point values can be stored in a JSON value and are not replaced by null. That is, the basic_json class behaves like `double` in this regard (no exception occurs). However, NaN and INF are serialized to `null`. - -#### Removal of deprecated functions - -Function `explicit basic_json(std::istream& i, const parser_callback_t cb = nullptr)` should be replaced by the `parse` function: Let `ss` be a stream and `cb` be a parse callback function. - -Old code: - -```cpp -json j(ss, cb); -``` - -New code: - -```cpp -json j = json::parse(ss, cb); -``` - -If no callback function is used, also the following code works: - -```cpp -json j; -j << ss; -``` - -or - -```cpp -json j; -ss >> j; -``` - -## v2.1.1 - -!!! summary "Files" - - - [json.hpp](https://github.com/nlohmann/json/releases/download/v2.1.1/json.hpp) (437 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.1.1/json.hpp.asc) (1 KB) - -Release date: 2017-02-25 -SHA-256: faa2321beb1aa7416d035e7417fcfa59692ac3d8c202728f9bcc302e2d558f57 - -### Summary - -This release **fixes a locale-related bug in the parser**. To do so, the whole number handling (lexer, parser, and also the serialization) have been overworked. Furthermore, a lot of small changes added up that were added to this release. All changes are backward-compatible. - -### Changes -- :bug: Locales that have a different character than `.` as decimal separator (e.g., the Norwegian locale `nb_NO.UTF-8`) led to truncated number parsing or parse errors. The library now has been fixed to work with **any locale**. Note that `.` is still the only valid decimal separator for JSON input. -- :bug: Numbers like `1.0` were correctly parsed as floating-point number, but serialized as integer (`1`). Now, **floating-point numbers correctly round trip**. -- :bug: Parsing incorrect JSON numbers with leading 0 (`0123`) could yield a [buffer overflow](https://github.com/nlohmann/json/issues/452). This is fixed now by detecting such errors directly by the lexer. -- :bug: Constructing a JSON value from a pointer was incorrectly interpreted as a Boolean; such code will now yield a compiler error. -- :bug: Comparing a JSON number with `0` led to a comparison with `null`. This is fixed now. -- :bug: All throw calls are now wrapped in macros. -- :lock: Starting during the preparation of this release (since 8 February 2017), commits and released files are **cryptographically signed** with [this GPG key](https://keybase.io/nlohmann/pgp_keys.asc?fingerprint=797167ae41c0a6d9232e48457f3cea63ae251b69). Previous releases have also been signed. -- :sparkles: The parser for MessagePack and CBOR now supports an optional start index parameter to define a byte offset for the parser. -- :rotating_light: Some more warnings have been fixed. With Clang, the code compiles **without warnings** with `-Weverything` (well, it needs `-Wno-documentation-unknown-command` and `-Wno-deprecated-declarations`, but you get the point). -- :hammer: The code can be compiled easier with many Android NDKs by avoiding macros like `UINT8_MAX` which previously required defining a preprocessor macro for compilation. -- :zap: The unit tests now compile two times faster. -- :heavy_plus_sign: [Cotire](https://github.com/sakra/cotire) is used to speed up the build. -- :pencil2: Fixed a lot of typos in the documentation. -- :memo: Added a section to the README file that lists all used [third-party code/tools](https://github.com/nlohmann/json#used-third-party-tools). -- :memo: Added a note on constructing a string value vs. parsing. -- :white_check_mark: The test suite now contains 11202597 unit tests. -- :memo: Improved the [Doxygen documentation](https://nlohmann.github.io/json/) by shortening the template parameters of class `basic_json`. -- :construction_worker: Removed Doozer. -- :construction_worker: Added Codacity. -- :arrow_up: Upgraded Catch to version 1.7.2. - - -## v2.1.0 - -!!! summary "Files" - - - [json.hpp](https://github.com/nlohmann/json/releases/download/v2.1.0/json.hpp) (426 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.1.0/json.hpp.asc) (1 KB) - -- Release date: 2017-01-28 -- SHA-256: a571dee92515b685784fd527e38405cf3f5e13e96edbfe3f03d6df2e363a767b - -### Summary - -This release introduces a means to convert from/to user-defined types. The release is backwards compatible. - -![conversion](https://cloud.githubusercontent.com/assets/159488/22399173/aebe8f7a-e597-11e6-930f-7494ee615827.png) - -### Changes -- :sparkles: The library now offers an elegant way to **convert from and to arbitrary value types**. All you need to do is to implement two functions: `to_json` and `from_json`. Then, a conversion is as simple as putting a `=` between variables. See the [README](https://github.com/nlohmann/json#arbitrary-types-conversions) for more information and examples. -- :sparkles: **Exceptions can now be switched off.** This can be done by defining the preprocessor symbol `JSON_NOEXCEPTION` or by passing `-fno-exceptions` to your compiler. In case the code would usually thrown an exception, `abort()` is now called. -- :sparkles: **Information on the library** can be queried with the new (static) function `meta()` which returns a JSON object with information on the version, compiler, and platform. See the [documentation]() for an example. -- :bug: A bug in the CBOR parser was fixed which led to a buffer overflow. -- :sparkles: The function [`type_name()`]() is now public. It allows to query the type of a JSON value as string. -- :white_check_mark: Added the [Big List of Naughty Strings](https://github.com/minimaxir/big-list-of-naughty-strings) as test case. -- :arrow_up: Updated to [Catch v1.6.0](https://github.com/philsquared/Catch/releases/tag/v1.6.0). -- :memo: Some typos in the documentation have been fixed. - - -## v2.0.10 - -!!! summary "Files" - - - [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.10/json.hpp) (409 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.10/json.hpp.asc) (1 KB) - -- Release date: 2017-01-02 -- SHA-256: ec27d4e74e9ce0f78066389a70724afd07f10761009322dc020656704ad5296d - -### Summary - -This release fixes several security-relevant bugs in the MessagePack and CBOR parsers. The fixes are backwards compatible. - -### Changes -- :bug: Fixed a lot of **bugs in the CBOR and MesssagePack parsers**. These bugs occurred if invalid input was parsed and then could lead in buffer overflows. These bugs were found with Google's [OSS-Fuzz](https://github.com/google/oss-fuzz), see #405, #407, #408, #409, #411, and #412 for more information. -- :construction_worker: We now also use the **[Doozer](https://doozer.io) continuous integration platform**. -- :construction_worker: The complete test suite is now also run with **Clang's address sanitizer and undefined-behavior sanitizer**. -- :white_check_mark: Overworked **fuzz testing**; CBOR and MessagePack implementations are now fuzz-tested. Furthermore, all fuzz tests now include a round trip which ensures created output can again be properly parsed and yields the same JSON value. -- :memo: Clarified documentation of `find()` function to always return `end()` when called on non-object value types. -- :hammer: Moved thirdparty test code to `test/thirdparty` directory. - -## v2.0.9 - -!!! summary "Files" - - - [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.9/json.hpp) (406 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.9/json.hpp.asc) (1 KB) - -- Release date: 2016-12-16 -- SHA-256: fbf3396f13e187d6c214c297bddc742d918ea9b55e10bfb3d9f458b9bfdc22e5 - -### Summary - -This release implements with **[CBOR](http://cbor.io)** and **[MessagePack](http://msgpack.org)** two **binary serialization/deserialization formats**. It further contains some small fixes and improvements. The fixes are backwards compatible. - -![cbor](https://cloud.githubusercontent.com/assets/159488/22399181/d4d60d32-e597-11e6-8dcb-825abcf9ac2a.png) - -### Changes -- :sparkles: The library can now read and write the binary formats **[CBOR](http://cbor.io)** (Concise Binary Object Representation) and **[MessagePack](http://msgpack.org)**. Both formats are aimed to produce a very compact representation of JSON which can be parsed very efficiently. See the [README file](https://github.com/nlohmann/json#binary-formats-cbor-and-messagepack) for more information and examples. -- :fire: simplified the iteration implementation allowing to remove dozens of lines of code -- :bug: fixed an [integer overflow error](https://github.com/nlohmann/json/issues/389) detected by [Google's OSS-Fuzz](https://github.com/google/oss-fuzz) -- :bug: suppressed documentation warnings inside the library to facilitate compilation with `-Wdocumentation` -- :bug: fixed an overflow detection error in the number parser -- :memo: updated [contribution guidelines](https://github.com/nlohmann/json/blob/develop/.github/CONTRIBUTING.md) to a list of frequentely asked features that will most likely be never added to the library -- :memo: added a **table of contents** to the [README file](https://github.com/nlohmann/json/blob/develop/README.md) to add some structure -- :memo: mentioned the many [examples](https://github.com/nlohmann/json/tree/develop/doc/examples) and the [documentation](https://nlohmann.github.io/json/) in the [README file]() -- :hammer: split [unit tests](https://github.com/nlohmann/json/tree/develop/test/src) into individual independent binaries to speed up compilation and testing -- :white_check_mark: the test suite now contains **11201886** tests - -## v2.0.8 - -!!! summary "Files" - - - [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.8/json.hpp) (360 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.8/json.hpp.asc) (1 KB) - -- Release date: 2016-12-02 -- SHA-256: b70db0ad34f8e0e61dc3f0cbab88099336c9674c193d8a3439d93d6aca2d7120 - -### Summary - -This release combines a lot of small fixes and improvements. The fixes are backwards compatible. - -### Changes -- :bug: fixed a bug that froze the parser if a passed file was not found (now, `std::invalid_argument` is thrown) -- :bug: fixed a bug that lead to an error of a file at EOF was parsed again (now, `std::invalid_argument` is thrown) -- :sparkles: the well known functions [`emplace`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a602f275f0359ab181221384989810604.html#a602f275f0359ab181221384989810604) and [`emplace_back`](http://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_af8a435033327d9237da414afc1cce513.html#af8a435033327d9237da414afc1cce513) have been added to JSON values and work as expected -- :zap: improved the performance of the serialization (`dump` function) -- :zap: improved the performance of the deserialization (parser) -- :construction_worker: some continuous integration images at [Travis](https://travis-ci.org/nlohmann/json) were added and retired; see [here](https://github.com/nlohmann/json#supported-compilers) for the current continuous integration setup -- :construction_worker: the [Coverity scan](https://scan.coverity.com/projects/nlohmann-json) works again -- :chart_with_upwards_trend: the benchmarking code has been improved to produce more stable results -- :memo: the [README](https://github.com/nlohmann/json/blob/develop/README.md) file has been extended and includes more frequently asked examples -- :white_check_mark: the test suite now contains 8905518 tests -- :arrow_up: updated [Catch](https://github.com/philsquared/Catch) to version 1.5.8 - -## v2.0.7 - -!!! summary "Files" - - - [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.7/json.hpp) (355 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.7/json.hpp.asc) (1 KB) - -- Release date: 2016-11-02 -- SHA-256: 5545c323670f8165bae90b9dc6078825e86ec310d96cc4e5b47233ea43715bbf - -### Summary - -This release fixes a few bugs in the JSON parser found in the [Parsing JSON is a Minefield 💣](http://seriot.ch/parsing_json.html) article. The fixes are backwards compatible. - -### Changes -- The article [Parsing JSON is a Minefield 💣](http://seriot.ch/parsing_json.html) discusses a lot of pitfalls of the JSON specification. When investigating the published test cases, a few bugs in the library were found and fixed: - - Files with less than 5 bytes can now be parsed without error. - - The library now properly rejects any file encoding other than UTF-8. Furthermore, incorrect surrogate pairs are properly detected and rejected. - - The library now accepts all but one "yes" test (y_string_utf16.json): UTF-16 is not supported. - - The library rejects all but one "no" test (n_number_then_00.json): Null bytes are treated as end of file instead of an error. This allows to parse input from null-terminated strings. -- The string length passed to a user-defined string literal is now exploited to choose a more efficient constructor. -- A few grammar mistakes in the README file have been fixed. - -## v2.0.6 - -!!! summary "Files" - - - [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.6/json.hpp) (349 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.6/json.hpp.asc) (1 KB) - -- Release date: 2016-10-15 -- SHA256: 459cc93d5e2f503e50c6d5876eb86bfea7daf405f5a567c5a2c9abc2383756ae - -### Summary - -This release fixes the semantics of `operator[]` for JSON Pointers (see below). This fix is backwards compatible. - -### Changes -- **`operator[]` for JSON Pointers** now behaves like the other versions of `operator[]` and transforms `null` values into objects or arrays if required. This allows to created nested structures like `j["/foo/bar/2"] = 17` (yielding `{"foo": "bar": [null, null, 17]}`) without problems. -- overworked a helper SFINAE function -- fixed some documentation issues -- fixed the CMake files to allow to run the test suite outside the main project directory -- restored test coverage to 100%. - -## v2.0.5 - -!!! summary "Files" - - - [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.5/json.hpp) (347 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.5/json.hpp.asc) (1 KB) - -- Release date: 2016-09-14 -- SHA-256: 8b7565263a44e2b7d3b89808bc73d2d639037ff0c1f379e3d56dbd77e00b98d9 - -### Summary - -This release fixes a regression bug in the stream parser (function `parse()` and the `<<`/`>>` operators). This fix is backwards compatible. - -### Changes -- **Bug fix**: The end of a file stream was not detected properly which led to parse errors. This bug should have been fixed with 2.0.4, but there was still a flaw in the code. - -## v2.0.4 - -!!! summary "Files" - - - [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.4/json.hpp) (347 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.4/json.hpp.asc) (1 KB) - -- Release date: 2016-09-11 -- SHA-256: 632ceec4c25c4e2153f71470d3a2b992c8355f6d8b4d627d05dd16095cd3aeda - -### Summary - -This release fixes a bug in the stream parser (function `parse()` and the `<<`/`>>` operators). This fix is backwards compatible. - -### Changes -- **Bug fix**: The end of a file stream was not detected properly which led to parse errors. -- Fixed a compiler warning about an unused variable. - -## v2.0.3 - -!!! summary "Files" - - - [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.3/json.hpp) (347 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.3/json.hpp.asc) (1 KB) - -- Release date: 2016-08-31 -- SHA-256: 535b73efe5546fde9e763c14aeadfc7b58183c0b3cd43c29741025aba6cf6bd3 - -### Summary - -This release combines a lot of small fixes and improvements. The release is backwards compatible. - -### Changes -- The **parser/deserialization functions have been generalized** to process any contiguous sequence of 1-byte elements (e.g., `char`, `unsigned char`, `uint8_t`). This includes all kind of string representations (string literals, char arrays, `std::string`, `const char*`), contiguous containers (C-style arrays, `std::vector`, `std::array`, `std::valarray`, `std::initializer_list`). User-defined containers providing random-access iterator access via `std::begin` and `std::end` can be used as well. See the documentation ([1](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_ace63ac4eb1dd7251a259d32e397461a3.html#ace63ac4eb1dd7251a259d32e397461a3), [2](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a90f05d55d9d0702c075cd281fd0d85ae.html#a90f05d55d9d0702c075cd281fd0d85ae), [3](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_aeffd70f622f8f2a51fd3d95af64b63a7.html#aeffd70f622f8f2a51fd3d95af64b63a7), [4](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_aa8dca2e91a6301c36890f844e64f0023.html#aa8dca2e91a6301c36890f844e64f0023)) for more information. Note that contiguous storage cannot be checked at compile time; if any of the parse functions are called with a noncompliant container, the behavior is undefined and will most likely yield segmentation violation. The preconditions are enforced by an assertion unless the library is compiled with preprocessor symbol `NDEBUG`. -- As a general remark on **assertions**: The library uses assertions to preclude undefined behavior. A [prominent example](https://github.com/nlohmann/json/issues/289) for this is the `operator[]` for const JSON objects. The behavior of this const version of the operator is undefined if the given key does not exist in the JSON object, because unlike the non-const version, it cannot add a `null` value at the given key. Assertions can be switched of by defining the preprocessor symbol `NDEBUG`. See the [documentation of `assert`](http://en.cppreference.com/w/cpp/error/assert) for more information. -- In the course of cleaning up the parser/deserialization functions, the constructor [`basic_json(std::istream&, const parser_callback_t)`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a32350263eb105764844c5a85e156a255.html#a32350263eb105764844c5a85e156a255) has been **deprecated** and will be deleted with the next major release 3.0.0 to unify the interface of the library. Deserialization will be done by stream operators or by calling one of the `parse` functions. That is, calls like `json j(i);` for an input stream `i` need to be replaced by `json j = json::parse(i);`. Compilers will produce a deprecation warning if client code uses this function. -- Minor improvements: - - Improved the performance of the serialization by avoiding the re-creation of a locale object. - - Fixed two MSVC warnings. Compiling the test suite with `/Wall` now only warns about non-inlined functions (C4710) and the deprecation of the constructor from input-stream (C4996). -- Some project internals: - - The project has qualified for the [Core Infrastructure Initiative Best Practices Badge](https://bestpractices.coreinfrastructure.org/projects/289). While most requirements where already satisfied, some led to a more explicit documentation of quality-ensuring procedures. For instance, static analysis is now executed with every commit on the build server. Furthermore, the [contribution guidelines document](https://github.com/nlohmann/json/blob/develop/.github/CONTRIBUTING.md) how to communicate security issues privately. - - The test suite has been overworked and split into several files to allow for faster compilation and analysis. The execute the test suite, simply execute `make check`. - - The continuous integration with [Travis](https://travis-ci.org/nlohmann/json) was extended with Clang versions 3.6.0 to 3.8.1 and now includes 18 different compiler/OS combinations. - - An 11-day run of [American fuzzy lop](http://lcamtuf.coredump.cx/afl/) checked 962 million inputs on the parser and found no issue. - -## v2.0.2 - -!!! summary "Files" - - - [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.2/json.hpp) (338 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.2/json.hpp.asc) (1 KB) - -- Release date: 2016-07-31 -- SHA-256: 8e97b7965b4594b00998d6704465412360e1a0ed927badb51ded8b82291a8f3d - -### Summary - -This release combines a lot of small fixes and improvements. The release is backwards compatible. - -### Changes -- The **parser** has been overworked, and a lot of small issues have been fixed: - - Improved parser performance by avoiding recursion and using move semantics for the return value. - - Unescaped control characters `\x10`-`\x1f` are not accepted any more. - - Fixed a bug in the parser when reading from an input stream. - - Improved test case coverage for UTF-8 parsing: now, all valid Unicode code points are tested both escaped and unescaped. - - The precision of output streams is now preserved by the parser. -- Started to check the **code correctness** by proving termination of important loops. Furthermore, individual assertions have been replaced by a more systematic function which checks the class invariants. Note that assertions should be switched off in production by defining the preprocessor macro `NDEBUG`, see the [documentation of `assert`](http://en.cppreference.com/w/cpp/error/assert). -- A lot of **code cleanup**: removed unused headers, fixed some compiler warnings, and fixed a build error for Windows-based Clang builds. -- Added some compile-time checks: - - Unsupported compilers are rejected during compilation with an `#error` command. - - Static assertion prohibits code with incompatible pointer types used in `get_ptr()`. -- Improved the [documentation](https://nlohmann.github.io/json/), and adjusted the documentation script to choose the correct version of `sed`. -- Replaced a lot of "raw loops" by STL functions like `std::all_of`, `std::for_each`, or `std::accumulate`. This facilitates reasoning about termination of loops and sometimes allowed to simplify functions to a single return statement. -- Implemented a `value()` function for JSON pointers (similar to `at` function). -- The Homebrew formula (see [Integration](https://github.com/nlohmann/json#integration)) is now tested for all Xcode builds (6.1 - 8.x) with Travis. -- Avoided output to `std::cout` in the test cases. - -## v2.0.1 - -!!! summary "Files" - - - [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.1/json.hpp) (321 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.1/json.hpp.asc) (1 KB) - -- Release date: 2016-06-28 -- SHA-256: ef550fcd7df572555bf068e9ec4e9d3b9e4cdd441cecb0dcea9ea7fd313f72dd - -### Summary - -This release fixes a performance regression in the JSON serialization (function `dump()`). This fix is backwards compatible. - -### Changes -- The locale of the output stream (or the internal string stream if a JSON value is serialized to a string) is now adjusted once for the whole serialization instead of for each floating-point number. -- The locale of an output stream is now correctly reset to the previous value by the JSON library. - - -## v2.0.0 - -!!! summary "Files" - - - [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.0/json.hpp) (321 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.0/json.hpp.asc) (1 KB) - -- Release date: 2016-06-24 -- SHA-256: ac9e1fb25c2ac9ca5fc501fcd2fe3281fe04f07018a1b48820e7b1b11491bb6c - -### Summary - -This release adds several features such as JSON Pointers, JSON Patch, or support for 64 bit unsigned integers. Furthermore, several (subtle) bugs have been fixed. - -As `noexcept` and `constexpr` specifier have been added to several functions, the public API has effectively been changed in a (potential) non-backwards compatible manner. As we adhere to [Semantic Versioning](http://semver.org), this calls for a new major version, so say hello to 2️⃣.0️⃣.0️⃣. - -### Changes -- 🔟 A JSON value now uses `uint64_t` (default value for template parameter `NumberUnsignedType`) as data type for **unsigned integer** values. This type is used automatically when an unsigned number is parsed. Furthermore, constructors, conversion operators and an `is_number_unsigned()` test have been added. -- 👉 **JSON Pointer** ([RFC 6901](https://tools.ietf.org/html/rfc6901)) support: A JSON Pointer is a string (similar to an XPath expression) to address a value inside a structured JSON value. JSON Pointers can be used in `at()` and `operator[]` functions. Furthermore, JSON values can be “flattened” to key/value pairs using `flatten()` where each key is a JSON Pointer. The original value can be restored by “unflattening” the flattened value using `unflatten()`. -- 🏥 **JSON Patch** ([RFC 6902](https://tools.ietf.org/html/rfc6902)) support. A JSON Patch is a JSON value that describes the required edit operations (add, change, remove, …) to transform a JSON value into another one. A JSON Patch can be created with function `diff(const basic_json&)` and applied with `patch(const basic_json&)`. Note the created patches use a rather primitive algorithm so far and leave room for improvement. -- 🇪🇺 The code is now **locale-independent**: Floating-point numbers are always serialized with a period (`.`) as decimal separator and ignores different settings from the locale. -- 🍺 **Homebrew** support: Install the library with `brew tap nlohmann/json && brew install nlohmann_json`. -- Added constructor to create a JSON value by parsing a `std::istream` (e.g., `std::stringstream` or `std::ifstream`). -- Added **`noexcept`** specifier to `basic_json(boolean_t)`, `basic_json(const number_integer_t)`, `basic_json(const int)`, `basic_json(const number_float_t)`, iterator functions (`begin()`, `end()`, etc.) -- When parsing numbers, the sign of `0.0` (vs. `-0.0`) is preserved. -- Improved MSVC 2015, Android, and MinGW support. See [README](https://github.com/nlohmann/json#supported-compilers) for more information. -- Improved test coverage (added 2,225,386 tests). -- Removed some misuses of `std::move`. -- Fixed several compiler warnings. -- Improved error messages from JSON parser. -- Updated to [`re2c`](http://re2c.org) to version 0.16 to use a minimal DFAs for the lexer. -- Updated test suite to use [Catch](https://github.com/philsquared/Catch) version 1.5.6. -- Made type getters (`is_number`, etc.) and const value access `constexpr`. -- Functions `push_back` and `operator+=` now work with key/value pairs passed as initializer list, e.g. `j_object += {"key", 1}`. -- Overworked `CMakeLists.txt` to make it easier to integrate the library into other projects. - -### Notes -- Parser error messages are still very vague and contain no information on the error location. -- The implemented `diff` function is rather primitive and does not create minimal diffs. -- The name of function `iteration_wrapper` may change in the future and the function will be deprecated in the next release. -- Roundtripping (i.e., parsing a JSON value from a string, serializing it, and comparing the strings) of floating-point numbers is not 100% accurate. Note that [RFC 8259](https://tools.ietf.org/html/rfc8259) defines no format to internally represent numbers and states not requirement for roundtripping. Nevertheless, benchmarks like [Native JSON Benchmark](https://github.com/miloyip/nativejson-benchmark) treat roundtripping deviations as conformance errors. - - -## v1.1.0 - -!!! summary "Files" - - - [json.hpp](https://github.com/nlohmann/json/releases/download/v1.1.0/json.hpp) (257 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v1.1.0/json.hpp.asc) (1 KB) - -- Release date: 2016-01-24 -- SHA-256: c0cf0e3017798ca6bb18e757ebc570d21a3bdac877845e2b9e9573d183ed2f05 - -### Summary - -This release fixes several small bugs and adds functionality in a backwards-compatible manner. Compared to the [last version (1.0.0)](https://github.com/nlohmann/json/releases/tag/v1.0.0), the following changes have been made: - -### Changes -- _Fixed_: **Floating-point numbers** are now serialized and deserialized properly such that rountripping works in more cases. [#185, #186, #190, #191, #194] -- _Added_: The code now contains **assertions** to detect undefined behavior during development. As the standard function `assert` is used, the assertions can be switched off by defining the preprocessor symbol `NDEBUG` during compilation. [#168] -- _Added_: It is now possible to get a **reference** to the stored values via the newly added function `get_ref()`. [#128, #184] -- _Fixed_: Access to object values via keys (**`operator[]`**) now works with all kind of string representations. [#171, #189] -- _Fixed_: The code now compiles again with **Microsoft Visual Studio 2015**. [#144, #167, #188] -- _Fixed_: All required headers are now included. -- _Fixed_: Typos and other small issues. [#162, #166, #175, #177, #179, #180] - -### Notes - -There are still known open issues (#178, #187) which will be fixed in version 2.0.0. However, these fixes will require a small API change and will not be entirely backwards-compatible. - - -## v1.0.0 - -!!! summary "Files" - - - [json.hpp](https://github.com/nlohmann/json/releases/download/v1.0.0/json.hpp) (243 KB) - - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v1.0.0/json.hpp.asc) (1 KB) - -- Release date: 2015-12-28 -- SHA-256: 767dc2fab1819d7b9e19b6e456d61e38d21ef7182606ecf01516e3f5230446de - -### Summary - -This is the first official release. Compared to the [prerelease version 1.0.0-rc1](https://github.com/nlohmann/json/releases/tag/v1.0.0-rc1), only a few minor improvements have been made: - -### Changes -- _Changed_: A **UTF-8 byte order mark** is silently ignored. -- _Changed_: `sprintf` is no longer used. -- _Changed_: `iterator_wrapper` also works for const objects; note: the name may change! -- _Changed_: **Error messages** during deserialization have been improved. -- _Added_: The `parse` function now also works with type `std::istream&&`. -- _Added_: Function `value(key, default_value)` returns either a copy of an object's element at the specified key or a given default value if no element with the key exists. -- _Added_: Public functions are tagged with the version they were introduced. This shall allow for better **versioning** in the future. -- _Added_: All public functions and types are **documented** (see http://nlohmann.github.io/json/doxygen/) including executable examples. -- _Added_: Allocation of all types (in particular arrays, strings, and objects) is now exception-safe. -- _Added_: They descriptions of thrown exceptions have been overworked and are part of the tests suite and documentation. diff --git a/docs/mkdocs/docs/home/sponsors.md b/docs/mkdocs/docs/home/sponsors.md deleted file mode 100644 index 9097049d49..0000000000 --- a/docs/mkdocs/docs/home/sponsors.md +++ /dev/null @@ -1,13 +0,0 @@ -# Sponsors - -You can sponsor this library at [GitHub Sponsors](https://github.com/sponsors/nlohmann). - -## Named Sponsors - -- [Michael Hartmann](https://github.com/reFX-Mike) -- [Stefan Hagen](https://github.com/sthagen) -- [Steve Sperandeo](https://github.com/homer6) -- [Robert Jefe Lindstädt](https://github.com/eljefedelrodeodeljefe) -- [Steve Wagner](https://github.com/ciroque) - -Thanks everyone! diff --git a/docs/mkdocs/docs/images/callback_events.png b/docs/mkdocs/docs/images/callback_events.png deleted file mode 100644 index 09aa2b3835..0000000000 Binary files a/docs/mkdocs/docs/images/callback_events.png and /dev/null differ diff --git a/docs/mkdocs/docs/images/json_syntax_number.png b/docs/mkdocs/docs/images/json_syntax_number.png deleted file mode 100644 index be23ffa69d..0000000000 Binary files a/docs/mkdocs/docs/images/json_syntax_number.png and /dev/null differ diff --git a/docs/mkdocs/docs/images/range-begin-end.svg b/docs/mkdocs/docs/images/range-begin-end.svg deleted file mode 100644 index 8e2b2fb6cf..0000000000 --- a/docs/mkdocs/docs/images/range-begin-end.svg +++ /dev/null @@ -1,435 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - Past-the-last element - - - - begin - - - - end - - - - - diff --git a/docs/mkdocs/docs/images/range-rbegin-rend.svg b/docs/mkdocs/docs/images/range-rbegin-rend.svg deleted file mode 100644 index dc6045fcf3..0000000000 --- a/docs/mkdocs/docs/images/range-rbegin-rend.svg +++ /dev/null @@ -1,1232 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - Past-the-last element - - - - begin - - - - end - - - - - - - - - - - - - - - - - - - - - - - - - Reversed sequence - - Reverse past-the-last element - - - - - - - - rend - - - - rbegin - - - Reverse iterator stores an iterator to the nextelement than the one it actually refers to - - - - - - - - - diff --git a/docs/mkdocs/docs/index.md b/docs/mkdocs/docs/index.md deleted file mode 100644 index 0e49c836c7..0000000000 --- a/docs/mkdocs/docs/index.md +++ /dev/null @@ -1,3 +0,0 @@ -# JSON for Modern C++ - -![](images/json.gif) diff --git a/docs/mkdocs/docs/integration/cmake.md b/docs/mkdocs/docs/integration/cmake.md deleted file mode 100644 index c8f9883ea5..0000000000 --- a/docs/mkdocs/docs/integration/cmake.md +++ /dev/null @@ -1,172 +0,0 @@ -# CMake - -## Integration - -You can use the `nlohmann_json::nlohmann_json` interface target in CMake. This target populates the appropriate usage -requirements for [`INTERFACE_INCLUDE_DIRECTORIES`](https://cmake.org/cmake/help/latest/prop_tgt/INTERFACE_INCLUDE_DIRECTORIES.html) -to point to the appropriate include directories and [`INTERFACE_COMPILE_FEATURES`](https://cmake.org/cmake/help/latest/prop_tgt/INTERFACE_COMPILE_FEATURES.html) -for the necessary C++11 flags. - -### External - -To use this library from a CMake project, you can locate it directly with [`find_package()`](https://cmake.org/cmake/help/latest/command/find_package.html) -and use the namespaced imported target from the generated package configuration: - -!!! example - - ```cmake title="CMakeLists.txt" - cmake_minimum_required(VERSION 3.1) - project(ExampleProject LANGUAGES CXX) - - find_package(nlohmann_json 3.11.2 REQUIRED) - - add_executable(example example.cpp) - target_link_libraries(example PRIVATE nlohmann_json::nlohmann_json) - ``` - -The package configuration file, `nlohmann_jsonConfig.cmake`, can be used either from an install tree or directly out of -the build tree. - -### Embedded - -To embed the library directly into an existing CMake project, place the entire source tree in a subdirectory and call -`add_subdirectory()` in your `CMakeLists.txt` file. - -!!! example - - ```cmake title="CMakeLists.txt" - cmake_minimum_required(VERSION 3.1) - project(ExampleProject LANGUAGES CXX) - - # If you only include this third party in PRIVATE source files, you do not need to install it - # when your main project gets installed. - set(JSON_Install OFF CACHE INTERNAL "") - - add_subdirectory(nlohmann_json) - - add_executable(example example.cpp) - target_link_libraries(example PRIVATE nlohmann_json::nlohmann_json) - ``` - -!!! note - - Do not use `#!cmake include(nlohmann_json/CMakeLists.txt)`, since that carries with it unintended consequences that - will break the build. It is generally discouraged (although not necessarily well documented as such) to use - `#!cmake include(...)` for pulling in other CMake projects anyways. - - -### Supporting Both - -To allow your project to support either an externally supplied or an embedded JSON library, you can use a pattern akin -to the following. - -!!! example - - ```cmake title="CMakeLists.txt" - project(ExampleProject LANGUAGES CXX) - - option(EXAMPLE_USE_EXTERNAL_JSON "Use an external JSON library" OFF) - - add_subdirectory(thirdparty) - - add_executable(example example.cpp) - - # Note that the namespaced target will always be available regardless of the import method - target_link_libraries(example PRIVATE nlohmann_json::nlohmann_json) - ``` - - ```cmake title="thirdparty/CMakeLists.txt" - if(EXAMPLE_USE_EXTERNAL_JSON) - find_package(nlohmann_json 3.11.2 REQUIRED) - else() - set(JSON_BuildTests OFF CACHE INTERNAL "") - add_subdirectory(nlohmann_json) - endif() - ``` - - `thirdparty/nlohmann_json` is then a complete copy of this source tree. - - -### FetchContent - -Since CMake v3.11, [FetchContent](https://cmake.org/cmake/help/v3.11/module/FetchContent.html) can be used to -automatically download a release as a dependency at configure type. - -!!! example - - ```cmake title="CMakeLists.txt" - cmake_minimum_required(VERSION 3.11) - project(ExampleProject LANGUAGES CXX) - - include(FetchContent) - - FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz) - FetchContent_MakeAvailable(json) - - add_executable(example example.cpp) - target_link_libraries(example PRIVATE nlohmann_json::nlohmann_json) - ``` - -!!! Note - - It is recommended to use the URL approach described above which is supported as of version 3.10.0. It is also - possible to pass the Git repository like - - ```cmake - FetchContent_Declare(json - GIT_REPOSITORY https://github.com/nlohmann/json - GIT_TAG v3.11.2 - ) - ``` - - However, the repository download size is quite large. You might want to depend on - a smaller repository. For instance, you might want to replace the URL in the example by - . - -## CMake Options - -### `JSON_BuildTests` - -Build the unit tests when [`BUILD_TESTING`](https://cmake.org/cmake/help/latest/command/enable_testing.html) is enabled. This option is `ON` by default if the library's CMake project is the top project. That is, when integrating the library as described above, the test suite is not built unless explicitly switched on with this option. - -### `JSON_CI` - -Enable CI build targets. The exact targets are used during the several CI steps and are subject to change without notice. This option is `OFF` by default. - -### `JSON_Diagnostics` - -Enable [extended diagnostic messages](../home/exceptions.md#extended-diagnostic-messages) by defining macro [`JSON_DIAGNOSTICS`](../api/macros/json_diagnostics.md). This option is `OFF` by default. - -### `JSON_DisableEnumSerialization` - -Disable default `enum` serialization by defining the macro -[`JSON_DISABLE_ENUM_SERIALIZATION`](../api/macros/json_disable_enum_serialization.md). This option is `OFF` by default. - -### `JSON_FastTests` - -Skip expensive/slow test suites. This option is `OFF` by default. Depends on `JSON_BuildTests`. - -### `JSON_GlobalUDLs` - -Place user-defined string literals in the global namespace by defining the macro -[`JSON_USE_GLOBAL_UDLS`](../api/macros/json_use_global_udls.md). This option is `OFF` by default. - -### `JSON_ImplicitConversions` - -Enable implicit conversions by defining macro [`JSON_USE_IMPLICIT_CONVERSIONS`](../api/macros/json_use_implicit_conversions.md). This option is `ON` by default. - -### `JSON_Install` - -Install CMake targets during install step. This option is `ON` by default if the library's CMake project is the top project. - -### `JSON_MultipleHeaders` - -Use non-amalgamated version of the library. This option is `OFF` by default. - -### `JSON_SystemInclude` - -Treat the library headers like system headers (i.e., adding `SYSTEM` to the [`target_include_directories`](https://cmake.org/cmake/help/latest/command/target_include_directories.html) call) to checks for this library by tools like Clang-Tidy. This option is `OFF` by default. - -### `JSON_Valgrind` - -Execute test suite with [Valgrind](https://valgrind.org). This option is `OFF` by default. Depends on `JSON_BuildTests`. diff --git a/docs/mkdocs/docs/integration/conan/CMakeLists.txt b/docs/mkdocs/docs/integration/conan/CMakeLists.txt deleted file mode 100644 index fd3e9ca716..0000000000 --- a/docs/mkdocs/docs/integration/conan/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -project(json_example) -cmake_minimum_required(VERSION 2.8.12) -add_definitions("-std=c++11") - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -add_executable(json_example example.cpp) -target_link_libraries(json_example ${CONAN_LIBS}) diff --git a/docs/mkdocs/docs/integration/conan/Conanfile.txt b/docs/mkdocs/docs/integration/conan/Conanfile.txt deleted file mode 100644 index a8a3e70378..0000000000 --- a/docs/mkdocs/docs/integration/conan/Conanfile.txt +++ /dev/null @@ -1,5 +0,0 @@ -[requires] -nlohmann_json/3.7.3 - -[generators] -cmake diff --git a/docs/mkdocs/docs/integration/conan/example.cpp b/docs/mkdocs/docs/integration/conan/example.cpp deleted file mode 100644 index e5a31be4bd..0000000000 --- a/docs/mkdocs/docs/integration/conan/example.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - std::cout << json::meta() << std::endl; -} diff --git a/docs/mkdocs/docs/integration/example.cpp b/docs/mkdocs/docs/integration/example.cpp deleted file mode 100644 index 1a7ac4de2e..0000000000 --- a/docs/mkdocs/docs/integration/example.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include -#include - -using json = nlohmann::json; - -int main() -{ - std::cout << std::setw(4) << json::meta() << std::endl; -} diff --git a/docs/mkdocs/docs/integration/index.md b/docs/mkdocs/docs/integration/index.md deleted file mode 100644 index 2bbaa86041..0000000000 --- a/docs/mkdocs/docs/integration/index.md +++ /dev/null @@ -1,18 +0,0 @@ -# Header only - -[`json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp) is the single required -file in `single_include/nlohmann` or [released here](https://github.com/nlohmann/json/releases). You need to add - -```cpp -#include - -// for convenience -using json = nlohmann::json; -``` - -to the files you want to process JSON and set the necessary switches to enable C++11 (e.g., `-std=c++11` for GCC and -Clang). - -You can further use file -[`single_include/nlohmann/json_fwd.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json_fwd.hpp) -for forward declarations. diff --git a/docs/mkdocs/docs/integration/migration_guide.md b/docs/mkdocs/docs/integration/migration_guide.md deleted file mode 100644 index d250f5b20b..0000000000 --- a/docs/mkdocs/docs/integration/migration_guide.md +++ /dev/null @@ -1,264 +0,0 @@ -# Migration Guide - -This page collects some guidelines on how to future-proof your code for future versions of this library. - -## Replace deprecated functions - -The following functions have been deprecated and will be removed in the next major version (i.e., 4.0.0). All -deprecations are annotated with -[`HEDLEY_DEPRECATED_FOR`](https://nemequ.github.io/hedley/api-reference.html#HEDLEY_DEPRECATED_FOR) to report which -function to use instead. - -#### Parsing - -- Function `friend std::istream& operator<<(basic_json&, std::istream&)` is deprecated since 3.0.0. Please use - [`friend std::istream& operator>>(std::istream&, basic_json&)`](../api/operator_gtgt.md) instead. - - === "Deprecated" - - ```cpp - nlohmann::json j; - std::stringstream ss("[1,2,3]"); - j << ss; - ``` - - === "Future-proof" - - ```cpp - nlohmann::json j; - std::stringstream ss("[1,2,3]"); - ss >> j; - ``` - -- Passing iterator pairs or pointer/length pairs to parsing functions ([`parse`](../api/basic_json/parse.md), - [`accept`](../api/basic_json/accept.md), [`sax_parse`](../api/basic_json/sax_parse.md), - [`from_cbor`](../api/basic_json/from_cbor.md), [`from_msgpack`](../api/basic_json/from_msgpack.md), - [`from_ubjson`](../api/basic_json/from_ubjson.md), and [`from_bson`](../api/basic_json/from_bson.md) via initializer - lists is deprecated since 3.8.0. Instead, pass two iterators; for instance, call `from_cbor(ptr, ptr+len)` instead of - `from_cbor({ptr, len})`. - - === "Deprecated" - - ```cpp - const char* s = "[1,2,3]"; - bool ok = nlohmann::json::accept({s, s + std::strlen(s)}); - ``` - - === "Future-proof" - - ```cpp - const char* s = "[1,2,3]"; - bool ok = nlohmann::json::accept(s, s + std::strlen(s)); - ``` - -#### JSON Pointers - -- Comparing JSON Pointers with strings via [`operator==`](../api/json_pointer/operator_eq.md) and - [`operator!=`](../api/json_pointer/operator_ne.md) is deprecated since 3.11.2. To compare a - [`json_pointer`](../api/json_pointer/index.md) `p` with a string `s`, convert `s` to a `json_pointer` first and use - [`json_pointer::operator==`](../api/json_pointer/operator_eq.md) or - [`json_pointer::operator!=`](../api/json_pointer/operator_ne.md). - - === "Deprecated" - - ```cpp - nlohmann::json::json_pointer lhs("/foo/bar/1"); - assert(lhs == "/foo/bar/1"); - ``` - - === "Future-proof" - - ```cpp - nlohmann::json::json_pointer lhs("/foo/bar/1"); - assert(lhs == nlohmann::json::json_pointer("/foo/bar/1")); - ``` - -- The implicit conversion from JSON Pointers to string - ([`json_pointer::operator string_t`](../api/json_pointer/operator_string_t.md)) is deprecated since 3.11.0. Use - [`json_pointer::to_string`](../api/json_pointer/to_string.md) instead. - - === "Deprecated" - - ```cpp - nlohmann::json::json_pointer ptr("/foo/bar/1"); - std::string s = ptr; - ``` - - === "Future-proof" - - ```cpp - nlohmann::json::json_pointer ptr("/foo/bar/1"); - std::string s = ptr.to_string(); - ``` - -- Passing a `basic_json` specialization as template parameter `RefStringType` to - [`json_pointer`](../api/json_pointer/index.md) is deprecated since 3.11.0. The string type can now be directly - provided. - - === "Deprecated" - - ```cpp - using my_json = nlohmann::basic_json; - nlohmann::json_pointer ptr("/foo/bar/1"); - ``` - - === "Future-proof" - - ```cpp - nlohmann::json_pointer ptr("/foo/bar/1"); - ``` - - Thereby, `nlohmann::my_json::json_pointer` is an alias for `nlohmann::json_pointer` and is always an - alias to the `json_pointer` with the appropriate string type for all specializations of `basic_json`. - -#### Miscellaneous functions - -- The function `iterator_wrapper` is deprecated since 3.1.0. Please use the member function - [`items`](../api/basic_json/items.md) instead. - - === "Deprecated" - - ```cpp - for (auto &x : nlohmann::json::iterator_wrapper(j)) - { - std::cout << x.key() << ":" << x.value() << std::endl; - } - ``` - - === "Future-proof" - - ```cpp - for (auto &x : j.items()) - { - std::cout << x.key() << ":" << x.value() << std::endl; - } - ``` - -- Function `friend std::ostream& operator>>(const basic_json&, std::ostream&)` is deprecated since 3.0.0. Please use - [`friend operator<<(std::ostream&, const basic_json&)`](../api/operator_ltlt.md) instead. - - === "Deprecated" - - ```cpp - j >> std::cout; - ``` - - === "Future-proof" - - ```cpp - std::cout << j; - ``` - -- The legacy comparison behavior for discarded values is deprecated since 3.11.0. It is already disabled by default and - can still be enabled by defining - [`JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON`](../api/macros/json_use_legacy_discarded_value_comparison.md) to `1`. - - === "Deprecated" - - ```cpp - #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 1 - #include - ``` - - === "Future-proof" - - ```cpp - #include - ``` - -## Replace implicit conversions - -Implicit conversions via [`operator ValueType`](../api/basic_json/operator_ValueType.md) will be switched off by default -in the next major release of the library. - -You can prepare existing code by already defining -[`JSON_USE_IMPLICIT_CONVERSIONS`](../api/macros/json_use_implicit_conversions.md) to `0` and replace any implicit -conversions with calls to [`get`](../api/basic_json/get.md), [`get_to`](../api/basic_json/get_to.md), -[`get_ref`](../api/basic_json/get_ref.md), or [`get_ptr`](../api/basic_json/get_ptr.md). - -=== "Deprecated" - - ```cpp - nlohmann::json j = "Hello, world!"; - std::string s = j; - ``` - -=== "Future-proof" - - ```cpp - nlohmann::json j = "Hello, world!"; - auto s = j.template get(); - ``` - -=== "Future-proof (alternative)" - - ```cpp - nlohmann::json j = "Hello, world!"; - std::string s; - j.get_to(s); - ``` - -You can prepare existing code by already defining -[`JSON_USE_IMPLICIT_CONVERSIONS`](../api/macros/json_use_implicit_conversions.md) to `0` and replace any implicit -conversions with calls to [`get`](../api/basic_json/get.md). - -## Import namespace `literals` for UDLs - -The user-defined string literals [`operator""_json`](../api/operator_literal_json.md) and -[`operator""_json_pointer`](../api/operator_literal_json_pointer.md) will be removed from the global namespace in the -next major release of the library. - -=== "Deprecated" - - ```cpp - nlohmann::json j = "[1,2,3]"_json; - ``` - -=== "Future-proof" - - ```cpp - using namespace nlohmann::literals; - nlohmann::json j = "[1,2,3]"_json; - ``` - -To prepare existing code, define [`JSON_USE_GLOBAL_UDLS`](../api/macros/json_use_global_udls.md) to `0` and bring the -string literals into scope where needed. - -## Do not hard-code the complete library namespace - -The [`nlohmann` namespace](../features/namespace.md) contains a sub-namespace to avoid problems when different -versions or configurations of the library are used in the same project. Always use `nlohmann` as namespace or, when the -exact version and configuration is relevant, use macro -[`NLOHMANN_JSON_NAMESPACE`](../api/macros/nlohmann_json_namespace.md) to denote the namespace. - -=== "Dangerous" - - ```cpp - void to_json(nlohmann::json_abi_v3_11_2::json& j, const person& p) - { - j["age"] = p.age; - } - ``` - -=== "Future-proof" - - ```cpp - void to_json(nlohmann::json& j, const person& p) - { - j["age"] = p.age; - } - ``` - -=== "Future-proof (alternative)" - - ```cpp - void to_json(NLOHMANN_JSON_NAMESPACE::json& j, const person& p) - { - j["age"] = p.age; - } - ``` - -## Do not use the `details` namespace - -The `details` namespace is not part of the public API of the library and can change in any version without announcement. -Do not rely on any function or type in the `details` namespace. diff --git a/docs/mkdocs/docs/integration/package_managers.md b/docs/mkdocs/docs/integration/package_managers.md deleted file mode 100644 index 46d7a8549a..0000000000 --- a/docs/mkdocs/docs/integration/package_managers.md +++ /dev/null @@ -1,198 +0,0 @@ -# Package Managers - -Throughout this page, we will describe how to compile the example file `example.cpp` below. - -```cpp ---8<-- "integration/example.cpp" -``` - -When executed, this program should create output similar to - -```json ---8<-- "../../examples/meta.output" -``` - -## Homebrew - -If you are using OS X and [Homebrew](http://brew.sh), just type - -```sh -brew install nlohmann-json -``` - -and you're set. If you want the bleeding edge rather than the latest release, use - -```sh -brew install nlohmann-json --HEAD -``` - -instead. See [nlohmann-json](https://formulae.brew.sh/formula/nlohmann-json) for more information. - -??? example - - 1. Create the following file: - - ```cpp title="example.cpp" - --8<-- "integration/example.cpp" - ``` - - 2. Install the package - - ```sh - brew install nlohmann-json - ``` - - 3. Determine the include path, which defaults to `/usr/local/Cellar/nlohmann-json/$version/include`, where `$version` is the version of the library, e.g. `3.7.3`. The path of the library can be determined with - - ```sh - brew list nlohmann-json - ``` - - 4. Compile the code. For instance, the code can be compiled using Clang with - - ```sh - clang++ example.cpp -I/usr/local/Cellar/nlohmann-json/3.7.3/include -std=c++11 -o example - ``` - -:material-update: The [formula](https://formulae.brew.sh/formula/nlohmann-json) is updated automatically. - -## Meson - -If you are using the [Meson Build System](http://mesonbuild.com), add this source tree as a [meson subproject](https://mesonbuild.com/Subprojects.html#using-a-subproject). You may also use the `include.zip` published in this project's [Releases](https://github.com/nlohmann/json/releases) to reduce the size of the vendored source tree. Alternatively, you can get a wrap file by downloading it from [Meson WrapDB](https://wrapdb.mesonbuild.com/nlohmann_json), or simply use `meson wrap install nlohmann_json`. Please see the meson project for any issues regarding the packaging. - -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. - -## Bazel - -This repository provides a [Bazel](https://bazel.build/) `WORKSPACE.bazel` and a corresponding `BUILD.bazel` file. Therefore, this repository can be referenced by workspace rules such as `http_archive`, `git_repository`, or `local_repository` from other Bazel workspaces. To use the library you only need to depend on the target `@nlohmann_json//:json` (e.g. via `deps` attribute). - -## Conan - -If you are using [Conan](https://www.conan.io/) to manage your dependencies, merely add `nlohmann_json/x.y.z` to your `conanfile`'s requires, where `x.y.z` is the release version you want to use. Please file issues [here](https://github.com/conan-io/conan-center-index/issues) if you experience problems with the packages. - -??? example - - 1. Create the following files: - - ```ini title="Conanfile.txt" - --8<-- "integration/conan/Conanfile.txt" - ``` - - ```cmake title="CMakeLists.txt" - --8<-- "integration/conan/CMakeLists.txt" - ``` - - ```cpp title="example.cpp" - --8<-- "integration/conan/example.cpp" - ``` - - 2. Build: - - ```sh - mkdir build - cd build - conan install .. - cmake .. - cmake --build . - ``` - -:material-update: The [package](https://conan.io/center/nlohmann_json) is updated automatically. - -## Spack - -If you are using [Spack](https://www.spack.io/) to manage your dependencies, you can use the [`nlohmann-json` package](https://spack.readthedocs.io/en/latest/package_list.html#nlohmann-json). Please see the [spack project](https://github.com/spack/spack) for any issues regarding the packaging. - -## Hunter - -If you are using [hunter](https://github.com/cpp-pm/hunter) on your project for external dependencies, then you can use the [nlohmann_json package](https://hunter.readthedocs.io/en/latest/packages/pkg/nlohmann_json.html). Please see the hunter project for any issues regarding the packaging. - -## Buckaroo - -If you are using [Buckaroo](https://buckaroo.pm), you can install this library's module with `buckaroo add github.com/buckaroo-pm/nlohmann-json`. Please file issues [here](https://github.com/buckaroo-pm/nlohmann-json). There is a demo repo [here](https://github.com/njlr/buckaroo-nholmann-json-example). - -## vcpkg - -If you are using [vcpkg](https://github.com/Microsoft/vcpkg/) on your project for external dependencies, then you can install the [nlohmann-json package](https://github.com/Microsoft/vcpkg/tree/master/ports/nlohmann-json) with `vcpkg install nlohmann-json` and follow the then displayed descriptions. Please see the vcpkg project for any issues regarding the packaging. - -??? example - - 1. Create the following files: - - ```cmake title="CMakeLists.txt" - --8<-- "integration/vcpkg/CMakeLists.txt" - ``` - - ```cpp title="example.cpp" - --8<-- "integration/vcpkg/example.cpp" - ``` - - 2. Install package: - - ```sh - vcpkg install nlohmann-json - ``` - - 3. Build: - - ```sh - mkdir build - cd build - cmake .. -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake - cmake --build . - ``` - - Note you need to adjust `/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake` to your system. - -## cget - -If you are using [cget](http://cget.readthedocs.io/en/latest/), you can install the latest development version with `cget install nlohmann/json`. A specific version can be installed with `cget install nlohmann/json@v3.1.0`. Also, the multiple header version can be installed by adding the `-DJSON_MultipleHeaders=ON` flag (i.e., `cget install nlohmann/json -DJSON_MultipleHeaders=ON`). - -:material-update: cget reads directly from the [GitHub repository](https://github.com/nlohmann/json) and is always up-to-date. - -## CocoaPods - -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). - -## NuGet - -If you are using [NuGet](https://www.nuget.org), you can use the package [nlohmann.json](https://www.nuget.org/packages/nlohmann.json/). Please check [this extensive description](https://github.com/nlohmann/json/issues/1132#issuecomment-452250255) on how to use the package. Please file issues [here](https://github.com/hnkb/nlohmann-json-nuget/issues). - -## Conda - -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). - -## MSYS2 - -If you are using [MSYS2](http://www.msys2.org/), you can use the [mingw-w64-nlohmann-json](https://packages.msys2.org/base/mingw-w64-nlohmann-json) package, just type `pacman -S mingw-w64-i686-nlohmann-json` or `pacman -S mingw-w64-x86_64-nlohmann-json` for installation. Please file issues [here](https://github.com/msys2/MINGW-packages/issues/new?title=%5Bnlohmann-json%5D) if you experience problems with the packages. - -:material-update: The [package](https://packages.msys2.org/base/mingw-w64-nlohmann-json) is updated automatically. - -## MacPorts - -If you are using [MacPorts](https://ports.macports.org), execute `sudo port install nlohmann-json` to install the [nlohmann-json](https://ports.macports.org/port/nlohmann-json/) package. - -:material-update: The [package](https://ports.macports.org/port/nlohmann-json/) is updated automatically. - -## build2 - -If you are using [`build2`](https://build2.org), you can use the [`nlohmann-json`](https://cppget.org/nlohmann-json) package from the public repository or directly from the [package's sources repository](https://github.com/build2-packaging/nlohmann-json). In your project's `manifest` file, just add `depends: nlohmann-json` (probably with some [version constraints](https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml#guide-add-remove-deps)). If you are not familiar with using dependencies in `build2`, [please read this introduction](https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml). -Please file issues [here](https://github.com/build2-packaging/nlohmann-json) if you experience problems with the packages. - -:material-update: The [package](https://cppget.org/nlohmann-json) is updated automatically. - -## wsjcpp - -If you are using [`wsjcpp`](http://wsjcpp.org), you can use the command `wsjcpp install "https://github.com/nlohmann/json:develop"` to get the latest version. Note you can change the branch ":develop" to an existing tag or another branch. - -:material-update: wsjcpp reads directly from the [GitHub repository](https://github.com/nlohmann/json) and is always up-to-date. - -## CPM.cmake - -If you are using [`CPM.cmake`](https://github.com/TheLartians/CPM.cmake), you can check this [`example`](https://github.com/TheLartians/CPM.cmake/tree/master/examples/json). After [adding CPM script](https://github.com/TheLartians/CPM.cmake#adding-cpm) to your project, implement the following snippet to your CMake: - -```cmake -CPMAddPackage( - NAME nlohmann_json - GITHUB_REPOSITORY nlohmann/json - VERSION 3.9.1) -``` diff --git a/docs/mkdocs/docs/integration/pkg-config.md b/docs/mkdocs/docs/integration/pkg-config.md deleted file mode 100644 index 429d0dea9a..0000000000 --- a/docs/mkdocs/docs/integration/pkg-config.md +++ /dev/null @@ -1,13 +0,0 @@ -# Pkg-config - -If you are using bare Makefiles, you can use `pkg-config` to generate the include flags that point to where the library is installed: - -```sh -pkg-config nlohmann_json --cflags -``` - -Users of the [Meson build system](package_managers.md#meson) will also be able to use a system-wide library, which will be found by `pkg-config`: - -```meson -json = dependency('nlohmann_json', required: true) -``` diff --git a/docs/mkdocs/docs/integration/vcpkg/CMakeLists.txt b/docs/mkdocs/docs/integration/vcpkg/CMakeLists.txt deleted file mode 100644 index d31f4e8359..0000000000 --- a/docs/mkdocs/docs/integration/vcpkg/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -project(json_example) -cmake_minimum_required(VERSION 2.8.12) - -find_package(nlohmann_json CONFIG REQUIRED) - -add_executable(json_example example.cpp) -target_link_libraries(json_example PRIVATE nlohmann_json::nlohmann_json) diff --git a/docs/mkdocs/docs/integration/vcpkg/example.cpp b/docs/mkdocs/docs/integration/vcpkg/example.cpp deleted file mode 100644 index e5a31be4bd..0000000000 --- a/docs/mkdocs/docs/integration/vcpkg/example.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -using json = nlohmann::json; - -int main() -{ - std::cout << json::meta() << std::endl; -} diff --git a/docs/mkdocs/mkdocs.yml b/docs/mkdocs/mkdocs.yml deleted file mode 100644 index 8319354a4b..0000000000 --- a/docs/mkdocs/mkdocs.yml +++ /dev/null @@ -1,365 +0,0 @@ -# Project information -site_name: JSON for Modern C++ -site_author: Niels Lohmann -site_url: https://json.nlohmann.me/ - -# Repository -repo_name: nlohmann/json -repo_url: https://github.com/nlohmann/json -edit_uri: edit/develop/docs/mkdocs/docs - -# Copyright -copyright: Copyright © 2013 - 2022 Niels Lohmann - -# Configuration -theme: - name: material - language: en - palette: - - media: '(prefers-color-scheme: light)' - scheme: default - primary: indigo - accent: indigo - toggle: - icon: material/brightness-7 - name: Switch to dark mode - - media: '(prefers-color-scheme: dark)' - scheme: slate - primary: indigo - accent: indigo - toggle: - icon: material/brightness-4 - name: Switch to light mode - - font: - text: Roboto - code: JetBrains Mono - features: - - navigation.instant - - navigation.tracking - - navigation.tabs - - navigation.indexes - - navigation.top - - content.tabs.link - -nav: - - Home: - - index.md - - home/license.md - - "Code of Conduct": home/code_of_conduct.md - - "FAQ": home/faq.md - - home/exceptions.md - - home/releases.md - - home/design_goals.md - - home/sponsors.md - - Features: - - features/arbitrary_types.md - - Binary Formats: - - features/binary_formats/index.md - - features/binary_formats/bjdata.md - - features/binary_formats/bson.md - - features/binary_formats/cbor.md - - features/binary_formats/messagepack.md - - features/binary_formats/ubjson.md - - features/binary_values.md - - features/comments.md - - Element Access: - - features/element_access/index.md - - features/element_access/unchecked_access.md - - features/element_access/checked_access.md - - features/element_access/default_value.md - - features/iterators.md - - features/json_pointer.md - - features/json_patch.md - - features/merge_patch.md - - 'nlohmann Namespace': features/namespace.md - - features/object_order.md - - Parsing: - - features/parsing/index.md - - features/parsing/json_lines.md - - features/parsing/parse_exceptions.md - - features/parsing/parser_callbacks.md - - features/parsing/sax_interface.md - - features/assertions.md - - features/enum_conversion.md - - features/macros.md - - Types: - - features/types/index.md - - features/types/number_handling.md - - Integration: - - integration/index.md - - integration/migration_guide.md - - integration/cmake.md - - integration/package_managers.md - - integration/pkg-config.md - - API Documentation: - - basic_json: - - 'Overview': api/basic_json/index.md - - '(Constructor)': api/basic_json/basic_json.md - - '(Destructor)': api/basic_json/~basic_json.md - - 'accept': api/basic_json/accept.md - - 'array': api/basic_json/array.md - - 'array_t': api/basic_json/array_t.md - - 'at': api/basic_json/at.md - - 'back': api/basic_json/back.md - - 'begin': api/basic_json/begin.md - - 'binary': api/basic_json/binary.md - - 'binary_t': api/basic_json/binary_t.md - - 'boolean_t': api/basic_json/boolean_t.md - - 'cbegin': api/basic_json/cbegin.md - - 'cbor_tag_handler_t': api/basic_json/cbor_tag_handler_t.md - - 'cend': api/basic_json/cend.md - - 'clear': api/basic_json/clear.md - - 'contains': api/basic_json/contains.md - - 'count': api/basic_json/count.md - - 'crbegin': api/basic_json/crbegin.md - - 'crend': api/basic_json/crend.md - - 'default_object_comparator_t': api/basic_json/default_object_comparator_t.md - - 'diff': api/basic_json/diff.md - - 'dump': api/basic_json/dump.md - - 'emplace': api/basic_json/emplace.md - - 'emplace_back': api/basic_json/emplace_back.md - - 'empty': api/basic_json/empty.md - - 'end': api/basic_json/end.md - - 'erase': api/basic_json/erase.md - - 'error_handler_t': api/basic_json/error_handler_t.md - - 'exception': api/basic_json/exception.md - - 'find': api/basic_json/find.md - - 'flatten': api/basic_json/flatten.md - - 'from_bjdata': api/basic_json/from_bjdata.md - - 'from_bson': api/basic_json/from_bson.md - - 'from_cbor': api/basic_json/from_cbor.md - - 'from_msgpack': api/basic_json/from_msgpack.md - - 'from_ubjson': api/basic_json/from_ubjson.md - - 'front': api/basic_json/front.md - - 'get': api/basic_json/get.md - - 'get_allocator': api/basic_json/get_allocator.md - - 'get_binary': api/basic_json/get_binary.md - - 'get_ptr': api/basic_json/get_ptr.md - - 'get_ref': api/basic_json/get_ref.md - - 'get_to': api/basic_json/get_to.md - - 'std::hash<basic_json>': api/basic_json/std_hash.md - - 'input_format_t': api/basic_json/input_format_t.md - - 'insert': api/basic_json/insert.md - - 'invalid_iterator': api/basic_json/invalid_iterator.md - - 'is_array': api/basic_json/is_array.md - - 'is_binary': api/basic_json/is_binary.md - - 'is_boolean': api/basic_json/is_boolean.md - - 'is_discarded': api/basic_json/is_discarded.md - - 'is_null': api/basic_json/is_null.md - - 'is_number': api/basic_json/is_number.md - - 'is_number_float': api/basic_json/is_number_float.md - - 'is_number_integer': api/basic_json/is_number_integer.md - - 'is_number_unsigned': api/basic_json/is_number_unsigned.md - - 'is_object': api/basic_json/is_object.md - - 'is_primitive': api/basic_json/is_primitive.md - - 'is_string': api/basic_json/is_string.md - - 'is_structured': api/basic_json/is_structured.md - - 'items': api/basic_json/items.md - - 'json_base_class_t': api/basic_json/json_base_class_t.md - - 'json_serializer': api/basic_json/json_serializer.md - - 'max_size': api/basic_json/max_size.md - - 'meta': api/basic_json/meta.md - - 'merge_patch': api/basic_json/merge_patch.md - - 'number_float_t': api/basic_json/number_float_t.md - - 'number_integer_t': api/basic_json/number_integer_t.md - - 'number_unsigned_t': api/basic_json/number_unsigned_t.md - - 'object': api/basic_json/object.md - - 'object_comparator_t': api/basic_json/object_comparator_t.md - - 'object_t': api/basic_json/object_t.md - - 'operator ValueType': api/basic_json/operator_ValueType.md - - 'operator value_t': api/basic_json/operator_value_t.md - - 'operator[]': api/basic_json/operator[].md - - 'operator=': api/basic_json/operator=.md - - 'operator+=': api/basic_json/operator+=.md - - 'operator==': api/basic_json/operator_eq.md - - 'operator!=': api/basic_json/operator_ne.md - - 'operator<': api/basic_json/operator_lt.md - - 'operator>': api/basic_json/operator_gt.md - - 'operator<=': api/basic_json/operator_le.md - - 'operator>=': api/basic_json/operator_ge.md - - 'operator<=>': api/basic_json/operator_spaceship.md - - 'out_of_range': api/basic_json/out_of_range.md - - 'other_error': api/basic_json/other_error.md - - 'parse': api/basic_json/parse.md - - 'parse_error': api/basic_json/parse_error.md - - 'parse_event_t': api/basic_json/parse_event_t.md - - 'parser_callback_t': api/basic_json/parser_callback_t.md - - 'patch': api/basic_json/patch.md - - 'patch_inplace': api/basic_json/patch_inplace.md - - 'push_back': api/basic_json/push_back.md - - 'rbegin': api/basic_json/rbegin.md - - 'rend': api/basic_json/rend.md - - 'sax_parse': api/basic_json/sax_parse.md - - 'size': api/basic_json/size.md - - 'string_t': api/basic_json/string_t.md - - 'swap': api/basic_json/swap.md - - 'std::swap<basic_json>': api/basic_json/std_swap.md - - 'to_bjdata': api/basic_json/to_bjdata.md - - 'to_bson': api/basic_json/to_bson.md - - 'to_cbor': api/basic_json/to_cbor.md - - 'to_msgpack': api/basic_json/to_msgpack.md - - 'to_string': api/basic_json/to_string.md - - 'to_ubjson': api/basic_json/to_ubjson.md - - 'type': api/basic_json/type.md - - 'type_error': api/basic_json/type_error.md - - 'type_name': api/basic_json/type_name.md - - 'unflatten': api/basic_json/unflatten.md - - 'update': api/basic_json/update.md - - 'value': api/basic_json/value.md - - 'value_t': api/basic_json/value_t.md - - byte_container_with_subtype: - - 'Overview': api/byte_container_with_subtype/index.md - - '(constructor)': api/byte_container_with_subtype/byte_container_with_subtype.md - - 'clear_subtype': api/byte_container_with_subtype/clear_subtype.md - - 'has_subtype': api/byte_container_with_subtype/has_subtype.md - - 'set_subtype': api/byte_container_with_subtype/set_subtype.md - - 'subtype': api/byte_container_with_subtype/subtype.md - - adl_serializer: - - 'Overview': api/adl_serializer/index.md - - 'from_json': api/adl_serializer/from_json.md - - 'to_json': api/adl_serializer/to_json.md - - 'json': api/json.md - - json_pointer: - - 'Overview': api/json_pointer/index.md - - '(Constructor)': api/json_pointer/json_pointer.md - - 'back': api/json_pointer/back.md - - 'empty': api/json_pointer/empty.md - - 'operator string_t': api/json_pointer/operator_string_t.md - - 'operator==': api/json_pointer/operator_eq.md - - 'operator!=': api/json_pointer/operator_ne.md - - 'operator/': api/json_pointer/operator_slash.md - - 'operator/=': api/json_pointer/operator_slasheq.md - - 'parent_pointer': api/json_pointer/parent_pointer.md - - 'pop_back': api/json_pointer/pop_back.md - - 'push_back': api/json_pointer/push_back.md - - 'string_t': api/json_pointer/string_t.md - - 'to_string': api/json_pointer/to_string.md - - json_sax: - - 'Overview': api/json_sax/index.md - - 'binary': api/json_sax/binary.md - - 'boolean': api/json_sax/boolean.md - - 'end_array': api/json_sax/end_array.md - - 'end_object': api/json_sax/end_object.md - - 'key': api/json_sax/key.md - - 'null': api/json_sax/null.md - - 'number_float': api/json_sax/number_float.md - - 'number_integer': api/json_sax/number_integer.md - - 'number_unsigned': api/json_sax/number_unsigned.md - - 'parse_error': api/json_sax/parse_error.md - - 'start_array': api/json_sax/start_array.md - - 'start_object': api/json_sax/start_object.md - - 'string': api/json_sax/string.md - - 'operator<<(basic_json)': api/operator_ltlt.md - - 'operator<<(json_pointer)': api/operator_ltlt.md - - 'operator>>(basic_json)': api/operator_gtgt.md - - 'operator""_json': api/operator_literal_json.md - - 'operator""_json_pointer': api/operator_literal_json_pointer.md - - 'ordered_json': api/ordered_json.md - - 'ordered_map': api/ordered_map.md - - macros: - - 'Overview': api/macros/index.md - - 'JSON_ASSERT': api/macros/json_assert.md - - 'JSON_CATCH_USER': api/macros/json_throw_user.md - - 'JSON_DIAGNOSTICS': api/macros/json_diagnostics.md - - 'JSON_DISABLE_ENUM_SERIALIZATION': api/macros/json_disable_enum_serialization.md - - 'JSON_HAS_CPP_11': api/macros/json_has_cpp_11.md - - 'JSON_HAS_CPP_14': api/macros/json_has_cpp_11.md - - 'JSON_HAS_CPP_17': api/macros/json_has_cpp_11.md - - 'JSON_HAS_CPP_20': api/macros/json_has_cpp_11.md - - 'JSON_HAS_EXPERIMENTAL_FILESYSTEM': api/macros/json_has_filesystem.md - - 'JSON_HAS_FILESYSTEM': api/macros/json_has_filesystem.md - - 'JSON_HAS_RANGES': api/macros/json_has_ranges.md - - 'JSON_HAS_THREE_WAY_COMPARISON': api/macros/json_has_three_way_comparison.md - - 'JSON_NOEXCEPTION': api/macros/json_noexception.md - - 'JSON_NO_IO': api/macros/json_no_io.md - - 'JSON_SKIP_LIBRARY_VERSION_CHECK': api/macros/json_skip_library_version_check.md - - 'JSON_SKIP_UNSUPPORTED_COMPILER_CHECK': api/macros/json_skip_unsupported_compiler_check.md - - 'JSON_THROW_USER': api/macros/json_throw_user.md - - 'JSON_TRY_USER': api/macros/json_throw_user.md - - 'JSON_USE_GLOBAL_UDLS': api/macros/json_use_global_udls.md - - 'JSON_USE_IMPLICIT_CONVERSIONS': api/macros/json_use_implicit_conversions.md - - 'JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON': api/macros/json_use_legacy_discarded_value_comparison.md - - 'NLOHMANN_DEFINE_TYPE_INTRUSIVE': api/macros/nlohmann_define_type_intrusive.md - - 'NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT': api/macros/nlohmann_define_type_intrusive.md - - 'NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE': api/macros/nlohmann_define_type_non_intrusive.md - - 'NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT': api/macros/nlohmann_define_type_non_intrusive.md - - 'NLOHMANN_JSON_NAMESPACE': api/macros/nlohmann_json_namespace.md - - 'NLOHMANN_JSON_NAMESPACE_BEGIN': api/macros/nlohmann_json_namespace_begin.md - - 'NLOHMANN_JSON_NAMESPACE_END': api/macros/nlohmann_json_namespace_begin.md - - 'NLOHMANN_JSON_NAMESPACE_NO_VERSION': api/macros/nlohmann_json_namespace_no_version.md - - 'NLOHMANN_JSON_SERIALIZE_ENUM': api/macros/nlohmann_json_serialize_enum.md - - 'NLOHMANN_JSON_VERSION_MAJOR': api/macros/nlohmann_json_version_major.md - - 'NLOHMANN_JSON_VERSION_MINOR': api/macros/nlohmann_json_version_major.md - - 'NLOHMANN_JSON_VERSION_PATCH': api/macros/nlohmann_json_version_major.md - -# Extras -extra: - social: - - icon: fontawesome/brands/github - link: https://github.com/nlohmann - - icon: fontawesome/brands/twitter - link: https://twitter.com/nlohmann - - icon: fontawesome/brands/linkedin - link: https://www.linkedin.com/in/nielslohmann/ - - icon: fontawesome/brands/xing - link: https://www.xing.com/profile/Niels_Lohmann - - icon: fontawesome/brands/paypal - link: https://www.paypal.me/nlohmann - generator: false - -# Extensions -markdown_extensions: - - abbr - - admonition - - attr_list - - def_list - - codehilite: - guess_lang: false - - toc: - permalink: true - - pymdownx.arithmatex - - pymdownx.betterem: - smart_enable: all - - pymdownx.caret - - pymdownx.critic - - pymdownx.details - - pymdownx.emoji: - emoji_index: !!python/name:materialx.emoji.twemoji - emoji_generator: !!python/name:materialx.emoji.to_svg - - pymdownx.inlinehilite - - pymdownx.magiclink - - pymdownx.mark - #- pymdownx.smartsymbols - - pymdownx.superfences - - pymdownx.tasklist: - custom_checkbox: true - - pymdownx.tabbed: - alternate_style: true - - pymdownx.tilde - - pymdownx.snippets: - base_path: docs - check_paths: true - - plantuml_markdown: - format: svg - -plugins: - - search: - separator: '[\s\-\.]' - lang: en - - minify: - minify_html: true - - git-revision-date-localized - - redirects: - redirect_maps: - 'api/basic_json/operator_gtgt.md': api/operator_gtgt.md - 'api/basic_json/operator_ltlt.md': api/operator_ltlt.md - 'api/basic_json/operator_literal_json.md': api/operator_literal_json.md - 'api/basic_json/operator_literal_json_pointer.md': api/operator_literal_json_pointer.md - 'api/json_pointer/operator_string.md': api/json_pointer/operator_string_t.md - -extra_css: - - css/custom.css - -extra_javascript: - - https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML diff --git a/docs/mkdocs/requirements.txt b/docs/mkdocs/requirements.txt deleted file mode 100644 index 26e9fc6839..0000000000 --- a/docs/mkdocs/requirements.txt +++ /dev/null @@ -1,49 +0,0 @@ -Babel==2.11.0 -certifi==2022.12.7 -charset-normalizer==2.1.1 -click==8.1.3 -csscompressor==0.9.5 -future==0.18.3 -ghp-import==2.1.0 -gitdb==4.0.10 -GitPython==3.1.29 -htmlmin==0.1.12 -httplib2==0.21.0 -idna==3.4 -importlib-metadata==5.1.0 -Jinja2==3.1.2 -joblib==1.2.0 -jsmin==3.0.1 -livereload==2.6.3 -lunr==0.6.2 -Markdown==3.3.7 # we cannot install a more recent version yet as mkdocs 1.4.2 depends on markdown<3.4 -markdown-include==0.8.0 -MarkupSafe==2.1.1 -mergedeep==1.3.4 -mkdocs==1.4.2 -mkdocs-git-revision-date-localized-plugin==1.1.0 -mkdocs-material==8.5.11 -mkdocs-material-extensions==1.1.1 -mkdocs-minify-plugin==0.6.2 -mkdocs-redirects==1.2.0 -mkdocs-simple-hooks==0.1.5 -nltk==3.8 -packaging==22.0 -plantuml==0.3.0 -plantuml-markdown==3.7.3 -Pygments==2.13.0 -pymdown-extensions==9.9 -pyparsing==3.0.9 -python-dateutil==2.8.2 -pytz==2022.7 -PyYAML==6.0 -pyyaml_env_tag==0.1 -regex==2022.10.31 -requests==2.28.1 -six==1.16.0 -smmap==5.0.0 -tornado==6.2 -tqdm==4.64.1 -urllib3==1.26.13 -watchdog==2.2.0 -zipp==3.11.0 diff --git a/docs/mkdocs/scripts/check_structure.py b/docs/mkdocs/scripts/check_structure.py deleted file mode 100755 index 643482af24..0000000000 --- a/docs/mkdocs/scripts/check_structure.py +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/env python - -import glob -import os.path -import re -import sys - -warnings = 0 - - -def report(rule, location, description): - global warnings - warnings += 1 - print(f'{warnings:3}. {location}: {description} [{rule}]') - - -def check_structure(): - expected_sections = [ - 'Template parameters', - 'Specializations', - 'Iterator invalidation', - 'Requirements', - 'Member types', - 'Member functions', - 'Member variables', - 'Static functions', - 'Non-member functions', - 'Literals', - 'Helper classes', - 'Parameters', - 'Return value', - 'Exception safety', - 'Exceptions', - 'Complexity', - 'Possible implementation', - 'Default definition', - 'Notes', - 'Examples', - 'See also', - 'Version history' - ] - - required_sections = [ - 'Examples', - 'Version history' - ] - - files = sorted(glob.glob('api/**/*.md', recursive=True)) - for file in files: - with open(file) as file_content: - section_idx = -1 # the index of the current h2 section - existing_sections = [] # the list of h2 sections in the file - in_initial_code_example = False # whether we are inside the first code example block - previous_line = None # the previous read line - h1sections = 0 # the number of h1 sections in the file - last_overload = 0 # the last seen overload number in the code example - documented_overloads = {} # the overloads that have been documented in the current block - current_section = None # the name of the current section - - for lineno, original_line in enumerate(file_content.readlines()): - line = original_line.strip() - - if line.startswith('# '): - h1sections += 1 - - # there should only be one top-level title - if h1sections > 1: - report('structure/unexpected_section', f'{file}:{lineno+1}', f'unexpected top-level title "{line}"') - h1sections = 1 - - # Overview pages should have a better title - if line == '# Overview': - report('style/title', f'{file}:{lineno+1}', 'overview pages should have a better title than "Overview"') - - # lines longer than 160 characters are bad (unless they are tables) - if len(line) > 160 and '|' not in line: - report('whitespace/line_length', f'{file}:{lineno+1} ({current_section})', f'line is too long ({len(line)} vs. 160 chars)') - - # sections in `` comments are treated as present - if line.startswith('') - existing_sections.append(current_section) - - # check if sections are correct - if line.startswith('## '): - # before starting a new section, check if the previous one documented all overloads - if current_section in documented_overloads and last_overload != 0: - if len(documented_overloads[current_section]) > 0 and len(documented_overloads[current_section]) != last_overload: - expected = list(range(1, last_overload+1)) - undocumented = [x for x in expected if x not in documented_overloads[current_section]] - unexpected = [x for x in documented_overloads[current_section] if x not in expected] - if len(undocumented): - report('style/numbering', f'{file}:{lineno} ({current_section})', f'undocumented overloads: {", ".join([f"({x})" for x in undocumented])}') - if len(unexpected): - report('style/numbering', f'{file}:{lineno} ({current_section})', f'unexpected overloads: {", ".join([f"({x})" for x in unexpected])}') - - current_section = line.strip('## ') - existing_sections.append(current_section) - - if current_section in expected_sections: - idx = expected_sections.index(current_section) - if idx <= section_idx: - report('structure/section_order', f'{file}:{lineno+1}', f'section "{current_section}" is in an unexpected order (should be before "{expected_sections[section_idx]}")') - section_idx = idx - else: - if 'index.md' not in file: # index.md files may have a different structure - report('structure/unknown_section', f'{file}:{lineno+1}', f'section "{current_section}" is not part of the expected sections') - - # collect the numbered items of the current section to later check if they match the number of overloads - if last_overload != 0 and not in_initial_code_example: - if len(original_line) and original_line[0].isdigit(): - number = int(re.findall(r"^(\d+).", original_line)[0]) - if current_section not in documented_overloads: - documented_overloads[current_section] = [] - documented_overloads[current_section].append(number) - - # code example - if line == '```cpp' and section_idx == -1: - in_initial_code_example = True - - if in_initial_code_example and line.startswith('//') and line not in ['// since C++20', '// until C++20']: - # check numbering of overloads - if any(map(str.isdigit, line)): - number = int(re.findall(r'\d+', line)[0]) - if number != last_overload + 1: - report('style/numbering', f'{file}:{lineno+1}', f'expected number ({number}) to be ({last_overload +1 })') - last_overload = number - - if any(map(str.isdigit, line)) and '(' not in line: - report('style/numbering', f'{file}:{lineno+1}', f'number should be in parentheses: {line}') - - if line == '```' and in_initial_code_example: - in_initial_code_example = False - - # consecutive blank lines are bad - if line == '' and previous_line == '': - report('whitespace/blank_lines', f'{file}:{lineno}-{lineno+1} ({current_section})', 'consecutive blank lines') - - # check that non-example admonitions have titles - untitled_admonition = re.match(r'^(\?\?\?|!!!) ([^ ]+)$', line) - if untitled_admonition and untitled_admonition.group(2) != 'example': - report('style/admonition_title', f'{file}:{lineno} ({current_section})', f'"{untitled_admonition.group(2)}" admonitions should have a title') - - previous_line = line - - if 'index.md' not in file: # index.md files may have a different structure - for required_section in required_sections: - if required_section not in existing_sections: - report('structure/missing_section', f'{file}:{lineno+1}', f'required section "{required_section}" was not found') - - -def check_examples(): - example_files = sorted(glob.glob('../../examples/*.cpp')) - markdown_files = sorted(glob.glob('**/*.md', recursive=True)) - - # check if every example file is used in at least one markdown file - for example_file in example_files: - example_file = os.path.join('examples', os.path.basename(example_file)) - - found = False - for markdown_file in markdown_files: - content = ' '.join(open(markdown_file).readlines()) - if example_file in content: - found = True - break - - if not found: - report('examples/missing', f'{example_file}', 'example file is not used in any documentation file') - - -if __name__ == '__main__': - print(120 * '-') - check_structure() - check_examples() - print(120 * '-') - - if warnings > 0: - sys.exit(1) diff --git a/docs/usages/ios.png b/docs/usages/ios.png deleted file mode 100755 index 1d2c1b8071..0000000000 Binary files a/docs/usages/ios.png and /dev/null differ diff --git a/docs/usages/macos.png b/docs/usages/macos.png deleted file mode 100644 index 107b5f07fd..0000000000 Binary files a/docs/usages/macos.png and /dev/null differ diff --git a/include/nlohmann/adl_serializer.hpp b/include/nlohmann/adl_serializer.hpp deleted file mode 100644 index f77f94473e..0000000000 --- a/include/nlohmann/adl_serializer.hpp +++ /dev/null @@ -1,55 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include - -#include -#include -#include -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN - -/// @sa https://json.nlohmann.me/api/adl_serializer/ -template -struct adl_serializer -{ - /// @brief convert a JSON value to any value type - /// @sa https://json.nlohmann.me/api/adl_serializer/from_json/ - template - static auto from_json(BasicJsonType && j, TargetType& val) noexcept( - noexcept(::nlohmann::from_json(std::forward(j), val))) - -> decltype(::nlohmann::from_json(std::forward(j), val), void()) - { - ::nlohmann::from_json(std::forward(j), val); - } - - /// @brief convert a JSON value to any value type - /// @sa https://json.nlohmann.me/api/adl_serializer/from_json/ - template - static auto from_json(BasicJsonType && j) noexcept( - noexcept(::nlohmann::from_json(std::forward(j), detail::identity_tag {}))) - -> decltype(::nlohmann::from_json(std::forward(j), detail::identity_tag {})) - { - return ::nlohmann::from_json(std::forward(j), detail::identity_tag {}); - } - - /// @brief convert any value type to a JSON value - /// @sa https://json.nlohmann.me/api/adl_serializer/to_json/ - template - static auto to_json(BasicJsonType& j, TargetType && val) noexcept( - noexcept(::nlohmann::to_json(j, std::forward(val)))) - -> decltype(::nlohmann::to_json(j, std::forward(val)), void()) - { - ::nlohmann::to_json(j, std::forward(val)); - } -}; - -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/byte_container_with_subtype.hpp b/include/nlohmann/byte_container_with_subtype.hpp deleted file mode 100644 index 1031cdcfea..0000000000 --- a/include/nlohmann/byte_container_with_subtype.hpp +++ /dev/null @@ -1,103 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // uint8_t, uint64_t -#include // tie -#include // move - -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN - -/// @brief an internal type for a backed binary type -/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/ -template -class byte_container_with_subtype : public BinaryType -{ - public: - using container_type = BinaryType; - using subtype_type = std::uint64_t; - - /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ - byte_container_with_subtype() noexcept(noexcept(container_type())) - : container_type() - {} - - /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ - byte_container_with_subtype(const container_type& b) noexcept(noexcept(container_type(b))) - : container_type(b) - {} - - /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ - byte_container_with_subtype(container_type&& b) noexcept(noexcept(container_type(std::move(b)))) - : container_type(std::move(b)) - {} - - /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ - byte_container_with_subtype(const container_type& b, subtype_type subtype_) noexcept(noexcept(container_type(b))) - : container_type(b) - , m_subtype(subtype_) - , m_has_subtype(true) - {} - - /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/ - byte_container_with_subtype(container_type&& b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b)))) - : container_type(std::move(b)) - , m_subtype(subtype_) - , m_has_subtype(true) - {} - - bool operator==(const byte_container_with_subtype& rhs) const - { - return std::tie(static_cast(*this), m_subtype, m_has_subtype) == - std::tie(static_cast(rhs), rhs.m_subtype, rhs.m_has_subtype); - } - - bool operator!=(const byte_container_with_subtype& rhs) const - { - return !(rhs == *this); - } - - /// @brief sets the binary subtype - /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/set_subtype/ - void set_subtype(subtype_type subtype_) noexcept - { - m_subtype = subtype_; - m_has_subtype = true; - } - - /// @brief return the binary subtype - /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/subtype/ - constexpr subtype_type subtype() const noexcept - { - return m_has_subtype ? m_subtype : static_cast(-1); - } - - /// @brief return whether the value has a subtype - /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/has_subtype/ - constexpr bool has_subtype() const noexcept - { - return m_has_subtype; - } - - /// @brief clears the binary subtype - /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/clear_subtype/ - void clear_subtype() noexcept - { - m_subtype = 0; - m_has_subtype = false; - } - - private: - subtype_type m_subtype = 0; - bool m_has_subtype = false; -}; - -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/abi_macros.hpp b/include/nlohmann/detail/abi_macros.hpp deleted file mode 100644 index 0d3108d166..0000000000 --- a/include/nlohmann/detail/abi_macros.hpp +++ /dev/null @@ -1,100 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -// This file contains all macro definitions affecting or depending on the ABI - -#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK - #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH) - #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 2 - #warning "Already included a different version of the library!" - #endif - #endif -#endif - -#define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum) -#define NLOHMANN_JSON_VERSION_MINOR 11 // NOLINT(modernize-macro-to-enum) -#define NLOHMANN_JSON_VERSION_PATCH 2 // NOLINT(modernize-macro-to-enum) - -#ifndef JSON_DIAGNOSTICS - #define JSON_DIAGNOSTICS 0 -#endif - -#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON - #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0 -#endif - -#if JSON_DIAGNOSTICS - #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag -#else - #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS -#endif - -#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON - #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp -#else - #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON -#endif - -#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION - #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0 -#endif - -// Construct the namespace ABI tags component -#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b -#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \ - NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) - -#define NLOHMANN_JSON_ABI_TAGS \ - NLOHMANN_JSON_ABI_TAGS_CONCAT( \ - NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \ - NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON) - -// Construct the namespace version component -#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \ - _v ## major ## _ ## minor ## _ ## patch -#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \ - NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) - -#if NLOHMANN_JSON_NAMESPACE_NO_VERSION -#define NLOHMANN_JSON_NAMESPACE_VERSION -#else -#define NLOHMANN_JSON_NAMESPACE_VERSION \ - NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \ - NLOHMANN_JSON_VERSION_MINOR, \ - NLOHMANN_JSON_VERSION_PATCH) -#endif - -// Combine namespace components -#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b -#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \ - NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) - -#ifndef NLOHMANN_JSON_NAMESPACE -#define NLOHMANN_JSON_NAMESPACE \ - nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \ - NLOHMANN_JSON_ABI_TAGS, \ - NLOHMANN_JSON_NAMESPACE_VERSION) -#endif - -#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN -#define NLOHMANN_JSON_NAMESPACE_BEGIN \ - namespace nlohmann \ - { \ - inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \ - NLOHMANN_JSON_ABI_TAGS, \ - NLOHMANN_JSON_NAMESPACE_VERSION) \ - { -#endif - -#ifndef NLOHMANN_JSON_NAMESPACE_END -#define NLOHMANN_JSON_NAMESPACE_END \ - } /* namespace (inline namespace) NOLINT(readability/namespace) */ \ - } // namespace nlohmann -#endif diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp deleted file mode 100644 index c6299aa0b2..0000000000 --- a/include/nlohmann/detail/conversions/from_json.hpp +++ /dev/null @@ -1,497 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // transform -#include // array -#include // forward_list -#include // inserter, front_inserter, end -#include // map -#include // string -#include // tuple, make_tuple -#include // is_arithmetic, is_same, is_enum, underlying_type, is_convertible -#include // unordered_map -#include // pair, declval -#include // valarray - -#include -#include -#include -#include -#include -#include -#include -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -template -inline void from_json(const BasicJsonType& j, typename std::nullptr_t& n) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_null())) - { - JSON_THROW(type_error::create(302, concat("type must be null, but is ", j.type_name()), &j)); - } - n = nullptr; -} - -// overloads for basic_json template parameters -template < typename BasicJsonType, typename ArithmeticType, - enable_if_t < std::is_arithmetic::value&& - !std::is_same::value, - int > = 0 > -void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) -{ - switch (static_cast(j)) - { - case value_t::number_unsigned: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::number_integer: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::number_float: - { - val = static_cast(*j.template get_ptr()); - break; - } - - case value_t::null: - case value_t::object: - case value_t::array: - case value_t::string: - case value_t::boolean: - case value_t::binary: - case value_t::discarded: - default: - JSON_THROW(type_error::create(302, concat("type must be number, but is ", j.type_name()), &j)); - } -} - -template -inline void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_boolean())) - { - JSON_THROW(type_error::create(302, concat("type must be boolean, but is ", j.type_name()), &j)); - } - b = *j.template get_ptr(); -} - -template -inline void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_string())) - { - JSON_THROW(type_error::create(302, concat("type must be string, but is ", j.type_name()), &j)); - } - s = *j.template get_ptr(); -} - -template < - typename BasicJsonType, typename StringType, - enable_if_t < - std::is_assignable::value - && is_detected_exact::value - && !std::is_same::value - && !is_json_ref::value, int > = 0 > -inline void from_json(const BasicJsonType& j, StringType& s) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_string())) - { - JSON_THROW(type_error::create(302, concat("type must be string, but is ", j.type_name()), &j)); - } - - s = *j.template get_ptr(); -} - -template -inline void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val) -{ - get_arithmetic_value(j, val); -} - -template -inline void from_json(const BasicJsonType& j, typename BasicJsonType::number_unsigned_t& val) -{ - get_arithmetic_value(j, val); -} - -template -inline void from_json(const BasicJsonType& j, typename BasicJsonType::number_integer_t& val) -{ - get_arithmetic_value(j, val); -} - -#if !JSON_DISABLE_ENUM_SERIALIZATION -template::value, int> = 0> -inline void from_json(const BasicJsonType& j, EnumType& e) -{ - typename std::underlying_type::type val; - get_arithmetic_value(j, val); - e = static_cast(val); -} -#endif // JSON_DISABLE_ENUM_SERIALIZATION - -// forward_list doesn't have an insert method -template::value, int> = 0> -inline void from_json(const BasicJsonType& j, std::forward_list& l) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); - } - l.clear(); - std::transform(j.rbegin(), j.rend(), - std::front_inserter(l), [](const BasicJsonType & i) - { - return i.template get(); - }); -} - -// valarray doesn't have an insert method -template::value, int> = 0> -inline void from_json(const BasicJsonType& j, std::valarray& l) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); - } - l.resize(j.size()); - std::transform(j.begin(), j.end(), std::begin(l), - [](const BasicJsonType & elem) - { - return elem.template get(); - }); -} - -template -auto from_json(const BasicJsonType& j, T (&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) --> decltype(j.template get(), void()) -{ - for (std::size_t i = 0; i < N; ++i) - { - arr[i] = j.at(i).template get(); - } -} - -template -inline void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_t& arr, priority_tag<3> /*unused*/) -{ - arr = *j.template get_ptr(); -} - -template -auto from_json_array_impl(const BasicJsonType& j, std::array& arr, - priority_tag<2> /*unused*/) --> decltype(j.template get(), void()) -{ - for (std::size_t i = 0; i < N; ++i) - { - arr[i] = j.at(i).template get(); - } -} - -template::value, - int> = 0> -auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/) --> decltype( - arr.reserve(std::declval()), - j.template get(), - void()) -{ - using std::end; - - ConstructibleArrayType ret; - ret.reserve(j.size()); - std::transform(j.begin(), j.end(), - std::inserter(ret, end(ret)), [](const BasicJsonType & i) - { - // get() returns *this, this won't call a from_json - // method when value_type is BasicJsonType - return i.template get(); - }); - arr = std::move(ret); -} - -template::value, - int> = 0> -inline void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, - priority_tag<0> /*unused*/) -{ - using std::end; - - ConstructibleArrayType ret; - std::transform( - j.begin(), j.end(), std::inserter(ret, end(ret)), - [](const BasicJsonType & i) - { - // get() returns *this, this won't call a from_json - // method when value_type is BasicJsonType - return i.template get(); - }); - arr = std::move(ret); -} - -template < typename BasicJsonType, typename ConstructibleArrayType, - enable_if_t < - is_constructible_array_type::value&& - !is_constructible_object_type::value&& - !is_constructible_string_type::value&& - !std::is_same::value&& - !is_basic_json::value, - int > = 0 > -auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) --> decltype(from_json_array_impl(j, arr, priority_tag<3> {}), -j.template get(), -void()) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); - } - - from_json_array_impl(j, arr, priority_tag<3> {}); -} - -template < typename BasicJsonType, typename T, std::size_t... Idx > -std::array from_json_inplace_array_impl(BasicJsonType&& j, - identity_tag> /*unused*/, index_sequence /*unused*/) -{ - return { { std::forward(j).at(Idx).template get()... } }; -} - -template < typename BasicJsonType, typename T, std::size_t N > -auto from_json(BasicJsonType&& j, identity_tag> tag) --> decltype(from_json_inplace_array_impl(std::forward(j), tag, make_index_sequence {})) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); - } - - return from_json_inplace_array_impl(std::forward(j), tag, make_index_sequence {}); -} - -template -inline void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_binary())) - { - JSON_THROW(type_error::create(302, concat("type must be binary, but is ", j.type_name()), &j)); - } - - bin = *j.template get_ptr(); -} - -template::value, int> = 0> -inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_object())) - { - JSON_THROW(type_error::create(302, concat("type must be object, but is ", j.type_name()), &j)); - } - - ConstructibleObjectType ret; - const auto* inner_object = j.template get_ptr(); - using value_type = typename ConstructibleObjectType::value_type; - std::transform( - inner_object->begin(), inner_object->end(), - std::inserter(ret, ret.begin()), - [](typename BasicJsonType::object_t::value_type const & p) - { - return value_type(p.first, p.second.template get()); - }); - obj = std::move(ret); -} - -// overload for arithmetic types, not chosen for basic_json template arguments -// (BooleanType, etc..); note: Is it really necessary to provide explicit -// overloads for boolean_t etc. in case of a custom BooleanType which is not -// an arithmetic type? -template < typename BasicJsonType, typename ArithmeticType, - enable_if_t < - std::is_arithmetic::value&& - !std::is_same::value&& - !std::is_same::value&& - !std::is_same::value&& - !std::is_same::value, - int > = 0 > -inline void from_json(const BasicJsonType& j, ArithmeticType& val) -{ - switch (static_cast(j)) - { - case value_t::number_unsigned: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::number_integer: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::number_float: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::boolean: - { - val = static_cast(*j.template get_ptr()); - break; - } - - case value_t::null: - case value_t::object: - case value_t::array: - case value_t::string: - case value_t::binary: - case value_t::discarded: - default: - JSON_THROW(type_error::create(302, concat("type must be number, but is ", j.type_name()), &j)); - } -} - -template -std::tuple from_json_tuple_impl_base(BasicJsonType&& j, index_sequence /*unused*/) -{ - return std::make_tuple(std::forward(j).at(Idx).template get()...); -} - -template < typename BasicJsonType, class A1, class A2 > -std::pair from_json_tuple_impl(BasicJsonType&& j, identity_tag> /*unused*/, priority_tag<0> /*unused*/) -{ - return {std::forward(j).at(0).template get(), - std::forward(j).at(1).template get()}; -} - -template -inline void from_json_tuple_impl(BasicJsonType&& j, std::pair& p, priority_tag<1> /*unused*/) -{ - p = from_json_tuple_impl(std::forward(j), identity_tag> {}, priority_tag<0> {}); -} - -template -std::tuple from_json_tuple_impl(BasicJsonType&& j, identity_tag> /*unused*/, priority_tag<2> /*unused*/) -{ - return from_json_tuple_impl_base(std::forward(j), index_sequence_for {}); -} - -template -inline void from_json_tuple_impl(BasicJsonType&& j, std::tuple& t, priority_tag<3> /*unused*/) -{ - t = from_json_tuple_impl_base(std::forward(j), index_sequence_for {}); -} - -template -auto from_json(BasicJsonType&& j, TupleRelated&& t) --> decltype(from_json_tuple_impl(std::forward(j), std::forward(t), priority_tag<3> {})) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); - } - - return from_json_tuple_impl(std::forward(j), std::forward(t), priority_tag<3> {}); -} - -template < typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator, - typename = enable_if_t < !std::is_constructible < - typename BasicJsonType::string_t, Key >::value >> -inline void from_json(const BasicJsonType& j, std::map& m) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); - } - m.clear(); - for (const auto& p : j) - { - if (JSON_HEDLEY_UNLIKELY(!p.is_array())) - { - JSON_THROW(type_error::create(302, concat("type must be array, but is ", p.type_name()), &j)); - } - m.emplace(p.at(0).template get(), p.at(1).template get()); - } -} - -template < typename BasicJsonType, typename Key, typename Value, typename Hash, typename KeyEqual, typename Allocator, - typename = enable_if_t < !std::is_constructible < - typename BasicJsonType::string_t, Key >::value >> -inline void from_json(const BasicJsonType& j, std::unordered_map& m) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, concat("type must be array, but is ", j.type_name()), &j)); - } - m.clear(); - for (const auto& p : j) - { - if (JSON_HEDLEY_UNLIKELY(!p.is_array())) - { - JSON_THROW(type_error::create(302, concat("type must be array, but is ", p.type_name()), &j)); - } - m.emplace(p.at(0).template get(), p.at(1).template get()); - } -} - -#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM -template -inline void from_json(const BasicJsonType& j, std_fs::path& p) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_string())) - { - JSON_THROW(type_error::create(302, concat("type must be string, but is ", j.type_name()), &j)); - } - p = *j.template get_ptr(); -} -#endif - -struct from_json_fn -{ - template - auto operator()(const BasicJsonType& j, T&& val) const - noexcept(noexcept(from_json(j, std::forward(val)))) - -> decltype(from_json(j, std::forward(val))) - { - return from_json(j, std::forward(val)); - } -}; - -} // namespace detail - -#ifndef JSON_HAS_CPP_17 -/// namespace to hold default `from_json` function -/// to see why this is required: -/// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html -namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces) -{ -#endif -JSON_INLINE_VARIABLE constexpr const auto& from_json = // NOLINT(misc-definitions-in-headers) - detail::static_const::value; -#ifndef JSON_HAS_CPP_17 -} // namespace -#endif - -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/conversions/to_chars.hpp b/include/nlohmann/detail/conversions/to_chars.hpp deleted file mode 100644 index 2d0914d72b..0000000000 --- a/include/nlohmann/detail/conversions/to_chars.hpp +++ /dev/null @@ -1,1118 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2009 Florian Loitsch -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // array -#include // signbit, isfinite -#include // intN_t, uintN_t -#include // memcpy, memmove -#include // numeric_limits -#include // conditional - -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -/*! -@brief implements the Grisu2 algorithm for binary to decimal floating-point -conversion. - -This implementation is a slightly modified version of the reference -implementation which may be obtained from -http://florian.loitsch.com/publications (bench.tar.gz). - -The code is distributed under the MIT license, Copyright (c) 2009 Florian Loitsch. - -For a detailed description of the algorithm see: - -[1] Loitsch, "Printing Floating-Point Numbers Quickly and Accurately with - Integers", Proceedings of the ACM SIGPLAN 2010 Conference on Programming - Language Design and Implementation, PLDI 2010 -[2] Burger, Dybvig, "Printing Floating-Point Numbers Quickly and Accurately", - Proceedings of the ACM SIGPLAN 1996 Conference on Programming Language - Design and Implementation, PLDI 1996 -*/ -namespace dtoa_impl -{ - -template -Target reinterpret_bits(const Source source) -{ - static_assert(sizeof(Target) == sizeof(Source), "size mismatch"); - - Target target; - std::memcpy(&target, &source, sizeof(Source)); - return target; -} - -struct diyfp // f * 2^e -{ - static constexpr int kPrecision = 64; // = q - - std::uint64_t f = 0; - int e = 0; - - constexpr diyfp(std::uint64_t f_, int e_) noexcept : f(f_), e(e_) {} - - /*! - @brief returns x - y - @pre x.e == y.e and x.f >= y.f - */ - static diyfp sub(const diyfp& x, const diyfp& y) noexcept - { - JSON_ASSERT(x.e == y.e); - JSON_ASSERT(x.f >= y.f); - - return {x.f - y.f, x.e}; - } - - /*! - @brief returns x * y - @note The result is rounded. (Only the upper q bits are returned.) - */ - static diyfp mul(const diyfp& x, const diyfp& y) noexcept - { - static_assert(kPrecision == 64, "internal error"); - - // Computes: - // f = round((x.f * y.f) / 2^q) - // e = x.e + y.e + q - - // Emulate the 64-bit * 64-bit multiplication: - // - // p = u * v - // = (u_lo + 2^32 u_hi) (v_lo + 2^32 v_hi) - // = (u_lo v_lo ) + 2^32 ((u_lo v_hi ) + (u_hi v_lo )) + 2^64 (u_hi v_hi ) - // = (p0 ) + 2^32 ((p1 ) + (p2 )) + 2^64 (p3 ) - // = (p0_lo + 2^32 p0_hi) + 2^32 ((p1_lo + 2^32 p1_hi) + (p2_lo + 2^32 p2_hi)) + 2^64 (p3 ) - // = (p0_lo ) + 2^32 (p0_hi + p1_lo + p2_lo ) + 2^64 (p1_hi + p2_hi + p3) - // = (p0_lo ) + 2^32 (Q ) + 2^64 (H ) - // = (p0_lo ) + 2^32 (Q_lo + 2^32 Q_hi ) + 2^64 (H ) - // - // (Since Q might be larger than 2^32 - 1) - // - // = (p0_lo + 2^32 Q_lo) + 2^64 (Q_hi + H) - // - // (Q_hi + H does not overflow a 64-bit int) - // - // = p_lo + 2^64 p_hi - - const std::uint64_t u_lo = x.f & 0xFFFFFFFFu; - const std::uint64_t u_hi = x.f >> 32u; - const std::uint64_t v_lo = y.f & 0xFFFFFFFFu; - const std::uint64_t v_hi = y.f >> 32u; - - const std::uint64_t p0 = u_lo * v_lo; - const std::uint64_t p1 = u_lo * v_hi; - const std::uint64_t p2 = u_hi * v_lo; - const std::uint64_t p3 = u_hi * v_hi; - - const std::uint64_t p0_hi = p0 >> 32u; - const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu; - const std::uint64_t p1_hi = p1 >> 32u; - const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu; - const std::uint64_t p2_hi = p2 >> 32u; - - std::uint64_t Q = p0_hi + p1_lo + p2_lo; - - // The full product might now be computed as - // - // p_hi = p3 + p2_hi + p1_hi + (Q >> 32) - // p_lo = p0_lo + (Q << 32) - // - // But in this particular case here, the full p_lo is not required. - // Effectively we only need to add the highest bit in p_lo to p_hi (and - // Q_hi + 1 does not overflow). - - Q += std::uint64_t{1} << (64u - 32u - 1u); // round, ties up - - const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u); - - return {h, x.e + y.e + 64}; - } - - /*! - @brief normalize x such that the significand is >= 2^(q-1) - @pre x.f != 0 - */ - static diyfp normalize(diyfp x) noexcept - { - JSON_ASSERT(x.f != 0); - - while ((x.f >> 63u) == 0) - { - x.f <<= 1u; - x.e--; - } - - return x; - } - - /*! - @brief normalize x such that the result has the exponent E - @pre e >= x.e and the upper e - x.e bits of x.f must be zero. - */ - static diyfp normalize_to(const diyfp& x, const int target_exponent) noexcept - { - const int delta = x.e - target_exponent; - - JSON_ASSERT(delta >= 0); - JSON_ASSERT(((x.f << delta) >> delta) == x.f); - - return {x.f << delta, target_exponent}; - } -}; - -struct boundaries -{ - diyfp w; - diyfp minus; - diyfp plus; -}; - -/*! -Compute the (normalized) diyfp representing the input number 'value' and its -boundaries. - -@pre value must be finite and positive -*/ -template -boundaries compute_boundaries(FloatType value) -{ - JSON_ASSERT(std::isfinite(value)); - JSON_ASSERT(value > 0); - - // Convert the IEEE representation into a diyfp. - // - // If v is denormal: - // value = 0.F * 2^(1 - bias) = ( F) * 2^(1 - bias - (p-1)) - // If v is normalized: - // value = 1.F * 2^(E - bias) = (2^(p-1) + F) * 2^(E - bias - (p-1)) - - static_assert(std::numeric_limits::is_iec559, - "internal error: dtoa_short requires an IEEE-754 floating-point implementation"); - - constexpr int kPrecision = std::numeric_limits::digits; // = p (includes the hidden bit) - constexpr int kBias = std::numeric_limits::max_exponent - 1 + (kPrecision - 1); - constexpr int kMinExp = 1 - kBias; - constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1); // = 2^(p-1) - - using bits_type = typename std::conditional::type; - - const auto bits = static_cast(reinterpret_bits(value)); - const std::uint64_t E = bits >> (kPrecision - 1); - const std::uint64_t F = bits & (kHiddenBit - 1); - - const bool is_denormal = E == 0; - const diyfp v = is_denormal - ? diyfp(F, kMinExp) - : diyfp(F + kHiddenBit, static_cast(E) - kBias); - - // Compute the boundaries m- and m+ of the floating-point value - // v = f * 2^e. - // - // Determine v- and v+, the floating-point predecessor and successor if v, - // respectively. - // - // v- = v - 2^e if f != 2^(p-1) or e == e_min (A) - // = v - 2^(e-1) if f == 2^(p-1) and e > e_min (B) - // - // v+ = v + 2^e - // - // Let m- = (v- + v) / 2 and m+ = (v + v+) / 2. All real numbers _strictly_ - // between m- and m+ round to v, regardless of how the input rounding - // algorithm breaks ties. - // - // ---+-------------+-------------+-------------+-------------+--- (A) - // v- m- v m+ v+ - // - // -----------------+------+------+-------------+-------------+--- (B) - // v- m- v m+ v+ - - const bool lower_boundary_is_closer = F == 0 && E > 1; - const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1); - const diyfp m_minus = lower_boundary_is_closer - ? diyfp(4 * v.f - 1, v.e - 2) // (B) - : diyfp(2 * v.f - 1, v.e - 1); // (A) - - // Determine the normalized w+ = m+. - const diyfp w_plus = diyfp::normalize(m_plus); - - // Determine w- = m- such that e_(w-) = e_(w+). - const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.e); - - return {diyfp::normalize(v), w_minus, w_plus}; -} - -// Given normalized diyfp w, Grisu needs to find a (normalized) cached -// power-of-ten c, such that the exponent of the product c * w = f * 2^e lies -// within a certain range [alpha, gamma] (Definition 3.2 from [1]) -// -// alpha <= e = e_c + e_w + q <= gamma -// -// or -// -// f_c * f_w * 2^alpha <= f_c 2^(e_c) * f_w 2^(e_w) * 2^q -// <= f_c * f_w * 2^gamma -// -// Since c and w are normalized, i.e. 2^(q-1) <= f < 2^q, this implies -// -// 2^(q-1) * 2^(q-1) * 2^alpha <= c * w * 2^q < 2^q * 2^q * 2^gamma -// -// or -// -// 2^(q - 2 + alpha) <= c * w < 2^(q + gamma) -// -// The choice of (alpha,gamma) determines the size of the table and the form of -// the digit generation procedure. Using (alpha,gamma)=(-60,-32) works out well -// in practice: -// -// The idea is to cut the number c * w = f * 2^e into two parts, which can be -// processed independently: An integral part p1, and a fractional part p2: -// -// f * 2^e = ( (f div 2^-e) * 2^-e + (f mod 2^-e) ) * 2^e -// = (f div 2^-e) + (f mod 2^-e) * 2^e -// = p1 + p2 * 2^e -// -// The conversion of p1 into decimal form requires a series of divisions and -// modulos by (a power of) 10. These operations are faster for 32-bit than for -// 64-bit integers, so p1 should ideally fit into a 32-bit integer. This can be -// achieved by choosing -// -// -e >= 32 or e <= -32 := gamma -// -// In order to convert the fractional part -// -// p2 * 2^e = p2 / 2^-e = d[-1] / 10^1 + d[-2] / 10^2 + ... -// -// into decimal form, the fraction is repeatedly multiplied by 10 and the digits -// d[-i] are extracted in order: -// -// (10 * p2) div 2^-e = d[-1] -// (10 * p2) mod 2^-e = d[-2] / 10^1 + ... -// -// The multiplication by 10 must not overflow. It is sufficient to choose -// -// 10 * p2 < 16 * p2 = 2^4 * p2 <= 2^64. -// -// Since p2 = f mod 2^-e < 2^-e, -// -// -e <= 60 or e >= -60 := alpha - -constexpr int kAlpha = -60; -constexpr int kGamma = -32; - -struct cached_power // c = f * 2^e ~= 10^k -{ - std::uint64_t f; - int e; - int k; -}; - -/*! -For a normalized diyfp w = f * 2^e, this function returns a (normalized) cached -power-of-ten c = f_c * 2^e_c, such that the exponent of the product w * c -satisfies (Definition 3.2 from [1]) - - alpha <= e_c + e + q <= gamma. -*/ -inline cached_power get_cached_power_for_binary_exponent(int e) -{ - // Now - // - // alpha <= e_c + e + q <= gamma (1) - // ==> f_c * 2^alpha <= c * 2^e * 2^q - // - // and since the c's are normalized, 2^(q-1) <= f_c, - // - // ==> 2^(q - 1 + alpha) <= c * 2^(e + q) - // ==> 2^(alpha - e - 1) <= c - // - // If c were an exact power of ten, i.e. c = 10^k, one may determine k as - // - // k = ceil( log_10( 2^(alpha - e - 1) ) ) - // = ceil( (alpha - e - 1) * log_10(2) ) - // - // From the paper: - // "In theory the result of the procedure could be wrong since c is rounded, - // and the computation itself is approximated [...]. In practice, however, - // this simple function is sufficient." - // - // For IEEE double precision floating-point numbers converted into - // normalized diyfp's w = f * 2^e, with q = 64, - // - // e >= -1022 (min IEEE exponent) - // -52 (p - 1) - // -52 (p - 1, possibly normalize denormal IEEE numbers) - // -11 (normalize the diyfp) - // = -1137 - // - // and - // - // e <= +1023 (max IEEE exponent) - // -52 (p - 1) - // -11 (normalize the diyfp) - // = 960 - // - // This binary exponent range [-1137,960] results in a decimal exponent - // range [-307,324]. One does not need to store a cached power for each - // k in this range. For each such k it suffices to find a cached power - // such that the exponent of the product lies in [alpha,gamma]. - // This implies that the difference of the decimal exponents of adjacent - // table entries must be less than or equal to - // - // floor( (gamma - alpha) * log_10(2) ) = 8. - // - // (A smaller distance gamma-alpha would require a larger table.) - - // NB: - // Actually this function returns c, such that -60 <= e_c + e + 64 <= -34. - - constexpr int kCachedPowersMinDecExp = -300; - constexpr int kCachedPowersDecStep = 8; - - static constexpr std::array kCachedPowers = - { - { - { 0xAB70FE17C79AC6CA, -1060, -300 }, - { 0xFF77B1FCBEBCDC4F, -1034, -292 }, - { 0xBE5691EF416BD60C, -1007, -284 }, - { 0x8DD01FAD907FFC3C, -980, -276 }, - { 0xD3515C2831559A83, -954, -268 }, - { 0x9D71AC8FADA6C9B5, -927, -260 }, - { 0xEA9C227723EE8BCB, -901, -252 }, - { 0xAECC49914078536D, -874, -244 }, - { 0x823C12795DB6CE57, -847, -236 }, - { 0xC21094364DFB5637, -821, -228 }, - { 0x9096EA6F3848984F, -794, -220 }, - { 0xD77485CB25823AC7, -768, -212 }, - { 0xA086CFCD97BF97F4, -741, -204 }, - { 0xEF340A98172AACE5, -715, -196 }, - { 0xB23867FB2A35B28E, -688, -188 }, - { 0x84C8D4DFD2C63F3B, -661, -180 }, - { 0xC5DD44271AD3CDBA, -635, -172 }, - { 0x936B9FCEBB25C996, -608, -164 }, - { 0xDBAC6C247D62A584, -582, -156 }, - { 0xA3AB66580D5FDAF6, -555, -148 }, - { 0xF3E2F893DEC3F126, -529, -140 }, - { 0xB5B5ADA8AAFF80B8, -502, -132 }, - { 0x87625F056C7C4A8B, -475, -124 }, - { 0xC9BCFF6034C13053, -449, -116 }, - { 0x964E858C91BA2655, -422, -108 }, - { 0xDFF9772470297EBD, -396, -100 }, - { 0xA6DFBD9FB8E5B88F, -369, -92 }, - { 0xF8A95FCF88747D94, -343, -84 }, - { 0xB94470938FA89BCF, -316, -76 }, - { 0x8A08F0F8BF0F156B, -289, -68 }, - { 0xCDB02555653131B6, -263, -60 }, - { 0x993FE2C6D07B7FAC, -236, -52 }, - { 0xE45C10C42A2B3B06, -210, -44 }, - { 0xAA242499697392D3, -183, -36 }, - { 0xFD87B5F28300CA0E, -157, -28 }, - { 0xBCE5086492111AEB, -130, -20 }, - { 0x8CBCCC096F5088CC, -103, -12 }, - { 0xD1B71758E219652C, -77, -4 }, - { 0x9C40000000000000, -50, 4 }, - { 0xE8D4A51000000000, -24, 12 }, - { 0xAD78EBC5AC620000, 3, 20 }, - { 0x813F3978F8940984, 30, 28 }, - { 0xC097CE7BC90715B3, 56, 36 }, - { 0x8F7E32CE7BEA5C70, 83, 44 }, - { 0xD5D238A4ABE98068, 109, 52 }, - { 0x9F4F2726179A2245, 136, 60 }, - { 0xED63A231D4C4FB27, 162, 68 }, - { 0xB0DE65388CC8ADA8, 189, 76 }, - { 0x83C7088E1AAB65DB, 216, 84 }, - { 0xC45D1DF942711D9A, 242, 92 }, - { 0x924D692CA61BE758, 269, 100 }, - { 0xDA01EE641A708DEA, 295, 108 }, - { 0xA26DA3999AEF774A, 322, 116 }, - { 0xF209787BB47D6B85, 348, 124 }, - { 0xB454E4A179DD1877, 375, 132 }, - { 0x865B86925B9BC5C2, 402, 140 }, - { 0xC83553C5C8965D3D, 428, 148 }, - { 0x952AB45CFA97A0B3, 455, 156 }, - { 0xDE469FBD99A05FE3, 481, 164 }, - { 0xA59BC234DB398C25, 508, 172 }, - { 0xF6C69A72A3989F5C, 534, 180 }, - { 0xB7DCBF5354E9BECE, 561, 188 }, - { 0x88FCF317F22241E2, 588, 196 }, - { 0xCC20CE9BD35C78A5, 614, 204 }, - { 0x98165AF37B2153DF, 641, 212 }, - { 0xE2A0B5DC971F303A, 667, 220 }, - { 0xA8D9D1535CE3B396, 694, 228 }, - { 0xFB9B7CD9A4A7443C, 720, 236 }, - { 0xBB764C4CA7A44410, 747, 244 }, - { 0x8BAB8EEFB6409C1A, 774, 252 }, - { 0xD01FEF10A657842C, 800, 260 }, - { 0x9B10A4E5E9913129, 827, 268 }, - { 0xE7109BFBA19C0C9D, 853, 276 }, - { 0xAC2820D9623BF429, 880, 284 }, - { 0x80444B5E7AA7CF85, 907, 292 }, - { 0xBF21E44003ACDD2D, 933, 300 }, - { 0x8E679C2F5E44FF8F, 960, 308 }, - { 0xD433179D9C8CB841, 986, 316 }, - { 0x9E19DB92B4E31BA9, 1013, 324 }, - } - }; - - // This computation gives exactly the same results for k as - // k = ceil((kAlpha - e - 1) * 0.30102999566398114) - // for |e| <= 1500, but doesn't require floating-point operations. - // NB: log_10(2) ~= 78913 / 2^18 - JSON_ASSERT(e >= -1500); - JSON_ASSERT(e <= 1500); - const int f = kAlpha - e - 1; - const int k = (f * 78913) / (1 << 18) + static_cast(f > 0); - - const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep; - JSON_ASSERT(index >= 0); - JSON_ASSERT(static_cast(index) < kCachedPowers.size()); - - const cached_power cached = kCachedPowers[static_cast(index)]; - JSON_ASSERT(kAlpha <= cached.e + e + 64); - JSON_ASSERT(kGamma >= cached.e + e + 64); - - return cached; -} - -/*! -For n != 0, returns k, such that pow10 := 10^(k-1) <= n < 10^k. -For n == 0, returns 1 and sets pow10 := 1. -*/ -inline int find_largest_pow10(const std::uint32_t n, std::uint32_t& pow10) -{ - // LCOV_EXCL_START - if (n >= 1000000000) - { - pow10 = 1000000000; - return 10; - } - // LCOV_EXCL_STOP - if (n >= 100000000) - { - pow10 = 100000000; - return 9; - } - if (n >= 10000000) - { - pow10 = 10000000; - return 8; - } - if (n >= 1000000) - { - pow10 = 1000000; - return 7; - } - if (n >= 100000) - { - pow10 = 100000; - return 6; - } - if (n >= 10000) - { - pow10 = 10000; - return 5; - } - if (n >= 1000) - { - pow10 = 1000; - return 4; - } - if (n >= 100) - { - pow10 = 100; - return 3; - } - if (n >= 10) - { - pow10 = 10; - return 2; - } - - pow10 = 1; - return 1; -} - -inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t delta, - std::uint64_t rest, std::uint64_t ten_k) -{ - JSON_ASSERT(len >= 1); - JSON_ASSERT(dist <= delta); - JSON_ASSERT(rest <= delta); - JSON_ASSERT(ten_k > 0); - - // <--------------------------- delta ----> - // <---- dist ---------> - // --------------[------------------+-------------------]-------------- - // M- w M+ - // - // ten_k - // <------> - // <---- rest ----> - // --------------[------------------+----+--------------]-------------- - // w V - // = buf * 10^k - // - // ten_k represents a unit-in-the-last-place in the decimal representation - // stored in buf. - // Decrement buf by ten_k while this takes buf closer to w. - - // The tests are written in this order to avoid overflow in unsigned - // integer arithmetic. - - while (rest < dist - && delta - rest >= ten_k - && (rest + ten_k < dist || dist - rest > rest + ten_k - dist)) - { - JSON_ASSERT(buf[len - 1] != '0'); - buf[len - 1]--; - rest += ten_k; - } -} - -/*! -Generates V = buffer * 10^decimal_exponent, such that M- <= V <= M+. -M- and M+ must be normalized and share the same exponent -60 <= e <= -32. -*/ -inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, - diyfp M_minus, diyfp w, diyfp M_plus) -{ - static_assert(kAlpha >= -60, "internal error"); - static_assert(kGamma <= -32, "internal error"); - - // Generates the digits (and the exponent) of a decimal floating-point - // number V = buffer * 10^decimal_exponent in the range [M-, M+]. The diyfp's - // w, M- and M+ share the same exponent e, which satisfies alpha <= e <= gamma. - // - // <--------------------------- delta ----> - // <---- dist ---------> - // --------------[------------------+-------------------]-------------- - // M- w M+ - // - // Grisu2 generates the digits of M+ from left to right and stops as soon as - // V is in [M-,M+]. - - JSON_ASSERT(M_plus.e >= kAlpha); - JSON_ASSERT(M_plus.e <= kGamma); - - std::uint64_t delta = diyfp::sub(M_plus, M_minus).f; // (significand of (M+ - M-), implicit exponent is e) - std::uint64_t dist = diyfp::sub(M_plus, w ).f; // (significand of (M+ - w ), implicit exponent is e) - - // Split M+ = f * 2^e into two parts p1 and p2 (note: e < 0): - // - // M+ = f * 2^e - // = ((f div 2^-e) * 2^-e + (f mod 2^-e)) * 2^e - // = ((p1 ) * 2^-e + (p2 )) * 2^e - // = p1 + p2 * 2^e - - const diyfp one(std::uint64_t{1} << -M_plus.e, M_plus.e); - - auto p1 = static_cast(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.) - std::uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e - - // 1) - // - // Generate the digits of the integral part p1 = d[n-1]...d[1]d[0] - - JSON_ASSERT(p1 > 0); - - std::uint32_t pow10{}; - const int k = find_largest_pow10(p1, pow10); - - // 10^(k-1) <= p1 < 10^k, pow10 = 10^(k-1) - // - // p1 = (p1 div 10^(k-1)) * 10^(k-1) + (p1 mod 10^(k-1)) - // = (d[k-1] ) * 10^(k-1) + (p1 mod 10^(k-1)) - // - // M+ = p1 + p2 * 2^e - // = d[k-1] * 10^(k-1) + (p1 mod 10^(k-1)) + p2 * 2^e - // = d[k-1] * 10^(k-1) + ((p1 mod 10^(k-1)) * 2^-e + p2) * 2^e - // = d[k-1] * 10^(k-1) + ( rest) * 2^e - // - // Now generate the digits d[n] of p1 from left to right (n = k-1,...,0) - // - // p1 = d[k-1]...d[n] * 10^n + d[n-1]...d[0] - // - // but stop as soon as - // - // rest * 2^e = (d[n-1]...d[0] * 2^-e + p2) * 2^e <= delta * 2^e - - int n = k; - while (n > 0) - { - // Invariants: - // M+ = buffer * 10^n + (p1 + p2 * 2^e) (buffer = 0 for n = k) - // pow10 = 10^(n-1) <= p1 < 10^n - // - const std::uint32_t d = p1 / pow10; // d = p1 div 10^(n-1) - const std::uint32_t r = p1 % pow10; // r = p1 mod 10^(n-1) - // - // M+ = buffer * 10^n + (d * 10^(n-1) + r) + p2 * 2^e - // = (buffer * 10 + d) * 10^(n-1) + (r + p2 * 2^e) - // - JSON_ASSERT(d <= 9); - buffer[length++] = static_cast('0' + d); // buffer := buffer * 10 + d - // - // M+ = buffer * 10^(n-1) + (r + p2 * 2^e) - // - p1 = r; - n--; - // - // M+ = buffer * 10^n + (p1 + p2 * 2^e) - // pow10 = 10^n - // - - // Now check if enough digits have been generated. - // Compute - // - // p1 + p2 * 2^e = (p1 * 2^-e + p2) * 2^e = rest * 2^e - // - // Note: - // Since rest and delta share the same exponent e, it suffices to - // compare the significands. - const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2; - if (rest <= delta) - { - // V = buffer * 10^n, with M- <= V <= M+. - - decimal_exponent += n; - - // We may now just stop. But instead look if the buffer could be - // decremented to bring V closer to w. - // - // pow10 = 10^n is now 1 ulp in the decimal representation V. - // The rounding procedure works with diyfp's with an implicit - // exponent of e. - // - // 10^n = (10^n * 2^-e) * 2^e = ulp * 2^e - // - const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e; - grisu2_round(buffer, length, dist, delta, rest, ten_n); - - return; - } - - pow10 /= 10; - // - // pow10 = 10^(n-1) <= p1 < 10^n - // Invariants restored. - } - - // 2) - // - // The digits of the integral part have been generated: - // - // M+ = d[k-1]...d[1]d[0] + p2 * 2^e - // = buffer + p2 * 2^e - // - // Now generate the digits of the fractional part p2 * 2^e. - // - // Note: - // No decimal point is generated: the exponent is adjusted instead. - // - // p2 actually represents the fraction - // - // p2 * 2^e - // = p2 / 2^-e - // = d[-1] / 10^1 + d[-2] / 10^2 + ... - // - // Now generate the digits d[-m] of p1 from left to right (m = 1,2,...) - // - // p2 * 2^e = d[-1]d[-2]...d[-m] * 10^-m - // + 10^-m * (d[-m-1] / 10^1 + d[-m-2] / 10^2 + ...) - // - // using - // - // 10^m * p2 = ((10^m * p2) div 2^-e) * 2^-e + ((10^m * p2) mod 2^-e) - // = ( d) * 2^-e + ( r) - // - // or - // 10^m * p2 * 2^e = d + r * 2^e - // - // i.e. - // - // M+ = buffer + p2 * 2^e - // = buffer + 10^-m * (d + r * 2^e) - // = (buffer * 10^m + d) * 10^-m + 10^-m * r * 2^e - // - // and stop as soon as 10^-m * r * 2^e <= delta * 2^e - - JSON_ASSERT(p2 > delta); - - int m = 0; - for (;;) - { - // Invariant: - // M+ = buffer * 10^-m + 10^-m * (d[-m-1] / 10 + d[-m-2] / 10^2 + ...) * 2^e - // = buffer * 10^-m + 10^-m * (p2 ) * 2^e - // = buffer * 10^-m + 10^-m * (1/10 * (10 * p2) ) * 2^e - // = buffer * 10^-m + 10^-m * (1/10 * ((10*p2 div 2^-e) * 2^-e + (10*p2 mod 2^-e)) * 2^e - // - JSON_ASSERT(p2 <= (std::numeric_limits::max)() / 10); - p2 *= 10; - const std::uint64_t d = p2 >> -one.e; // d = (10 * p2) div 2^-e - const std::uint64_t r = p2 & (one.f - 1); // r = (10 * p2) mod 2^-e - // - // M+ = buffer * 10^-m + 10^-m * (1/10 * (d * 2^-e + r) * 2^e - // = buffer * 10^-m + 10^-m * (1/10 * (d + r * 2^e)) - // = (buffer * 10 + d) * 10^(-m-1) + 10^(-m-1) * r * 2^e - // - JSON_ASSERT(d <= 9); - buffer[length++] = static_cast('0' + d); // buffer := buffer * 10 + d - // - // M+ = buffer * 10^(-m-1) + 10^(-m-1) * r * 2^e - // - p2 = r; - m++; - // - // M+ = buffer * 10^-m + 10^-m * p2 * 2^e - // Invariant restored. - - // Check if enough digits have been generated. - // - // 10^-m * p2 * 2^e <= delta * 2^e - // p2 * 2^e <= 10^m * delta * 2^e - // p2 <= 10^m * delta - delta *= 10; - dist *= 10; - if (p2 <= delta) - { - break; - } - } - - // V = buffer * 10^-m, with M- <= V <= M+. - - decimal_exponent -= m; - - // 1 ulp in the decimal representation is now 10^-m. - // Since delta and dist are now scaled by 10^m, we need to do the - // same with ulp in order to keep the units in sync. - // - // 10^m * 10^-m = 1 = 2^-e * 2^e = ten_m * 2^e - // - const std::uint64_t ten_m = one.f; - grisu2_round(buffer, length, dist, delta, p2, ten_m); - - // By construction this algorithm generates the shortest possible decimal - // number (Loitsch, Theorem 6.2) which rounds back to w. - // For an input number of precision p, at least - // - // N = 1 + ceil(p * log_10(2)) - // - // decimal digits are sufficient to identify all binary floating-point - // numbers (Matula, "In-and-Out conversions"). - // This implies that the algorithm does not produce more than N decimal - // digits. - // - // N = 17 for p = 53 (IEEE double precision) - // N = 9 for p = 24 (IEEE single precision) -} - -/*! -v = buf * 10^decimal_exponent -len is the length of the buffer (number of decimal digits) -The buffer must be large enough, i.e. >= max_digits10. -*/ -JSON_HEDLEY_NON_NULL(1) -inline void grisu2(char* buf, int& len, int& decimal_exponent, - diyfp m_minus, diyfp v, diyfp m_plus) -{ - JSON_ASSERT(m_plus.e == m_minus.e); - JSON_ASSERT(m_plus.e == v.e); - - // --------(-----------------------+-----------------------)-------- (A) - // m- v m+ - // - // --------------------(-----------+-----------------------)-------- (B) - // m- v m+ - // - // First scale v (and m- and m+) such that the exponent is in the range - // [alpha, gamma]. - - const cached_power cached = get_cached_power_for_binary_exponent(m_plus.e); - - const diyfp c_minus_k(cached.f, cached.e); // = c ~= 10^-k - - // The exponent of the products is = v.e + c_minus_k.e + q and is in the range [alpha,gamma] - const diyfp w = diyfp::mul(v, c_minus_k); - const diyfp w_minus = diyfp::mul(m_minus, c_minus_k); - const diyfp w_plus = diyfp::mul(m_plus, c_minus_k); - - // ----(---+---)---------------(---+---)---------------(---+---)---- - // w- w w+ - // = c*m- = c*v = c*m+ - // - // diyfp::mul rounds its result and c_minus_k is approximated too. w, w- and - // w+ are now off by a small amount. - // In fact: - // - // w - v * 10^k < 1 ulp - // - // To account for this inaccuracy, add resp. subtract 1 ulp. - // - // --------+---[---------------(---+---)---------------]---+-------- - // w- M- w M+ w+ - // - // Now any number in [M-, M+] (bounds included) will round to w when input, - // regardless of how the input rounding algorithm breaks ties. - // - // And digit_gen generates the shortest possible such number in [M-, M+]. - // Note that this does not mean that Grisu2 always generates the shortest - // possible number in the interval (m-, m+). - const diyfp M_minus(w_minus.f + 1, w_minus.e); - const diyfp M_plus (w_plus.f - 1, w_plus.e ); - - decimal_exponent = -cached.k; // = -(-k) = k - - grisu2_digit_gen(buf, len, decimal_exponent, M_minus, w, M_plus); -} - -/*! -v = buf * 10^decimal_exponent -len is the length of the buffer (number of decimal digits) -The buffer must be large enough, i.e. >= max_digits10. -*/ -template -JSON_HEDLEY_NON_NULL(1) -void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) -{ - static_assert(diyfp::kPrecision >= std::numeric_limits::digits + 3, - "internal error: not enough precision"); - - JSON_ASSERT(std::isfinite(value)); - JSON_ASSERT(value > 0); - - // If the neighbors (and boundaries) of 'value' are always computed for double-precision - // numbers, all float's can be recovered using strtod (and strtof). However, the resulting - // decimal representations are not exactly "short". - // - // The documentation for 'std::to_chars' (https://en.cppreference.com/w/cpp/utility/to_chars) - // says "value is converted to a string as if by std::sprintf in the default ("C") locale" - // and since sprintf promotes floats to doubles, I think this is exactly what 'std::to_chars' - // does. - // On the other hand, the documentation for 'std::to_chars' requires that "parsing the - // representation using the corresponding std::from_chars function recovers value exactly". That - // indicates that single precision floating-point numbers should be recovered using - // 'std::strtof'. - // - // NB: If the neighbors are computed for single-precision numbers, there is a single float - // (7.0385307e-26f) which can't be recovered using strtod. The resulting double precision - // value is off by 1 ulp. -#if 0 // NOLINT(readability-avoid-unconditional-preprocessor-if) - const boundaries w = compute_boundaries(static_cast(value)); -#else - const boundaries w = compute_boundaries(value); -#endif - - grisu2(buf, len, decimal_exponent, w.minus, w.w, w.plus); -} - -/*! -@brief appends a decimal representation of e to buf -@return a pointer to the element following the exponent. -@pre -1000 < e < 1000 -*/ -JSON_HEDLEY_NON_NULL(1) -JSON_HEDLEY_RETURNS_NON_NULL -inline char* append_exponent(char* buf, int e) -{ - JSON_ASSERT(e > -1000); - JSON_ASSERT(e < 1000); - - if (e < 0) - { - e = -e; - *buf++ = '-'; - } - else - { - *buf++ = '+'; - } - - auto k = static_cast(e); - if (k < 10) - { - // Always print at least two digits in the exponent. - // This is for compatibility with printf("%g"). - *buf++ = '0'; - *buf++ = static_cast('0' + k); - } - else if (k < 100) - { - *buf++ = static_cast('0' + k / 10); - k %= 10; - *buf++ = static_cast('0' + k); - } - else - { - *buf++ = static_cast('0' + k / 100); - k %= 100; - *buf++ = static_cast('0' + k / 10); - k %= 10; - *buf++ = static_cast('0' + k); - } - - return buf; -} - -/*! -@brief prettify v = buf * 10^decimal_exponent - -If v is in the range [10^min_exp, 10^max_exp) it will be printed in fixed-point -notation. Otherwise it will be printed in exponential notation. - -@pre min_exp < 0 -@pre max_exp > 0 -*/ -JSON_HEDLEY_NON_NULL(1) -JSON_HEDLEY_RETURNS_NON_NULL -inline char* format_buffer(char* buf, int len, int decimal_exponent, - int min_exp, int max_exp) -{ - JSON_ASSERT(min_exp < 0); - JSON_ASSERT(max_exp > 0); - - const int k = len; - const int n = len + decimal_exponent; - - // v = buf * 10^(n-k) - // k is the length of the buffer (number of decimal digits) - // n is the position of the decimal point relative to the start of the buffer. - - if (k <= n && n <= max_exp) - { - // digits[000] - // len <= max_exp + 2 - - std::memset(buf + k, '0', static_cast(n) - static_cast(k)); - // Make it look like a floating-point number (#362, #378) - buf[n + 0] = '.'; - buf[n + 1] = '0'; - return buf + (static_cast(n) + 2); - } - - if (0 < n && n <= max_exp) - { - // dig.its - // len <= max_digits10 + 1 - - JSON_ASSERT(k > n); - - std::memmove(buf + (static_cast(n) + 1), buf + n, static_cast(k) - static_cast(n)); - buf[n] = '.'; - return buf + (static_cast(k) + 1U); - } - - if (min_exp < n && n <= 0) - { - // 0.[000]digits - // len <= 2 + (-min_exp - 1) + max_digits10 - - std::memmove(buf + (2 + static_cast(-n)), buf, static_cast(k)); - buf[0] = '0'; - buf[1] = '.'; - std::memset(buf + 2, '0', static_cast(-n)); - return buf + (2U + static_cast(-n) + static_cast(k)); - } - - if (k == 1) - { - // dE+123 - // len <= 1 + 5 - - buf += 1; - } - else - { - // d.igitsE+123 - // len <= max_digits10 + 1 + 5 - - std::memmove(buf + 2, buf + 1, static_cast(k) - 1); - buf[1] = '.'; - buf += 1 + static_cast(k); - } - - *buf++ = 'e'; - return append_exponent(buf, n - 1); -} - -} // namespace dtoa_impl - -/*! -@brief generates a decimal representation of the floating-point number value in [first, last). - -The format of the resulting decimal representation is similar to printf's %g -format. Returns an iterator pointing past-the-end of the decimal representation. - -@note The input number must be finite, i.e. NaN's and Inf's are not supported. -@note The buffer must be large enough. -@note The result is NOT null-terminated. -*/ -template -JSON_HEDLEY_NON_NULL(1, 2) -JSON_HEDLEY_RETURNS_NON_NULL -char* to_chars(char* first, const char* last, FloatType value) -{ - static_cast(last); // maybe unused - fix warning - JSON_ASSERT(std::isfinite(value)); - - // Use signbit(value) instead of (value < 0) since signbit works for -0. - if (std::signbit(value)) - { - value = -value; - *first++ = '-'; - } - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wfloat-equal" -#endif - if (value == 0) // +-0 - { - *first++ = '0'; - // Make it look like a floating-point number (#362, #378) - *first++ = '.'; - *first++ = '0'; - return first; - } -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif - - JSON_ASSERT(last - first >= std::numeric_limits::max_digits10); - - // Compute v = buffer * 10^decimal_exponent. - // The decimal digits are stored in the buffer, which needs to be interpreted - // as an unsigned decimal integer. - // len is the length of the buffer, i.e. the number of decimal digits. - int len = 0; - int decimal_exponent = 0; - dtoa_impl::grisu2(first, len, decimal_exponent, value); - - JSON_ASSERT(len <= std::numeric_limits::max_digits10); - - // Format the buffer like printf("%.*g", prec, value) - constexpr int kMinExp = -4; - // Use digits10 here to increase compatibility with version 2. - constexpr int kMaxExp = std::numeric_limits::digits10; - - JSON_ASSERT(last - first >= kMaxExp + 2); - JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits::max_digits10); - JSON_ASSERT(last - first >= std::numeric_limits::max_digits10 + 6); - - return dtoa_impl::format_buffer(first, len, decimal_exponent, kMinExp, kMaxExp); -} - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp deleted file mode 100644 index e70207f7cc..0000000000 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ /dev/null @@ -1,446 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // copy -#include // begin, end -#include // string -#include // tuple, get -#include // is_same, is_constructible, is_floating_point, is_enum, underlying_type -#include // move, forward, declval, pair -#include // valarray -#include // vector - -#include -#include -#include -#include -#include -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -////////////////// -// constructors // -////////////////// - -/* - * Note all external_constructor<>::construct functions need to call - * j.m_data.m_value.destroy(j.m_data.m_type) to avoid a memory leak in case j contains an - * allocated value (e.g., a string). See bug issue - * https://github.com/nlohmann/json/issues/2865 for more information. - */ - -template struct external_constructor; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept - { - j.m_data.m_value.destroy(j.m_data.m_type); - j.m_data.m_type = value_t::boolean; - j.m_data.m_value = b; - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s) - { - j.m_data.m_value.destroy(j.m_data.m_type); - j.m_data.m_type = value_t::string; - j.m_data.m_value = s; - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s) - { - j.m_data.m_value.destroy(j.m_data.m_type); - j.m_data.m_type = value_t::string; - j.m_data.m_value = std::move(s); - j.assert_invariant(); - } - - template < typename BasicJsonType, typename CompatibleStringType, - enable_if_t < !std::is_same::value, - int > = 0 > - static void construct(BasicJsonType& j, const CompatibleStringType& str) - { - j.m_data.m_value.destroy(j.m_data.m_type); - j.m_data.m_type = value_t::string; - j.m_data.m_value.string = j.template create(str); - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b) - { - j.m_data.m_value.destroy(j.m_data.m_type); - j.m_data.m_type = value_t::binary; - j.m_data.m_value = typename BasicJsonType::binary_t(b); - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b) - { - j.m_data.m_value.destroy(j.m_data.m_type); - j.m_data.m_type = value_t::binary; - j.m_data.m_value = typename BasicJsonType::binary_t(std::move(b)); - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept - { - j.m_data.m_value.destroy(j.m_data.m_type); - j.m_data.m_type = value_t::number_float; - j.m_data.m_value = val; - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept - { - j.m_data.m_value.destroy(j.m_data.m_type); - j.m_data.m_type = value_t::number_unsigned; - j.m_data.m_value = val; - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept - { - j.m_data.m_value.destroy(j.m_data.m_type); - j.m_data.m_type = value_t::number_integer; - j.m_data.m_value = val; - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr) - { - j.m_data.m_value.destroy(j.m_data.m_type); - j.m_data.m_type = value_t::array; - j.m_data.m_value = arr; - j.set_parents(); - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr) - { - j.m_data.m_value.destroy(j.m_data.m_type); - j.m_data.m_type = value_t::array; - j.m_data.m_value = std::move(arr); - j.set_parents(); - j.assert_invariant(); - } - - template < typename BasicJsonType, typename CompatibleArrayType, - enable_if_t < !std::is_same::value, - int > = 0 > - static void construct(BasicJsonType& j, const CompatibleArrayType& arr) - { - using std::begin; - using std::end; - - j.m_data.m_value.destroy(j.m_data.m_type); - j.m_data.m_type = value_t::array; - j.m_data.m_value.array = j.template create(begin(arr), end(arr)); - j.set_parents(); - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, const std::vector& arr) - { - j.m_data.m_value.destroy(j.m_data.m_type); - j.m_data.m_type = value_t::array; - j.m_data.m_value = value_t::array; - j.m_data.m_value.array->reserve(arr.size()); - for (const bool x : arr) - { - j.m_data.m_value.array->push_back(x); - j.set_parent(j.m_data.m_value.array->back()); - } - j.assert_invariant(); - } - - template::value, int> = 0> - static void construct(BasicJsonType& j, const std::valarray& arr) - { - j.m_data.m_value.destroy(j.m_data.m_type); - j.m_data.m_type = value_t::array; - j.m_data.m_value = value_t::array; - j.m_data.m_value.array->resize(arr.size()); - if (arr.size() > 0) - { - std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin()); - } - j.set_parents(); - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj) - { - j.m_data.m_value.destroy(j.m_data.m_type); - j.m_data.m_type = value_t::object; - j.m_data.m_value = obj; - j.set_parents(); - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj) - { - j.m_data.m_value.destroy(j.m_data.m_type); - j.m_data.m_type = value_t::object; - j.m_data.m_value = std::move(obj); - j.set_parents(); - j.assert_invariant(); - } - - template < typename BasicJsonType, typename CompatibleObjectType, - enable_if_t < !std::is_same::value, int > = 0 > - static void construct(BasicJsonType& j, const CompatibleObjectType& obj) - { - using std::begin; - using std::end; - - j.m_data.m_value.destroy(j.m_data.m_type); - j.m_data.m_type = value_t::object; - j.m_data.m_value.object = j.template create(begin(obj), end(obj)); - j.set_parents(); - j.assert_invariant(); - } -}; - -///////////// -// to_json // -///////////// - -template::value, int> = 0> -inline void to_json(BasicJsonType& j, T b) noexcept -{ - external_constructor::construct(j, b); -} - -template < typename BasicJsonType, typename BoolRef, - enable_if_t < - ((std::is_same::reference, BoolRef>::value - && !std::is_same ::reference, typename BasicJsonType::boolean_t&>::value) - || (std::is_same::const_reference, BoolRef>::value - && !std::is_same ::const_reference>, - typename BasicJsonType::boolean_t >::value)) - && std::is_convertible::value, int > = 0 > -inline void to_json(BasicJsonType& j, const BoolRef& b) noexcept -{ - external_constructor::construct(j, static_cast(b)); -} - -template::value, int> = 0> -inline void to_json(BasicJsonType& j, const CompatibleString& s) -{ - external_constructor::construct(j, s); -} - -template -inline void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s) -{ - external_constructor::construct(j, std::move(s)); -} - -template::value, int> = 0> -inline void to_json(BasicJsonType& j, FloatType val) noexcept -{ - external_constructor::construct(j, static_cast(val)); -} - -template::value, int> = 0> -inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept -{ - external_constructor::construct(j, static_cast(val)); -} - -template::value, int> = 0> -inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept -{ - external_constructor::construct(j, static_cast(val)); -} - -#if !JSON_DISABLE_ENUM_SERIALIZATION -template::value, int> = 0> -inline void to_json(BasicJsonType& j, EnumType e) noexcept -{ - using underlying_type = typename std::underlying_type::type; - external_constructor::construct(j, static_cast(e)); -} -#endif // JSON_DISABLE_ENUM_SERIALIZATION - -template -inline void to_json(BasicJsonType& j, const std::vector& e) -{ - external_constructor::construct(j, e); -} - -template < typename BasicJsonType, typename CompatibleArrayType, - enable_if_t < is_compatible_array_type::value&& - !is_compatible_object_type::value&& - !is_compatible_string_type::value&& - !std::is_same::value&& - !is_basic_json::value, - int > = 0 > -inline void to_json(BasicJsonType& j, const CompatibleArrayType& arr) -{ - external_constructor::construct(j, arr); -} - -template -inline void to_json(BasicJsonType& j, const typename BasicJsonType::binary_t& bin) -{ - external_constructor::construct(j, bin); -} - -template::value, int> = 0> -inline void to_json(BasicJsonType& j, const std::valarray& arr) -{ - external_constructor::construct(j, std::move(arr)); -} - -template -inline void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr) -{ - external_constructor::construct(j, std::move(arr)); -} - -template < typename BasicJsonType, typename CompatibleObjectType, - enable_if_t < is_compatible_object_type::value&& !is_basic_json::value, int > = 0 > -inline void to_json(BasicJsonType& j, const CompatibleObjectType& obj) -{ - external_constructor::construct(j, obj); -} - -template -inline void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj) -{ - external_constructor::construct(j, std::move(obj)); -} - -template < - typename BasicJsonType, typename T, std::size_t N, - enable_if_t < !std::is_constructible::value, // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - int > = 0 > -inline void to_json(BasicJsonType& j, const T(&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) -{ - external_constructor::construct(j, arr); -} - -template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible::value&& std::is_constructible::value, int > = 0 > -inline void to_json(BasicJsonType& j, const std::pair& p) -{ - j = { p.first, p.second }; -} - -// for https://github.com/nlohmann/json/pull/1134 -template>::value, int> = 0> -inline void to_json(BasicJsonType& j, const T& b) -{ - j = { {b.key(), b.value()} }; -} - -template -inline void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence /*unused*/) -{ - j = { std::get(t)... }; -} - -template::value, int > = 0> -inline void to_json(BasicJsonType& j, const T& t) -{ - to_json_tuple_impl(j, t, make_index_sequence::value> {}); -} - -#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM -template -inline void to_json(BasicJsonType& j, const std_fs::path& p) -{ - j = p.string(); -} -#endif - -struct to_json_fn -{ - template - auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward(val)))) - -> decltype(to_json(j, std::forward(val)), void()) - { - return to_json(j, std::forward(val)); - } -}; -} // namespace detail - -#ifndef JSON_HAS_CPP_17 -/// namespace to hold default `to_json` function -/// to see why this is required: -/// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html -namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces) -{ -#endif -JSON_INLINE_VARIABLE constexpr const auto& to_json = // NOLINT(misc-definitions-in-headers) - detail::static_const::value; -#ifndef JSON_HAS_CPP_17 -} // namespace -#endif - -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/exceptions.hpp b/include/nlohmann/detail/exceptions.hpp deleted file mode 100644 index 23b390c253..0000000000 --- a/include/nlohmann/detail/exceptions.hpp +++ /dev/null @@ -1,258 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // nullptr_t -#include // exception -#if JSON_DIAGNOSTICS - #include // accumulate -#endif -#include // runtime_error -#include // to_string -#include // vector - -#include -#include -#include -#include -#include -#include -#include - - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -//////////////// -// exceptions // -//////////////// - -/// @brief general exception of the @ref basic_json class -/// @sa https://json.nlohmann.me/api/basic_json/exception/ -class exception : public std::exception -{ - public: - /// returns the explanatory string - const char* what() const noexcept override - { - return m.what(); - } - - /// the id of the exception - const int id; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) - - protected: - JSON_HEDLEY_NON_NULL(3) - exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} // NOLINT(bugprone-throw-keyword-missing) - - static std::string name(const std::string& ename, int id_) - { - return concat("[json.exception.", ename, '.', std::to_string(id_), "] "); - } - - static std::string diagnostics(std::nullptr_t /*leaf_element*/) - { - return ""; - } - - template - static std::string diagnostics(const BasicJsonType* leaf_element) - { -#if JSON_DIAGNOSTICS - std::vector tokens; - for (const auto* current = leaf_element; current != nullptr && current->m_parent != nullptr; current = current->m_parent) - { - switch (current->m_parent->type()) - { - case value_t::array: - { - for (std::size_t i = 0; i < current->m_parent->m_data.m_value.array->size(); ++i) - { - if (¤t->m_parent->m_data.m_value.array->operator[](i) == current) - { - tokens.emplace_back(std::to_string(i)); - break; - } - } - break; - } - - case value_t::object: - { - for (const auto& element : *current->m_parent->m_data.m_value.object) - { - if (&element.second == current) - { - tokens.emplace_back(element.first.c_str()); - break; - } - } - break; - } - - case value_t::null: // LCOV_EXCL_LINE - case value_t::string: // LCOV_EXCL_LINE - case value_t::boolean: // LCOV_EXCL_LINE - case value_t::number_integer: // LCOV_EXCL_LINE - case value_t::number_unsigned: // LCOV_EXCL_LINE - case value_t::number_float: // LCOV_EXCL_LINE - case value_t::binary: // LCOV_EXCL_LINE - case value_t::discarded: // LCOV_EXCL_LINE - default: // LCOV_EXCL_LINE - break; // LCOV_EXCL_LINE - } - } - - if (tokens.empty()) - { - return ""; - } - - auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{}, - [](const std::string & a, const std::string & b) - { - return concat(a, '/', detail::escape(b)); - }); - return concat('(', str, ") "); -#else - static_cast(leaf_element); - return ""; -#endif - } - - private: - /// an exception object as storage for error messages - std::runtime_error m; -}; - -/// @brief exception indicating a parse error -/// @sa https://json.nlohmann.me/api/basic_json/parse_error/ -class parse_error : public exception -{ - public: - /*! - @brief create a parse error exception - @param[in] id_ the id of the exception - @param[in] pos the position where the error occurred (or with - chars_read_total=0 if the position cannot be - determined) - @param[in] what_arg the explanatory string - @return parse_error object - */ - template::value, int> = 0> - static parse_error create(int id_, const position_t& pos, const std::string& what_arg, BasicJsonContext context) - { - const std::string w = concat(exception::name("parse_error", id_), "parse error", - position_string(pos), ": ", exception::diagnostics(context), what_arg); - return {id_, pos.chars_read_total, w.c_str()}; - } - - template::value, int> = 0> - static parse_error create(int id_, std::size_t byte_, const std::string& what_arg, BasicJsonContext context) - { - const std::string w = concat(exception::name("parse_error", id_), "parse error", - (byte_ != 0 ? (concat(" at byte ", std::to_string(byte_))) : ""), - ": ", exception::diagnostics(context), what_arg); - return {id_, byte_, w.c_str()}; - } - - /*! - @brief byte index of the parse error - - The byte index of the last read character in the input file. - - @note For an input with n bytes, 1 is the index of the first character and - n+1 is the index of the terminating null byte or the end of file. - This also holds true when reading a byte vector (CBOR or MessagePack). - */ - const std::size_t byte; - - private: - parse_error(int id_, std::size_t byte_, const char* what_arg) - : exception(id_, what_arg), byte(byte_) {} - - static std::string position_string(const position_t& pos) - { - return concat(" at line ", std::to_string(pos.lines_read + 1), - ", column ", std::to_string(pos.chars_read_current_line)); - } -}; - -/// @brief exception indicating errors with iterators -/// @sa https://json.nlohmann.me/api/basic_json/invalid_iterator/ -class invalid_iterator : public exception -{ - public: - template::value, int> = 0> - static invalid_iterator create(int id_, const std::string& what_arg, BasicJsonContext context) - { - const std::string w = concat(exception::name("invalid_iterator", id_), exception::diagnostics(context), what_arg); - return {id_, w.c_str()}; - } - - private: - JSON_HEDLEY_NON_NULL(3) - invalid_iterator(int id_, const char* what_arg) - : exception(id_, what_arg) {} -}; - -/// @brief exception indicating executing a member function with a wrong type -/// @sa https://json.nlohmann.me/api/basic_json/type_error/ -class type_error : public exception -{ - public: - template::value, int> = 0> - static type_error create(int id_, const std::string& what_arg, BasicJsonContext context) - { - const std::string w = concat(exception::name("type_error", id_), exception::diagnostics(context), what_arg); - return {id_, w.c_str()}; - } - - private: - JSON_HEDLEY_NON_NULL(3) - type_error(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; - -/// @brief exception indicating access out of the defined range -/// @sa https://json.nlohmann.me/api/basic_json/out_of_range/ -class out_of_range : public exception -{ - public: - template::value, int> = 0> - static out_of_range create(int id_, const std::string& what_arg, BasicJsonContext context) - { - const std::string w = concat(exception::name("out_of_range", id_), exception::diagnostics(context), what_arg); - return {id_, w.c_str()}; - } - - private: - JSON_HEDLEY_NON_NULL(3) - out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; - -/// @brief exception indicating other library errors -/// @sa https://json.nlohmann.me/api/basic_json/other_error/ -class other_error : public exception -{ - public: - template::value, int> = 0> - static other_error create(int id_, const std::string& what_arg, BasicJsonContext context) - { - const std::string w = concat(exception::name("other_error", id_), exception::diagnostics(context), what_arg); - return {id_, w.c_str()}; - } - - private: - JSON_HEDLEY_NON_NULL(3) - other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/hash.hpp b/include/nlohmann/detail/hash.hpp deleted file mode 100644 index 3f05af8308..0000000000 --- a/include/nlohmann/detail/hash.hpp +++ /dev/null @@ -1,129 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // uint8_t -#include // size_t -#include // hash - -#include -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -// boost::hash_combine -inline std::size_t combine(std::size_t seed, std::size_t h) noexcept -{ - seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U); - return seed; -} - -/*! -@brief hash a JSON value - -The hash function tries to rely on std::hash where possible. Furthermore, the -type of the JSON value is taken into account to have different hash values for -null, 0, 0U, and false, etc. - -@tparam BasicJsonType basic_json specialization -@param j JSON value to hash -@return hash value of j -*/ -template -std::size_t hash(const BasicJsonType& j) -{ - using string_t = typename BasicJsonType::string_t; - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - - const auto type = static_cast(j.type()); - switch (j.type()) - { - case BasicJsonType::value_t::null: - case BasicJsonType::value_t::discarded: - { - return combine(type, 0); - } - - case BasicJsonType::value_t::object: - { - auto seed = combine(type, j.size()); - for (const auto& element : j.items()) - { - const auto h = std::hash {}(element.key()); - seed = combine(seed, h); - seed = combine(seed, hash(element.value())); - } - return seed; - } - - case BasicJsonType::value_t::array: - { - auto seed = combine(type, j.size()); - for (const auto& element : j) - { - seed = combine(seed, hash(element)); - } - return seed; - } - - case BasicJsonType::value_t::string: - { - const auto h = std::hash {}(j.template get_ref()); - return combine(type, h); - } - - case BasicJsonType::value_t::boolean: - { - const auto h = std::hash {}(j.template get()); - return combine(type, h); - } - - case BasicJsonType::value_t::number_integer: - { - const auto h = std::hash {}(j.template get()); - return combine(type, h); - } - - case BasicJsonType::value_t::number_unsigned: - { - const auto h = std::hash {}(j.template get()); - return combine(type, h); - } - - case BasicJsonType::value_t::number_float: - { - const auto h = std::hash {}(j.template get()); - return combine(type, h); - } - - case BasicJsonType::value_t::binary: - { - auto seed = combine(type, j.get_binary().size()); - const auto h = std::hash {}(j.get_binary().has_subtype()); - seed = combine(seed, h); - seed = combine(seed, static_cast(j.get_binary().subtype())); - for (const auto byte : j.get_binary()) - { - seed = combine(seed, std::hash {}(byte)); - } - return seed; - } - - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - return 0; // LCOV_EXCL_LINE - } -} - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/input/binary_reader.hpp b/include/nlohmann/detail/input/binary_reader.hpp deleted file mode 100644 index 832c36ddf8..0000000000 --- a/include/nlohmann/detail/input/binary_reader.hpp +++ /dev/null @@ -1,3010 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // generate_n -#include // array -#include // ldexp -#include // size_t -#include // uint8_t, uint16_t, uint32_t, uint64_t -#include // snprintf -#include // memcpy -#include // back_inserter -#include // numeric_limits -#include // char_traits, string -#include // make_pair, move -#include // vector - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -/// how to treat CBOR tags -enum class cbor_tag_handler_t -{ - error, ///< throw a parse_error exception in case of a tag - ignore, ///< ignore tags - store ///< store tags as binary type -}; - -/*! -@brief determine system byte order - -@return true if and only if system's byte order is little endian - -@note from https://stackoverflow.com/a/1001328/266378 -*/ -static inline bool little_endianness(int num = 1) noexcept -{ - return *reinterpret_cast(&num) == 1; -} - - -/////////////////// -// binary reader // -/////////////////// - -/*! -@brief deserialization of CBOR, MessagePack, and UBJSON values -*/ -template> -class binary_reader -{ - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - using json_sax_t = SAX; - using char_type = typename InputAdapterType::char_type; - using char_int_type = typename std::char_traits::int_type; - - public: - /*! - @brief create a binary reader - - @param[in] adapter input adapter to read from - */ - explicit binary_reader(InputAdapterType&& adapter, const input_format_t format = input_format_t::json) noexcept : ia(std::move(adapter)), input_format(format) - { - (void)detail::is_sax_static_asserts {}; - } - - // make class move-only - binary_reader(const binary_reader&) = delete; - binary_reader(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - binary_reader& operator=(const binary_reader&) = delete; - binary_reader& operator=(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - ~binary_reader() = default; - - /*! - @param[in] format the binary format to parse - @param[in] sax_ a SAX event processor - @param[in] strict whether to expect the input to be consumed completed - @param[in] tag_handler how to treat CBOR tags - - @return whether parsing was successful - */ - JSON_HEDLEY_NON_NULL(3) - bool sax_parse(const input_format_t format, - json_sax_t* sax_, - const bool strict = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) - { - sax = sax_; - bool result = false; - - switch (format) - { - case input_format_t::bson: - result = parse_bson_internal(); - break; - - case input_format_t::cbor: - result = parse_cbor_internal(true, tag_handler); - break; - - case input_format_t::msgpack: - result = parse_msgpack_internal(); - break; - - case input_format_t::ubjson: - case input_format_t::bjdata: - result = parse_ubjson_internal(); - break; - - case input_format_t::json: // LCOV_EXCL_LINE - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - } - - // strict mode: next byte must be EOF - if (result && strict) - { - if (input_format == input_format_t::ubjson || input_format == input_format_t::bjdata) - { - get_ignore_noop(); - } - else - { - get(); - } - - if (JSON_HEDLEY_UNLIKELY(current != std::char_traits::eof())) - { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read, - exception_message(input_format, concat("expected end of input; last byte: 0x", get_token_string()), "value"), nullptr)); - } - } - - return result; - } - - private: - ////////// - // BSON // - ////////// - - /*! - @brief Reads in a BSON-object and passes it to the SAX-parser. - @return whether a valid BSON-value was passed to the SAX parser - */ - bool parse_bson_internal() - { - std::int32_t document_size{}; - get_number(input_format_t::bson, document_size); - - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast(-1)))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/false))) - { - return false; - } - - return sax->end_object(); - } - - /*! - @brief Parses a C-style string from the BSON input. - @param[in,out] result A reference to the string variable where the read - string is to be stored. - @return `true` if the \x00-byte indicating the end of the string was - encountered before the EOF; false` indicates an unexpected EOF. - */ - bool get_bson_cstr(string_t& result) - { - auto out = std::back_inserter(result); - while (true) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson, "cstring"))) - { - return false; - } - if (current == 0x00) - { - return true; - } - *out++ = static_cast(current); - } - } - - /*! - @brief Parses a zero-terminated string of length @a len from the BSON - input. - @param[in] len The length (including the zero-byte at the end) of the - string to be read. - @param[in,out] result A reference to the string variable where the read - string is to be stored. - @tparam NumberType The type of the length @a len - @pre len >= 1 - @return `true` if the string was successfully parsed - */ - template - bool get_bson_string(const NumberType len, string_t& result) - { - if (JSON_HEDLEY_UNLIKELY(len < 1)) - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, - exception_message(input_format_t::bson, concat("string length must be at least 1, is ", std::to_string(len)), "string"), nullptr)); - } - - return get_string(input_format_t::bson, len - static_cast(1), result) && get() != std::char_traits::eof(); - } - - /*! - @brief Parses a byte array input of length @a len from the BSON input. - @param[in] len The length of the byte array to be read. - @param[in,out] result A reference to the binary variable where the read - array is to be stored. - @tparam NumberType The type of the length @a len - @pre len >= 0 - @return `true` if the byte array was successfully parsed - */ - template - bool get_bson_binary(const NumberType len, binary_t& result) - { - if (JSON_HEDLEY_UNLIKELY(len < 0)) - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, - exception_message(input_format_t::bson, concat("byte array length cannot be negative, is ", std::to_string(len)), "binary"), nullptr)); - } - - // All BSON binary values have a subtype - std::uint8_t subtype{}; - get_number(input_format_t::bson, subtype); - result.set_subtype(subtype); - - return get_binary(input_format_t::bson, len, result); - } - - /*! - @brief Read a BSON document element of the given @a element_type. - @param[in] element_type The BSON element type, c.f. http://bsonspec.org/spec.html - @param[in] element_type_parse_position The position in the input stream, - where the `element_type` was read. - @warning Not all BSON element types are supported yet. An unsupported - @a element_type will give rise to a parse_error.114: - Unsupported BSON record type 0x... - @return whether a valid BSON-object/array was passed to the SAX parser - */ - bool parse_bson_element_internal(const char_int_type element_type, - const std::size_t element_type_parse_position) - { - switch (element_type) - { - case 0x01: // double - { - double number{}; - return get_number(input_format_t::bson, number) && sax->number_float(static_cast(number), ""); - } - - case 0x02: // string - { - std::int32_t len{}; - string_t value; - return get_number(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value); - } - - case 0x03: // object - { - return parse_bson_internal(); - } - - case 0x04: // array - { - return parse_bson_array(); - } - - case 0x05: // binary - { - std::int32_t len{}; - binary_t value; - return get_number(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value); - } - - case 0x08: // boolean - { - return sax->boolean(get() != 0); - } - - case 0x0A: // null - { - return sax->null(); - } - - case 0x10: // int32 - { - std::int32_t value{}; - return get_number(input_format_t::bson, value) && sax->number_integer(value); - } - - case 0x12: // int64 - { - std::int64_t value{}; - return get_number(input_format_t::bson, value) && sax->number_integer(value); - } - - default: // anything else not supported (yet) - { - std::array cr{{}}; - static_cast((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(element_type))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - const std::string cr_str{cr.data()}; - return sax->parse_error(element_type_parse_position, cr_str, - parse_error::create(114, element_type_parse_position, concat("Unsupported BSON record type 0x", cr_str), nullptr)); - } - } - } - - /*! - @brief Read a BSON element list (as specified in the BSON-spec) - - The same binary layout is used for objects and arrays, hence it must be - indicated with the argument @a is_array which one is expected - (true --> array, false --> object). - - @param[in] is_array Determines if the element list being read is to be - treated as an object (@a is_array == false), or as an - array (@a is_array == true). - @return whether a valid BSON-object/array was passed to the SAX parser - */ - bool parse_bson_element_list(const bool is_array) - { - string_t key; - - while (auto element_type = get()) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson, "element list"))) - { - return false; - } - - const std::size_t element_type_parse_position = chars_read; - if (JSON_HEDLEY_UNLIKELY(!get_bson_cstr(key))) - { - return false; - } - - if (!is_array && !sax->key(key)) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position))) - { - return false; - } - - // get_bson_cstr only appends - key.clear(); - } - - return true; - } - - /*! - @brief Reads an array from the BSON input and passes it to the SAX-parser. - @return whether a valid BSON-array was passed to the SAX parser - */ - bool parse_bson_array() - { - std::int32_t document_size{}; - get_number(input_format_t::bson, document_size); - - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast(-1)))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/true))) - { - return false; - } - - return sax->end_array(); - } - - ////////// - // CBOR // - ////////// - - /*! - @param[in] get_char whether a new character should be retrieved from the - input (true) or whether the last read character should - be considered instead (false) - @param[in] tag_handler how CBOR tags should be treated - - @return whether a valid CBOR value was passed to the SAX parser - */ - bool parse_cbor_internal(const bool get_char, - const cbor_tag_handler_t tag_handler) - { - switch (get_char ? get() : current) - { - // EOF - case std::char_traits::eof(): - return unexpect_eof(input_format_t::cbor, "value"); - - // Integer 0x00..0x17 (0..23) - case 0x00: - case 0x01: - case 0x02: - case 0x03: - case 0x04: - case 0x05: - case 0x06: - case 0x07: - case 0x08: - case 0x09: - case 0x0A: - case 0x0B: - case 0x0C: - case 0x0D: - case 0x0E: - case 0x0F: - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - return sax->number_unsigned(static_cast(current)); - - case 0x18: // Unsigned integer (one-byte uint8_t follows) - { - std::uint8_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); - } - - case 0x19: // Unsigned integer (two-byte uint16_t follows) - { - std::uint16_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); - } - - case 0x1A: // Unsigned integer (four-byte uint32_t follows) - { - std::uint32_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); - } - - case 0x1B: // Unsigned integer (eight-byte uint64_t follows) - { - std::uint64_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); - } - - // Negative integer -1-0x00..-1-0x17 (-1..-24) - case 0x20: - case 0x21: - case 0x22: - case 0x23: - case 0x24: - case 0x25: - case 0x26: - case 0x27: - case 0x28: - case 0x29: - case 0x2A: - case 0x2B: - case 0x2C: - case 0x2D: - case 0x2E: - case 0x2F: - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - case 0x36: - case 0x37: - return sax->number_integer(static_cast(0x20 - 1 - current)); - - case 0x38: // Negative integer (one-byte uint8_t follows) - { - std::uint8_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); - } - - case 0x39: // Negative integer -1-n (two-byte uint16_t follows) - { - std::uint16_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); - } - - case 0x3A: // Negative integer -1-n (four-byte uint32_t follows) - { - std::uint32_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); - } - - case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows) - { - std::uint64_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - - static_cast(number)); - } - - // Binary data (0x00..0x17 bytes follow) - case 0x40: - case 0x41: - case 0x42: - case 0x43: - case 0x44: - case 0x45: - case 0x46: - case 0x47: - case 0x48: - case 0x49: - case 0x4A: - case 0x4B: - case 0x4C: - case 0x4D: - case 0x4E: - case 0x4F: - case 0x50: - case 0x51: - case 0x52: - case 0x53: - case 0x54: - case 0x55: - case 0x56: - case 0x57: - case 0x58: // Binary data (one-byte uint8_t for n follows) - case 0x59: // Binary data (two-byte uint16_t for n follow) - case 0x5A: // Binary data (four-byte uint32_t for n follow) - case 0x5B: // Binary data (eight-byte uint64_t for n follow) - case 0x5F: // Binary data (indefinite length) - { - binary_t b; - return get_cbor_binary(b) && sax->binary(b); - } - - // UTF-8 string (0x00..0x17 bytes follow) - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - case 0x68: - case 0x69: - case 0x6A: - case 0x6B: - case 0x6C: - case 0x6D: - case 0x6E: - case 0x6F: - case 0x70: - case 0x71: - case 0x72: - case 0x73: - case 0x74: - case 0x75: - case 0x76: - case 0x77: - case 0x78: // UTF-8 string (one-byte uint8_t for n follows) - case 0x79: // UTF-8 string (two-byte uint16_t for n follow) - case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) - case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) - case 0x7F: // UTF-8 string (indefinite length) - { - string_t s; - return get_cbor_string(s) && sax->string(s); - } - - // array (0x00..0x17 data items follow) - case 0x80: - case 0x81: - case 0x82: - case 0x83: - case 0x84: - case 0x85: - case 0x86: - case 0x87: - case 0x88: - case 0x89: - case 0x8A: - case 0x8B: - case 0x8C: - case 0x8D: - case 0x8E: - case 0x8F: - case 0x90: - case 0x91: - case 0x92: - case 0x93: - case 0x94: - case 0x95: - case 0x96: - case 0x97: - return get_cbor_array( - conditional_static_cast(static_cast(current) & 0x1Fu), tag_handler); - - case 0x98: // array (one-byte uint8_t for n follows) - { - std::uint8_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); - } - - case 0x99: // array (two-byte uint16_t for n follow) - { - std::uint16_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); - } - - case 0x9A: // array (four-byte uint32_t for n follow) - { - std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast(len), tag_handler); - } - - case 0x9B: // array (eight-byte uint64_t for n follow) - { - std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast(len), tag_handler); - } - - case 0x9F: // array (indefinite length) - return get_cbor_array(static_cast(-1), tag_handler); - - // map (0x00..0x17 pairs of data items follow) - case 0xA0: - case 0xA1: - case 0xA2: - case 0xA3: - case 0xA4: - case 0xA5: - case 0xA6: - case 0xA7: - case 0xA8: - case 0xA9: - case 0xAA: - case 0xAB: - case 0xAC: - case 0xAD: - case 0xAE: - case 0xAF: - case 0xB0: - case 0xB1: - case 0xB2: - case 0xB3: - case 0xB4: - case 0xB5: - case 0xB6: - case 0xB7: - return get_cbor_object(conditional_static_cast(static_cast(current) & 0x1Fu), tag_handler); - - case 0xB8: // map (one-byte uint8_t for n follows) - { - std::uint8_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); - } - - case 0xB9: // map (two-byte uint16_t for n follow) - { - std::uint16_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); - } - - case 0xBA: // map (four-byte uint32_t for n follow) - { - std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast(len), tag_handler); - } - - case 0xBB: // map (eight-byte uint64_t for n follow) - { - std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast(len), tag_handler); - } - - case 0xBF: // map (indefinite length) - return get_cbor_object(static_cast(-1), tag_handler); - - case 0xC6: // tagged item - case 0xC7: - case 0xC8: - case 0xC9: - case 0xCA: - case 0xCB: - case 0xCC: - case 0xCD: - case 0xCE: - case 0xCF: - case 0xD0: - case 0xD1: - case 0xD2: - case 0xD3: - case 0xD4: - case 0xD8: // tagged item (1 bytes follow) - case 0xD9: // tagged item (2 bytes follow) - case 0xDA: // tagged item (4 bytes follow) - case 0xDB: // tagged item (8 bytes follow) - { - switch (tag_handler) - { - case cbor_tag_handler_t::error: - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, - exception_message(input_format_t::cbor, concat("invalid byte: 0x", last_token), "value"), nullptr)); - } - - case cbor_tag_handler_t::ignore: - { - // ignore binary subtype - switch (current) - { - case 0xD8: - { - std::uint8_t subtype_to_ignore{}; - get_number(input_format_t::cbor, subtype_to_ignore); - break; - } - case 0xD9: - { - std::uint16_t subtype_to_ignore{}; - get_number(input_format_t::cbor, subtype_to_ignore); - break; - } - case 0xDA: - { - std::uint32_t subtype_to_ignore{}; - get_number(input_format_t::cbor, subtype_to_ignore); - break; - } - case 0xDB: - { - std::uint64_t subtype_to_ignore{}; - get_number(input_format_t::cbor, subtype_to_ignore); - break; - } - default: - break; - } - return parse_cbor_internal(true, tag_handler); - } - - case cbor_tag_handler_t::store: - { - binary_t b; - // use binary subtype and store in binary container - switch (current) - { - case 0xD8: - { - std::uint8_t subtype{}; - get_number(input_format_t::cbor, subtype); - b.set_subtype(detail::conditional_static_cast(subtype)); - break; - } - case 0xD9: - { - std::uint16_t subtype{}; - get_number(input_format_t::cbor, subtype); - b.set_subtype(detail::conditional_static_cast(subtype)); - break; - } - case 0xDA: - { - std::uint32_t subtype{}; - get_number(input_format_t::cbor, subtype); - b.set_subtype(detail::conditional_static_cast(subtype)); - break; - } - case 0xDB: - { - std::uint64_t subtype{}; - get_number(input_format_t::cbor, subtype); - b.set_subtype(detail::conditional_static_cast(subtype)); - break; - } - default: - return parse_cbor_internal(true, tag_handler); - } - get(); - return get_cbor_binary(b) && sax->binary(b); - } - - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - return false; // LCOV_EXCL_LINE - } - } - - case 0xF4: // false - return sax->boolean(false); - - case 0xF5: // true - return sax->boolean(true); - - case 0xF6: // null - return sax->null(); - - case 0xF9: // Half-Precision Float (two-byte IEEE 754) - { - const auto byte1_raw = get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number"))) - { - return false; - } - const auto byte2_raw = get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number"))) - { - return false; - } - - const auto byte1 = static_cast(byte1_raw); - const auto byte2 = static_cast(byte2_raw); - - // code from RFC 7049, Appendix D, Figure 3: - // As half-precision floating-point numbers were only added - // to IEEE 754 in 2008, today's programming platforms often - // still only have limited support for them. It is very - // easy to include at least decoding support for them even - // without such support. An example of a small decoder for - // half-precision floating-point numbers in the C language - // is shown in Fig. 3. - const auto half = static_cast((byte1 << 8u) + byte2); - const double val = [&half] - { - const int exp = (half >> 10u) & 0x1Fu; - const unsigned int mant = half & 0x3FFu; - JSON_ASSERT(0 <= exp&& exp <= 32); - JSON_ASSERT(mant <= 1024); - switch (exp) - { - case 0: - return std::ldexp(mant, -24); - case 31: - return (mant == 0) - ? std::numeric_limits::infinity() - : std::numeric_limits::quiet_NaN(); - default: - return std::ldexp(mant + 1024, exp - 25); - } - }(); - return sax->number_float((half & 0x8000u) != 0 - ? static_cast(-val) - : static_cast(val), ""); - } - - case 0xFA: // Single-Precision Float (four-byte IEEE 754) - { - float number{}; - return get_number(input_format_t::cbor, number) && sax->number_float(static_cast(number), ""); - } - - case 0xFB: // Double-Precision Float (eight-byte IEEE 754) - { - double number{}; - return get_number(input_format_t::cbor, number) && sax->number_float(static_cast(number), ""); - } - - default: // anything else (0xFF is handled inside the other types) - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, - exception_message(input_format_t::cbor, concat("invalid byte: 0x", last_token), "value"), nullptr)); - } - } - } - - /*! - @brief reads a CBOR string - - This function first reads starting bytes to determine the expected - string length and then copies this number of bytes into a string. - Additionally, CBOR's strings with indefinite lengths are supported. - - @param[out] result created string - - @return whether string creation completed - */ - bool get_cbor_string(string_t& result) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "string"))) - { - return false; - } - - switch (current) - { - // UTF-8 string (0x00..0x17 bytes follow) - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - case 0x68: - case 0x69: - case 0x6A: - case 0x6B: - case 0x6C: - case 0x6D: - case 0x6E: - case 0x6F: - case 0x70: - case 0x71: - case 0x72: - case 0x73: - case 0x74: - case 0x75: - case 0x76: - case 0x77: - { - return get_string(input_format_t::cbor, static_cast(current) & 0x1Fu, result); - } - - case 0x78: // UTF-8 string (one-byte uint8_t for n follows) - { - std::uint8_t len{}; - return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); - } - - case 0x79: // UTF-8 string (two-byte uint16_t for n follow) - { - std::uint16_t len{}; - return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); - } - - case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) - { - std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); - } - - case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) - { - std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); - } - - case 0x7F: // UTF-8 string (indefinite length) - { - while (get() != 0xFF) - { - string_t chunk; - if (!get_cbor_string(chunk)) - { - return false; - } - result.append(chunk); - } - return true; - } - - default: - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, - exception_message(input_format_t::cbor, concat("expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token), "string"), nullptr)); - } - } - } - - /*! - @brief reads a CBOR byte array - - This function first reads starting bytes to determine the expected - byte array length and then copies this number of bytes into the byte array. - Additionally, CBOR's byte arrays with indefinite lengths are supported. - - @param[out] result created byte array - - @return whether byte array creation completed - */ - bool get_cbor_binary(binary_t& result) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "binary"))) - { - return false; - } - - switch (current) - { - // Binary data (0x00..0x17 bytes follow) - case 0x40: - case 0x41: - case 0x42: - case 0x43: - case 0x44: - case 0x45: - case 0x46: - case 0x47: - case 0x48: - case 0x49: - case 0x4A: - case 0x4B: - case 0x4C: - case 0x4D: - case 0x4E: - case 0x4F: - case 0x50: - case 0x51: - case 0x52: - case 0x53: - case 0x54: - case 0x55: - case 0x56: - case 0x57: - { - return get_binary(input_format_t::cbor, static_cast(current) & 0x1Fu, result); - } - - case 0x58: // Binary data (one-byte uint8_t for n follows) - { - std::uint8_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); - } - - case 0x59: // Binary data (two-byte uint16_t for n follow) - { - std::uint16_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); - } - - case 0x5A: // Binary data (four-byte uint32_t for n follow) - { - std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); - } - - case 0x5B: // Binary data (eight-byte uint64_t for n follow) - { - std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); - } - - case 0x5F: // Binary data (indefinite length) - { - while (get() != 0xFF) - { - binary_t chunk; - if (!get_cbor_binary(chunk)) - { - return false; - } - result.insert(result.end(), chunk.begin(), chunk.end()); - } - return true; - } - - default: - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, - exception_message(input_format_t::cbor, concat("expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token), "binary"), nullptr)); - } - } - } - - /*! - @param[in] len the length of the array or static_cast(-1) for an - array of indefinite size - @param[in] tag_handler how CBOR tags should be treated - @return whether array creation completed - */ - bool get_cbor_array(const std::size_t len, - const cbor_tag_handler_t tag_handler) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len))) - { - return false; - } - - if (len != static_cast(-1)) - { - for (std::size_t i = 0; i < len; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) - { - return false; - } - } - } - else - { - while (get() != 0xFF) - { - if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(false, tag_handler))) - { - return false; - } - } - } - - return sax->end_array(); - } - - /*! - @param[in] len the length of the object or static_cast(-1) for an - object of indefinite size - @param[in] tag_handler how CBOR tags should be treated - @return whether object creation completed - */ - bool get_cbor_object(const std::size_t len, - const cbor_tag_handler_t tag_handler) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len))) - { - return false; - } - - if (len != 0) - { - string_t key; - if (len != static_cast(-1)) - { - for (std::size_t i = 0; i < len; ++i) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) - { - return false; - } - key.clear(); - } - } - else - { - while (get() != 0xFF) - { - if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) - { - return false; - } - key.clear(); - } - } - } - - return sax->end_object(); - } - - ///////////// - // MsgPack // - ///////////// - - /*! - @return whether a valid MessagePack value was passed to the SAX parser - */ - bool parse_msgpack_internal() - { - switch (get()) - { - // EOF - case std::char_traits::eof(): - return unexpect_eof(input_format_t::msgpack, "value"); - - // positive fixint - case 0x00: - case 0x01: - case 0x02: - case 0x03: - case 0x04: - case 0x05: - case 0x06: - case 0x07: - case 0x08: - case 0x09: - case 0x0A: - case 0x0B: - case 0x0C: - case 0x0D: - case 0x0E: - case 0x0F: - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - case 0x18: - case 0x19: - case 0x1A: - case 0x1B: - case 0x1C: - case 0x1D: - case 0x1E: - case 0x1F: - case 0x20: - case 0x21: - case 0x22: - case 0x23: - case 0x24: - case 0x25: - case 0x26: - case 0x27: - case 0x28: - case 0x29: - case 0x2A: - case 0x2B: - case 0x2C: - case 0x2D: - case 0x2E: - case 0x2F: - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - case 0x36: - case 0x37: - case 0x38: - case 0x39: - case 0x3A: - case 0x3B: - case 0x3C: - case 0x3D: - case 0x3E: - case 0x3F: - case 0x40: - case 0x41: - case 0x42: - case 0x43: - case 0x44: - case 0x45: - case 0x46: - case 0x47: - case 0x48: - case 0x49: - case 0x4A: - case 0x4B: - case 0x4C: - case 0x4D: - case 0x4E: - case 0x4F: - case 0x50: - case 0x51: - case 0x52: - case 0x53: - case 0x54: - case 0x55: - case 0x56: - case 0x57: - case 0x58: - case 0x59: - case 0x5A: - case 0x5B: - case 0x5C: - case 0x5D: - case 0x5E: - case 0x5F: - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - case 0x68: - case 0x69: - case 0x6A: - case 0x6B: - case 0x6C: - case 0x6D: - case 0x6E: - case 0x6F: - case 0x70: - case 0x71: - case 0x72: - case 0x73: - case 0x74: - case 0x75: - case 0x76: - case 0x77: - case 0x78: - case 0x79: - case 0x7A: - case 0x7B: - case 0x7C: - case 0x7D: - case 0x7E: - case 0x7F: - return sax->number_unsigned(static_cast(current)); - - // fixmap - case 0x80: - case 0x81: - case 0x82: - case 0x83: - case 0x84: - case 0x85: - case 0x86: - case 0x87: - case 0x88: - case 0x89: - case 0x8A: - case 0x8B: - case 0x8C: - case 0x8D: - case 0x8E: - case 0x8F: - return get_msgpack_object(conditional_static_cast(static_cast(current) & 0x0Fu)); - - // fixarray - case 0x90: - case 0x91: - case 0x92: - case 0x93: - case 0x94: - case 0x95: - case 0x96: - case 0x97: - case 0x98: - case 0x99: - case 0x9A: - case 0x9B: - case 0x9C: - case 0x9D: - case 0x9E: - case 0x9F: - return get_msgpack_array(conditional_static_cast(static_cast(current) & 0x0Fu)); - - // fixstr - case 0xA0: - case 0xA1: - case 0xA2: - case 0xA3: - case 0xA4: - case 0xA5: - case 0xA6: - case 0xA7: - case 0xA8: - case 0xA9: - case 0xAA: - case 0xAB: - case 0xAC: - case 0xAD: - case 0xAE: - case 0xAF: - case 0xB0: - case 0xB1: - case 0xB2: - case 0xB3: - case 0xB4: - case 0xB5: - case 0xB6: - case 0xB7: - case 0xB8: - case 0xB9: - case 0xBA: - case 0xBB: - case 0xBC: - case 0xBD: - case 0xBE: - case 0xBF: - case 0xD9: // str 8 - case 0xDA: // str 16 - case 0xDB: // str 32 - { - string_t s; - return get_msgpack_string(s) && sax->string(s); - } - - case 0xC0: // nil - return sax->null(); - - case 0xC2: // false - return sax->boolean(false); - - case 0xC3: // true - return sax->boolean(true); - - case 0xC4: // bin 8 - case 0xC5: // bin 16 - case 0xC6: // bin 32 - case 0xC7: // ext 8 - case 0xC8: // ext 16 - case 0xC9: // ext 32 - case 0xD4: // fixext 1 - case 0xD5: // fixext 2 - case 0xD6: // fixext 4 - case 0xD7: // fixext 8 - case 0xD8: // fixext 16 - { - binary_t b; - return get_msgpack_binary(b) && sax->binary(b); - } - - case 0xCA: // float 32 - { - float number{}; - return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast(number), ""); - } - - case 0xCB: // float 64 - { - double number{}; - return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast(number), ""); - } - - case 0xCC: // uint 8 - { - std::uint8_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); - } - - case 0xCD: // uint 16 - { - std::uint16_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); - } - - case 0xCE: // uint 32 - { - std::uint32_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); - } - - case 0xCF: // uint 64 - { - std::uint64_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); - } - - case 0xD0: // int 8 - { - std::int8_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_integer(number); - } - - case 0xD1: // int 16 - { - std::int16_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_integer(number); - } - - case 0xD2: // int 32 - { - std::int32_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_integer(number); - } - - case 0xD3: // int 64 - { - std::int64_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_integer(number); - } - - case 0xDC: // array 16 - { - std::uint16_t len{}; - return get_number(input_format_t::msgpack, len) && get_msgpack_array(static_cast(len)); - } - - case 0xDD: // array 32 - { - std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast(len)); - } - - case 0xDE: // map 16 - { - std::uint16_t len{}; - return get_number(input_format_t::msgpack, len) && get_msgpack_object(static_cast(len)); - } - - case 0xDF: // map 32 - { - std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast(len)); - } - - // negative fixint - case 0xE0: - case 0xE1: - case 0xE2: - case 0xE3: - case 0xE4: - case 0xE5: - case 0xE6: - case 0xE7: - case 0xE8: - case 0xE9: - case 0xEA: - case 0xEB: - case 0xEC: - case 0xED: - case 0xEE: - case 0xEF: - case 0xF0: - case 0xF1: - case 0xF2: - case 0xF3: - case 0xF4: - case 0xF5: - case 0xF6: - case 0xF7: - case 0xF8: - case 0xF9: - case 0xFA: - case 0xFB: - case 0xFC: - case 0xFD: - case 0xFE: - case 0xFF: - return sax->number_integer(static_cast(current)); - - default: // anything else - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, - exception_message(input_format_t::msgpack, concat("invalid byte: 0x", last_token), "value"), nullptr)); - } - } - } - - /*! - @brief reads a MessagePack string - - This function first reads starting bytes to determine the expected - string length and then copies this number of bytes into a string. - - @param[out] result created string - - @return whether string creation completed - */ - bool get_msgpack_string(string_t& result) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::msgpack, "string"))) - { - return false; - } - - switch (current) - { - // fixstr - case 0xA0: - case 0xA1: - case 0xA2: - case 0xA3: - case 0xA4: - case 0xA5: - case 0xA6: - case 0xA7: - case 0xA8: - case 0xA9: - case 0xAA: - case 0xAB: - case 0xAC: - case 0xAD: - case 0xAE: - case 0xAF: - case 0xB0: - case 0xB1: - case 0xB2: - case 0xB3: - case 0xB4: - case 0xB5: - case 0xB6: - case 0xB7: - case 0xB8: - case 0xB9: - case 0xBA: - case 0xBB: - case 0xBC: - case 0xBD: - case 0xBE: - case 0xBF: - { - return get_string(input_format_t::msgpack, static_cast(current) & 0x1Fu, result); - } - - case 0xD9: // str 8 - { - std::uint8_t len{}; - return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); - } - - case 0xDA: // str 16 - { - std::uint16_t len{}; - return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); - } - - case 0xDB: // str 32 - { - std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); - } - - default: - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, - exception_message(input_format_t::msgpack, concat("expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token), "string"), nullptr)); - } - } - } - - /*! - @brief reads a MessagePack byte array - - This function first reads starting bytes to determine the expected - byte array length and then copies this number of bytes into a byte array. - - @param[out] result created byte array - - @return whether byte array creation completed - */ - bool get_msgpack_binary(binary_t& result) - { - // helper function to set the subtype - auto assign_and_return_true = [&result](std::int8_t subtype) - { - result.set_subtype(static_cast(subtype)); - return true; - }; - - switch (current) - { - case 0xC4: // bin 8 - { - std::uint8_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); - } - - case 0xC5: // bin 16 - { - std::uint16_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); - } - - case 0xC6: // bin 32 - { - std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); - } - - case 0xC7: // ext 8 - { - std::uint8_t len{}; - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); - } - - case 0xC8: // ext 16 - { - std::uint16_t len{}; - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); - } - - case 0xC9: // ext 32 - { - std::uint32_t len{}; - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); - } - - case 0xD4: // fixext 1 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 1, result) && - assign_and_return_true(subtype); - } - - case 0xD5: // fixext 2 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 2, result) && - assign_and_return_true(subtype); - } - - case 0xD6: // fixext 4 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 4, result) && - assign_and_return_true(subtype); - } - - case 0xD7: // fixext 8 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 8, result) && - assign_and_return_true(subtype); - } - - case 0xD8: // fixext 16 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 16, result) && - assign_and_return_true(subtype); - } - - default: // LCOV_EXCL_LINE - return false; // LCOV_EXCL_LINE - } - } - - /*! - @param[in] len the length of the array - @return whether array creation completed - */ - bool get_msgpack_array(const std::size_t len) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len))) - { - return false; - } - - for (std::size_t i = 0; i < len; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!parse_msgpack_internal())) - { - return false; - } - } - - return sax->end_array(); - } - - /*! - @param[in] len the length of the object - @return whether object creation completed - */ - bool get_msgpack_object(const std::size_t len) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len))) - { - return false; - } - - string_t key; - for (std::size_t i = 0; i < len; ++i) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!get_msgpack_string(key) || !sax->key(key))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_msgpack_internal())) - { - return false; - } - key.clear(); - } - - return sax->end_object(); - } - - //////////// - // UBJSON // - //////////// - - /*! - @param[in] get_char whether a new character should be retrieved from the - input (true, default) or whether the last read - character should be considered instead - - @return whether a valid UBJSON value was passed to the SAX parser - */ - bool parse_ubjson_internal(const bool get_char = true) - { - return get_ubjson_value(get_char ? get_ignore_noop() : current); - } - - /*! - @brief reads a UBJSON string - - This function is either called after reading the 'S' byte explicitly - indicating a string, or in case of an object key where the 'S' byte can be - left out. - - @param[out] result created string - @param[in] get_char whether a new character should be retrieved from the - input (true, default) or whether the last read - character should be considered instead - - @return whether string creation completed - */ - bool get_ubjson_string(string_t& result, const bool get_char = true) - { - if (get_char) - { - get(); // TODO(niels): may we ignore N here? - } - - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "value"))) - { - return false; - } - - switch (current) - { - case 'U': - { - std::uint8_t len{}; - return get_number(input_format, len) && get_string(input_format, len, result); - } - - case 'i': - { - std::int8_t len{}; - return get_number(input_format, len) && get_string(input_format, len, result); - } - - case 'I': - { - std::int16_t len{}; - return get_number(input_format, len) && get_string(input_format, len, result); - } - - case 'l': - { - std::int32_t len{}; - return get_number(input_format, len) && get_string(input_format, len, result); - } - - case 'L': - { - std::int64_t len{}; - return get_number(input_format, len) && get_string(input_format, len, result); - } - - case 'u': - { - if (input_format != input_format_t::bjdata) - { - break; - } - std::uint16_t len{}; - return get_number(input_format, len) && get_string(input_format, len, result); - } - - case 'm': - { - if (input_format != input_format_t::bjdata) - { - break; - } - std::uint32_t len{}; - return get_number(input_format, len) && get_string(input_format, len, result); - } - - case 'M': - { - if (input_format != input_format_t::bjdata) - { - break; - } - std::uint64_t len{}; - return get_number(input_format, len) && get_string(input_format, len, result); - } - - default: - break; - } - auto last_token = get_token_string(); - std::string message; - - if (input_format != input_format_t::bjdata) - { - message = "expected length type specification (U, i, I, l, L); last byte: 0x" + last_token; - } - else - { - message = "expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token; - } - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message, "string"), nullptr)); - } - - /*! - @param[out] dim an integer vector storing the ND array dimensions - @return whether reading ND array size vector is successful - */ - bool get_ubjson_ndarray_size(std::vector& dim) - { - std::pair size_and_type; - size_t dimlen = 0; - bool no_ndarray = true; - - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type, no_ndarray))) - { - return false; - } - - if (size_and_type.first != npos) - { - if (size_and_type.second != 0) - { - if (size_and_type.second != 'N') - { - for (std::size_t i = 0; i < size_and_type.first; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_value(dimlen, no_ndarray, size_and_type.second))) - { - return false; - } - dim.push_back(dimlen); - } - } - } - else - { - for (std::size_t i = 0; i < size_and_type.first; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_value(dimlen, no_ndarray))) - { - return false; - } - dim.push_back(dimlen); - } - } - } - else - { - while (current != ']') - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_value(dimlen, no_ndarray, current))) - { - return false; - } - dim.push_back(dimlen); - get_ignore_noop(); - } - } - return true; - } - - /*! - @param[out] result determined size - @param[in,out] is_ndarray for input, `true` means already inside an ndarray vector - or ndarray dimension is not allowed; `false` means ndarray - is allowed; for output, `true` means an ndarray is found; - is_ndarray can only return `true` when its initial value - is `false` - @param[in] prefix type marker if already read, otherwise set to 0 - - @return whether size determination completed - */ - bool get_ubjson_size_value(std::size_t& result, bool& is_ndarray, char_int_type prefix = 0) - { - if (prefix == 0) - { - prefix = get_ignore_noop(); - } - - switch (prefix) - { - case 'U': - { - std::uint8_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) - { - return false; - } - result = static_cast(number); - return true; - } - - case 'i': - { - std::int8_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) - { - return false; - } - if (number < 0) - { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, - exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); - } - result = static_cast(number); // NOLINT(bugprone-signed-char-misuse,cert-str34-c): number is not a char - return true; - } - - case 'I': - { - std::int16_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) - { - return false; - } - if (number < 0) - { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, - exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); - } - result = static_cast(number); - return true; - } - - case 'l': - { - std::int32_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) - { - return false; - } - if (number < 0) - { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, - exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); - } - result = static_cast(number); - return true; - } - - case 'L': - { - std::int64_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) - { - return false; - } - if (number < 0) - { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, - exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); - } - if (!value_in_range_of(number)) - { - return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, - exception_message(input_format, "integer value overflow", "size"), nullptr)); - } - result = static_cast(number); - return true; - } - - case 'u': - { - if (input_format != input_format_t::bjdata) - { - break; - } - std::uint16_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) - { - return false; - } - result = static_cast(number); - return true; - } - - case 'm': - { - if (input_format != input_format_t::bjdata) - { - break; - } - std::uint32_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) - { - return false; - } - result = conditional_static_cast(number); - return true; - } - - case 'M': - { - if (input_format != input_format_t::bjdata) - { - break; - } - std::uint64_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format, number))) - { - return false; - } - if (!value_in_range_of(number)) - { - return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, - exception_message(input_format, "integer value overflow", "size"), nullptr)); - } - result = detail::conditional_static_cast(number); - return true; - } - - case '[': - { - if (input_format != input_format_t::bjdata) - { - break; - } - if (is_ndarray) // ndarray dimensional vector can only contain integers, and can not embed another array - { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "ndarray dimensional vector is not allowed", "size"), nullptr)); - } - std::vector dim; - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_ndarray_size(dim))) - { - return false; - } - if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1)) // return normal array size if 1D row vector - { - result = dim.at(dim.size() - 1); - return true; - } - if (!dim.empty()) // if ndarray, convert to an object in JData annotated array format - { - for (auto i : dim) // test if any dimension in an ndarray is 0, if so, return a 1D empty container - { - if ( i == 0 ) - { - result = 0; - return true; - } - } - - string_t key = "_ArraySize_"; - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(3) || !sax->key(key) || !sax->start_array(dim.size()))) - { - return false; - } - result = 1; - for (auto i : dim) - { - result *= i; - if (result == 0 || result == npos) // because dim elements shall not have zeros, result = 0 means overflow happened; it also can't be npos as it is used to initialize size in get_ubjson_size_type() - { - return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format, "excessive ndarray size caused overflow", "size"), nullptr)); - } - if (JSON_HEDLEY_UNLIKELY(!sax->number_unsigned(static_cast(i)))) - { - return false; - } - } - is_ndarray = true; - return sax->end_array(); - } - result = 0; - return true; - } - - default: - break; - } - auto last_token = get_token_string(); - std::string message; - - if (input_format != input_format_t::bjdata) - { - message = "expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token; - } - else - { - message = "expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token; - } - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message, "size"), nullptr)); - } - - /*! - @brief determine the type and size for a container - - In the optimized UBJSON format, a type and a size can be provided to allow - for a more compact representation. - - @param[out] result pair of the size and the type - @param[in] inside_ndarray whether the parser is parsing an ND array dimensional vector - - @return whether pair creation completed - */ - bool get_ubjson_size_type(std::pair& result, bool inside_ndarray = false) - { - result.first = npos; // size - result.second = 0; // type - bool is_ndarray = false; - - get_ignore_noop(); - - if (current == '$') - { - result.second = get(); // must not ignore 'N', because 'N' maybe the type - if (input_format == input_format_t::bjdata - && JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second))) - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, - exception_message(input_format, concat("marker 0x", last_token, " is not a permitted optimized array type"), "type"), nullptr)); - } - - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "type"))) - { - return false; - } - - get_ignore_noop(); - if (JSON_HEDLEY_UNLIKELY(current != '#')) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "value"))) - { - return false; - } - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, - exception_message(input_format, concat("expected '#' after type information; last byte: 0x", last_token), "size"), nullptr)); - } - - const bool is_error = get_ubjson_size_value(result.first, is_ndarray); - if (input_format == input_format_t::bjdata && is_ndarray) - { - if (inside_ndarray) - { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read, - exception_message(input_format, "ndarray can not be recursive", "size"), nullptr)); - } - result.second |= (1 << 8); // use bit 8 to indicate ndarray, all UBJSON and BJData markers should be ASCII letters - } - return is_error; - } - - if (current == '#') - { - const bool is_error = get_ubjson_size_value(result.first, is_ndarray); - if (input_format == input_format_t::bjdata && is_ndarray) - { - return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read, - exception_message(input_format, "ndarray requires both type and size", "size"), nullptr)); - } - return is_error; - } - - return true; - } - - /*! - @param prefix the previously read or set type prefix - @return whether value creation completed - */ - bool get_ubjson_value(const char_int_type prefix) - { - switch (prefix) - { - case std::char_traits::eof(): // EOF - return unexpect_eof(input_format, "value"); - - case 'T': // true - return sax->boolean(true); - case 'F': // false - return sax->boolean(false); - - case 'Z': // null - return sax->null(); - - case 'U': - { - std::uint8_t number{}; - return get_number(input_format, number) && sax->number_unsigned(number); - } - - case 'i': - { - std::int8_t number{}; - return get_number(input_format, number) && sax->number_integer(number); - } - - case 'I': - { - std::int16_t number{}; - return get_number(input_format, number) && sax->number_integer(number); - } - - case 'l': - { - std::int32_t number{}; - return get_number(input_format, number) && sax->number_integer(number); - } - - case 'L': - { - std::int64_t number{}; - return get_number(input_format, number) && sax->number_integer(number); - } - - case 'u': - { - if (input_format != input_format_t::bjdata) - { - break; - } - std::uint16_t number{}; - return get_number(input_format, number) && sax->number_unsigned(number); - } - - case 'm': - { - if (input_format != input_format_t::bjdata) - { - break; - } - std::uint32_t number{}; - return get_number(input_format, number) && sax->number_unsigned(number); - } - - case 'M': - { - if (input_format != input_format_t::bjdata) - { - break; - } - std::uint64_t number{}; - return get_number(input_format, number) && sax->number_unsigned(number); - } - - case 'h': - { - if (input_format != input_format_t::bjdata) - { - break; - } - const auto byte1_raw = get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "number"))) - { - return false; - } - const auto byte2_raw = get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "number"))) - { - return false; - } - - const auto byte1 = static_cast(byte1_raw); - const auto byte2 = static_cast(byte2_raw); - - // code from RFC 7049, Appendix D, Figure 3: - // As half-precision floating-point numbers were only added - // to IEEE 754 in 2008, today's programming platforms often - // still only have limited support for them. It is very - // easy to include at least decoding support for them even - // without such support. An example of a small decoder for - // half-precision floating-point numbers in the C language - // is shown in Fig. 3. - const auto half = static_cast((byte2 << 8u) + byte1); - const double val = [&half] - { - const int exp = (half >> 10u) & 0x1Fu; - const unsigned int mant = half & 0x3FFu; - JSON_ASSERT(0 <= exp&& exp <= 32); - JSON_ASSERT(mant <= 1024); - switch (exp) - { - case 0: - return std::ldexp(mant, -24); - case 31: - return (mant == 0) - ? std::numeric_limits::infinity() - : std::numeric_limits::quiet_NaN(); - default: - return std::ldexp(mant + 1024, exp - 25); - } - }(); - return sax->number_float((half & 0x8000u) != 0 - ? static_cast(-val) - : static_cast(val), ""); - } - - case 'd': - { - float number{}; - return get_number(input_format, number) && sax->number_float(static_cast(number), ""); - } - - case 'D': - { - double number{}; - return get_number(input_format, number) && sax->number_float(static_cast(number), ""); - } - - case 'H': - { - return get_ubjson_high_precision_number(); - } - - case 'C': // char - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "char"))) - { - return false; - } - if (JSON_HEDLEY_UNLIKELY(current > 127)) - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, - exception_message(input_format, concat("byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token), "char"), nullptr)); - } - string_t s(1, static_cast(current)); - return sax->string(s); - } - - case 'S': // string - { - string_t s; - return get_ubjson_string(s) && sax->string(s); - } - - case '[': // array - return get_ubjson_array(); - - case '{': // object - return get_ubjson_object(); - - default: // anything else - break; - } - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format, "invalid byte: 0x" + last_token, "value"), nullptr)); - } - - /*! - @return whether array creation completed - */ - bool get_ubjson_array() - { - std::pair size_and_type; - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type))) - { - return false; - } - - // if bit-8 of size_and_type.second is set to 1, encode bjdata ndarray as an object in JData annotated array format (https://github.com/NeuroJSON/jdata): - // {"_ArrayType_" : "typeid", "_ArraySize_" : [n1, n2, ...], "_ArrayData_" : [v1, v2, ...]} - - if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0) - { - size_and_type.second &= ~(static_cast(1) << 8); // use bit 8 to indicate ndarray, here we remove the bit to restore the type marker - auto it = std::lower_bound(bjd_types_map.begin(), bjd_types_map.end(), size_and_type.second, [](const bjd_type & p, char_int_type t) - { - return p.first < t; - }); - string_t key = "_ArrayType_"; - if (JSON_HEDLEY_UNLIKELY(it == bjd_types_map.end() || it->first != size_and_type.second)) - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, - exception_message(input_format, "invalid byte: 0x" + last_token, "type"), nullptr)); - } - - string_t type = it->second; // sax->string() takes a reference - if (JSON_HEDLEY_UNLIKELY(!sax->key(key) || !sax->string(type))) - { - return false; - } - - if (size_and_type.second == 'C') - { - size_and_type.second = 'U'; - } - - key = "_ArrayData_"; - if (JSON_HEDLEY_UNLIKELY(!sax->key(key) || !sax->start_array(size_and_type.first) )) - { - return false; - } - - for (std::size_t i = 0; i < size_and_type.first; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second))) - { - return false; - } - } - - return (sax->end_array() && sax->end_object()); - } - - if (size_and_type.first != npos) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(size_and_type.first))) - { - return false; - } - - if (size_and_type.second != 0) - { - if (size_and_type.second != 'N') - { - for (std::size_t i = 0; i < size_and_type.first; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second))) - { - return false; - } - } - } - } - else - { - for (std::size_t i = 0; i < size_and_type.first; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) - { - return false; - } - } - } - } - else - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast(-1)))) - { - return false; - } - - while (current != ']') - { - if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal(false))) - { - return false; - } - get_ignore_noop(); - } - } - - return sax->end_array(); - } - - /*! - @return whether object creation completed - */ - bool get_ubjson_object() - { - std::pair size_and_type; - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type))) - { - return false; - } - - // do not accept ND-array size in objects in BJData - if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0) - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, - exception_message(input_format, "BJData object does not support ND-array size in optimized format", "object"), nullptr)); - } - - string_t key; - if (size_and_type.first != npos) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(size_and_type.first))) - { - return false; - } - - if (size_and_type.second != 0) - { - for (std::size_t i = 0; i < size_and_type.first; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key))) - { - return false; - } - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second))) - { - return false; - } - key.clear(); - } - } - else - { - for (std::size_t i = 0; i < size_and_type.first; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key))) - { - return false; - } - if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) - { - return false; - } - key.clear(); - } - } - } - else - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast(-1)))) - { - return false; - } - - while (current != '}') - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key, false) || !sax->key(key))) - { - return false; - } - if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) - { - return false; - } - get_ignore_noop(); - key.clear(); - } - } - - return sax->end_object(); - } - - // Note, no reader for UBJSON binary types is implemented because they do - // not exist - - bool get_ubjson_high_precision_number() - { - // get size of following number string - std::size_t size{}; - bool no_ndarray = true; - auto res = get_ubjson_size_value(size, no_ndarray); - if (JSON_HEDLEY_UNLIKELY(!res)) - { - return res; - } - - // get number string - std::vector number_vector; - for (std::size_t i = 0; i < size; ++i) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "number"))) - { - return false; - } - number_vector.push_back(static_cast(current)); - } - - // parse number string - using ia_type = decltype(detail::input_adapter(number_vector)); - auto number_lexer = detail::lexer(detail::input_adapter(number_vector), false); - const auto result_number = number_lexer.scan(); - const auto number_string = number_lexer.get_token_string(); - const auto result_remainder = number_lexer.scan(); - - using token_type = typename detail::lexer_base::token_type; - - if (JSON_HEDLEY_UNLIKELY(result_remainder != token_type::end_of_input)) - { - return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, - exception_message(input_format, concat("invalid number text: ", number_lexer.get_token_string()), "high-precision number"), nullptr)); - } - - switch (result_number) - { - case token_type::value_integer: - return sax->number_integer(number_lexer.get_number_integer()); - case token_type::value_unsigned: - return sax->number_unsigned(number_lexer.get_number_unsigned()); - case token_type::value_float: - return sax->number_float(number_lexer.get_number_float(), std::move(number_string)); - case token_type::uninitialized: - case token_type::literal_true: - case token_type::literal_false: - case token_type::literal_null: - case token_type::value_string: - case token_type::begin_array: - case token_type::begin_object: - case token_type::end_array: - case token_type::end_object: - case token_type::name_separator: - case token_type::value_separator: - case token_type::parse_error: - case token_type::end_of_input: - case token_type::literal_or_value: - default: - return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, - exception_message(input_format, concat("invalid number text: ", number_lexer.get_token_string()), "high-precision number"), nullptr)); - } - } - - /////////////////////// - // Utility functions // - /////////////////////// - - /*! - @brief get next character from the input - - This function provides the interface to the used input adapter. It does - not throw in case the input reached EOF, but returns a -'ve valued - `std::char_traits::eof()` in that case. - - @return character read from the input - */ - char_int_type get() - { - ++chars_read; - return current = ia.get_character(); - } - - /*! - @return character read from the input after ignoring all 'N' entries - */ - char_int_type get_ignore_noop() - { - do - { - get(); - } - while (current == 'N'); - - return current; - } - - /* - @brief read a number from the input - - @tparam NumberType the type of the number - @param[in] format the current format (for diagnostics) - @param[out] result number of type @a NumberType - - @return whether conversion completed - - @note This function needs to respect the system's endianness, because - bytes in CBOR, MessagePack, and UBJSON are stored in network order - (big endian) and therefore need reordering on little endian systems. - On the other hand, BSON and BJData use little endian and should reorder - on big endian systems. - */ - template - bool get_number(const input_format_t format, NumberType& result) - { - // step 1: read input into array with system's byte order - std::array vec{}; - for (std::size_t i = 0; i < sizeof(NumberType); ++i) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "number"))) - { - return false; - } - - // reverse byte order prior to conversion if necessary - if (is_little_endian != (InputIsLittleEndian || format == input_format_t::bjdata)) - { - vec[sizeof(NumberType) - i - 1] = static_cast(current); - } - else - { - vec[i] = static_cast(current); // LCOV_EXCL_LINE - } - } - - // step 2: convert array into number of type T and return - std::memcpy(&result, vec.data(), sizeof(NumberType)); - return true; - } - - /*! - @brief create a string by reading characters from the input - - @tparam NumberType the type of the number - @param[in] format the current format (for diagnostics) - @param[in] len number of characters to read - @param[out] result string created by reading @a len bytes - - @return whether string creation completed - - @note We can not reserve @a len bytes for the result, because @a len - may be too large. Usually, @ref unexpect_eof() detects the end of - the input before we run out of string memory. - */ - template - bool get_string(const input_format_t format, - const NumberType len, - string_t& result) - { - bool success = true; - for (NumberType i = 0; i < len; i++) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "string"))) - { - success = false; - break; - } - result.push_back(static_cast(current)); - } - return success; - } - - /*! - @brief create a byte array by reading bytes from the input - - @tparam NumberType the type of the number - @param[in] format the current format (for diagnostics) - @param[in] len number of bytes to read - @param[out] result byte array created by reading @a len bytes - - @return whether byte array creation completed - - @note We can not reserve @a len bytes for the result, because @a len - may be too large. Usually, @ref unexpect_eof() detects the end of - the input before we run out of memory. - */ - template - bool get_binary(const input_format_t format, - const NumberType len, - binary_t& result) - { - bool success = true; - for (NumberType i = 0; i < len; i++) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "binary"))) - { - success = false; - break; - } - result.push_back(static_cast(current)); - } - return success; - } - - /*! - @param[in] format the current format (for diagnostics) - @param[in] context further context information (for diagnostics) - @return whether the last read character is not EOF - */ - JSON_HEDLEY_NON_NULL(3) - bool unexpect_eof(const input_format_t format, const char* context) const - { - if (JSON_HEDLEY_UNLIKELY(current == std::char_traits::eof())) - { - return sax->parse_error(chars_read, "", - parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), nullptr)); - } - return true; - } - - /*! - @return a string representation of the last read byte - */ - std::string get_token_string() const - { - std::array cr{{}}; - static_cast((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(current))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - return std::string{cr.data()}; - } - - /*! - @param[in] format the current format - @param[in] detail a detailed error message - @param[in] context further context information - @return a message string to use in the parse_error exceptions - */ - std::string exception_message(const input_format_t format, - const std::string& detail, - const std::string& context) const - { - std::string error_msg = "syntax error while parsing "; - - switch (format) - { - case input_format_t::cbor: - error_msg += "CBOR"; - break; - - case input_format_t::msgpack: - error_msg += "MessagePack"; - break; - - case input_format_t::ubjson: - error_msg += "UBJSON"; - break; - - case input_format_t::bson: - error_msg += "BSON"; - break; - - case input_format_t::bjdata: - error_msg += "BJData"; - break; - - case input_format_t::json: // LCOV_EXCL_LINE - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - } - - return concat(error_msg, ' ', context, ": ", detail); - } - - private: - static JSON_INLINE_VARIABLE constexpr std::size_t npos = static_cast(-1); - - /// input adapter - InputAdapterType ia; - - /// the current character - char_int_type current = std::char_traits::eof(); - - /// the number of characters read - std::size_t chars_read = 0; - - /// whether we can assume little endianness - const bool is_little_endian = little_endianness(); - - /// input format - const input_format_t input_format = input_format_t::json; - - /// the SAX parser - json_sax_t* sax = nullptr; - - // excluded markers in bjdata optimized type -#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \ - make_array('F', 'H', 'N', 'S', 'T', 'Z', '[', '{') - -#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \ - make_array( \ - bjd_type{'C', "char"}, \ - bjd_type{'D', "double"}, \ - bjd_type{'I', "int16"}, \ - bjd_type{'L', "int64"}, \ - bjd_type{'M', "uint64"}, \ - bjd_type{'U', "uint8"}, \ - bjd_type{'d', "single"}, \ - bjd_type{'i', "int8"}, \ - bjd_type{'l', "int32"}, \ - bjd_type{'m', "uint32"}, \ - bjd_type{'u', "uint16"}) - - JSON_PRIVATE_UNLESS_TESTED: - // lookup tables - // NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes) - const decltype(JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_) bjd_optimized_type_markers = - JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_; - - using bjd_type = std::pair; - // NOLINTNEXTLINE(cppcoreguidelines-non-private-member-variables-in-classes) - const decltype(JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_) bjd_types_map = - JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_; - -#undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ -#undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ -}; - -#ifndef JSON_HAS_CPP_17 - template - constexpr std::size_t binary_reader::npos; -#endif - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/input/input_adapters.hpp b/include/nlohmann/detail/input/input_adapters.hpp deleted file mode 100644 index cf53b1d572..0000000000 --- a/include/nlohmann/detail/input/input_adapters.hpp +++ /dev/null @@ -1,494 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // array -#include // size_t -#include // strlen -#include // begin, end, iterator_traits, random_access_iterator_tag, distance, next -#include // shared_ptr, make_shared, addressof -#include // accumulate -#include // string, char_traits -#include // enable_if, is_base_of, is_pointer, is_integral, remove_pointer -#include // pair, declval - -#ifndef JSON_NO_IO - #include // FILE * - #include // istream -#endif // JSON_NO_IO - -#include -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -/// the supported input formats -enum class input_format_t { json, cbor, msgpack, ubjson, bson, bjdata }; - -//////////////////// -// input adapters // -//////////////////// - -#ifndef JSON_NO_IO -/*! -Input adapter for stdio file access. This adapter read only 1 byte and do not use any - buffer. This adapter is a very low level adapter. -*/ -class file_input_adapter -{ - public: - using char_type = char; - - JSON_HEDLEY_NON_NULL(2) - explicit file_input_adapter(std::FILE* f) noexcept - : m_file(f) - { - JSON_ASSERT(m_file != nullptr); - } - - // make class move-only - file_input_adapter(const file_input_adapter&) = delete; - file_input_adapter(file_input_adapter&&) noexcept = default; - file_input_adapter& operator=(const file_input_adapter&) = delete; - file_input_adapter& operator=(file_input_adapter&&) = delete; - ~file_input_adapter() = default; - - std::char_traits::int_type get_character() noexcept - { - return std::fgetc(m_file); - } - - private: - /// the file pointer to read from - std::FILE* m_file; -}; - - -/*! -Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at -beginning of input. Does not support changing the underlying std::streambuf -in mid-input. Maintains underlying std::istream and std::streambuf to support -subsequent use of standard std::istream operations to process any input -characters following those used in parsing the JSON input. Clears the -std::istream flags; any input errors (e.g., EOF) will be detected by the first -subsequent call for input from the std::istream. -*/ -class input_stream_adapter -{ - public: - using char_type = char; - - ~input_stream_adapter() - { - // clear stream flags; we use underlying streambuf I/O, do not - // maintain ifstream flags, except eof - if (is != nullptr) - { - is->clear(is->rdstate() & std::ios::eofbit); - } - } - - explicit input_stream_adapter(std::istream& i) - : is(&i), sb(i.rdbuf()) - {} - - // delete because of pointer members - input_stream_adapter(const input_stream_adapter&) = delete; - input_stream_adapter& operator=(input_stream_adapter&) = delete; - input_stream_adapter& operator=(input_stream_adapter&&) = delete; - - input_stream_adapter(input_stream_adapter&& rhs) noexcept - : is(rhs.is), sb(rhs.sb) - { - rhs.is = nullptr; - rhs.sb = nullptr; - } - - // std::istream/std::streambuf use std::char_traits::to_int_type, to - // ensure that std::char_traits::eof() and the character 0xFF do not - // end up as the same value, e.g. 0xFFFFFFFF. - std::char_traits::int_type get_character() - { - auto res = sb->sbumpc(); - // set eof manually, as we don't use the istream interface. - if (JSON_HEDLEY_UNLIKELY(res == std::char_traits::eof())) - { - is->clear(is->rdstate() | std::ios::eofbit); - } - return res; - } - - private: - /// the associated input stream - std::istream* is = nullptr; - std::streambuf* sb = nullptr; -}; -#endif // JSON_NO_IO - -// General-purpose iterator-based adapter. It might not be as fast as -// theoretically possible for some containers, but it is extremely versatile. -template -class iterator_input_adapter -{ - public: - using char_type = typename std::iterator_traits::value_type; - - iterator_input_adapter(IteratorType first, IteratorType last) - : current(std::move(first)), end(std::move(last)) - {} - - typename std::char_traits::int_type get_character() - { - if (JSON_HEDLEY_LIKELY(current != end)) - { - auto result = std::char_traits::to_int_type(*current); - std::advance(current, 1); - return result; - } - - return std::char_traits::eof(); - } - - private: - IteratorType current; - IteratorType end; - - template - friend struct wide_string_input_helper; - - bool empty() const - { - return current == end; - } -}; - - -template -struct wide_string_input_helper; - -template -struct wide_string_input_helper -{ - // UTF-32 - static void fill_buffer(BaseInputAdapter& input, - std::array::int_type, 4>& utf8_bytes, - size_t& utf8_bytes_index, - size_t& utf8_bytes_filled) - { - utf8_bytes_index = 0; - - if (JSON_HEDLEY_UNLIKELY(input.empty())) - { - utf8_bytes[0] = std::char_traits::eof(); - utf8_bytes_filled = 1; - } - else - { - // get the current character - const auto wc = input.get_character(); - - // UTF-32 to UTF-8 encoding - if (wc < 0x80) - { - utf8_bytes[0] = static_cast::int_type>(wc); - utf8_bytes_filled = 1; - } - else if (wc <= 0x7FF) - { - utf8_bytes[0] = static_cast::int_type>(0xC0u | ((static_cast(wc) >> 6u) & 0x1Fu)); - utf8_bytes[1] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 2; - } - else if (wc <= 0xFFFF) - { - utf8_bytes[0] = static_cast::int_type>(0xE0u | ((static_cast(wc) >> 12u) & 0x0Fu)); - utf8_bytes[1] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 6u) & 0x3Fu)); - utf8_bytes[2] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 3; - } - else if (wc <= 0x10FFFF) - { - utf8_bytes[0] = static_cast::int_type>(0xF0u | ((static_cast(wc) >> 18u) & 0x07u)); - utf8_bytes[1] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 12u) & 0x3Fu)); - utf8_bytes[2] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 6u) & 0x3Fu)); - utf8_bytes[3] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 4; - } - else - { - // unknown character - utf8_bytes[0] = static_cast::int_type>(wc); - utf8_bytes_filled = 1; - } - } - } -}; - -template -struct wide_string_input_helper -{ - // UTF-16 - static void fill_buffer(BaseInputAdapter& input, - std::array::int_type, 4>& utf8_bytes, - size_t& utf8_bytes_index, - size_t& utf8_bytes_filled) - { - utf8_bytes_index = 0; - - if (JSON_HEDLEY_UNLIKELY(input.empty())) - { - utf8_bytes[0] = std::char_traits::eof(); - utf8_bytes_filled = 1; - } - else - { - // get the current character - const auto wc = input.get_character(); - - // UTF-16 to UTF-8 encoding - if (wc < 0x80) - { - utf8_bytes[0] = static_cast::int_type>(wc); - utf8_bytes_filled = 1; - } - else if (wc <= 0x7FF) - { - utf8_bytes[0] = static_cast::int_type>(0xC0u | ((static_cast(wc) >> 6u))); - utf8_bytes[1] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 2; - } - else if (0xD800 > wc || wc >= 0xE000) - { - utf8_bytes[0] = static_cast::int_type>(0xE0u | ((static_cast(wc) >> 12u))); - utf8_bytes[1] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 6u) & 0x3Fu)); - utf8_bytes[2] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 3; - } - else - { - if (JSON_HEDLEY_UNLIKELY(!input.empty())) - { - const auto wc2 = static_cast(input.get_character()); - const auto charcode = 0x10000u + (((static_cast(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu)); - utf8_bytes[0] = static_cast::int_type>(0xF0u | (charcode >> 18u)); - utf8_bytes[1] = static_cast::int_type>(0x80u | ((charcode >> 12u) & 0x3Fu)); - utf8_bytes[2] = static_cast::int_type>(0x80u | ((charcode >> 6u) & 0x3Fu)); - utf8_bytes[3] = static_cast::int_type>(0x80u | (charcode & 0x3Fu)); - utf8_bytes_filled = 4; - } - else - { - utf8_bytes[0] = static_cast::int_type>(wc); - utf8_bytes_filled = 1; - } - } - } - } -}; - -// Wraps another input apdater to convert wide character types into individual bytes. -template -class wide_string_input_adapter -{ - public: - using char_type = char; - - wide_string_input_adapter(BaseInputAdapter base) - : base_adapter(base) {} - - typename std::char_traits::int_type get_character() noexcept - { - // check if buffer needs to be filled - if (utf8_bytes_index == utf8_bytes_filled) - { - fill_buffer(); - - JSON_ASSERT(utf8_bytes_filled > 0); - JSON_ASSERT(utf8_bytes_index == 0); - } - - // use buffer - JSON_ASSERT(utf8_bytes_filled > 0); - JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled); - return utf8_bytes[utf8_bytes_index++]; - } - - private: - BaseInputAdapter base_adapter; - - template - void fill_buffer() - { - wide_string_input_helper::fill_buffer(base_adapter, utf8_bytes, utf8_bytes_index, utf8_bytes_filled); - } - - /// a buffer for UTF-8 bytes - std::array::int_type, 4> utf8_bytes = {{0, 0, 0, 0}}; - - /// index to the utf8_codes array for the next valid byte - std::size_t utf8_bytes_index = 0; - /// number of valid bytes in the utf8_codes array - std::size_t utf8_bytes_filled = 0; -}; - - -template -struct iterator_input_adapter_factory -{ - using iterator_type = IteratorType; - using char_type = typename std::iterator_traits::value_type; - using adapter_type = iterator_input_adapter; - - static adapter_type create(IteratorType first, IteratorType last) - { - return adapter_type(std::move(first), std::move(last)); - } -}; - -template -struct is_iterator_of_multibyte -{ - using value_type = typename std::iterator_traits::value_type; - enum - { - value = sizeof(value_type) > 1 - }; -}; - -template -struct iterator_input_adapter_factory::value>> -{ - using iterator_type = IteratorType; - using char_type = typename std::iterator_traits::value_type; - using base_adapter_type = iterator_input_adapter; - using adapter_type = wide_string_input_adapter; - - static adapter_type create(IteratorType first, IteratorType last) - { - return adapter_type(base_adapter_type(std::move(first), std::move(last))); - } -}; - -// General purpose iterator-based input -template -typename iterator_input_adapter_factory::adapter_type input_adapter(IteratorType first, IteratorType last) -{ - using factory_type = iterator_input_adapter_factory; - return factory_type::create(first, last); -} - -// Convenience shorthand from container to iterator -// Enables ADL on begin(container) and end(container) -// Encloses the using declarations in namespace for not to leak them to outside scope - -namespace container_input_adapter_factory_impl -{ - -using std::begin; -using std::end; - -template -struct container_input_adapter_factory {}; - -template -struct container_input_adapter_factory< ContainerType, - void_t()), end(std::declval()))>> - { - using adapter_type = decltype(input_adapter(begin(std::declval()), end(std::declval()))); - - static adapter_type create(const ContainerType& container) -{ - return input_adapter(begin(container), end(container)); -} - }; - -} // namespace container_input_adapter_factory_impl - -template -typename container_input_adapter_factory_impl::container_input_adapter_factory::adapter_type input_adapter(const ContainerType& container) -{ - return container_input_adapter_factory_impl::container_input_adapter_factory::create(container); -} - -#ifndef JSON_NO_IO -// Special cases with fast paths -inline file_input_adapter input_adapter(std::FILE* file) -{ - return file_input_adapter(file); -} - -inline input_stream_adapter input_adapter(std::istream& stream) -{ - return input_stream_adapter(stream); -} - -inline input_stream_adapter input_adapter(std::istream&& stream) -{ - return input_stream_adapter(stream); -} -#endif // JSON_NO_IO - -using contiguous_bytes_input_adapter = decltype(input_adapter(std::declval(), std::declval())); - -// Null-delimited strings, and the like. -template < typename CharT, - typename std::enable_if < - std::is_pointer::value&& - !std::is_array::value&& - std::is_integral::type>::value&& - sizeof(typename std::remove_pointer::type) == 1, - int >::type = 0 > -contiguous_bytes_input_adapter input_adapter(CharT b) -{ - auto length = std::strlen(reinterpret_cast(b)); - const auto* ptr = reinterpret_cast(b); - return input_adapter(ptr, ptr + length); -} - -template -auto input_adapter(T (&array)[N]) -> decltype(input_adapter(array, array + N)) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) -{ - return input_adapter(array, array + N); -} - -// This class only handles inputs of input_buffer_adapter type. -// It's required so that expressions like {ptr, len} can be implicitly cast -// to the correct adapter. -class span_input_adapter -{ - public: - template < typename CharT, - typename std::enable_if < - std::is_pointer::value&& - std::is_integral::type>::value&& - sizeof(typename std::remove_pointer::type) == 1, - int >::type = 0 > - span_input_adapter(CharT b, std::size_t l) - : ia(reinterpret_cast(b), reinterpret_cast(b) + l) {} - - template::iterator_category, std::random_access_iterator_tag>::value, - int>::type = 0> - span_input_adapter(IteratorType first, IteratorType last) - : ia(input_adapter(first, last)) {} - - contiguous_bytes_input_adapter&& get() - { - return std::move(ia); // NOLINT(hicpp-move-const-arg,performance-move-const-arg) - } - - private: - contiguous_bytes_input_adapter ia; -}; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/input/json_sax.hpp b/include/nlohmann/detail/input/json_sax.hpp deleted file mode 100644 index 1bf46c2324..0000000000 --- a/include/nlohmann/detail/input/json_sax.hpp +++ /dev/null @@ -1,728 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include -#include // string -#include // move -#include // vector - -#include -#include -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN - -/*! -@brief SAX interface - -This class describes the SAX interface used by @ref nlohmann::json::sax_parse. -Each function is called in different situations while the input is parsed. The -boolean return value informs the parser whether to continue processing the -input. -*/ -template -struct json_sax -{ - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - - /*! - @brief a null value was read - @return whether parsing should proceed - */ - virtual bool null() = 0; - - /*! - @brief a boolean value was read - @param[in] val boolean value - @return whether parsing should proceed - */ - virtual bool boolean(bool val) = 0; - - /*! - @brief an integer number was read - @param[in] val integer value - @return whether parsing should proceed - */ - virtual bool number_integer(number_integer_t val) = 0; - - /*! - @brief an unsigned integer number was read - @param[in] val unsigned integer value - @return whether parsing should proceed - */ - virtual bool number_unsigned(number_unsigned_t val) = 0; - - /*! - @brief a floating-point number was read - @param[in] val floating-point value - @param[in] s raw token value - @return whether parsing should proceed - */ - virtual bool number_float(number_float_t val, const string_t& s) = 0; - - /*! - @brief a string value was read - @param[in] val string value - @return whether parsing should proceed - @note It is safe to move the passed string value. - */ - virtual bool string(string_t& val) = 0; - - /*! - @brief a binary value was read - @param[in] val binary value - @return whether parsing should proceed - @note It is safe to move the passed binary value. - */ - virtual bool binary(binary_t& val) = 0; - - /*! - @brief the beginning of an object was read - @param[in] elements number of object elements or -1 if unknown - @return whether parsing should proceed - @note binary formats may report the number of elements - */ - virtual bool start_object(std::size_t elements) = 0; - - /*! - @brief an object key was read - @param[in] val object key - @return whether parsing should proceed - @note It is safe to move the passed string. - */ - virtual bool key(string_t& val) = 0; - - /*! - @brief the end of an object was read - @return whether parsing should proceed - */ - virtual bool end_object() = 0; - - /*! - @brief the beginning of an array was read - @param[in] elements number of array elements or -1 if unknown - @return whether parsing should proceed - @note binary formats may report the number of elements - */ - virtual bool start_array(std::size_t elements) = 0; - - /*! - @brief the end of an array was read - @return whether parsing should proceed - */ - virtual bool end_array() = 0; - - /*! - @brief a parse error occurred - @param[in] position the position in the input where the error occurs - @param[in] last_token the last read token - @param[in] ex an exception object describing the error - @return whether parsing should proceed (must return false) - */ - virtual bool parse_error(std::size_t position, - const std::string& last_token, - const detail::exception& ex) = 0; - - json_sax() = default; - json_sax(const json_sax&) = default; - json_sax(json_sax&&) noexcept = default; - json_sax& operator=(const json_sax&) = default; - json_sax& operator=(json_sax&&) noexcept = default; - virtual ~json_sax() = default; -}; - - -namespace detail -{ -/*! -@brief SAX implementation to create a JSON value from SAX events - -This class implements the @ref json_sax interface and processes the SAX events -to create a JSON value which makes it basically a DOM parser. The structure or -hierarchy of the JSON value is managed by the stack `ref_stack` which contains -a pointer to the respective array or object for each recursion depth. - -After successful parsing, the value that is passed by reference to the -constructor contains the parsed value. - -@tparam BasicJsonType the JSON type -*/ -template -class json_sax_dom_parser -{ - public: - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - - /*! - @param[in,out] r reference to a JSON value that is manipulated while - parsing - @param[in] allow_exceptions_ whether parse errors yield exceptions - */ - explicit json_sax_dom_parser(BasicJsonType& r, const bool allow_exceptions_ = true) - : root(r), allow_exceptions(allow_exceptions_) - {} - - // make class move-only - json_sax_dom_parser(const json_sax_dom_parser&) = delete; - json_sax_dom_parser(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - json_sax_dom_parser& operator=(const json_sax_dom_parser&) = delete; - json_sax_dom_parser& operator=(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - ~json_sax_dom_parser() = default; - - bool null() - { - handle_value(nullptr); - return true; - } - - bool boolean(bool val) - { - handle_value(val); - return true; - } - - bool number_integer(number_integer_t val) - { - handle_value(val); - return true; - } - - bool number_unsigned(number_unsigned_t val) - { - handle_value(val); - return true; - } - - bool number_float(number_float_t val, const string_t& /*unused*/) - { - handle_value(val); - return true; - } - - bool string(string_t& val) - { - handle_value(val); - return true; - } - - bool binary(binary_t& val) - { - handle_value(std::move(val)); - return true; - } - - bool start_object(std::size_t len) - { - ref_stack.push_back(handle_value(BasicJsonType::value_t::object)); - - if (JSON_HEDLEY_UNLIKELY(len != static_cast(-1) && len > ref_stack.back()->max_size())) - { - JSON_THROW(out_of_range::create(408, concat("excessive object size: ", std::to_string(len)), ref_stack.back())); - } - - return true; - } - - bool key(string_t& val) - { - JSON_ASSERT(!ref_stack.empty()); - JSON_ASSERT(ref_stack.back()->is_object()); - - // add null at given key and store the reference for later - object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val)); - return true; - } - - bool end_object() - { - JSON_ASSERT(!ref_stack.empty()); - JSON_ASSERT(ref_stack.back()->is_object()); - - ref_stack.back()->set_parents(); - ref_stack.pop_back(); - return true; - } - - bool start_array(std::size_t len) - { - ref_stack.push_back(handle_value(BasicJsonType::value_t::array)); - - if (JSON_HEDLEY_UNLIKELY(len != static_cast(-1) && len > ref_stack.back()->max_size())) - { - JSON_THROW(out_of_range::create(408, concat("excessive array size: ", std::to_string(len)), ref_stack.back())); - } - - return true; - } - - bool end_array() - { - JSON_ASSERT(!ref_stack.empty()); - JSON_ASSERT(ref_stack.back()->is_array()); - - ref_stack.back()->set_parents(); - ref_stack.pop_back(); - return true; - } - - template - bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, - const Exception& ex) - { - errored = true; - static_cast(ex); - if (allow_exceptions) - { - JSON_THROW(ex); - } - return false; - } - - constexpr bool is_errored() const - { - return errored; - } - - private: - /*! - @invariant If the ref stack is empty, then the passed value will be the new - root. - @invariant If the ref stack contains a value, then it is an array or an - object to which we can add elements - */ - template - JSON_HEDLEY_RETURNS_NON_NULL - BasicJsonType* handle_value(Value&& v) - { - if (ref_stack.empty()) - { - root = BasicJsonType(std::forward(v)); - return &root; - } - - JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object()); - - if (ref_stack.back()->is_array()) - { - ref_stack.back()->m_data.m_value.array->emplace_back(std::forward(v)); - return &(ref_stack.back()->m_data.m_value.array->back()); - } - - JSON_ASSERT(ref_stack.back()->is_object()); - JSON_ASSERT(object_element); - *object_element = BasicJsonType(std::forward(v)); - return object_element; - } - - /// the parsed JSON value - BasicJsonType& root; - /// stack to model hierarchy of values - std::vector ref_stack {}; - /// helper to hold the reference for the next object element - BasicJsonType* object_element = nullptr; - /// whether a syntax error occurred - bool errored = false; - /// whether to throw exceptions in case of errors - const bool allow_exceptions = true; -}; - -template -class json_sax_dom_callback_parser -{ - public: - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - using parser_callback_t = typename BasicJsonType::parser_callback_t; - using parse_event_t = typename BasicJsonType::parse_event_t; - - json_sax_dom_callback_parser(BasicJsonType& r, - const parser_callback_t cb, - const bool allow_exceptions_ = true) - : root(r), callback(cb), allow_exceptions(allow_exceptions_) - { - keep_stack.push_back(true); - } - - // make class move-only - json_sax_dom_callback_parser(const json_sax_dom_callback_parser&) = delete; - json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - json_sax_dom_callback_parser& operator=(const json_sax_dom_callback_parser&) = delete; - json_sax_dom_callback_parser& operator=(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - ~json_sax_dom_callback_parser() = default; - - bool null() - { - handle_value(nullptr); - return true; - } - - bool boolean(bool val) - { - handle_value(val); - return true; - } - - bool number_integer(number_integer_t val) - { - handle_value(val); - return true; - } - - bool number_unsigned(number_unsigned_t val) - { - handle_value(val); - return true; - } - - bool number_float(number_float_t val, const string_t& /*unused*/) - { - handle_value(val); - return true; - } - - bool string(string_t& val) - { - handle_value(val); - return true; - } - - bool binary(binary_t& val) - { - handle_value(std::move(val)); - return true; - } - - bool start_object(std::size_t len) - { - // check callback for object start - const bool keep = callback(static_cast(ref_stack.size()), parse_event_t::object_start, discarded); - keep_stack.push_back(keep); - - auto val = handle_value(BasicJsonType::value_t::object, true); - ref_stack.push_back(val.second); - - // check object limit - if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != static_cast(-1) && len > ref_stack.back()->max_size())) - { - JSON_THROW(out_of_range::create(408, concat("excessive object size: ", std::to_string(len)), ref_stack.back())); - } - - return true; - } - - bool key(string_t& val) - { - BasicJsonType k = BasicJsonType(val); - - // check callback for key - const bool keep = callback(static_cast(ref_stack.size()), parse_event_t::key, k); - key_keep_stack.push_back(keep); - - // add discarded value at given key and store the reference for later - if (keep && ref_stack.back()) - { - object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) = discarded); - } - - return true; - } - - bool end_object() - { - if (ref_stack.back()) - { - if (!callback(static_cast(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back())) - { - // discard object - *ref_stack.back() = discarded; - } - else - { - ref_stack.back()->set_parents(); - } - } - - JSON_ASSERT(!ref_stack.empty()); - JSON_ASSERT(!keep_stack.empty()); - ref_stack.pop_back(); - keep_stack.pop_back(); - - if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured()) - { - // remove discarded value - for (auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it) - { - if (it->is_discarded()) - { - ref_stack.back()->erase(it); - break; - } - } - } - - return true; - } - - bool start_array(std::size_t len) - { - const bool keep = callback(static_cast(ref_stack.size()), parse_event_t::array_start, discarded); - keep_stack.push_back(keep); - - auto val = handle_value(BasicJsonType::value_t::array, true); - ref_stack.push_back(val.second); - - // check array limit - if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != static_cast(-1) && len > ref_stack.back()->max_size())) - { - JSON_THROW(out_of_range::create(408, concat("excessive array size: ", std::to_string(len)), ref_stack.back())); - } - - return true; - } - - bool end_array() - { - bool keep = true; - - if (ref_stack.back()) - { - keep = callback(static_cast(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back()); - if (keep) - { - ref_stack.back()->set_parents(); - } - else - { - // discard array - *ref_stack.back() = discarded; - } - } - - JSON_ASSERT(!ref_stack.empty()); - JSON_ASSERT(!keep_stack.empty()); - ref_stack.pop_back(); - keep_stack.pop_back(); - - // remove discarded value - if (!keep && !ref_stack.empty() && ref_stack.back()->is_array()) - { - ref_stack.back()->m_data.m_value.array->pop_back(); - } - - return true; - } - - template - bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, - const Exception& ex) - { - errored = true; - static_cast(ex); - if (allow_exceptions) - { - JSON_THROW(ex); - } - return false; - } - - constexpr bool is_errored() const - { - return errored; - } - - private: - /*! - @param[in] v value to add to the JSON value we build during parsing - @param[in] skip_callback whether we should skip calling the callback - function; this is required after start_array() and - start_object() SAX events, because otherwise we would call the - callback function with an empty array or object, respectively. - - @invariant If the ref stack is empty, then the passed value will be the new - root. - @invariant If the ref stack contains a value, then it is an array or an - object to which we can add elements - - @return pair of boolean (whether value should be kept) and pointer (to the - passed value in the ref_stack hierarchy; nullptr if not kept) - */ - template - std::pair handle_value(Value&& v, const bool skip_callback = false) - { - JSON_ASSERT(!keep_stack.empty()); - - // do not handle this value if we know it would be added to a discarded - // container - if (!keep_stack.back()) - { - return {false, nullptr}; - } - - // create value - auto value = BasicJsonType(std::forward(v)); - - // check callback - const bool keep = skip_callback || callback(static_cast(ref_stack.size()), parse_event_t::value, value); - - // do not handle this value if we just learnt it shall be discarded - if (!keep) - { - return {false, nullptr}; - } - - if (ref_stack.empty()) - { - root = std::move(value); - return {true, &root}; - } - - // skip this value if we already decided to skip the parent - // (https://github.com/nlohmann/json/issues/971#issuecomment-413678360) - if (!ref_stack.back()) - { - return {false, nullptr}; - } - - // we now only expect arrays and objects - JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object()); - - // array - if (ref_stack.back()->is_array()) - { - ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value)); - return {true, &(ref_stack.back()->m_data.m_value.array->back())}; - } - - // object - JSON_ASSERT(ref_stack.back()->is_object()); - // check if we should store an element for the current key - JSON_ASSERT(!key_keep_stack.empty()); - const bool store_element = key_keep_stack.back(); - key_keep_stack.pop_back(); - - if (!store_element) - { - return {false, nullptr}; - } - - JSON_ASSERT(object_element); - *object_element = std::move(value); - return {true, object_element}; - } - - /// the parsed JSON value - BasicJsonType& root; - /// stack to model hierarchy of values - std::vector ref_stack {}; - /// stack to manage which values to keep - std::vector keep_stack {}; - /// stack to manage which object keys to keep - std::vector key_keep_stack {}; - /// helper to hold the reference for the next object element - BasicJsonType* object_element = nullptr; - /// whether a syntax error occurred - bool errored = false; - /// callback function - const parser_callback_t callback = nullptr; - /// whether to throw exceptions in case of errors - const bool allow_exceptions = true; - /// a discarded value for the callback - BasicJsonType discarded = BasicJsonType::value_t::discarded; -}; - -template -class json_sax_acceptor -{ - public: - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - - bool null() - { - return true; - } - - bool boolean(bool /*unused*/) - { - return true; - } - - bool number_integer(number_integer_t /*unused*/) - { - return true; - } - - bool number_unsigned(number_unsigned_t /*unused*/) - { - return true; - } - - bool number_float(number_float_t /*unused*/, const string_t& /*unused*/) - { - return true; - } - - bool string(string_t& /*unused*/) - { - return true; - } - - bool binary(binary_t& /*unused*/) - { - return true; - } - - bool start_object(std::size_t /*unused*/ = static_cast(-1)) - { - return true; - } - - bool key(string_t& /*unused*/) - { - return true; - } - - bool end_object() - { - return true; - } - - bool start_array(std::size_t /*unused*/ = static_cast(-1)) - { - return true; - } - - bool end_array() - { - return true; - } - - bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const detail::exception& /*unused*/) - { - return false; - } -}; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp deleted file mode 100644 index 72e9951081..0000000000 --- a/include/nlohmann/detail/input/lexer.hpp +++ /dev/null @@ -1,1632 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // array -#include // localeconv -#include // size_t -#include // snprintf -#include // strtof, strtod, strtold, strtoll, strtoull -#include // initializer_list -#include // char_traits, string -#include // move -#include // vector - -#include -#include -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -/////////// -// lexer // -/////////// - -template -class lexer_base -{ - public: - /// token types for the parser - enum class token_type - { - uninitialized, ///< indicating the scanner is uninitialized - literal_true, ///< the `true` literal - literal_false, ///< the `false` literal - literal_null, ///< the `null` literal - value_string, ///< a string -- use get_string() for actual value - value_unsigned, ///< an unsigned integer -- use get_number_unsigned() for actual value - value_integer, ///< a signed integer -- use get_number_integer() for actual value - value_float, ///< an floating point number -- use get_number_float() for actual value - begin_array, ///< the character for array begin `[` - begin_object, ///< the character for object begin `{` - end_array, ///< the character for array end `]` - end_object, ///< the character for object end `}` - name_separator, ///< the name separator `:` - value_separator, ///< the value separator `,` - parse_error, ///< indicating a parse error - end_of_input, ///< indicating the end of the input buffer - literal_or_value ///< a literal or the begin of a value (only for diagnostics) - }; - - /// return name of values of type token_type (only used for errors) - JSON_HEDLEY_RETURNS_NON_NULL - JSON_HEDLEY_CONST - static const char* token_type_name(const token_type t) noexcept - { - switch (t) - { - case token_type::uninitialized: - return ""; - case token_type::literal_true: - return "true literal"; - case token_type::literal_false: - return "false literal"; - case token_type::literal_null: - return "null literal"; - case token_type::value_string: - return "string literal"; - case token_type::value_unsigned: - case token_type::value_integer: - case token_type::value_float: - return "number literal"; - case token_type::begin_array: - return "'['"; - case token_type::begin_object: - return "'{'"; - case token_type::end_array: - return "']'"; - case token_type::end_object: - return "'}'"; - case token_type::name_separator: - return "':'"; - case token_type::value_separator: - return "','"; - case token_type::parse_error: - return ""; - case token_type::end_of_input: - return "end of input"; - case token_type::literal_or_value: - return "'[', '{', or a literal"; - // LCOV_EXCL_START - default: // catch non-enum values - return "unknown token"; - // LCOV_EXCL_STOP - } - } -}; -/*! -@brief lexical analysis - -This class organizes the lexical analysis during JSON deserialization. -*/ -template -class lexer : public lexer_base -{ - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using char_type = typename InputAdapterType::char_type; - using char_int_type = typename std::char_traits::int_type; - - public: - using token_type = typename lexer_base::token_type; - - explicit lexer(InputAdapterType&& adapter, bool ignore_comments_ = false) noexcept - : ia(std::move(adapter)) - , ignore_comments(ignore_comments_) - , decimal_point_char(static_cast(get_decimal_point())) - {} - - // delete because of pointer members - lexer(const lexer&) = delete; - lexer(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - lexer& operator=(lexer&) = delete; - lexer& operator=(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - ~lexer() = default; - - private: - ///////////////////// - // locales - ///////////////////// - - /// return the locale-dependent decimal point - JSON_HEDLEY_PURE - static char get_decimal_point() noexcept - { - const auto* loc = localeconv(); - JSON_ASSERT(loc != nullptr); - return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point); - } - - ///////////////////// - // scan functions - ///////////////////// - - /*! - @brief get codepoint from 4 hex characters following `\u` - - For input "\u c1 c2 c3 c4" the codepoint is: - (c1 * 0x1000) + (c2 * 0x0100) + (c3 * 0x0010) + c4 - = (c1 << 12) + (c2 << 8) + (c3 << 4) + (c4 << 0) - - Furthermore, the possible characters '0'..'9', 'A'..'F', and 'a'..'f' - must be converted to the integers 0x0..0x9, 0xA..0xF, 0xA..0xF, resp. The - conversion is done by subtracting the offset (0x30, 0x37, and 0x57) - between the ASCII value of the character and the desired integer value. - - @return codepoint (0x0000..0xFFFF) or -1 in case of an error (e.g. EOF or - non-hex character) - */ - int get_codepoint() - { - // this function only makes sense after reading `\u` - JSON_ASSERT(current == 'u'); - int codepoint = 0; - - const auto factors = { 12u, 8u, 4u, 0u }; - for (const auto factor : factors) - { - get(); - - if (current >= '0' && current <= '9') - { - codepoint += static_cast((static_cast(current) - 0x30u) << factor); - } - else if (current >= 'A' && current <= 'F') - { - codepoint += static_cast((static_cast(current) - 0x37u) << factor); - } - else if (current >= 'a' && current <= 'f') - { - codepoint += static_cast((static_cast(current) - 0x57u) << factor); - } - else - { - return -1; - } - } - - JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF); - return codepoint; - } - - /*! - @brief check if the next byte(s) are inside a given range - - Adds the current byte and, for each passed range, reads a new byte and - checks if it is inside the range. If a violation was detected, set up an - error message and return false. Otherwise, return true. - - @param[in] ranges list of integers; interpreted as list of pairs of - inclusive lower and upper bound, respectively - - @pre The passed list @a ranges must have 2, 4, or 6 elements; that is, - 1, 2, or 3 pairs. This precondition is enforced by an assertion. - - @return true if and only if no range violation was detected - */ - bool next_byte_in_range(std::initializer_list ranges) - { - JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6); - add(current); - - for (auto range = ranges.begin(); range != ranges.end(); ++range) - { - get(); - if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) - { - add(current); - } - else - { - error_message = "invalid string: ill-formed UTF-8 byte"; - return false; - } - } - - return true; - } - - /*! - @brief scan a string literal - - This function scans a string according to Sect. 7 of RFC 8259. While - scanning, bytes are escaped and copied into buffer token_buffer. Then the - function returns successfully, token_buffer is *not* null-terminated (as it - may contain \0 bytes), and token_buffer.size() is the number of bytes in the - string. - - @return token_type::value_string if string could be successfully scanned, - token_type::parse_error otherwise - - @note In case of errors, variable error_message contains a textual - description. - */ - token_type scan_string() - { - // reset token_buffer (ignore opening quote) - reset(); - - // we entered the function by reading an open quote - JSON_ASSERT(current == '\"'); - - while (true) - { - // get next character - switch (get()) - { - // end of file while parsing string - case std::char_traits::eof(): - { - error_message = "invalid string: missing closing quote"; - return token_type::parse_error; - } - - // closing quote - case '\"': - { - return token_type::value_string; - } - - // escapes - case '\\': - { - switch (get()) - { - // quotation mark - case '\"': - add('\"'); - break; - // reverse solidus - case '\\': - add('\\'); - break; - // solidus - case '/': - add('/'); - break; - // backspace - case 'b': - add('\b'); - break; - // form feed - case 'f': - add('\f'); - break; - // line feed - case 'n': - add('\n'); - break; - // carriage return - case 'r': - add('\r'); - break; - // tab - case 't': - add('\t'); - break; - - // unicode escapes - case 'u': - { - const int codepoint1 = get_codepoint(); - int codepoint = codepoint1; // start with codepoint1 - - if (JSON_HEDLEY_UNLIKELY(codepoint1 == -1)) - { - error_message = "invalid string: '\\u' must be followed by 4 hex digits"; - return token_type::parse_error; - } - - // check if code point is a high surrogate - if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF) - { - // expect next \uxxxx entry - if (JSON_HEDLEY_LIKELY(get() == '\\' && get() == 'u')) - { - const int codepoint2 = get_codepoint(); - - if (JSON_HEDLEY_UNLIKELY(codepoint2 == -1)) - { - error_message = "invalid string: '\\u' must be followed by 4 hex digits"; - return token_type::parse_error; - } - - // check if codepoint2 is a low surrogate - if (JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 && codepoint2 <= 0xDFFF)) - { - // overwrite codepoint - codepoint = static_cast( - // high surrogate occupies the most significant 22 bits - (static_cast(codepoint1) << 10u) - // low surrogate occupies the least significant 15 bits - + static_cast(codepoint2) - // there is still the 0xD800, 0xDC00 and 0x10000 noise - // in the result, so we have to subtract with: - // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00 - - 0x35FDC00u); - } - else - { - error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF"; - return token_type::parse_error; - } - } - else - { - error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF"; - return token_type::parse_error; - } - } - else - { - if (JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 && codepoint1 <= 0xDFFF)) - { - error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF"; - return token_type::parse_error; - } - } - - // result of the above calculation yields a proper codepoint - JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF); - - // translate codepoint into bytes - if (codepoint < 0x80) - { - // 1-byte characters: 0xxxxxxx (ASCII) - add(static_cast(codepoint)); - } - else if (codepoint <= 0x7FF) - { - // 2-byte characters: 110xxxxx 10xxxxxx - add(static_cast(0xC0u | (static_cast(codepoint) >> 6u))); - add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); - } - else if (codepoint <= 0xFFFF) - { - // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx - add(static_cast(0xE0u | (static_cast(codepoint) >> 12u))); - add(static_cast(0x80u | ((static_cast(codepoint) >> 6u) & 0x3Fu))); - add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); - } - else - { - // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - add(static_cast(0xF0u | (static_cast(codepoint) >> 18u))); - add(static_cast(0x80u | ((static_cast(codepoint) >> 12u) & 0x3Fu))); - add(static_cast(0x80u | ((static_cast(codepoint) >> 6u) & 0x3Fu))); - add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); - } - - break; - } - - // other characters after escape - default: - error_message = "invalid string: forbidden character after backslash"; - return token_type::parse_error; - } - - break; - } - - // invalid control characters - case 0x00: - { - error_message = "invalid string: control character U+0000 (NUL) must be escaped to \\u0000"; - return token_type::parse_error; - } - - case 0x01: - { - error_message = "invalid string: control character U+0001 (SOH) must be escaped to \\u0001"; - return token_type::parse_error; - } - - case 0x02: - { - error_message = "invalid string: control character U+0002 (STX) must be escaped to \\u0002"; - return token_type::parse_error; - } - - case 0x03: - { - error_message = "invalid string: control character U+0003 (ETX) must be escaped to \\u0003"; - return token_type::parse_error; - } - - case 0x04: - { - error_message = "invalid string: control character U+0004 (EOT) must be escaped to \\u0004"; - return token_type::parse_error; - } - - case 0x05: - { - error_message = "invalid string: control character U+0005 (ENQ) must be escaped to \\u0005"; - return token_type::parse_error; - } - - case 0x06: - { - error_message = "invalid string: control character U+0006 (ACK) must be escaped to \\u0006"; - return token_type::parse_error; - } - - case 0x07: - { - error_message = "invalid string: control character U+0007 (BEL) must be escaped to \\u0007"; - return token_type::parse_error; - } - - case 0x08: - { - error_message = "invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b"; - return token_type::parse_error; - } - - case 0x09: - { - error_message = "invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t"; - return token_type::parse_error; - } - - case 0x0A: - { - error_message = "invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n"; - return token_type::parse_error; - } - - case 0x0B: - { - error_message = "invalid string: control character U+000B (VT) must be escaped to \\u000B"; - return token_type::parse_error; - } - - case 0x0C: - { - error_message = "invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f"; - return token_type::parse_error; - } - - case 0x0D: - { - error_message = "invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r"; - return token_type::parse_error; - } - - case 0x0E: - { - error_message = "invalid string: control character U+000E (SO) must be escaped to \\u000E"; - return token_type::parse_error; - } - - case 0x0F: - { - error_message = "invalid string: control character U+000F (SI) must be escaped to \\u000F"; - return token_type::parse_error; - } - - case 0x10: - { - error_message = "invalid string: control character U+0010 (DLE) must be escaped to \\u0010"; - return token_type::parse_error; - } - - case 0x11: - { - error_message = "invalid string: control character U+0011 (DC1) must be escaped to \\u0011"; - return token_type::parse_error; - } - - case 0x12: - { - error_message = "invalid string: control character U+0012 (DC2) must be escaped to \\u0012"; - return token_type::parse_error; - } - - case 0x13: - { - error_message = "invalid string: control character U+0013 (DC3) must be escaped to \\u0013"; - return token_type::parse_error; - } - - case 0x14: - { - error_message = "invalid string: control character U+0014 (DC4) must be escaped to \\u0014"; - return token_type::parse_error; - } - - case 0x15: - { - error_message = "invalid string: control character U+0015 (NAK) must be escaped to \\u0015"; - return token_type::parse_error; - } - - case 0x16: - { - error_message = "invalid string: control character U+0016 (SYN) must be escaped to \\u0016"; - return token_type::parse_error; - } - - case 0x17: - { - error_message = "invalid string: control character U+0017 (ETB) must be escaped to \\u0017"; - return token_type::parse_error; - } - - case 0x18: - { - error_message = "invalid string: control character U+0018 (CAN) must be escaped to \\u0018"; - return token_type::parse_error; - } - - case 0x19: - { - error_message = "invalid string: control character U+0019 (EM) must be escaped to \\u0019"; - return token_type::parse_error; - } - - case 0x1A: - { - error_message = "invalid string: control character U+001A (SUB) must be escaped to \\u001A"; - return token_type::parse_error; - } - - case 0x1B: - { - error_message = "invalid string: control character U+001B (ESC) must be escaped to \\u001B"; - return token_type::parse_error; - } - - case 0x1C: - { - error_message = "invalid string: control character U+001C (FS) must be escaped to \\u001C"; - return token_type::parse_error; - } - - case 0x1D: - { - error_message = "invalid string: control character U+001D (GS) must be escaped to \\u001D"; - return token_type::parse_error; - } - - case 0x1E: - { - error_message = "invalid string: control character U+001E (RS) must be escaped to \\u001E"; - return token_type::parse_error; - } - - case 0x1F: - { - error_message = "invalid string: control character U+001F (US) must be escaped to \\u001F"; - return token_type::parse_error; - } - - // U+0020..U+007F (except U+0022 (quote) and U+005C (backspace)) - case 0x20: - case 0x21: - case 0x23: - case 0x24: - case 0x25: - case 0x26: - case 0x27: - case 0x28: - case 0x29: - case 0x2A: - case 0x2B: - case 0x2C: - case 0x2D: - case 0x2E: - case 0x2F: - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - case 0x36: - case 0x37: - case 0x38: - case 0x39: - case 0x3A: - case 0x3B: - case 0x3C: - case 0x3D: - case 0x3E: - case 0x3F: - case 0x40: - case 0x41: - case 0x42: - case 0x43: - case 0x44: - case 0x45: - case 0x46: - case 0x47: - case 0x48: - case 0x49: - case 0x4A: - case 0x4B: - case 0x4C: - case 0x4D: - case 0x4E: - case 0x4F: - case 0x50: - case 0x51: - case 0x52: - case 0x53: - case 0x54: - case 0x55: - case 0x56: - case 0x57: - case 0x58: - case 0x59: - case 0x5A: - case 0x5B: - case 0x5D: - case 0x5E: - case 0x5F: - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - case 0x68: - case 0x69: - case 0x6A: - case 0x6B: - case 0x6C: - case 0x6D: - case 0x6E: - case 0x6F: - case 0x70: - case 0x71: - case 0x72: - case 0x73: - case 0x74: - case 0x75: - case 0x76: - case 0x77: - case 0x78: - case 0x79: - case 0x7A: - case 0x7B: - case 0x7C: - case 0x7D: - case 0x7E: - case 0x7F: - { - add(current); - break; - } - - // U+0080..U+07FF: bytes C2..DF 80..BF - case 0xC2: - case 0xC3: - case 0xC4: - case 0xC5: - case 0xC6: - case 0xC7: - case 0xC8: - case 0xC9: - case 0xCA: - case 0xCB: - case 0xCC: - case 0xCD: - case 0xCE: - case 0xCF: - case 0xD0: - case 0xD1: - case 0xD2: - case 0xD3: - case 0xD4: - case 0xD5: - case 0xD6: - case 0xD7: - case 0xD8: - case 0xD9: - case 0xDA: - case 0xDB: - case 0xDC: - case 0xDD: - case 0xDE: - case 0xDF: - { - if (JSON_HEDLEY_UNLIKELY(!next_byte_in_range({0x80, 0xBF}))) - { - return token_type::parse_error; - } - break; - } - - // U+0800..U+0FFF: bytes E0 A0..BF 80..BF - case 0xE0: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+1000..U+CFFF: bytes E1..EC 80..BF 80..BF - // U+E000..U+FFFF: bytes EE..EF 80..BF 80..BF - case 0xE1: - case 0xE2: - case 0xE3: - case 0xE4: - case 0xE5: - case 0xE6: - case 0xE7: - case 0xE8: - case 0xE9: - case 0xEA: - case 0xEB: - case 0xEC: - case 0xEE: - case 0xEF: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+D000..U+D7FF: bytes ED 80..9F 80..BF - case 0xED: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF - case 0xF0: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+40000..U+FFFFF F1..F3 80..BF 80..BF 80..BF - case 0xF1: - case 0xF2: - case 0xF3: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF - case 0xF4: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // remaining bytes (80..C1 and F5..FF) are ill-formed - default: - { - error_message = "invalid string: ill-formed UTF-8 byte"; - return token_type::parse_error; - } - } - } - } - - /*! - * @brief scan a comment - * @return whether comment could be scanned successfully - */ - bool scan_comment() - { - switch (get()) - { - // single-line comments skip input until a newline or EOF is read - case '/': - { - while (true) - { - switch (get()) - { - case '\n': - case '\r': - case std::char_traits::eof(): - case '\0': - return true; - - default: - break; - } - } - } - - // multi-line comments skip input until */ is read - case '*': - { - while (true) - { - switch (get()) - { - case std::char_traits::eof(): - case '\0': - { - error_message = "invalid comment; missing closing '*/'"; - return false; - } - - case '*': - { - switch (get()) - { - case '/': - return true; - - default: - { - unget(); - continue; - } - } - } - - default: - continue; - } - } - } - - // unexpected character after reading '/' - default: - { - error_message = "invalid comment; expecting '/' or '*' after '/'"; - return false; - } - } - } - - JSON_HEDLEY_NON_NULL(2) - static void strtof(float& f, const char* str, char** endptr) noexcept - { - f = std::strtof(str, endptr); - } - - JSON_HEDLEY_NON_NULL(2) - static void strtof(double& f, const char* str, char** endptr) noexcept - { - f = std::strtod(str, endptr); - } - - JSON_HEDLEY_NON_NULL(2) - static void strtof(long double& f, const char* str, char** endptr) noexcept - { - f = std::strtold(str, endptr); - } - - /*! - @brief scan a number literal - - This function scans a string according to Sect. 6 of RFC 8259. - - The function is realized with a deterministic finite state machine derived - from the grammar described in RFC 8259. Starting in state "init", the - input is read and used to determined the next state. Only state "done" - accepts the number. State "error" is a trap state to model errors. In the - table below, "anything" means any character but the ones listed before. - - state | 0 | 1-9 | e E | + | - | . | anything - ---------|----------|----------|----------|---------|---------|----------|----------- - init | zero | any1 | [error] | [error] | minus | [error] | [error] - minus | zero | any1 | [error] | [error] | [error] | [error] | [error] - zero | done | done | exponent | done | done | decimal1 | done - any1 | any1 | any1 | exponent | done | done | decimal1 | done - decimal1 | decimal2 | decimal2 | [error] | [error] | [error] | [error] | [error] - decimal2 | decimal2 | decimal2 | exponent | done | done | done | done - exponent | any2 | any2 | [error] | sign | sign | [error] | [error] - sign | any2 | any2 | [error] | [error] | [error] | [error] | [error] - any2 | any2 | any2 | done | done | done | done | done - - The state machine is realized with one label per state (prefixed with - "scan_number_") and `goto` statements between them. The state machine - contains cycles, but any cycle can be left when EOF is read. Therefore, - the function is guaranteed to terminate. - - During scanning, the read bytes are stored in token_buffer. This string is - then converted to a signed integer, an unsigned integer, or a - floating-point number. - - @return token_type::value_unsigned, token_type::value_integer, or - token_type::value_float if number could be successfully scanned, - token_type::parse_error otherwise - - @note The scanner is independent of the current locale. Internally, the - locale's decimal point is used instead of `.` to work with the - locale-dependent converters. - */ - token_type scan_number() // lgtm [cpp/use-of-goto] - { - // reset token_buffer to store the number's bytes - reset(); - - // the type of the parsed number; initially set to unsigned; will be - // changed if minus sign, decimal point or exponent is read - token_type number_type = token_type::value_unsigned; - - // state (init): we just found out we need to scan a number - switch (current) - { - case '-': - { - add(current); - goto scan_number_minus; - } - - case '0': - { - add(current); - goto scan_number_zero; - } - - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any1; - } - - // all other characters are rejected outside scan_number() - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - } - -scan_number_minus: - // state: we just parsed a leading minus sign - number_type = token_type::value_integer; - switch (get()) - { - case '0': - { - add(current); - goto scan_number_zero; - } - - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any1; - } - - default: - { - error_message = "invalid number; expected digit after '-'"; - return token_type::parse_error; - } - } - -scan_number_zero: - // state: we just parse a zero (maybe with a leading minus sign) - switch (get()) - { - case '.': - { - add(decimal_point_char); - goto scan_number_decimal1; - } - - case 'e': - case 'E': - { - add(current); - goto scan_number_exponent; - } - - default: - goto scan_number_done; - } - -scan_number_any1: - // state: we just parsed a number 0-9 (maybe with a leading minus sign) - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any1; - } - - case '.': - { - add(decimal_point_char); - goto scan_number_decimal1; - } - - case 'e': - case 'E': - { - add(current); - goto scan_number_exponent; - } - - default: - goto scan_number_done; - } - -scan_number_decimal1: - // state: we just parsed a decimal point - number_type = token_type::value_float; - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_decimal2; - } - - default: - { - error_message = "invalid number; expected digit after '.'"; - return token_type::parse_error; - } - } - -scan_number_decimal2: - // we just parsed at least one number after a decimal point - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_decimal2; - } - - case 'e': - case 'E': - { - add(current); - goto scan_number_exponent; - } - - default: - goto scan_number_done; - } - -scan_number_exponent: - // we just parsed an exponent - number_type = token_type::value_float; - switch (get()) - { - case '+': - case '-': - { - add(current); - goto scan_number_sign; - } - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any2; - } - - default: - { - error_message = - "invalid number; expected '+', '-', or digit after exponent"; - return token_type::parse_error; - } - } - -scan_number_sign: - // we just parsed an exponent sign - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any2; - } - - default: - { - error_message = "invalid number; expected digit after exponent sign"; - return token_type::parse_error; - } - } - -scan_number_any2: - // we just parsed a number after the exponent or exponent sign - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any2; - } - - default: - goto scan_number_done; - } - -scan_number_done: - // unget the character after the number (we only read it to know that - // we are done scanning a number) - unget(); - - char* endptr = nullptr; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - errno = 0; - - // try to parse integers first and fall back to floats - if (number_type == token_type::value_unsigned) - { - const auto x = std::strtoull(token_buffer.data(), &endptr, 10); - - // we checked the number format before - JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); - - if (errno == 0) - { - value_unsigned = static_cast(x); - if (value_unsigned == x) - { - return token_type::value_unsigned; - } - } - } - else if (number_type == token_type::value_integer) - { - const auto x = std::strtoll(token_buffer.data(), &endptr, 10); - - // we checked the number format before - JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); - - if (errno == 0) - { - value_integer = static_cast(x); - if (value_integer == x) - { - return token_type::value_integer; - } - } - } - - // this code is reached if we parse a floating-point number or if an - // integer conversion above failed - strtof(value_float, token_buffer.data(), &endptr); - - // we checked the number format before - JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); - - return token_type::value_float; - } - - /*! - @param[in] literal_text the literal text to expect - @param[in] length the length of the passed literal text - @param[in] return_type the token type to return on success - */ - JSON_HEDLEY_NON_NULL(2) - token_type scan_literal(const char_type* literal_text, const std::size_t length, - token_type return_type) - { - JSON_ASSERT(std::char_traits::to_char_type(current) == literal_text[0]); - for (std::size_t i = 1; i < length; ++i) - { - if (JSON_HEDLEY_UNLIKELY(std::char_traits::to_char_type(get()) != literal_text[i])) - { - error_message = "invalid literal"; - return token_type::parse_error; - } - } - return return_type; - } - - ///////////////////// - // input management - ///////////////////// - - /// reset token_buffer; current character is beginning of token - void reset() noexcept - { - token_buffer.clear(); - token_string.clear(); - token_string.push_back(std::char_traits::to_char_type(current)); - } - - /* - @brief get next character from the input - - This function provides the interface to the used input adapter. It does - not throw in case the input reached EOF, but returns a - `std::char_traits::eof()` in that case. Stores the scanned characters - for use in error messages. - - @return character read from the input - */ - char_int_type get() - { - ++position.chars_read_total; - ++position.chars_read_current_line; - - if (next_unget) - { - // just reset the next_unget variable and work with current - next_unget = false; - } - else - { - current = ia.get_character(); - } - - if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) - { - token_string.push_back(std::char_traits::to_char_type(current)); - } - - if (current == '\n') - { - ++position.lines_read; - position.chars_read_current_line = 0; - } - - return current; - } - - /*! - @brief unget current character (read it again on next get) - - We implement unget by setting variable next_unget to true. The input is not - changed - we just simulate ungetting by modifying chars_read_total, - chars_read_current_line, and token_string. The next call to get() will - behave as if the unget character is read again. - */ - void unget() - { - next_unget = true; - - --position.chars_read_total; - - // in case we "unget" a newline, we have to also decrement the lines_read - if (position.chars_read_current_line == 0) - { - if (position.lines_read > 0) - { - --position.lines_read; - } - } - else - { - --position.chars_read_current_line; - } - - if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) - { - JSON_ASSERT(!token_string.empty()); - token_string.pop_back(); - } - } - - /// add a character to token_buffer - void add(char_int_type c) - { - token_buffer.push_back(static_cast(c)); - } - - public: - ///////////////////// - // value getters - ///////////////////// - - /// return integer value - constexpr number_integer_t get_number_integer() const noexcept - { - return value_integer; - } - - /// return unsigned integer value - constexpr number_unsigned_t get_number_unsigned() const noexcept - { - return value_unsigned; - } - - /// return floating-point value - constexpr number_float_t get_number_float() const noexcept - { - return value_float; - } - - /// return current string value (implicitly resets the token; useful only once) - string_t& get_string() - { - return token_buffer; - } - - ///////////////////// - // diagnostics - ///////////////////// - - /// return position of last read token - constexpr position_t get_position() const noexcept - { - return position; - } - - /// return the last read token (for errors only). Will never contain EOF - /// (an arbitrary value that is not a valid char value, often -1), because - /// 255 may legitimately occur. May contain NUL, which should be escaped. - std::string get_token_string() const - { - // escape control characters - std::string result; - for (const auto c : token_string) - { - if (static_cast(c) <= '\x1F') - { - // escape control characters - std::array cs{{}}; - static_cast((std::snprintf)(cs.data(), cs.size(), "", static_cast(c))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - result += cs.data(); - } - else - { - // add character as is - result.push_back(static_cast(c)); - } - } - - return result; - } - - /// return syntax error message - JSON_HEDLEY_RETURNS_NON_NULL - constexpr const char* get_error_message() const noexcept - { - return error_message; - } - - ///////////////////// - // actual scanner - ///////////////////// - - /*! - @brief skip the UTF-8 byte order mark - @return true iff there is no BOM or the correct BOM has been skipped - */ - bool skip_bom() - { - if (get() == 0xEF) - { - // check if we completely parse the BOM - return get() == 0xBB && get() == 0xBF; - } - - // the first character is not the beginning of the BOM; unget it to - // process is later - unget(); - return true; - } - - void skip_whitespace() - { - do - { - get(); - } - while (current == ' ' || current == '\t' || current == '\n' || current == '\r'); - } - - token_type scan() - { - // initially, skip the BOM - if (position.chars_read_total == 0 && !skip_bom()) - { - error_message = "invalid BOM; must be 0xEF 0xBB 0xBF if given"; - return token_type::parse_error; - } - - // read next character and ignore whitespace - skip_whitespace(); - - // ignore comments - while (ignore_comments && current == '/') - { - if (!scan_comment()) - { - return token_type::parse_error; - } - - // skip following whitespace - skip_whitespace(); - } - - switch (current) - { - // structural characters - case '[': - return token_type::begin_array; - case ']': - return token_type::end_array; - case '{': - return token_type::begin_object; - case '}': - return token_type::end_object; - case ':': - return token_type::name_separator; - case ',': - return token_type::value_separator; - - // literals - case 't': - { - std::array true_literal = {{static_cast('t'), static_cast('r'), static_cast('u'), static_cast('e')}}; - return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true); - } - case 'f': - { - std::array false_literal = {{static_cast('f'), static_cast('a'), static_cast('l'), static_cast('s'), static_cast('e')}}; - return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false); - } - case 'n': - { - std::array null_literal = {{static_cast('n'), static_cast('u'), static_cast('l'), static_cast('l')}}; - return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null); - } - - // string - case '\"': - return scan_string(); - - // number - case '-': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return scan_number(); - - // end of input (the null byte is needed when parsing from - // string literals) - case '\0': - case std::char_traits::eof(): - return token_type::end_of_input; - - // error - default: - error_message = "invalid literal"; - return token_type::parse_error; - } - } - - private: - /// input adapter - InputAdapterType ia; - - /// whether comments should be ignored (true) or signaled as errors (false) - const bool ignore_comments = false; - - /// the current character - char_int_type current = std::char_traits::eof(); - - /// whether the next get() call should just return current - bool next_unget = false; - - /// the start position of the current token - position_t position {}; - - /// raw input token string (for error messages) - std::vector token_string {}; - - /// buffer for variable-length tokens (numbers, strings) - string_t token_buffer {}; - - /// a description of occurred lexer errors - const char* error_message = ""; - - // number values - number_integer_t value_integer = 0; - number_unsigned_t value_unsigned = 0; - number_float_t value_float = 0; - - /// the decimal point - const char_int_type decimal_point_char = '.'; -}; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/input/parser.hpp b/include/nlohmann/detail/input/parser.hpp deleted file mode 100644 index 8acbd4fcad..0000000000 --- a/include/nlohmann/detail/input/parser.hpp +++ /dev/null @@ -1,507 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // isfinite -#include // uint8_t -#include // function -#include // string -#include // move -#include // vector - -#include -#include -#include -#include -#include -#include -#include -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ -//////////// -// parser // -//////////// - -enum class parse_event_t : std::uint8_t -{ - /// the parser read `{` and started to process a JSON object - object_start, - /// the parser read `}` and finished processing a JSON object - object_end, - /// the parser read `[` and started to process a JSON array - array_start, - /// the parser read `]` and finished processing a JSON array - array_end, - /// the parser read a key of a value in an object - key, - /// the parser finished reading a JSON value - value -}; - -template -using parser_callback_t = - std::function; - -/*! -@brief syntax analysis - -This class implements a recursive descent parser. -*/ -template -class parser -{ - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using lexer_t = lexer; - using token_type = typename lexer_t::token_type; - - public: - /// a parser reading from an input adapter - explicit parser(InputAdapterType&& adapter, - const parser_callback_t cb = nullptr, - const bool allow_exceptions_ = true, - const bool skip_comments = false) - : callback(cb) - , m_lexer(std::move(adapter), skip_comments) - , allow_exceptions(allow_exceptions_) - { - // read first token - get_token(); - } - - /*! - @brief public parser interface - - @param[in] strict whether to expect the last token to be EOF - @param[in,out] result parsed JSON value - - @throw parse_error.101 in case of an unexpected token - @throw parse_error.102 if to_unicode fails or surrogate error - @throw parse_error.103 if to_unicode fails - */ - void parse(const bool strict, BasicJsonType& result) - { - if (callback) - { - json_sax_dom_callback_parser sdp(result, callback, allow_exceptions); - sax_parse_internal(&sdp); - - // in strict mode, input must be completely read - if (strict && (get_token() != token_type::end_of_input)) - { - sdp.parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), - exception_message(token_type::end_of_input, "value"), nullptr)); - } - - // in case of an error, return discarded value - if (sdp.is_errored()) - { - result = value_t::discarded; - return; - } - - // set top-level value to null if it was discarded by the callback - // function - if (result.is_discarded()) - { - result = nullptr; - } - } - else - { - json_sax_dom_parser sdp(result, allow_exceptions); - sax_parse_internal(&sdp); - - // in strict mode, input must be completely read - if (strict && (get_token() != token_type::end_of_input)) - { - sdp.parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), nullptr)); - } - - // in case of an error, return discarded value - if (sdp.is_errored()) - { - result = value_t::discarded; - return; - } - } - - result.assert_invariant(); - } - - /*! - @brief public accept interface - - @param[in] strict whether to expect the last token to be EOF - @return whether the input is a proper JSON text - */ - bool accept(const bool strict = true) - { - json_sax_acceptor sax_acceptor; - return sax_parse(&sax_acceptor, strict); - } - - template - JSON_HEDLEY_NON_NULL(2) - bool sax_parse(SAX* sax, const bool strict = true) - { - (void)detail::is_sax_static_asserts {}; - const bool result = sax_parse_internal(sax); - - // strict mode: next byte must be EOF - if (result && strict && (get_token() != token_type::end_of_input)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), nullptr)); - } - - return result; - } - - private: - template - JSON_HEDLEY_NON_NULL(2) - bool sax_parse_internal(SAX* sax) - { - // stack to remember the hierarchy of structured values we are parsing - // true = array; false = object - std::vector states; - // value to avoid a goto (see comment where set to true) - bool skip_to_state_evaluation = false; - - while (true) - { - if (!skip_to_state_evaluation) - { - // invariant: get_token() was called before each iteration - switch (last_token) - { - case token_type::begin_object: - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast(-1)))) - { - return false; - } - - // closing } -> we are done - if (get_token() == token_type::end_object) - { - if (JSON_HEDLEY_UNLIKELY(!sax->end_object())) - { - return false; - } - break; - } - - // parse key - if (JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), nullptr)); - } - if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) - { - return false; - } - - // parse separator (:) - if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr)); - } - - // remember we are now inside an object - states.push_back(false); - - // parse values - get_token(); - continue; - } - - case token_type::begin_array: - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast(-1)))) - { - return false; - } - - // closing ] -> we are done - if (get_token() == token_type::end_array) - { - if (JSON_HEDLEY_UNLIKELY(!sax->end_array())) - { - return false; - } - break; - } - - // remember we are now inside an array - states.push_back(true); - - // parse values (no need to call get_token) - continue; - } - - case token_type::value_float: - { - const auto res = m_lexer.get_number_float(); - - if (JSON_HEDLEY_UNLIKELY(!std::isfinite(res))) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - out_of_range::create(406, concat("number overflow parsing '", m_lexer.get_token_string(), '\''), nullptr)); - } - - if (JSON_HEDLEY_UNLIKELY(!sax->number_float(res, m_lexer.get_string()))) - { - return false; - } - - break; - } - - case token_type::literal_false: - { - if (JSON_HEDLEY_UNLIKELY(!sax->boolean(false))) - { - return false; - } - break; - } - - case token_type::literal_null: - { - if (JSON_HEDLEY_UNLIKELY(!sax->null())) - { - return false; - } - break; - } - - case token_type::literal_true: - { - if (JSON_HEDLEY_UNLIKELY(!sax->boolean(true))) - { - return false; - } - break; - } - - case token_type::value_integer: - { - if (JSON_HEDLEY_UNLIKELY(!sax->number_integer(m_lexer.get_number_integer()))) - { - return false; - } - break; - } - - case token_type::value_string: - { - if (JSON_HEDLEY_UNLIKELY(!sax->string(m_lexer.get_string()))) - { - return false; - } - break; - } - - case token_type::value_unsigned: - { - if (JSON_HEDLEY_UNLIKELY(!sax->number_unsigned(m_lexer.get_number_unsigned()))) - { - return false; - } - break; - } - - case token_type::parse_error: - { - // using "uninitialized" to avoid "expected" message - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), nullptr)); - } - - case token_type::uninitialized: - case token_type::end_array: - case token_type::end_object: - case token_type::name_separator: - case token_type::value_separator: - case token_type::end_of_input: - case token_type::literal_or_value: - default: // the last token was unexpected - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr)); - } - } - } - else - { - skip_to_state_evaluation = false; - } - - // we reached this line after we successfully parsed a value - if (states.empty()) - { - // empty stack: we reached the end of the hierarchy: done - return true; - } - - if (states.back()) // array - { - // comma -> next value - if (get_token() == token_type::value_separator) - { - // parse a new value - get_token(); - continue; - } - - // closing ] - if (JSON_HEDLEY_LIKELY(last_token == token_type::end_array)) - { - if (JSON_HEDLEY_UNLIKELY(!sax->end_array())) - { - return false; - } - - // We are done with this array. Before we can parse a - // new value, we need to evaluate the new state first. - // By setting skip_to_state_evaluation to false, we - // are effectively jumping to the beginning of this if. - JSON_ASSERT(!states.empty()); - states.pop_back(); - skip_to_state_evaluation = true; - continue; - } - - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array, "array"), nullptr)); - } - - // states.back() is false -> object - - // comma -> next value - if (get_token() == token_type::value_separator) - { - // parse key - if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::value_string)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), nullptr)); - } - - if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) - { - return false; - } - - // parse separator (:) - if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr)); - } - - // parse values - get_token(); - continue; - } - - // closing } - if (JSON_HEDLEY_LIKELY(last_token == token_type::end_object)) - { - if (JSON_HEDLEY_UNLIKELY(!sax->end_object())) - { - return false; - } - - // We are done with this object. Before we can parse a - // new value, we need to evaluate the new state first. - // By setting skip_to_state_evaluation to false, we - // are effectively jumping to the beginning of this if. - JSON_ASSERT(!states.empty()); - states.pop_back(); - skip_to_state_evaluation = true; - continue; - } - - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object, "object"), nullptr)); - } - } - - /// get next token from lexer - token_type get_token() - { - return last_token = m_lexer.scan(); - } - - std::string exception_message(const token_type expected, const std::string& context) - { - std::string error_msg = "syntax error "; - - if (!context.empty()) - { - error_msg += concat("while parsing ", context, ' '); - } - - error_msg += "- "; - - if (last_token == token_type::parse_error) - { - error_msg += concat(m_lexer.get_error_message(), "; last read: '", - m_lexer.get_token_string(), '\''); - } - else - { - error_msg += concat("unexpected ", lexer_t::token_type_name(last_token)); - } - - if (expected != token_type::uninitialized) - { - error_msg += concat("; expected ", lexer_t::token_type_name(expected)); - } - - return error_msg; - } - - private: - /// callback function - const parser_callback_t callback = nullptr; - /// the type of the last read token - token_type last_token = token_type::uninitialized; - /// the lexer - lexer_t m_lexer; - /// whether to throw exceptions in case of errors - const bool allow_exceptions = true; -}; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/input/position_t.hpp b/include/nlohmann/detail/input/position_t.hpp deleted file mode 100644 index 396db0e16b..0000000000 --- a/include/nlohmann/detail/input/position_t.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // size_t - -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -/// struct to capture the start position of the current token -struct position_t -{ - /// the total number of characters read - std::size_t chars_read_total = 0; - /// the number of characters read in the current line - std::size_t chars_read_current_line = 0; - /// the number of lines read - std::size_t lines_read = 0; - - /// conversion to size_t to preserve SAX interface - constexpr operator size_t() const - { - return chars_read_total; - } -}; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/iterators/internal_iterator.hpp b/include/nlohmann/detail/iterators/internal_iterator.hpp deleted file mode 100644 index 13a212c8d9..0000000000 --- a/include/nlohmann/detail/iterators/internal_iterator.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -/*! -@brief an iterator value - -@note This structure could easily be a union, but MSVC currently does not allow -unions members with complex constructors, see https://github.com/nlohmann/json/pull/105. -*/ -template struct internal_iterator -{ - /// iterator for JSON objects - typename BasicJsonType::object_t::iterator object_iterator {}; - /// iterator for JSON arrays - typename BasicJsonType::array_t::iterator array_iterator {}; - /// generic iterator for all other types - primitive_iterator_t primitive_iterator {}; -}; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/iterators/iter_impl.hpp b/include/nlohmann/detail/iterators/iter_impl.hpp deleted file mode 100644 index 028de6e172..0000000000 --- a/include/nlohmann/detail/iterators/iter_impl.hpp +++ /dev/null @@ -1,751 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next -#include // conditional, is_const, remove_const - -#include -#include -#include -#include -#include -#include -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -// forward declare, to be able to friend it later on -template class iteration_proxy; -template class iteration_proxy_value; - -/*! -@brief a template for a bidirectional iterator for the @ref basic_json class -This class implements a both iterators (iterator and const_iterator) for the -@ref basic_json class. -@note An iterator is called *initialized* when a pointer to a JSON value has - been set (e.g., by a constructor or a copy assignment). If the iterator is - default-constructed, it is *uninitialized* and most methods are undefined. - **The library uses assertions to detect calls on uninitialized iterators.** -@requirement The class satisfies the following concept requirements: -- -[BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator): - The iterator that can be moved can be moved in both directions (i.e. - incremented and decremented). -@since version 1.0.0, simplified in version 2.0.9, change to bidirectional - iterators in version 3.0.0 (see https://github.com/nlohmann/json/issues/593) -*/ -template -class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions) -{ - /// the iterator with BasicJsonType of different const-ness - using other_iter_impl = iter_impl::value, typename std::remove_const::type, const BasicJsonType>::type>; - /// allow basic_json to access private members - friend other_iter_impl; - friend BasicJsonType; - friend iteration_proxy; - friend iteration_proxy_value; - - using object_t = typename BasicJsonType::object_t; - using array_t = typename BasicJsonType::array_t; - // make sure BasicJsonType is basic_json or const basic_json - static_assert(is_basic_json::type>::value, - "iter_impl only accepts (const) basic_json"); - // superficial check for the LegacyBidirectionalIterator named requirement - static_assert(std::is_base_of::value - && std::is_base_of::iterator_category>::value, - "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement."); - - public: - /// The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17. - /// The C++ Standard has never required user-defined iterators to derive from std::iterator. - /// A user-defined iterator should provide publicly accessible typedefs named - /// iterator_category, value_type, difference_type, pointer, and reference. - /// Note that value_type is required to be non-const, even for constant iterators. - using iterator_category = std::bidirectional_iterator_tag; - - /// the type of the values when the iterator is dereferenced - using value_type = typename BasicJsonType::value_type; - /// a type to represent differences between iterators - using difference_type = typename BasicJsonType::difference_type; - /// defines a pointer to the type iterated over (value_type) - using pointer = typename std::conditional::value, - typename BasicJsonType::const_pointer, - typename BasicJsonType::pointer>::type; - /// defines a reference to the type iterated over (value_type) - using reference = - typename std::conditional::value, - typename BasicJsonType::const_reference, - typename BasicJsonType::reference>::type; - - iter_impl() = default; - ~iter_impl() = default; - iter_impl(iter_impl&&) noexcept = default; - iter_impl& operator=(iter_impl&&) noexcept = default; - - /*! - @brief constructor for a given JSON instance - @param[in] object pointer to a JSON object for this iterator - @pre object != nullptr - @post The iterator is initialized; i.e. `m_object != nullptr`. - */ - explicit iter_impl(pointer object) noexcept : m_object(object) - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_data.m_type) - { - case value_t::object: - { - m_it.object_iterator = typename object_t::iterator(); - break; - } - - case value_t::array: - { - m_it.array_iterator = typename array_t::iterator(); - 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: - case value_t::discarded: - default: - { - m_it.primitive_iterator = primitive_iterator_t(); - break; - } - } - } - - /*! - @note The conventional copy constructor and copy assignment are implicitly - defined. Combined with the following converting constructor and - assignment, they support: (1) copy from iterator to iterator, (2) - copy from const iterator to const iterator, and (3) conversion from - iterator to const iterator. However conversion from const iterator - to iterator is not defined. - */ - - /*! - @brief const copy constructor - @param[in] other const iterator to copy from - @note This copy constructor had to be defined explicitly to circumvent a bug - occurring on msvc v19.0 compiler (VS 2015) debug build. For more - information refer to: https://github.com/nlohmann/json/issues/1608 - */ - iter_impl(const iter_impl& other) noexcept - : m_object(other.m_object), m_it(other.m_it) - {} - - /*! - @brief converting assignment - @param[in] other const iterator to copy from - @return const/non-const iterator - @note It is not checked whether @a other is initialized. - */ - iter_impl& operator=(const iter_impl& other) noexcept - { - if (&other != this) - { - m_object = other.m_object; - m_it = other.m_it; - } - return *this; - } - - /*! - @brief converting constructor - @param[in] other non-const iterator to copy from - @note It is not checked whether @a other is initialized. - */ - iter_impl(const iter_impl::type>& other) noexcept - : m_object(other.m_object), m_it(other.m_it) - {} - - /*! - @brief converting assignment - @param[in] other non-const iterator to copy from - @return const/non-const iterator - @note It is not checked whether @a other is initialized. - */ - iter_impl& operator=(const iter_impl::type>& other) noexcept // NOLINT(cert-oop54-cpp) - { - m_object = other.m_object; - m_it = other.m_it; - return *this; - } - - JSON_PRIVATE_UNLESS_TESTED: - /*! - @brief set the iterator to the first value - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - void set_begin() noexcept - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_data.m_type) - { - case value_t::object: - { - m_it.object_iterator = m_object->m_data.m_value.object->begin(); - break; - } - - case value_t::array: - { - m_it.array_iterator = m_object->m_data.m_value.array->begin(); - break; - } - - case value_t::null: - { - // set to end so begin()==end() is true: null is empty - m_it.primitive_iterator.set_end(); - break; - } - - 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: - case value_t::discarded: - default: - { - m_it.primitive_iterator.set_begin(); - break; - } - } - } - - /*! - @brief set the iterator past the last value - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - void set_end() noexcept - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_data.m_type) - { - case value_t::object: - { - m_it.object_iterator = m_object->m_data.m_value.object->end(); - break; - } - - case value_t::array: - { - m_it.array_iterator = m_object->m_data.m_value.array->end(); - 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: - case value_t::discarded: - default: - { - m_it.primitive_iterator.set_end(); - break; - } - } - } - - public: - /*! - @brief return a reference to the value pointed to by the iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - reference operator*() const - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_data.m_type) - { - case value_t::object: - { - JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end()); - return m_it.object_iterator->second; - } - - case value_t::array: - { - JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end()); - return *m_it.array_iterator; - } - - case value_t::null: - JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object)); - - 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: - case value_t::discarded: - default: - { - if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) - { - return *m_object; - } - - JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object)); - } - } - } - - /*! - @brief dereference the iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - pointer operator->() const - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_data.m_type) - { - case value_t::object: - { - JSON_ASSERT(m_it.object_iterator != m_object->m_data.m_value.object->end()); - return &(m_it.object_iterator->second); - } - - case value_t::array: - { - JSON_ASSERT(m_it.array_iterator != m_object->m_data.m_value.array->end()); - return &*m_it.array_iterator; - } - - 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: - case value_t::discarded: - default: - { - if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) - { - return m_object; - } - - JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object)); - } - } - } - - /*! - @brief post-increment (it++) - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl operator++(int)& // NOLINT(cert-dcl21-cpp) - { - auto result = *this; - ++(*this); - return result; - } - - /*! - @brief pre-increment (++it) - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl& operator++() - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_data.m_type) - { - case value_t::object: - { - std::advance(m_it.object_iterator, 1); - break; - } - - case value_t::array: - { - std::advance(m_it.array_iterator, 1); - 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: - case value_t::discarded: - default: - { - ++m_it.primitive_iterator; - break; - } - } - - return *this; - } - - /*! - @brief post-decrement (it--) - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl operator--(int)& // NOLINT(cert-dcl21-cpp) - { - auto result = *this; - --(*this); - return result; - } - - /*! - @brief pre-decrement (--it) - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl& operator--() - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_data.m_type) - { - case value_t::object: - { - std::advance(m_it.object_iterator, -1); - break; - } - - case value_t::array: - { - std::advance(m_it.array_iterator, -1); - 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: - case value_t::discarded: - default: - { - --m_it.primitive_iterator; - break; - } - } - - return *this; - } - - /*! - @brief comparison: equal - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - template < typename IterImpl, detail::enable_if_t < (std::is_same::value || std::is_same::value), std::nullptr_t > = nullptr > - bool operator==(const IterImpl& other) const - { - // if objects are not the same, the comparison is undefined - if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) - { - JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", m_object)); - } - - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_data.m_type) - { - case value_t::object: - return (m_it.object_iterator == other.m_it.object_iterator); - - case value_t::array: - return (m_it.array_iterator == other.m_it.array_iterator); - - 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: - case value_t::discarded: - default: - return (m_it.primitive_iterator == other.m_it.primitive_iterator); - } - } - - /*! - @brief comparison: not equal - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - template < typename IterImpl, detail::enable_if_t < (std::is_same::value || std::is_same::value), std::nullptr_t > = nullptr > - bool operator!=(const IterImpl& other) const - { - return !operator==(other); - } - - /*! - @brief comparison: smaller - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - bool operator<(const iter_impl& other) const - { - // if objects are not the same, the comparison is undefined - if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) - { - JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", m_object)); - } - - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_data.m_type) - { - case value_t::object: - JSON_THROW(invalid_iterator::create(213, "cannot compare order of object iterators", m_object)); - - case value_t::array: - return (m_it.array_iterator < other.m_it.array_iterator); - - 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: - case value_t::discarded: - default: - return (m_it.primitive_iterator < other.m_it.primitive_iterator); - } - } - - /*! - @brief comparison: less than or equal - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - bool operator<=(const iter_impl& other) const - { - return !other.operator < (*this); - } - - /*! - @brief comparison: greater than - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - bool operator>(const iter_impl& other) const - { - return !operator<=(other); - } - - /*! - @brief comparison: greater than or equal - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - bool operator>=(const iter_impl& other) const - { - return !operator<(other); - } - - /*! - @brief add to iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl& operator+=(difference_type i) - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_data.m_type) - { - case value_t::object: - JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", m_object)); - - case value_t::array: - { - std::advance(m_it.array_iterator, i); - 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: - case value_t::discarded: - default: - { - m_it.primitive_iterator += i; - break; - } - } - - return *this; - } - - /*! - @brief subtract from iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl& operator-=(difference_type i) - { - return operator+=(-i); - } - - /*! - @brief add to iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl operator+(difference_type i) const - { - auto result = *this; - result += i; - return result; - } - - /*! - @brief addition of distance and iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - friend iter_impl operator+(difference_type i, const iter_impl& it) - { - auto result = it; - result += i; - return result; - } - - /*! - @brief subtract from iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl operator-(difference_type i) const - { - auto result = *this; - result -= i; - return result; - } - - /*! - @brief return difference - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - difference_type operator-(const iter_impl& other) const - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_data.m_type) - { - case value_t::object: - JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", m_object)); - - case value_t::array: - return m_it.array_iterator - other.m_it.array_iterator; - - 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: - case value_t::discarded: - default: - return m_it.primitive_iterator - other.m_it.primitive_iterator; - } - } - - /*! - @brief access to successor - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - reference operator[](difference_type n) const - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_data.m_type) - { - case value_t::object: - JSON_THROW(invalid_iterator::create(208, "cannot use operator[] for object iterators", m_object)); - - case value_t::array: - return *std::next(m_it.array_iterator, n); - - case value_t::null: - JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object)); - - 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: - case value_t::discarded: - default: - { - if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n)) - { - return *m_object; - } - - JSON_THROW(invalid_iterator::create(214, "cannot get value", m_object)); - } - } - } - - /*! - @brief return the key of an object iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - const typename object_t::key_type& key() const - { - JSON_ASSERT(m_object != nullptr); - - if (JSON_HEDLEY_LIKELY(m_object->is_object())) - { - return m_it.object_iterator->first; - } - - JSON_THROW(invalid_iterator::create(207, "cannot use key() for non-object iterators", m_object)); - } - - /*! - @brief return the value of an iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - reference value() const - { - return operator*(); - } - - JSON_PRIVATE_UNLESS_TESTED: - /// associated JSON instance - pointer m_object = nullptr; - /// the actual iterator of the associated instance - internal_iterator::type> m_it {}; -}; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/iterators/iteration_proxy.hpp b/include/nlohmann/detail/iterators/iteration_proxy.hpp deleted file mode 100644 index 33bfc36ba3..0000000000 --- a/include/nlohmann/detail/iterators/iteration_proxy.hpp +++ /dev/null @@ -1,242 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // size_t -#include // input_iterator_tag -#include // string, to_string -#include // tuple_size, get, tuple_element -#include // move - -#if JSON_HAS_RANGES - #include // enable_borrowed_range -#endif - -#include -#include -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -template -void int_to_string( string_type& target, std::size_t value ) -{ - // For ADL - using std::to_string; - target = to_string(value); -} -template class iteration_proxy_value -{ - public: - using difference_type = std::ptrdiff_t; - using value_type = iteration_proxy_value; - using pointer = value_type *; - using reference = value_type &; - using iterator_category = std::input_iterator_tag; - using string_type = typename std::remove_cv< typename std::remove_reference().key() ) >::type >::type; - - private: - /// the iterator - IteratorType anchor{}; - /// an index for arrays (used to create key names) - std::size_t array_index = 0; - /// last stringified array index - mutable std::size_t array_index_last = 0; - /// a string representation of the array index - mutable string_type array_index_str = "0"; - /// an empty string (to return a reference for primitive values) - string_type empty_str{}; - - public: - explicit iteration_proxy_value() = default; - explicit iteration_proxy_value(IteratorType it, std::size_t array_index_ = 0) - noexcept(std::is_nothrow_move_constructible::value - && std::is_nothrow_default_constructible::value) - : anchor(std::move(it)) - , array_index(array_index_) - {} - - iteration_proxy_value(iteration_proxy_value const&) = default; - iteration_proxy_value& operator=(iteration_proxy_value const&) = default; - // older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions - iteration_proxy_value(iteration_proxy_value&&) - noexcept(std::is_nothrow_move_constructible::value - && std::is_nothrow_move_constructible::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - iteration_proxy_value& operator=(iteration_proxy_value&&) - noexcept(std::is_nothrow_move_assignable::value - && std::is_nothrow_move_assignable::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - ~iteration_proxy_value() = default; - - /// dereference operator (needed for range-based for) - const iteration_proxy_value& operator*() const - { - return *this; - } - - /// increment operator (needed for range-based for) - iteration_proxy_value& operator++() - { - ++anchor; - ++array_index; - - return *this; - } - - iteration_proxy_value operator++(int)& // NOLINT(cert-dcl21-cpp) - { - auto tmp = iteration_proxy_value(anchor, array_index); - ++anchor; - ++array_index; - return tmp; - } - - /// equality operator (needed for InputIterator) - bool operator==(const iteration_proxy_value& o) const - { - return anchor == o.anchor; - } - - /// inequality operator (needed for range-based for) - bool operator!=(const iteration_proxy_value& o) const - { - return anchor != o.anchor; - } - - /// return key of the iterator - const string_type& key() const - { - JSON_ASSERT(anchor.m_object != nullptr); - - switch (anchor.m_object->type()) - { - // use integer array index as key - case value_t::array: - { - if (array_index != array_index_last) - { - int_to_string( array_index_str, array_index ); - array_index_last = array_index; - } - return array_index_str; - } - - // use key from the object - case value_t::object: - return anchor.key(); - - // use an empty key for all primitive types - 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: - case value_t::discarded: - default: - return empty_str; - } - } - - /// return value of the iterator - typename IteratorType::reference value() const - { - return anchor.value(); - } -}; - -/// proxy class for the items() function -template class iteration_proxy -{ - private: - /// the container to iterate - typename IteratorType::pointer container = nullptr; - - public: - explicit iteration_proxy() = default; - - /// construct iteration proxy from a container - explicit iteration_proxy(typename IteratorType::reference cont) noexcept - : container(&cont) {} - - iteration_proxy(iteration_proxy const&) = default; - iteration_proxy& operator=(iteration_proxy const&) = default; - iteration_proxy(iteration_proxy&&) noexcept = default; - iteration_proxy& operator=(iteration_proxy&&) noexcept = default; - ~iteration_proxy() = default; - - /// return iterator begin (needed for range-based for) - iteration_proxy_value begin() const noexcept - { - return iteration_proxy_value(container->begin()); - } - - /// return iterator end (needed for range-based for) - iteration_proxy_value end() const noexcept - { - return iteration_proxy_value(container->end()); - } -}; - -// Structured Bindings Support -// For further reference see https://blog.tartanllama.xyz/structured-bindings/ -// And see https://github.com/nlohmann/json/pull/1391 -template = 0> -auto get(const nlohmann::detail::iteration_proxy_value& i) -> decltype(i.key()) -{ - return i.key(); -} -// Structured Bindings Support -// For further reference see https://blog.tartanllama.xyz/structured-bindings/ -// And see https://github.com/nlohmann/json/pull/1391 -template = 0> -auto get(const nlohmann::detail::iteration_proxy_value& i) -> decltype(i.value()) -{ - return i.value(); -} - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END - -// The Addition to the STD Namespace is required to add -// Structured Bindings Support to the iteration_proxy_value class -// For further reference see https://blog.tartanllama.xyz/structured-bindings/ -// And see https://github.com/nlohmann/json/pull/1391 -namespace std -{ - -#if defined(__clang__) - // Fix: https://github.com/nlohmann/json/issues/1401 - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wmismatched-tags" -#endif -template -class tuple_size<::nlohmann::detail::iteration_proxy_value> // NOLINT(cert-dcl58-cpp) - : public std::integral_constant {}; - -template -class tuple_element> // NOLINT(cert-dcl58-cpp) -{ - public: - using type = decltype( - get(std::declval < - ::nlohmann::detail::iteration_proxy_value> ())); -}; -#if defined(__clang__) - #pragma clang diagnostic pop -#endif - -} // namespace std - -#if JSON_HAS_RANGES - template - inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy> = true; -#endif diff --git a/include/nlohmann/detail/iterators/iterator_traits.hpp b/include/nlohmann/detail/iterators/iterator_traits.hpp deleted file mode 100644 index 34a20eee85..0000000000 --- a/include/nlohmann/detail/iterators/iterator_traits.hpp +++ /dev/null @@ -1,61 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // random_access_iterator_tag - -#include -#include -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -template -struct iterator_types {}; - -template -struct iterator_types < - It, - void_t> -{ - using difference_type = typename It::difference_type; - using value_type = typename It::value_type; - using pointer = typename It::pointer; - using reference = typename It::reference; - using iterator_category = typename It::iterator_category; -}; - -// This is required as some compilers implement std::iterator_traits in a way that -// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. -template -struct iterator_traits -{ -}; - -template -struct iterator_traits < T, enable_if_t < !std::is_pointer::value >> - : iterator_types -{ -}; - -template -struct iterator_traits::value>> -{ - using iterator_category = std::random_access_iterator_tag; - using value_type = T; - using difference_type = ptrdiff_t; - using pointer = T*; - using reference = T&; -}; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/iterators/json_reverse_iterator.hpp b/include/nlohmann/detail/iterators/json_reverse_iterator.hpp deleted file mode 100644 index eb450e986e..0000000000 --- a/include/nlohmann/detail/iterators/json_reverse_iterator.hpp +++ /dev/null @@ -1,130 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // ptrdiff_t -#include // reverse_iterator -#include // declval - -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -////////////////////// -// reverse_iterator // -////////////////////// - -/*! -@brief a template for a reverse iterator class - -@tparam Base the base iterator type to reverse. Valid types are @ref -iterator (to create @ref reverse_iterator) and @ref const_iterator (to -create @ref const_reverse_iterator). - -@requirement The class satisfies the following concept requirements: -- -[BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator): - The iterator that can be moved can be moved in both directions (i.e. - incremented and decremented). -- [OutputIterator](https://en.cppreference.com/w/cpp/named_req/OutputIterator): - It is possible to write to the pointed-to element (only if @a Base is - @ref iterator). - -@since version 1.0.0 -*/ -template -class json_reverse_iterator : public std::reverse_iterator -{ - public: - using difference_type = std::ptrdiff_t; - /// shortcut to the reverse iterator adapter - using base_iterator = std::reverse_iterator; - /// the reference type for the pointed-to element - using reference = typename Base::reference; - - /// create reverse iterator from iterator - explicit json_reverse_iterator(const typename base_iterator::iterator_type& it) noexcept - : base_iterator(it) {} - - /// create reverse iterator from base class - explicit json_reverse_iterator(const base_iterator& it) noexcept : base_iterator(it) {} - - /// post-increment (it++) - json_reverse_iterator operator++(int)& // NOLINT(cert-dcl21-cpp) - { - return static_cast(base_iterator::operator++(1)); - } - - /// pre-increment (++it) - json_reverse_iterator& operator++() - { - return static_cast(base_iterator::operator++()); - } - - /// post-decrement (it--) - json_reverse_iterator operator--(int)& // NOLINT(cert-dcl21-cpp) - { - return static_cast(base_iterator::operator--(1)); - } - - /// pre-decrement (--it) - json_reverse_iterator& operator--() - { - return static_cast(base_iterator::operator--()); - } - - /// add to iterator - json_reverse_iterator& operator+=(difference_type i) - { - return static_cast(base_iterator::operator+=(i)); - } - - /// add to iterator - json_reverse_iterator operator+(difference_type i) const - { - return static_cast(base_iterator::operator+(i)); - } - - /// subtract from iterator - json_reverse_iterator operator-(difference_type i) const - { - return static_cast(base_iterator::operator-(i)); - } - - /// return difference - difference_type operator-(const json_reverse_iterator& other) const - { - return base_iterator(*this) - base_iterator(other); - } - - /// access to successor - reference operator[](difference_type n) const - { - return *(this->operator+(n)); - } - - /// return the key of an object iterator - auto key() const -> decltype(std::declval().key()) - { - auto it = --this->base(); - return it.key(); - } - - /// return the value of an iterator - reference value() const - { - auto it = --this->base(); - return it.operator * (); - } -}; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/iterators/primitive_iterator.hpp b/include/nlohmann/detail/iterators/primitive_iterator.hpp deleted file mode 100644 index 0bc3ca804e..0000000000 --- a/include/nlohmann/detail/iterators/primitive_iterator.hpp +++ /dev/null @@ -1,132 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // ptrdiff_t -#include // numeric_limits - -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -/* -@brief an iterator for primitive JSON types - -This class models an iterator for primitive JSON types (boolean, number, -string). It's only purpose is to allow the iterator/const_iterator classes -to "iterate" over primitive values. Internally, the iterator is modeled by -a `difference_type` variable. Value begin_value (`0`) models the begin, -end_value (`1`) models past the end. -*/ -class primitive_iterator_t -{ - private: - using difference_type = std::ptrdiff_t; - static constexpr difference_type begin_value = 0; - static constexpr difference_type end_value = begin_value + 1; - - JSON_PRIVATE_UNLESS_TESTED: - /// iterator as signed integer type - difference_type m_it = (std::numeric_limits::min)(); - - public: - constexpr difference_type get_value() const noexcept - { - return m_it; - } - - /// set iterator to a defined beginning - void set_begin() noexcept - { - m_it = begin_value; - } - - /// set iterator to a defined past the end - void set_end() noexcept - { - m_it = end_value; - } - - /// return whether the iterator can be dereferenced - constexpr bool is_begin() const noexcept - { - return m_it == begin_value; - } - - /// return whether the iterator is at end - constexpr bool is_end() const noexcept - { - return m_it == end_value; - } - - friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept - { - return lhs.m_it == rhs.m_it; - } - - friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept - { - return lhs.m_it < rhs.m_it; - } - - primitive_iterator_t operator+(difference_type n) noexcept - { - auto result = *this; - result += n; - return result; - } - - friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept - { - return lhs.m_it - rhs.m_it; - } - - primitive_iterator_t& operator++() noexcept - { - ++m_it; - return *this; - } - - primitive_iterator_t operator++(int)& noexcept // NOLINT(cert-dcl21-cpp) - { - auto result = *this; - ++m_it; - return result; - } - - primitive_iterator_t& operator--() noexcept - { - --m_it; - return *this; - } - - primitive_iterator_t operator--(int)& noexcept // NOLINT(cert-dcl21-cpp) - { - auto result = *this; - --m_it; - return result; - } - - primitive_iterator_t& operator+=(difference_type n) noexcept - { - m_it += n; - return *this; - } - - primitive_iterator_t& operator-=(difference_type n) noexcept - { - m_it -= n; - return *this; - } -}; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/json_custom_base_class.hpp b/include/nlohmann/detail/json_custom_base_class.hpp deleted file mode 100644 index ff06653aba..0000000000 --- a/include/nlohmann/detail/json_custom_base_class.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include // conditional, is_same - -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -/*! -@brief Default base class of the @ref basic_json class. - -So that the correct implementations of the copy / move ctors / assign operators -of @ref basic_json do not require complex case distinctions -(no base class / custom base class used as customization point), -@ref basic_json always has a base class. -By default, this class is used because it is empty and thus has no effect -on the behavior of @ref basic_json. -*/ -struct json_default_base {}; - -template -using json_base_class = typename std::conditional < - std::is_same::value, - json_default_base, - T - >::type; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/json_pointer.hpp b/include/nlohmann/detail/json_pointer.hpp deleted file mode 100644 index eb712ed91a..0000000000 --- a/include/nlohmann/detail/json_pointer.hpp +++ /dev/null @@ -1,988 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // all_of -#include // isdigit -#include // errno, ERANGE -#include // strtoull -#ifndef JSON_NO_IO - #include // ostream -#endif // JSON_NO_IO -#include // max -#include // accumulate -#include // string -#include // move -#include // vector - -#include -#include -#include -#include -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN - -/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document -/// @sa https://json.nlohmann.me/api/json_pointer/ -template -class json_pointer -{ - // allow basic_json to access private members - NLOHMANN_BASIC_JSON_TPL_DECLARATION - friend class basic_json; - - template - friend class json_pointer; - - template - struct string_t_helper - { - using type = T; - }; - - NLOHMANN_BASIC_JSON_TPL_DECLARATION - struct string_t_helper - { - using type = StringType; - }; - - public: - // for backwards compatibility accept BasicJsonType - using string_t = typename string_t_helper::type; - - /// @brief create JSON pointer - /// @sa https://json.nlohmann.me/api/json_pointer/json_pointer/ - explicit json_pointer(const string_t& s = "") - : reference_tokens(split(s)) - {} - - /// @brief return a string representation of the JSON pointer - /// @sa https://json.nlohmann.me/api/json_pointer/to_string/ - string_t to_string() const - { - return std::accumulate(reference_tokens.begin(), reference_tokens.end(), - string_t{}, - [](const string_t& a, const string_t& b) - { - return detail::concat(a, '/', detail::escape(b)); - }); - } - - /// @brief return a string representation of the JSON pointer - /// @sa https://json.nlohmann.me/api/json_pointer/operator_string/ - JSON_HEDLEY_DEPRECATED_FOR(3.11.0, to_string()) - operator string_t() const - { - return to_string(); - } - -#ifndef JSON_NO_IO - /// @brief write string representation of the JSON pointer to stream - /// @sa https://json.nlohmann.me/api/basic_json/operator_ltlt/ - friend std::ostream& operator<<(std::ostream& o, const json_pointer& ptr) - { - o << ptr.to_string(); - return o; - } -#endif - - /// @brief append another JSON pointer at the end of this JSON pointer - /// @sa https://json.nlohmann.me/api/json_pointer/operator_slasheq/ - json_pointer& operator/=(const json_pointer& ptr) - { - reference_tokens.insert(reference_tokens.end(), - ptr.reference_tokens.begin(), - ptr.reference_tokens.end()); - return *this; - } - - /// @brief append an unescaped reference token at the end of this JSON pointer - /// @sa https://json.nlohmann.me/api/json_pointer/operator_slasheq/ - json_pointer& operator/=(string_t token) - { - push_back(std::move(token)); - return *this; - } - - /// @brief append an array index at the end of this JSON pointer - /// @sa https://json.nlohmann.me/api/json_pointer/operator_slasheq/ - json_pointer& operator/=(std::size_t array_idx) - { - return *this /= std::to_string(array_idx); - } - - /// @brief create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer - /// @sa https://json.nlohmann.me/api/json_pointer/operator_slash/ - friend json_pointer operator/(const json_pointer& lhs, - const json_pointer& rhs) - { - return json_pointer(lhs) /= rhs; - } - - /// @brief create a new JSON pointer by appending the unescaped token at the end of the JSON pointer - /// @sa https://json.nlohmann.me/api/json_pointer/operator_slash/ - friend json_pointer operator/(const json_pointer& lhs, string_t token) // NOLINT(performance-unnecessary-value-param) - { - return json_pointer(lhs) /= std::move(token); - } - - /// @brief create a new JSON pointer by appending the array-index-token at the end of the JSON pointer - /// @sa https://json.nlohmann.me/api/json_pointer/operator_slash/ - friend json_pointer operator/(const json_pointer& lhs, std::size_t array_idx) - { - return json_pointer(lhs) /= array_idx; - } - - /// @brief returns the parent of this JSON pointer - /// @sa https://json.nlohmann.me/api/json_pointer/parent_pointer/ - json_pointer parent_pointer() const - { - if (empty()) - { - return *this; - } - - json_pointer res = *this; - res.pop_back(); - return res; - } - - /// @brief remove last reference token - /// @sa https://json.nlohmann.me/api/json_pointer/pop_back/ - void pop_back() - { - if (JSON_HEDLEY_UNLIKELY(empty())) - { - JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", nullptr)); - } - - reference_tokens.pop_back(); - } - - /// @brief return last reference token - /// @sa https://json.nlohmann.me/api/json_pointer/back/ - const string_t& back() const - { - if (JSON_HEDLEY_UNLIKELY(empty())) - { - JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", nullptr)); - } - - return reference_tokens.back(); - } - - /// @brief append an unescaped token at the end of the reference pointer - /// @sa https://json.nlohmann.me/api/json_pointer/push_back/ - void push_back(const string_t& token) - { - reference_tokens.push_back(token); - } - - /// @brief append an unescaped token at the end of the reference pointer - /// @sa https://json.nlohmann.me/api/json_pointer/push_back/ - void push_back(string_t&& token) - { - reference_tokens.push_back(std::move(token)); - } - - /// @brief return whether pointer points to the root document - /// @sa https://json.nlohmann.me/api/json_pointer/empty/ - bool empty() const noexcept - { - return reference_tokens.empty(); - } - - private: - /*! - @param[in] s reference token to be converted into an array index - - @return integer representation of @a s - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index begins not with a digit - @throw out_of_range.404 if string @a s could not be converted to an integer - @throw out_of_range.410 if an array index exceeds size_type - */ - template - static typename BasicJsonType::size_type array_index(const string_t& s) - { - using size_type = typename BasicJsonType::size_type; - - // error condition (cf. RFC 6901, Sect. 4) - if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && s[0] == '0')) - { - JSON_THROW(detail::parse_error::create(106, 0, detail::concat("array index '", s, "' must not begin with '0'"), nullptr)); - } - - // error condition (cf. RFC 6901, Sect. 4) - if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && !(s[0] >= '1' && s[0] <= '9'))) - { - JSON_THROW(detail::parse_error::create(109, 0, detail::concat("array index '", s, "' is not a number"), nullptr)); - } - - const char* p = s.c_str(); - char* p_end = nullptr; - errno = 0; // strtoull doesn't reset errno - const unsigned long long res = std::strtoull(p, &p_end, 10); // NOLINT(runtime/int) - if (p == p_end // invalid input or empty string - || errno == ERANGE // out of range - || JSON_HEDLEY_UNLIKELY(static_cast(p_end - p) != s.size())) // incomplete read - { - JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", s, "'"), nullptr)); - } - - // only triggered on special platforms (like 32bit), see also - // https://github.com/nlohmann/json/pull/2203 - if (res >= static_cast((std::numeric_limits::max)())) // NOLINT(runtime/int) - { - JSON_THROW(detail::out_of_range::create(410, detail::concat("array index ", s, " exceeds size_type"), nullptr)); // LCOV_EXCL_LINE - } - - return static_cast(res); - } - - JSON_PRIVATE_UNLESS_TESTED: - json_pointer top() const - { - if (JSON_HEDLEY_UNLIKELY(empty())) - { - JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", nullptr)); - } - - json_pointer result = *this; - result.reference_tokens = {reference_tokens[0]}; - return result; - } - - private: - /*! - @brief create and return a reference to the pointed to value - - @complexity Linear in the number of reference tokens. - - @throw parse_error.109 if array index is not a number - @throw type_error.313 if value cannot be unflattened - */ - template - BasicJsonType& get_and_create(BasicJsonType& j) const - { - auto* result = &j; - - // in case no reference tokens exist, return a reference to the JSON value - // j which will be overwritten by a primitive value - for (const auto& reference_token : reference_tokens) - { - switch (result->type()) - { - case detail::value_t::null: - { - if (reference_token == "0") - { - // start a new array if reference token is 0 - result = &result->operator[](0); - } - else - { - // start a new object otherwise - result = &result->operator[](reference_token); - } - break; - } - - case detail::value_t::object: - { - // create an entry in the object - result = &result->operator[](reference_token); - break; - } - - case detail::value_t::array: - { - // create an entry in the array - result = &result->operator[](array_index(reference_token)); - break; - } - - /* - The following code is only reached if there exists a reference - token _and_ the current value is primitive. In this case, we have - an error situation, because primitive values may only occur as - single value; that is, with an empty list of reference tokens. - */ - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - JSON_THROW(detail::type_error::create(313, "invalid value to unflatten", &j)); - } - } - - return *result; - } - - /*! - @brief return a reference to the pointed to value - - @note This version does not throw if a value is not present, but tries to - create nested values instead. For instance, calling this function - with pointer `"/this/that"` on a null value is equivalent to calling - `operator[]("this").operator[]("that")` on that value, effectively - changing the null value to an object. - - @param[in] ptr a JSON value - - @return reference to the JSON value pointed to by the JSON pointer - - @complexity Linear in the length of the JSON pointer. - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.404 if the JSON pointer can not be resolved - */ - template - BasicJsonType& get_unchecked(BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - // convert null values to arrays or objects before continuing - if (ptr->is_null()) - { - // check if reference token is a number - const bool nums = - std::all_of(reference_token.begin(), reference_token.end(), - [](const unsigned char x) - { - return std::isdigit(x); - }); - - // change value to array for numbers or "-" or to object otherwise - *ptr = (nums || reference_token == "-") - ? detail::value_t::array - : detail::value_t::object; - } - - switch (ptr->type()) - { - case detail::value_t::object: - { - // use unchecked object access - ptr = &ptr->operator[](reference_token); - break; - } - - case detail::value_t::array: - { - if (reference_token == "-") - { - // explicitly treat "-" as index beyond the end - ptr = &ptr->operator[](ptr->m_data.m_value.array->size()); - } - else - { - // convert array index to number; unchecked access - ptr = &ptr->operator[](array_index(reference_token)); - } - break; - } - - case detail::value_t::null: - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", reference_token, "'"), ptr)); - } - } - - return *ptr; - } - - /*! - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.402 if the array index '-' is used - @throw out_of_range.404 if the JSON pointer can not be resolved - */ - template - BasicJsonType& get_checked(BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - switch (ptr->type()) - { - case detail::value_t::object: - { - // note: at performs range check - ptr = &ptr->at(reference_token); - break; - } - - case detail::value_t::array: - { - if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) - { - // "-" always fails the range check - JSON_THROW(detail::out_of_range::create(402, detail::concat( - "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), - ") is out of range"), ptr)); - } - - // note: at performs range check - ptr = &ptr->at(array_index(reference_token)); - break; - } - - case detail::value_t::null: - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", reference_token, "'"), ptr)); - } - } - - return *ptr; - } - - /*! - @brief return a const reference to the pointed to value - - @param[in] ptr a JSON value - - @return const reference to the JSON value pointed to by the JSON - pointer - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.402 if the array index '-' is used - @throw out_of_range.404 if the JSON pointer can not be resolved - */ - template - const BasicJsonType& get_unchecked(const BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - switch (ptr->type()) - { - case detail::value_t::object: - { - // use unchecked object access - ptr = &ptr->operator[](reference_token); - break; - } - - case detail::value_t::array: - { - if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) - { - // "-" cannot be used for const access - JSON_THROW(detail::out_of_range::create(402, detail::concat("array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), ") is out of range"), ptr)); - } - - // use unchecked array access - ptr = &ptr->operator[](array_index(reference_token)); - break; - } - - case detail::value_t::null: - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", reference_token, "'"), ptr)); - } - } - - return *ptr; - } - - /*! - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.402 if the array index '-' is used - @throw out_of_range.404 if the JSON pointer can not be resolved - */ - template - const BasicJsonType& get_checked(const BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - switch (ptr->type()) - { - case detail::value_t::object: - { - // note: at performs range check - ptr = &ptr->at(reference_token); - break; - } - - case detail::value_t::array: - { - if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) - { - // "-" always fails the range check - JSON_THROW(detail::out_of_range::create(402, detail::concat( - "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()), - ") is out of range"), ptr)); - } - - // note: at performs range check - ptr = &ptr->at(array_index(reference_token)); - break; - } - - case detail::value_t::null: - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - JSON_THROW(detail::out_of_range::create(404, detail::concat("unresolved reference token '", reference_token, "'"), ptr)); - } - } - - return *ptr; - } - - /*! - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - */ - template - bool contains(const BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - switch (ptr->type()) - { - case detail::value_t::object: - { - if (!ptr->contains(reference_token)) - { - // we did not find the key in the object - return false; - } - - ptr = &ptr->operator[](reference_token); - break; - } - - case detail::value_t::array: - { - if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) - { - // "-" always fails the range check - return false; - } - if (JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !("0" <= reference_token && reference_token <= "9"))) - { - // invalid char - return false; - } - if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1)) - { - if (JSON_HEDLEY_UNLIKELY(!('1' <= reference_token[0] && reference_token[0] <= '9'))) - { - // first char should be between '1' and '9' - return false; - } - for (std::size_t i = 1; i < reference_token.size(); i++) - { - if (JSON_HEDLEY_UNLIKELY(!('0' <= reference_token[i] && reference_token[i] <= '9'))) - { - // other char should be between '0' and '9' - return false; - } - } - } - - const auto idx = array_index(reference_token); - if (idx >= ptr->size()) - { - // index out of range - return false; - } - - ptr = &ptr->operator[](idx); - break; - } - - case detail::value_t::null: - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - { - // we do not expect primitive values if there is still a - // reference token to process - return false; - } - } - } - - // no reference token left means we found a primitive value - return true; - } - - /*! - @brief split the string input to reference tokens - - @note This function is only called by the json_pointer constructor. - All exceptions below are documented there. - - @throw parse_error.107 if the pointer is not empty or begins with '/' - @throw parse_error.108 if character '~' is not followed by '0' or '1' - */ - static std::vector split(const string_t& reference_string) - { - std::vector result; - - // special case: empty reference string -> no reference tokens - if (reference_string.empty()) - { - return result; - } - - // check if nonempty reference string begins with slash - if (JSON_HEDLEY_UNLIKELY(reference_string[0] != '/')) - { - JSON_THROW(detail::parse_error::create(107, 1, detail::concat("JSON pointer must be empty or begin with '/' - was: '", reference_string, "'"), nullptr)); - } - - // extract the reference tokens: - // - slash: position of the last read slash (or end of string) - // - start: position after the previous slash - for ( - // search for the first slash after the first character - std::size_t slash = reference_string.find_first_of('/', 1), - // set the beginning of the first reference token - start = 1; - // we can stop if start == 0 (if slash == string_t::npos) - start != 0; - // set the beginning of the next reference token - // (will eventually be 0 if slash == string_t::npos) - start = (slash == string_t::npos) ? 0 : slash + 1, - // find next slash - slash = reference_string.find_first_of('/', start)) - { - // use the text between the beginning of the reference token - // (start) and the last slash (slash). - auto reference_token = reference_string.substr(start, slash - start); - - // check reference tokens are properly escaped - for (std::size_t pos = reference_token.find_first_of('~'); - pos != string_t::npos; - pos = reference_token.find_first_of('~', pos + 1)) - { - JSON_ASSERT(reference_token[pos] == '~'); - - // ~ must be followed by 0 or 1 - if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 || - (reference_token[pos + 1] != '0' && - reference_token[pos + 1] != '1'))) - { - JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'", nullptr)); - } - } - - // finally, store the reference token - detail::unescape(reference_token); - result.push_back(reference_token); - } - - return result; - } - - private: - /*! - @param[in] reference_string the reference string to the current value - @param[in] value the value to consider - @param[in,out] result the result object to insert values to - - @note Empty objects or arrays are flattened to `null`. - */ - template - static void flatten(const string_t& reference_string, - const BasicJsonType& value, - BasicJsonType& result) - { - switch (value.type()) - { - case detail::value_t::array: - { - if (value.m_data.m_value.array->empty()) - { - // flatten empty array as null - result[reference_string] = nullptr; - } - else - { - // iterate array and use index as reference string - for (std::size_t i = 0; i < value.m_data.m_value.array->size(); ++i) - { - flatten(detail::concat(reference_string, '/', std::to_string(i)), - value.m_data.m_value.array->operator[](i), result); - } - } - break; - } - - case detail::value_t::object: - { - if (value.m_data.m_value.object->empty()) - { - // flatten empty object as null - result[reference_string] = nullptr; - } - else - { - // iterate object and use keys as reference string - for (const auto& element : *value.m_data.m_value.object) - { - flatten(detail::concat(reference_string, '/', detail::escape(element.first)), element.second, result); - } - } - break; - } - - case detail::value_t::null: - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - { - // add primitive value with its reference string - result[reference_string] = value; - break; - } - } - } - - /*! - @param[in] value flattened JSON - - @return unflattened JSON - - @throw parse_error.109 if array index is not a number - @throw type_error.314 if value is not an object - @throw type_error.315 if object values are not primitive - @throw type_error.313 if value cannot be unflattened - */ - template - static BasicJsonType - unflatten(const BasicJsonType& value) - { - if (JSON_HEDLEY_UNLIKELY(!value.is_object())) - { - JSON_THROW(detail::type_error::create(314, "only objects can be unflattened", &value)); - } - - BasicJsonType result; - - // iterate the JSON object values - for (const auto& element : *value.m_data.m_value.object) - { - if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive())) - { - JSON_THROW(detail::type_error::create(315, "values in object must be primitive", &element.second)); - } - - // assign value to reference pointed to by JSON pointer; Note that if - // the JSON pointer is "" (i.e., points to the whole value), function - // get_and_create returns a reference to result itself. An assignment - // will then create a primitive value. - json_pointer(element.first).get_and_create(result) = element.second; - } - - return result; - } - - // can't use conversion operator because of ambiguity - json_pointer convert() const& - { - json_pointer result; - result.reference_tokens = reference_tokens; - return result; - } - - json_pointer convert()&& - { - json_pointer result; - result.reference_tokens = std::move(reference_tokens); - return result; - } - - public: -#if JSON_HAS_THREE_WAY_COMPARISON - /// @brief compares two JSON pointers for equality - /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ - template - bool operator==(const json_pointer& rhs) const noexcept - { - return reference_tokens == rhs.reference_tokens; - } - - /// @brief compares JSON pointer and string for equality - /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ - JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer)) - bool operator==(const string_t& rhs) const - { - return *this == json_pointer(rhs); - } - - /// @brief 3-way compares two JSON pointers - template - std::strong_ordering operator<=>(const json_pointer& rhs) const noexcept // *NOPAD* - { - return reference_tokens <=> rhs.reference_tokens; // *NOPAD* - } -#else - /// @brief compares two JSON pointers for equality - /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ - template - // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator==(const json_pointer& lhs, - const json_pointer& rhs) noexcept; - - /// @brief compares JSON pointer and string for equality - /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ - template - // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator==(const json_pointer& lhs, - const StringType& rhs); - - /// @brief compares string and JSON pointer for equality - /// @sa https://json.nlohmann.me/api/json_pointer/operator_eq/ - template - // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator==(const StringType& lhs, - const json_pointer& rhs); - - /// @brief compares two JSON pointers for inequality - /// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/ - template - // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator!=(const json_pointer& lhs, - const json_pointer& rhs) noexcept; - - /// @brief compares JSON pointer and string for inequality - /// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/ - template - // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator!=(const json_pointer& lhs, - const StringType& rhs); - - /// @brief compares string and JSON pointer for inequality - /// @sa https://json.nlohmann.me/api/json_pointer/operator_ne/ - template - // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator!=(const StringType& lhs, - const json_pointer& rhs); - - /// @brief compares two JSON pointer for less-than - template - // NOLINTNEXTLINE(readability-redundant-declaration) - friend bool operator<(const json_pointer& lhs, - const json_pointer& rhs) noexcept; -#endif - - private: - /// the reference tokens - std::vector reference_tokens; -}; - -#if !JSON_HAS_THREE_WAY_COMPARISON -// functions cannot be defined inside class due to ODR violations -template -inline bool operator==(const json_pointer& lhs, - const json_pointer& rhs) noexcept -{ - return lhs.reference_tokens == rhs.reference_tokens; -} - -template::string_t> -JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer)) -inline bool operator==(const json_pointer& lhs, - const StringType& rhs) -{ - return lhs == json_pointer(rhs); -} - -template::string_t> -JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator==(json_pointer, json_pointer)) -inline bool operator==(const StringType& lhs, - const json_pointer& rhs) -{ - return json_pointer(lhs) == rhs; -} - -template -inline bool operator!=(const json_pointer& lhs, - const json_pointer& rhs) noexcept -{ - return !(lhs == rhs); -} - -template::string_t> -JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer)) -inline bool operator!=(const json_pointer& lhs, - const StringType& rhs) -{ - return !(lhs == rhs); -} - -template::string_t> -JSON_HEDLEY_DEPRECATED_FOR(3.11.2, operator!=(json_pointer, json_pointer)) -inline bool operator!=(const StringType& lhs, - const json_pointer& rhs) -{ - return !(lhs == rhs); -} - -template -inline bool operator<(const json_pointer& lhs, - const json_pointer& rhs) noexcept -{ - return lhs.reference_tokens < rhs.reference_tokens; -} -#endif - -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/json_ref.hpp b/include/nlohmann/detail/json_ref.hpp deleted file mode 100644 index 47911fb552..0000000000 --- a/include/nlohmann/detail/json_ref.hpp +++ /dev/null @@ -1,78 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include -#include - -#include -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -template -class json_ref -{ - public: - using value_type = BasicJsonType; - - json_ref(value_type&& value) - : owned_value(std::move(value)) - {} - - json_ref(const value_type& value) - : value_ref(&value) - {} - - json_ref(std::initializer_list init) - : owned_value(init) - {} - - template < - class... Args, - enable_if_t::value, int> = 0 > - json_ref(Args && ... args) - : owned_value(std::forward(args)...) - {} - - // class should be movable only - json_ref(json_ref&&) noexcept = default; - json_ref(const json_ref&) = delete; - json_ref& operator=(const json_ref&) = delete; - json_ref& operator=(json_ref&&) = delete; - ~json_ref() = default; - - value_type moved_or_copied() const - { - if (value_ref == nullptr) - { - return std::move(owned_value); - } - return *value_ref; - } - - value_type const& operator*() const - { - return value_ref ? *value_ref : owned_value; - } - - value_type const* operator->() const - { - return &** this; - } - - private: - mutable value_type owned_value = nullptr; - value_type const* value_ref = nullptr; -}; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp deleted file mode 100644 index 2870a4f1de..0000000000 --- a/include/nlohmann/detail/macro_scope.hpp +++ /dev/null @@ -1,469 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // declval, pair -#include -#include - -// This file contains all internal macro definitions (except those affecting ABI) -// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them - -#include - -// exclude unsupported compilers -#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) - #if defined(__clang__) - #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 - #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" - #endif - #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) - #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 - #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" - #endif - #endif -#endif - -// C++ language standard detection -// if the user manually specified the used c++ version this is skipped -#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11) - #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) - #define JSON_HAS_CPP_20 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 - #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 - #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) - #define JSON_HAS_CPP_14 - #endif - // the cpp 11 flag is always specified because it is the minimal required version - #define JSON_HAS_CPP_11 -#endif - -#ifdef __has_include - #if __has_include() - #include - #endif -#endif - -#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM) - #ifdef JSON_HAS_CPP_17 - #if defined(__cpp_lib_filesystem) - #define JSON_HAS_FILESYSTEM 1 - #elif defined(__cpp_lib_experimental_filesystem) - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 - #elif !defined(__has_include) - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 - #elif __has_include() - #define JSON_HAS_FILESYSTEM 1 - #elif __has_include() - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 - #endif - - // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ - #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif - - // no filesystem support before GCC 8: https://en.cppreference.com/w/cpp/compiler_support - #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif - - // no filesystem support before Clang 7: https://en.cppreference.com/w/cpp/compiler_support - #if defined(__clang_major__) && __clang_major__ < 7 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif - - // no filesystem support before MSVC 19.14: https://en.cppreference.com/w/cpp/compiler_support - #if defined(_MSC_VER) && _MSC_VER < 1914 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif - - // no filesystem support before iOS 13 - #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif - - // no filesystem support before macOS Catalina - #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif - #endif -#endif - -#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0 -#endif - -#ifndef JSON_HAS_FILESYSTEM - #define JSON_HAS_FILESYSTEM 0 -#endif - -#ifndef JSON_HAS_THREE_WAY_COMPARISON - #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \ - && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L - #define JSON_HAS_THREE_WAY_COMPARISON 1 - #else - #define JSON_HAS_THREE_WAY_COMPARISON 0 - #endif -#endif - -#ifndef JSON_HAS_RANGES - // ranges header shipping in GCC 11.1.0 (released 2021-04-27) has syntax error - #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427 - #define JSON_HAS_RANGES 0 - #elif defined(__cpp_lib_ranges) - #define JSON_HAS_RANGES 1 - #else - #define JSON_HAS_RANGES 0 - #endif -#endif - -#ifdef JSON_HAS_CPP_17 - #define JSON_INLINE_VARIABLE inline -#else - #define JSON_INLINE_VARIABLE -#endif - -#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address) - #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]] -#else - #define JSON_NO_UNIQUE_ADDRESS -#endif - -// disable documentation warnings on clang -#if defined(__clang__) - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wdocumentation" - #pragma clang diagnostic ignored "-Wdocumentation-unknown-command" -#endif - -// allow disabling exceptions -#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) - #define JSON_THROW(exception) throw exception - #define JSON_TRY try - #define JSON_CATCH(exception) catch(exception) - #define JSON_INTERNAL_CATCH(exception) catch(exception) -#else - #include - #define JSON_THROW(exception) std::abort() - #define JSON_TRY if(true) - #define JSON_CATCH(exception) if(false) - #define JSON_INTERNAL_CATCH(exception) if(false) -#endif - -// override exception macros -#if defined(JSON_THROW_USER) - #undef JSON_THROW - #define JSON_THROW JSON_THROW_USER -#endif -#if defined(JSON_TRY_USER) - #undef JSON_TRY - #define JSON_TRY JSON_TRY_USER -#endif -#if defined(JSON_CATCH_USER) - #undef JSON_CATCH - #define JSON_CATCH JSON_CATCH_USER - #undef JSON_INTERNAL_CATCH - #define JSON_INTERNAL_CATCH JSON_CATCH_USER -#endif -#if defined(JSON_INTERNAL_CATCH_USER) - #undef JSON_INTERNAL_CATCH - #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER -#endif - -// allow overriding assert -#if !defined(JSON_ASSERT) - #include // assert - #define JSON_ASSERT(x) assert(x) -#endif - -// allow to access some private functions (needed by the test suite) -#if defined(JSON_TESTS_PRIVATE) - #define JSON_PRIVATE_UNLESS_TESTED public -#else - #define JSON_PRIVATE_UNLESS_TESTED private -#endif - -/*! -@brief macro to briefly define a mapping between an enum and JSON -@def NLOHMANN_JSON_SERIALIZE_ENUM -@since version 3.4.0 -*/ -#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ - template \ - inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), \ - [e](const std::pair& ej_pair) -> bool \ - { \ - return ej_pair.first == e; \ - }); \ - j = ((it != std::end(m)) ? it : std::begin(m))->second; \ - } \ - template \ - inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), \ - [&j](const std::pair& ej_pair) -> bool \ - { \ - return ej_pair.second == j; \ - }); \ - e = ((it != std::end(m)) ? it : std::begin(m))->first; \ - } - -// Ugly macros to avoid uglier copy-paste when specializing basic_json. They -// may be removed in the future once the class is split. - -#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ - template class ObjectType, \ - template class ArrayType, \ - class StringType, class BooleanType, class NumberIntegerType, \ - class NumberUnsignedType, class NumberFloatType, \ - template class AllocatorType, \ - template class JSONSerializer, \ - class BinaryType, \ - class CustomBaseClass> - -#define NLOHMANN_BASIC_JSON_TPL \ - basic_json - -// Macros to simplify conversion from/to types - -#define NLOHMANN_JSON_EXPAND( x ) x -#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME -#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ - NLOHMANN_JSON_PASTE64, \ - NLOHMANN_JSON_PASTE63, \ - NLOHMANN_JSON_PASTE62, \ - NLOHMANN_JSON_PASTE61, \ - NLOHMANN_JSON_PASTE60, \ - NLOHMANN_JSON_PASTE59, \ - NLOHMANN_JSON_PASTE58, \ - NLOHMANN_JSON_PASTE57, \ - NLOHMANN_JSON_PASTE56, \ - NLOHMANN_JSON_PASTE55, \ - NLOHMANN_JSON_PASTE54, \ - NLOHMANN_JSON_PASTE53, \ - NLOHMANN_JSON_PASTE52, \ - NLOHMANN_JSON_PASTE51, \ - NLOHMANN_JSON_PASTE50, \ - NLOHMANN_JSON_PASTE49, \ - NLOHMANN_JSON_PASTE48, \ - NLOHMANN_JSON_PASTE47, \ - NLOHMANN_JSON_PASTE46, \ - NLOHMANN_JSON_PASTE45, \ - NLOHMANN_JSON_PASTE44, \ - NLOHMANN_JSON_PASTE43, \ - NLOHMANN_JSON_PASTE42, \ - NLOHMANN_JSON_PASTE41, \ - NLOHMANN_JSON_PASTE40, \ - NLOHMANN_JSON_PASTE39, \ - NLOHMANN_JSON_PASTE38, \ - NLOHMANN_JSON_PASTE37, \ - NLOHMANN_JSON_PASTE36, \ - NLOHMANN_JSON_PASTE35, \ - NLOHMANN_JSON_PASTE34, \ - NLOHMANN_JSON_PASTE33, \ - NLOHMANN_JSON_PASTE32, \ - NLOHMANN_JSON_PASTE31, \ - NLOHMANN_JSON_PASTE30, \ - NLOHMANN_JSON_PASTE29, \ - NLOHMANN_JSON_PASTE28, \ - NLOHMANN_JSON_PASTE27, \ - NLOHMANN_JSON_PASTE26, \ - NLOHMANN_JSON_PASTE25, \ - NLOHMANN_JSON_PASTE24, \ - NLOHMANN_JSON_PASTE23, \ - NLOHMANN_JSON_PASTE22, \ - NLOHMANN_JSON_PASTE21, \ - NLOHMANN_JSON_PASTE20, \ - NLOHMANN_JSON_PASTE19, \ - NLOHMANN_JSON_PASTE18, \ - NLOHMANN_JSON_PASTE17, \ - NLOHMANN_JSON_PASTE16, \ - NLOHMANN_JSON_PASTE15, \ - NLOHMANN_JSON_PASTE14, \ - NLOHMANN_JSON_PASTE13, \ - NLOHMANN_JSON_PASTE12, \ - NLOHMANN_JSON_PASTE11, \ - NLOHMANN_JSON_PASTE10, \ - NLOHMANN_JSON_PASTE9, \ - NLOHMANN_JSON_PASTE8, \ - NLOHMANN_JSON_PASTE7, \ - NLOHMANN_JSON_PASTE6, \ - NLOHMANN_JSON_PASTE5, \ - NLOHMANN_JSON_PASTE4, \ - NLOHMANN_JSON_PASTE3, \ - NLOHMANN_JSON_PASTE2, \ - NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) -#define NLOHMANN_JSON_PASTE2(func, v1) func(v1) -#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2) -#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3) -#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4) -#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5) -#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6) -#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7) -#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8) -#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9) -#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10) -#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) -#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) -#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) -#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) -#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) -#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) -#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) -#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) -#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) -#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) -#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) -#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) -#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) -#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) -#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) -#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) -#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) -#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) -#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) -#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) -#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) -#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) -#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) -#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) -#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) -#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) -#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) -#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) -#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) -#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) -#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) -#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) -#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) -#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) -#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) -#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) -#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) -#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) -#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) -#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) -#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) -#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) -#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) -#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) -#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) -#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) -#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) -#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) -#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) -#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) - -#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; -#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); -#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1); - -/*! -@brief macro -@def NLOHMANN_DEFINE_TYPE_INTRUSIVE -@since version 3.9.0 -*/ -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ - friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } - -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \ - friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } - -/*! -@brief macro -@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE -@since version 3.9.0 -*/ -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ - inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } - -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \ - inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } - - -// inspired from https://stackoverflow.com/a/26745591 -// allows to call any std function as if (e.g. with begin): -// using std::begin; begin(x); -// -// it allows using the detected idiom to retrieve the return type -// of such an expression -#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \ - namespace detail { \ - using std::std_name; \ - \ - template \ - using result_of_##std_name = decltype(std_name(std::declval()...)); \ - } \ - \ - namespace detail2 { \ - struct std_name##_tag \ - { \ - }; \ - \ - template \ - std_name##_tag std_name(T&&...); \ - \ - template \ - using result_of_##std_name = decltype(std_name(std::declval()...)); \ - \ - template \ - struct would_call_std_##std_name \ - { \ - static constexpr auto const value = ::nlohmann::detail:: \ - is_detected_exact::value; \ - }; \ - } /* namespace detail2 */ \ - \ - template \ - struct would_call_std_##std_name : detail2::would_call_std_##std_name \ - { \ - } - -#ifndef JSON_USE_IMPLICIT_CONVERSIONS - #define JSON_USE_IMPLICIT_CONVERSIONS 1 -#endif - -#if JSON_USE_IMPLICIT_CONVERSIONS - #define JSON_EXPLICIT -#else - #define JSON_EXPLICIT explicit -#endif - -#ifndef JSON_DISABLE_ENUM_SERIALIZATION - #define JSON_DISABLE_ENUM_SERIALIZATION 0 -#endif - -#ifndef JSON_USE_GLOBAL_UDLS - #define JSON_USE_GLOBAL_UDLS 1 -#endif diff --git a/include/nlohmann/detail/macro_unscope.hpp b/include/nlohmann/detail/macro_unscope.hpp deleted file mode 100644 index 4a871f0c24..0000000000 --- a/include/nlohmann/detail/macro_unscope.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -// restore clang diagnostic settings -#if defined(__clang__) - #pragma clang diagnostic pop -#endif - -// clean up -#undef JSON_ASSERT -#undef JSON_INTERNAL_CATCH -#undef JSON_THROW -#undef JSON_PRIVATE_UNLESS_TESTED -#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION -#undef NLOHMANN_BASIC_JSON_TPL -#undef JSON_EXPLICIT -#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL -#undef JSON_INLINE_VARIABLE -#undef JSON_NO_UNIQUE_ADDRESS -#undef JSON_DISABLE_ENUM_SERIALIZATION -#undef JSON_USE_GLOBAL_UDLS - -#ifndef JSON_TEST_KEEP_MACROS - #undef JSON_CATCH - #undef JSON_TRY - #undef JSON_HAS_CPP_11 - #undef JSON_HAS_CPP_14 - #undef JSON_HAS_CPP_17 - #undef JSON_HAS_CPP_20 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #undef JSON_HAS_THREE_WAY_COMPARISON - #undef JSON_HAS_RANGES - #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON -#endif - -#include diff --git a/include/nlohmann/detail/meta/call_std/begin.hpp b/include/nlohmann/detail/meta/call_std/begin.hpp deleted file mode 100644 index 27d36c66a0..0000000000 --- a/include/nlohmann/detail/meta/call_std/begin.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN - -NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin); - -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/meta/call_std/end.hpp b/include/nlohmann/detail/meta/call_std/end.hpp deleted file mode 100644 index d10bf8333c..0000000000 --- a/include/nlohmann/detail/meta/call_std/end.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN - -NLOHMANN_CAN_CALL_STD_FUNC_IMPL(end); - -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/meta/cpp_future.hpp b/include/nlohmann/detail/meta/cpp_future.hpp deleted file mode 100644 index 22f25140da..0000000000 --- a/include/nlohmann/detail/meta/cpp_future.hpp +++ /dev/null @@ -1,171 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-FileCopyrightText: 2018 The Abseil Authors -// SPDX-License-Identifier: MIT - -#pragma once - -#include // array -#include // size_t -#include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type -#include // index_sequence, make_index_sequence, index_sequence_for - -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -template -using uncvref_t = typename std::remove_cv::type>::type; - -#ifdef JSON_HAS_CPP_14 - -// the following utilities are natively available in C++14 -using std::enable_if_t; -using std::index_sequence; -using std::make_index_sequence; -using std::index_sequence_for; - -#else - -// alias templates to reduce boilerplate -template -using enable_if_t = typename std::enable_if::type; - -// The following code is taken from https://github.com/abseil/abseil-cpp/blob/10cb35e459f5ecca5b2ff107635da0bfa41011b4/absl/utility/utility.h -// which is part of Google Abseil (https://github.com/abseil/abseil-cpp), licensed under the Apache License 2.0. - -//// START OF CODE FROM GOOGLE ABSEIL - -// integer_sequence -// -// Class template representing a compile-time integer sequence. An instantiation -// of `integer_sequence` has a sequence of integers encoded in its -// type through its template arguments (which is a common need when -// working with C++11 variadic templates). `absl::integer_sequence` is designed -// to be a drop-in replacement for C++14's `std::integer_sequence`. -// -// Example: -// -// template< class T, T... Ints > -// void user_function(integer_sequence); -// -// int main() -// { -// // user_function's `T` will be deduced to `int` and `Ints...` -// // will be deduced to `0, 1, 2, 3, 4`. -// user_function(make_integer_sequence()); -// } -template -struct integer_sequence -{ - using value_type = T; - static constexpr std::size_t size() noexcept - { - return sizeof...(Ints); - } -}; - -// index_sequence -// -// A helper template for an `integer_sequence` of `size_t`, -// `absl::index_sequence` is designed to be a drop-in replacement for C++14's -// `std::index_sequence`. -template -using index_sequence = integer_sequence; - -namespace utility_internal -{ - -template -struct Extend; - -// Note that SeqSize == sizeof...(Ints). It's passed explicitly for efficiency. -template -struct Extend, SeqSize, 0> -{ - using type = integer_sequence < T, Ints..., (Ints + SeqSize)... >; -}; - -template -struct Extend, SeqSize, 1> -{ - using type = integer_sequence < T, Ints..., (Ints + SeqSize)..., 2 * SeqSize >; -}; - -// Recursion helper for 'make_integer_sequence'. -// 'Gen::type' is an alias for 'integer_sequence'. -template -struct Gen -{ - using type = - typename Extend < typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type; -}; - -template -struct Gen -{ - using type = integer_sequence; -}; - -} // namespace utility_internal - -// Compile-time sequences of integers - -// make_integer_sequence -// -// This template alias is equivalent to -// `integer_sequence`, and is designed to be a drop-in -// replacement for C++14's `std::make_integer_sequence`. -template -using make_integer_sequence = typename utility_internal::Gen::type; - -// make_index_sequence -// -// This template alias is equivalent to `index_sequence<0, 1, ..., N-1>`, -// and is designed to be a drop-in replacement for C++14's -// `std::make_index_sequence`. -template -using make_index_sequence = make_integer_sequence; - -// index_sequence_for -// -// Converts a typename pack into an index sequence of the same length, and -// is designed to be a drop-in replacement for C++14's -// `std::index_sequence_for()` -template -using index_sequence_for = make_index_sequence; - -//// END OF CODE FROM GOOGLE ABSEIL - -#endif - -// dispatch utility (taken from ranges-v3) -template struct priority_tag : priority_tag < N - 1 > {}; -template<> struct priority_tag<0> {}; - -// taken from ranges-v3 -template -struct static_const -{ - static JSON_INLINE_VARIABLE constexpr T value{}; -}; - -#ifndef JSON_HAS_CPP_17 - template - constexpr T static_const::value; -#endif - -template -inline constexpr std::array make_array(Args&& ... args) -{ - return std::array {{static_cast(std::forward(args))...}}; -} - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/meta/detected.hpp b/include/nlohmann/detail/meta/detected.hpp deleted file mode 100644 index b2f6db9fc4..0000000000 --- a/include/nlohmann/detail/meta/detected.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include - -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -// https://en.cppreference.com/w/cpp/experimental/is_detected -struct nonesuch -{ - nonesuch() = delete; - ~nonesuch() = delete; - nonesuch(nonesuch const&) = delete; - nonesuch(nonesuch const&&) = delete; - void operator=(nonesuch const&) = delete; - void operator=(nonesuch&&) = delete; -}; - -template class Op, - class... Args> -struct detector -{ - using value_t = std::false_type; - using type = Default; -}; - -template class Op, class... Args> -struct detector>, Op, Args...> -{ - using value_t = std::true_type; - using type = Op; -}; - -template class Op, class... Args> -using is_detected = typename detector::value_t; - -template class Op, class... Args> -struct is_detected_lazy : is_detected { }; - -template class Op, class... Args> -using detected_t = typename detector::type; - -template class Op, class... Args> -using detected_or = detector; - -template class Op, class... Args> -using detected_or_t = typename detected_or::type; - -template class Op, class... Args> -using is_detected_exact = std::is_same>; - -template class Op, class... Args> -using is_detected_convertible = - std::is_convertible, To>; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/meta/identity_tag.hpp b/include/nlohmann/detail/meta/identity_tag.hpp deleted file mode 100644 index 71164f281b..0000000000 --- a/include/nlohmann/detail/meta/identity_tag.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -// dispatching helper struct -template struct identity_tag {}; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/meta/is_sax.hpp b/include/nlohmann/detail/meta/is_sax.hpp deleted file mode 100644 index 2150089632..0000000000 --- a/include/nlohmann/detail/meta/is_sax.hpp +++ /dev/null @@ -1,159 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // size_t -#include // declval -#include // string - -#include -#include -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ - -template -using null_function_t = decltype(std::declval().null()); - -template -using boolean_function_t = - decltype(std::declval().boolean(std::declval())); - -template -using number_integer_function_t = - decltype(std::declval().number_integer(std::declval())); - -template -using number_unsigned_function_t = - decltype(std::declval().number_unsigned(std::declval())); - -template -using number_float_function_t = decltype(std::declval().number_float( - std::declval(), std::declval())); - -template -using string_function_t = - decltype(std::declval().string(std::declval())); - -template -using binary_function_t = - decltype(std::declval().binary(std::declval())); - -template -using start_object_function_t = - decltype(std::declval().start_object(std::declval())); - -template -using key_function_t = - decltype(std::declval().key(std::declval())); - -template -using end_object_function_t = decltype(std::declval().end_object()); - -template -using start_array_function_t = - decltype(std::declval().start_array(std::declval())); - -template -using end_array_function_t = decltype(std::declval().end_array()); - -template -using parse_error_function_t = decltype(std::declval().parse_error( - std::declval(), std::declval(), - std::declval())); - -template -struct is_sax -{ - private: - static_assert(is_basic_json::value, - "BasicJsonType must be of type basic_json<...>"); - - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - using exception_t = typename BasicJsonType::exception; - - public: - static constexpr bool value = - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value; -}; - -template -struct is_sax_static_asserts -{ - private: - static_assert(is_basic_json::value, - "BasicJsonType must be of type basic_json<...>"); - - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - using exception_t = typename BasicJsonType::exception; - - public: - static_assert(is_detected_exact::value, - "Missing/invalid function: bool null()"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool boolean(bool)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool boolean(bool)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool number_integer(number_integer_t)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool number_unsigned(number_unsigned_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool number_float(number_float_t, const string_t&)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool string(string_t&)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool binary(binary_t&)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool start_object(std::size_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool key(string_t&)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool end_object()"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool start_array(std::size_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool end_array()"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool parse_error(std::size_t, const " - "std::string&, const exception&)"); -}; - -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/meta/std_fs.hpp b/include/nlohmann/detail/meta/std_fs.hpp deleted file mode 100644 index c0961580ef..0000000000 --- a/include/nlohmann/detail/meta/std_fs.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include - -#if JSON_HAS_EXPERIMENTAL_FILESYSTEM -#include -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ -namespace std_fs = std::experimental::filesystem; -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END -#elif JSON_HAS_FILESYSTEM -#include -NLOHMANN_JSON_NAMESPACE_BEGIN -namespace detail -{ -namespace std_fs = std::filesystem; -} // namespace detail -NLOHMANN_JSON_NAMESPACE_END -#endif diff --git a/include/nlohmann/detail/meta/type_traits.hpp b/include/nlohmann/detail/meta/type_traits.hpp deleted file mode 100644 index cfc7e5ad31..0000000000 --- a/include/nlohmann/detail/meta/type_traits.hpp +++ /dev/null @@ -1,740 +0,0 @@ -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.11.2 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - -#pragma once - -#include // numeric_limits -#include // false_type, is_constructible, is_integral, is_same, true_type -#include // declval -#include // tuple - -#include -#include -#include -#include -#include -#include -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN -/*! -@brief detail namespace with internal helper functions - -This namespace collects functions that should not be exposed, -implementations of some @ref basic_json methods, and meta-programming helpers. - -@since version 2.1.0 -*/ -namespace detail -{ - -///////////// -// helpers // -///////////// - -// Note to maintainers: -// -// Every trait in this file expects a non CV-qualified type. -// The only exceptions are in the 'aliases for detected' section -// (i.e. those of the form: decltype(T::member_function(std::declval()))) -// -// In this case, T has to be properly CV-qualified to constraint the function arguments -// (e.g. to_json(BasicJsonType&, const T&)) - -template struct is_basic_json : std::false_type {}; - -NLOHMANN_BASIC_JSON_TPL_DECLARATION -struct is_basic_json : std::true_type {}; - -// used by exceptions create() member functions -// true_type for pointer to possibly cv-qualified basic_json or std::nullptr_t -// false_type otherwise -template -struct is_basic_json_context : - std::integral_constant < bool, - is_basic_json::type>::type>::value - || std::is_same::value > -{}; - -////////////////////// -// json_ref helpers // -////////////////////// - -template -class json_ref; - -template -struct is_json_ref : std::false_type {}; - -template -struct is_json_ref> : std::true_type {}; - -////////////////////////// -// aliases for detected // -////////////////////////// - -template -using mapped_type_t = typename T::mapped_type; - -template -using key_type_t = typename T::key_type; - -template -using value_type_t = typename T::value_type; - -template -using difference_type_t = typename T::difference_type; - -template -using pointer_t = typename T::pointer; - -template -using reference_t = typename T::reference; - -template -using iterator_category_t = typename T::iterator_category; - -template -using to_json_function = decltype(T::to_json(std::declval()...)); - -template -using from_json_function = decltype(T::from_json(std::declval()...)); - -template -using get_template_function = decltype(std::declval().template get()); - -// trait checking if JSONSerializer::from_json(json const&, udt&) exists -template -struct has_from_json : std::false_type {}; - -// trait checking if j.get is valid -// use this trait instead of std::is_constructible or std::is_convertible, -// both rely on, or make use of implicit conversions, and thus fail when T -// has several constructors/operator= (see https://github.com/nlohmann/json/issues/958) -template -struct is_getable -{ - static constexpr bool value = is_detected::value; -}; - -template -struct has_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> -{ - using serializer = typename BasicJsonType::template json_serializer; - - static constexpr bool value = - is_detected_exact::value; -}; - -// This trait checks if JSONSerializer::from_json(json const&) exists -// this overload is used for non-default-constructible user-defined-types -template -struct has_non_default_from_json : std::false_type {}; - -template -struct has_non_default_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> -{ - using serializer = typename BasicJsonType::template json_serializer; - - static constexpr bool value = - is_detected_exact::value; -}; - -// This trait checks if BasicJsonType::json_serializer::to_json exists -// Do not evaluate the trait when T is a basic_json type, to avoid template instantiation infinite recursion. -template -struct has_to_json : std::false_type {}; - -template -struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> -{ - using serializer = typename BasicJsonType::template json_serializer; - - static constexpr bool value = - is_detected_exact::value; -}; - -template -using detect_key_compare = typename T::key_compare; - -template -struct has_key_compare : std::integral_constant::value> {}; - -// obtains the actual object key comparator -template -struct actual_object_comparator -{ - using object_t = typename BasicJsonType::object_t; - using object_comparator_t = typename BasicJsonType::default_object_comparator_t; - using type = typename std::conditional < has_key_compare::value, - typename object_t::key_compare, object_comparator_t>::type; -}; - -template -using actual_object_comparator_t = typename actual_object_comparator::type; - -/////////////////// -// is_ functions // -/////////////////// - -// https://en.cppreference.com/w/cpp/types/conjunction -template struct conjunction : std::true_type { }; -template struct conjunction : B { }; -template -struct conjunction -: std::conditional(B::value), conjunction, B>::type {}; - -// https://en.cppreference.com/w/cpp/types/negation -template struct negation : std::integral_constant < bool, !B::value > { }; - -// Reimplementation of is_constructible and is_default_constructible, due to them being broken for -// std::pair and std::tuple until LWG 2367 fix (see https://cplusplus.github.io/LWG/lwg-defects.html#2367). -// This causes compile errors in e.g. clang 3.5 or gcc 4.9. -template -struct is_default_constructible : std::is_default_constructible {}; - -template -struct is_default_constructible> - : conjunction, is_default_constructible> {}; - -template -struct is_default_constructible> - : conjunction, is_default_constructible> {}; - -template -struct is_default_constructible> - : conjunction...> {}; - -template -struct is_default_constructible> - : conjunction...> {}; - - -template -struct is_constructible : std::is_constructible {}; - -template -struct is_constructible> : is_default_constructible> {}; - -template -struct is_constructible> : is_default_constructible> {}; - -template -struct is_constructible> : is_default_constructible> {}; - -template -struct is_constructible> : is_default_constructible> {}; - - -template -struct is_iterator_traits : std::false_type {}; - -template -struct is_iterator_traits> -{ - private: - using traits = iterator_traits; - - public: - static constexpr auto value = - is_detected::value && - is_detected::value && - is_detected::value && - is_detected::value && - is_detected::value; -}; - -template -struct is_range -{ - private: - using t_ref = typename std::add_lvalue_reference::type; - - using iterator = detected_t; - using sentinel = detected_t; - - // to be 100% correct, it should use https://en.cppreference.com/w/cpp/iterator/input_or_output_iterator - // and https://en.cppreference.com/w/cpp/iterator/sentinel_for - // but reimplementing these would be too much work, as a lot of other concepts are used underneath - static constexpr auto is_iterator_begin = - is_iterator_traits>::value; - - public: - static constexpr bool value = !std::is_same::value && !std::is_same::value && is_iterator_begin; -}; - -template -using iterator_t = enable_if_t::value, result_of_begin())>>; - -template -using range_value_t = value_type_t>>; - -// The following implementation of is_complete_type is taken from -// https://blogs.msdn.microsoft.com/vcblog/2015/12/02/partial-support-for-expression-sfinae-in-vs-2015-update-1/ -// and is written by Xiang Fan who agreed to using it in this library. - -template -struct is_complete_type : std::false_type {}; - -template -struct is_complete_type : std::true_type {}; - -template -struct is_compatible_object_type_impl : std::false_type {}; - -template -struct is_compatible_object_type_impl < - BasicJsonType, CompatibleObjectType, - enable_if_t < is_detected::value&& - is_detected::value >> -{ - using object_t = typename BasicJsonType::object_t; - - // macOS's is_constructible does not play well with nonesuch... - static constexpr bool value = - is_constructible::value && - is_constructible::value; -}; - -template -struct is_compatible_object_type - : is_compatible_object_type_impl {}; - -template -struct is_constructible_object_type_impl : std::false_type {}; - -template -struct is_constructible_object_type_impl < - BasicJsonType, ConstructibleObjectType, - enable_if_t < is_detected::value&& - is_detected::value >> -{ - using object_t = typename BasicJsonType::object_t; - - static constexpr bool value = - (is_default_constructible::value && - (std::is_move_assignable::value || - std::is_copy_assignable::value) && - (is_constructible::value && - std::is_same < - typename object_t::mapped_type, - typename ConstructibleObjectType::mapped_type >::value)) || - (has_from_json::value || - has_non_default_from_json < - BasicJsonType, - typename ConstructibleObjectType::mapped_type >::value); -}; - -template -struct is_constructible_object_type - : is_constructible_object_type_impl {}; - -template -struct is_compatible_string_type -{ - static constexpr auto value = - is_constructible::value; -}; - -template -struct is_constructible_string_type -{ - // launder type through decltype() to fix compilation failure on ICPC -#ifdef __INTEL_COMPILER - using laundered_type = decltype(std::declval()); -#else - using laundered_type = ConstructibleStringType; -#endif - - static constexpr auto value = - conjunction < - is_constructible, - is_detected_exact>::value; -}; - -template -struct is_compatible_array_type_impl : std::false_type {}; - -template -struct is_compatible_array_type_impl < - BasicJsonType, CompatibleArrayType, - enable_if_t < - is_detected::value&& - is_iterator_traits>>::value&& -// special case for types like std::filesystem::path whose iterator's value_type are themselves -// c.f. https://github.com/nlohmann/json/pull/3073 - !std::is_same>::value >> -{ - static constexpr bool value = - is_constructible>::value; -}; - -template -struct is_compatible_array_type - : is_compatible_array_type_impl {}; - -template -struct is_constructible_array_type_impl : std::false_type {}; - -template -struct is_constructible_array_type_impl < - BasicJsonType, ConstructibleArrayType, - enable_if_t::value >> - : std::true_type {}; - -template -struct is_constructible_array_type_impl < - BasicJsonType, ConstructibleArrayType, - enable_if_t < !std::is_same::value&& - !is_compatible_string_type::value&& - is_default_constructible::value&& -(std::is_move_assignable::value || - std::is_copy_assignable::value)&& -is_detected::value&& -is_iterator_traits>>::value&& -is_detected::value&& -// special case for types like std::filesystem::path whose iterator's value_type are themselves -// c.f. https://github.com/nlohmann/json/pull/3073 -!std::is_same>::value&& - is_complete_type < - detected_t>::value >> -{ - using value_type = range_value_t; - - static constexpr bool value = - std::is_same::value || - has_from_json::value || - has_non_default_from_json < - BasicJsonType, - value_type >::value; -}; - -template -struct is_constructible_array_type - : is_constructible_array_type_impl {}; - -template -struct is_compatible_integer_type_impl : std::false_type {}; - -template -struct is_compatible_integer_type_impl < - RealIntegerType, CompatibleNumberIntegerType, - enable_if_t < std::is_integral::value&& - std::is_integral::value&& - !std::is_same::value >> -{ - // is there an assert somewhere on overflows? - using RealLimits = std::numeric_limits; - using CompatibleLimits = std::numeric_limits; - - static constexpr auto value = - is_constructible::value && - CompatibleLimits::is_integer && - RealLimits::is_signed == CompatibleLimits::is_signed; -}; - -template -struct is_compatible_integer_type - : is_compatible_integer_type_impl {}; - -template -struct is_compatible_type_impl: std::false_type {}; - -template -struct is_compatible_type_impl < - BasicJsonType, CompatibleType, - enable_if_t::value >> -{ - static constexpr bool value = - has_to_json::value; -}; - -template -struct is_compatible_type - : is_compatible_type_impl {}; - -template -struct is_constructible_tuple : std::false_type {}; - -template -struct is_constructible_tuple> : conjunction...> {}; - -template -struct is_json_iterator_of : std::false_type {}; - -template -struct is_json_iterator_of : std::true_type {}; - -template -struct is_json_iterator_of : std::true_type -{}; - -// checks if a given type T is a template specialization of Primary -template