提交 0cb94aa8 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Update nlohmann::json C++ dep to 3.8.0

上级 5f594e2b
# Changelog # Changelog
### 3.6.8 (WIP)
* Update `nlohmann::json` C++ dep to 3.8.0.
### 3.6.7 ### 3.6.7
* `ConsumerScore`: Add `producerScores`, scores of all RTP streams in the producer ordered by encoding (just useful when the producer uses simulcast). * `ConsumerScore`: Add `producerScores`, scores of all RTP streams in the producer ordered by encoding (just useful when the producer uses simulcast).
......
version: 2 version: 2
jobs: jobs:
build: build_stable:
docker: docker:
- image: debian:stretch - image: debian:stretch
...@@ -8,23 +8,41 @@ jobs: ...@@ -8,23 +8,41 @@ jobs:
- checkout - checkout
- run: - run:
name: Install sudo name: Install required tools
command: 'apt-get update && apt-get install -y sudo && rm -rf /var/lib/apt/lists/*' command: 'apt-get update && apt-get install -y gcc g++ git cmake'
- run: - run:
name: Install GCC name: Run CMake
command: 'apt-get update && apt-get install -y gcc g++' command: 'mkdir build ; cd build ; cmake .. -DJSON_BuildTests=On'
- run: - run:
name: Install CMake name: Compile
command: 'apt-get update && sudo apt-get install -y cmake' command: 'cmake --build build'
- run: - run:
name: Create build files name: Execute test suite
command: 'mkdir build ; cd build ; cmake ..' command: 'cd build ; ctest --output-on-failure -j 2'
build_bleeding_edge:
docker:
- image: archlinux
steps:
- checkout
- run: - run:
name: Versions name: Install required tools
command: 'g++ --version ; uname -a' command: 'pacman -Sy --noconfirm base base-devel gcc git cmake'
- run:
name: Run CMake
command: 'mkdir build ; cd build ; cmake .. -DJSON_BuildTests=On'
- run: - run:
name: Compile name: Compile
command: 'cmake --build build' command: 'cmake --build build'
- run: - run:
name: Execute test suite name: Execute test suite
command: 'cd build ; ctest -j 2' command: 'cd build ; ctest --output-on-failure -j 2'
workflows:
version: 2
build_and_test_all:
jobs:
- build_stable
- build_bleeding_edge
{
"targets": {
"raspbian-jessie": {
"buildenv": "raspbian-jessie",
"builddeps": ["build-essential", "wget"],
"buildcmd": [
"uname -a",
"cat /etc/os-release",
"g++ --version",
"cd",
"wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz",
"tar xfz cmake-3.14.0.tar.gz",
"cd cmake-3.14.0",
"./bootstrap",
"make -j8",
"cd",
"mkdir build",
"cd build",
"../cmake-3.14.0/bin/cmake /project/repo/checkout",
"make -j8",
"../cmake-3.14.0/bin/ctest -VV -j4 --timeout 10000"
]
},
"xenial-armhf": {
"buildenv": "xenial-armhf",
"builddeps": ["build-essential", "wget"],
"buildcmd": [
"uname -a",
"lsb_release -a",
"g++ --version",
"cd",
"wget --no-check-certificate https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz",
"tar xfz cmake-3.14.0.tar.gz",
"cd cmake-3.14.0",
"./bootstrap",
"make -j8",
"cd",
"mkdir build",
"cd build",
"../cmake-3.14.0/bin/cmake /project/repo/checkout",
"make -j8",
"../cmake-3.14.0/bin/ctest -VV -j4 --timeout 10000"
]
},
"fedora24-x86_64": {
"buildenv": "fedora24-x86_64",
"builddeps": ["cmake", "make", "gcc gcc-c++"],
"buildcmd": [
"uname -a",
"cat /etc/fedora-release",
"g++ --version",
"cd",
"mkdir build",
"cd build",
"cmake /project/repo/checkout",
"make -j8",
"ctest -VV -j8"
]
},
"centos7-x86_64": {
"buildenv": "centos7-x86_64",
"builddeps": ["make", "wget", "gcc-c++"],
"buildcmd": [
"uname -a",
"rpm -q centos-release",
"g++ --version",
"cd",
"wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz",
"tar xfz cmake-3.14.0.tar.gz",
"cd cmake-3.14.0",
"./bootstrap",
"make -j8",
"cd",
"mkdir build",
"cd build",
"../cmake-3.14.0/bin/cmake /project/repo/checkout",
"make -j8",
"../cmake-3.14.0/bin/ctest -VV -j8"
]
}
}
}
# JSON for Modern C++ has been originally written by Niels Lohmann. # JSON for Modern C++ has been originally written by Niels Lohmann.
# Since 2013 over 140 contributors have helped to improve the library. # Since 2013 over 140 contributors have helped to improve the library.
# This CODEOWNERS file is only to make sure that @nlohmann is requsted # This CODEOWNERS file is only to make sure that @nlohmann is requested
# for a code review in case of a pull request. # for a code review in case of a pull request.
* @nlohmann * @nlohmann
...@@ -56,7 +56,7 @@ To make changes, you need to edit the following files: ...@@ -56,7 +56,7 @@ To make changes, you need to edit the following files:
- 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. - 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 these kind of bugs). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project. - Specifically, I am aware of compilation problems with **Microsoft Visual Studio** (there even is an [issue label](https://github.com/nlohmann/json/issues?utf8=✓&q=label%3A%22visual+studio%22+) for these kind of bugs). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project.
- Please refrain from proposing changes that would **break [JSON](http://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension. - 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 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/rfc7159.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). - We do not preserve the **insertion order of object elements**. The [JSON standard](https://tools.ietf.org/html/rfc7159.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).
...@@ -66,6 +66,6 @@ To make changes, you need to edit the following files: ...@@ -66,6 +66,6 @@ To make changes, you need to edit the following files:
The following areas really need contribution: 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 of GCC or Clang. - 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. - 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. - 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.
github: nlohmann
custom: http://paypal.me/nlohmann custom: http://paypal.me/nlohmann
...@@ -7,16 +7,51 @@ assignees: '' ...@@ -7,16 +7,51 @@ assignees: ''
--- ---
- What is the issue you have? <!-- Provide a concise summary of the issue in the title above. -->
- Please describe the steps to reproduce the issue. Can you provide a small but working code example? #### What is the issue you have?
- What is the expected behavior? <!-- Provide a detailed introduction to the issue itself, and why you consider it to be a bug. -->
<!-- If possible, be specific and add stack traces, error messages, etc. Avoid vague terms like "crash" or "doesn't work". -->
- And what is the actual behavior instead? #### Please describe the steps to reproduce the issue.
- Which compiler and operating system are you using? Is it a [supported compiler](https://github.com/nlohmann/json#supported-compilers)? <!-- Provide a link to a live example, or an unambiguous set of steps to -->
<!-- reproduce this bug. Include code to reproduce, if relevant -->
- Did you use a released version of the library or the version from the `develop` branch? 1.
2.
3.
- If you experience a compilation error: can you [compile and run the unit tests](https://github.com/nlohmann/json#execute-unit-tests)? #### Can you provide a small but working code example?
<!-- Please understand that we cannot analyze and debug large code bases. -->
#### What is the expected behavior?
<!-- Tell us what should happen -->
#### And what is the actual behavior instead?
<!-- Tell us what happens instead. -->
#### Which compiler and operating system are you using?
<!-- Include as many relevant details about the environment you experienced the bug in. -->
<!-- Make sure you use a supported compiler, see https://github.com/nlohmann/json#supported-compilers. -->
- Compiler: ___
- Operating system: ___
#### Which version of the library did you use?
<!-- Please add an `x` to the respective line. -->
- [ ] latest release version 3.7.3
- [ ] other release - please state the version: ___
- [ ] the `develop` branch
#### If you experience a compilation error: can you [compile and run the unit tests](https://github.com/nlohmann/json#execute-unit-tests)?
- [ ] yes
- [ ] no - please copy/paste the error message below
...@@ -7,6 +7,10 @@ assignees: '' ...@@ -7,6 +7,10 @@ assignees: ''
--- ---
- Describe the feature in as much detail as possible. #### Which feature do you want to see in the library?
- Include sample usage where appropriate. <!-- Describe the feature in as much detail as possible. -->
#### How would the feature be usable for other users?
<!-- Include sample usage where appropriate. -->
...@@ -7,10 +7,34 @@ assignees: '' ...@@ -7,10 +7,34 @@ assignees: ''
--- ---
- Describe what you want to achieve. <!-- Provide a concise summary of the issue in the title above. -->
- Describe what you tried. #### What do you want to achieve?
- Describe which system (OS, compiler) you are using. <!-- Please describe the feature as detailed as possible. -->
- Describe which version of the library you are using (release version, develop branch). #### What have you tried?
<!-- There are thousands of issues to search: https://github.com/nlohmann/json/issues?q=is%3Aissue+ -->
<!-- There is a full documentation of the API: https://nlohmann.github.io/json/ -->
<!-- There is a detailed README file: https://github.com/nlohmann/json/blob/develop/README.md -->
#### Can you provide a small code example?
<!-- Please understand that we cannot analyze and debug large code bases. -->
#### Which compiler and operating system are you using?
<!-- Include as many relevant details about the environment you experienced the bug in. -->
<!-- Make sure you use a supported compiler, see https://github.com/nlohmann/json#supported-compilers. -->
- Compiler: ___
- Operating system: ___
#### Which version of the library did you use?
<!-- Please add an `x` to the respective line. -->
- [ ] latest release version 3.7.3
- [ ] other release - please state the version: ___
- [ ] the `develop` branch
...@@ -15,5 +15,5 @@ Read the [Contribution Guidelines](https://github.com/nlohmann/json/blob/develop ...@@ -15,5 +15,5 @@ Read the [Contribution Guidelines](https://github.com/nlohmann/json/blob/develop
- 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. - 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 these kind of bugs). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project. - Specifically, I am aware of compilation problems with **Microsoft Visual Studio** (there even is an [issue label](https://github.com/nlohmann/json/issues?utf8=✓&q=label%3A%22visual+studio%22+) for these kind of bugs). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project.
- Please refrain from proposing changes that would **break [JSON](http://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension. - 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**. - Please do not open pull requests that address **multiple issues**.
name: macOS
on: [push, pull_request]
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: cmake
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
- name: build
run: cmake --build build --parallel 10
- name: test
run: cd build ; ctest -j 10 --output-on-failure
name: C/C++ CI name: Ubuntu
on: [push] on: [push, pull_request]
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- name: prepare
run: mkdir build
- name: cmake - name: cmake
run: cd build ; cmake .. run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
- name: build - name: build
run: make -C build run: cmake --build build --parallel 10
- name: test - name: test
run: cd build ; ctest -j 10 run: cd build ; ctest -j 10 --output-on-failure
name: Windows
on: [push, pull_request]
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: cmake
run: cmake -S . -B build -G "Visual Studio 16 2019" -D CMAKE_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
...@@ -18,8 +18,17 @@ me.nlohmann.json.docset ...@@ -18,8 +18,17 @@ me.nlohmann.json.docset
benchmarks/files/numbers/*.json benchmarks/files/numbers/*.json
.wsjcpp-logs/*
.wsjcpp/*
.idea .idea
cmake-build-debug cmake-build-debug
test/test-* test/test-*
/.vs /.vs
doc/mkdocs/venv/
doc/mkdocs/docs/images
doc/mkdocs/docs/examples
doc/mkdocs/site
doc/mkdocs/docs/__pycache__/
...@@ -95,16 +95,17 @@ matrix: ...@@ -95,16 +95,17 @@ matrix:
- os: linux - os: linux
compiler: gcc compiler: gcc
dist: bionic
addons: addons:
apt: apt:
sources: ['ubuntu-toolchain-r-test'] sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9', 'ninja-build'] packages: ['g++-7', 'ninja-build']
before_script: before_script:
- pip install --user cpp-coveralls - pip install --user cpp-coveralls
after_success: after_success:
- coveralls --build-root test --include include/nlohmann --gcov 'gcov-4.9' --gcov-options '\-lp' - coveralls --build-root test --include include/nlohmann --gcov 'gcov-7' --gcov-options '\-lp'
env: env:
- COMPILER=g++-4.9 - COMPILER=g++-7
- CMAKE_OPTIONS=-DJSON_Coverage=ON - CMAKE_OPTIONS=-DJSON_Coverage=ON
- MULTIPLE_HEADERS=ON - MULTIPLE_HEADERS=ON
...@@ -131,18 +132,6 @@ matrix: ...@@ -131,18 +132,6 @@ matrix:
# OSX / Clang # OSX / Clang
- os: osx
osx_image: xcode8.3
- os: osx
osx_image: xcode9
- os: osx
osx_image: xcode9.1
- os: osx
osx_image: xcode9.2
- os: osx - os: osx
osx_image: xcode9.3 osx_image: xcode9.3
...@@ -158,6 +147,9 @@ matrix: ...@@ -158,6 +147,9 @@ matrix:
- os: osx - os: osx
osx_image: xcode10.2 osx_image: xcode10.2
- os: osx
osx_image: xcode11.2
# Linux / GCC # Linux / GCC
- os: linux - os: linux
...@@ -329,13 +321,9 @@ script: ...@@ -329,13 +321,9 @@ script:
# by default, use the single-header version # by default, use the single-header version
- if [[ "${MULTIPLE_HEADERS}" == "" ]]; then export MULTIPLE_HEADERS=OFF; fi - if [[ "${MULTIPLE_HEADERS}" == "" ]]; then export MULTIPLE_HEADERS=OFF; fi
# show OS/compiler version
- uname -a
- $CXX --version
# compile and execute unit tests # compile and execute unit tests
- mkdir -p build && cd build - mkdir -p build && cd build
- cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -GNinja && cmake --build . --config Release - cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -DJSON_BuildTests=On -GNinja && cmake --build . --config Release
- ctest -C Release --timeout 2700 -V -j - ctest -C Release --timeout 2700 -V -j
- cd .. - cd ..
......
{
"checkRunSettings": {
"vulnerableCheckRunConclusionLevel": "failure"
},
"issueSettings": {
"minSeverityLevel": "LOW"
}
}
\ No newline at end of file
...@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.1) ...@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.1)
## PROJECT ## PROJECT
## name and version ## name and version
## ##
project(nlohmann_json VERSION 3.7.3 LANGUAGES CXX) project(nlohmann_json VERSION 3.8.0 LANGUAGES CXX)
## ##
## INCLUDE ## INCLUDE
...@@ -89,8 +89,13 @@ endif() ...@@ -89,8 +89,13 @@ endif()
## install header files, generate and install cmake config files for find_package() ## install header files, generate and install cmake config files for find_package()
## ##
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
write_basic_package_version_file( # use a custom package version config file instead of
${NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE} COMPATIBILITY SameMajorVersion # 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( configure_file(
${NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE} ${NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE}
...@@ -112,7 +117,7 @@ if(JSON_Install) ...@@ -112,7 +117,7 @@ if(JSON_Install)
FILES ${NLOHMANN_NATVIS_FILE} FILES ${NLOHMANN_NATVIS_FILE}
DESTINATION . DESTINATION .
) )
endif() endif()
export( export(
TARGETS ${NLOHMANN_JSON_TARGET_NAME} TARGETS ${NLOHMANN_JSON_TARGET_NAME}
NAMESPACE ${PROJECT_NAME}:: NAMESPACE ${PROJECT_NAME}::
......
# Change Log # Changelog
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
## [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)
- Object properties should not be re-sorted alphabetically [\#2179](https://github.com/nlohmann/json/issues/2179)
- 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\<struct\> 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)
- Adding a value to an existing json puts it at the beginning instead of the end [\#2149](https://github.com/nlohmann/json/issues/2149)
- JSON Data Mapping Key-Value from other Key-Value [\#2148](https://github.com/nlohmann/json/issues/2148)
- Conflicts with std \<any\> 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)
- UTF8 [\#2095](https://github.com/nlohmann/json/issues/2095)
- 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 \<ciso646\> [\#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)
- Add support for JSONC [\#2061](https://github.com/nlohmann/json/issues/2061)
- How to convert a const std::vector\<char8\_t\> 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\<T, std::vector\<T\>\> [\#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 \<typename T\> 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\<string, string\> [\#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)
- GDB pretty printing support [\#1952](https://github.com/nlohmann/json/issues/1952)
- 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\<std::uint8\_t\> [\#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)
- Compilation failure using Clang on Windows [\#1898](https://github.com/nlohmann/json/issues/1898)
- 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)
- Fail to build when including json.hpp as a system include [\#1818](https://github.com/nlohmann/json/issues/1818)
- 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 \<ciso646\> 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))
- fix \#1982:json\_pointer.contains\(\) exception is incorrectly raised [\#2019](https://github.com/nlohmann/json/pull/2019) ([dota17](https://github.com/dota17))
- catch exceptions for json\_pointer : ..../+99 [\#1990](https://github.com/nlohmann/json/pull/1990) ([dota17](https://github.com/dota17))
- 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))
- templated input adapters [\#1950](https://github.com/nlohmann/json/pull/1950) ([FrancoisChabot](https://github.com/FrancoisChabot))
- 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) ## [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) [Full Changelog](https://github.com/nlohmann/json/compare/v3.7.2...v3.7.3)
- Project branches [\#1839](https://github.com/nlohmann/json/issues/1839) - Project branches [\#1839](https://github.com/nlohmann/json/issues/1839)
...@@ -13,6 +344,7 @@ All notable changes to this project will be documented in this file. This projec ...@@ -13,6 +344,7 @@ All notable changes to this project will be documented in this file. This projec
- Fix quadratic destruction complexity [\#1838](https://github.com/nlohmann/json/pull/1838) ([nickaein](https://github.com/nickaein)) - 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) ## [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) [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) - Segmentation fault in destructor in case of large inputs [\#1835](https://github.com/nlohmann/json/issues/1835)
...@@ -29,6 +361,7 @@ All notable changes to this project will be documented in this file. This projec ...@@ -29,6 +361,7 @@ All notable changes to this project will be documented in this file. This projec
- Prevent stackoverflow caused by recursive deconstruction [\#1436](https://github.com/nlohmann/json/pull/1436) ([nickaein](https://github.com/nickaein)) - 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) ## [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) [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) - std::is\_constructible is always true with tuple [\#1825](https://github.com/nlohmann/json/issues/1825)
...@@ -162,6 +495,7 @@ All notable changes to this project will be documented in this file. This projec ...@@ -162,6 +495,7 @@ All notable changes to this project will be documented in this file. This projec
- release: add singleinclude and meson.build to include.zip [\#1694](https://github.com/nlohmann/json/pull/1694) ([eli-schwartz](https://github.com/eli-schwartz)) - 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) ## [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) [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) - How can I retrieve uknown strings from json file in my C++ program. [\#1684](https://github.com/nlohmann/json/issues/1684)
...@@ -239,10 +573,8 @@ All notable changes to this project will be documented in this file. This projec ...@@ -239,10 +573,8 @@ All notable changes to this project will be documented in this file. This projec
- Writing an array into a nlohmann::json object [\#1578](https://github.com/nlohmann/json/issues/1578) - 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) - 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) - Homebrew on OSX doesn't install cmake config file [\#1576](https://github.com/nlohmann/json/issues/1576)
- `unflatten` vs objects with number-ish keys [\#1575](https://github.com/nlohmann/json/issues/1575)
- JSON Parse Out of Range Error [\#1574](https://github.com/nlohmann/json/issues/1574) - 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) - Integrating into existing CMake Project [\#1573](https://github.com/nlohmann/json/issues/1573)
- A "thinner" source code tar as part of release? [\#1572](https://github.com/nlohmann/json/issues/1572)
- conversion to std::string failed [\#1571](https://github.com/nlohmann/json/issues/1571) - 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) - 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 generate dll file for this project [\#1568](https://github.com/nlohmann/json/issues/1568)
...@@ -289,11 +621,10 @@ All notable changes to this project will be documented in this file. This projec ...@@ -289,11 +621,10 @@ All notable changes to this project will be documented in this file. This projec
- Intermittent issues with loadJSON [\#1484](https://github.com/nlohmann/json/issues/1484) - 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) - use json construct std::string [\#1462](https://github.com/nlohmann/json/issues/1462)
- JSON Creation [\#1461](https://github.com/nlohmann/json/issues/1461) - JSON Creation [\#1461](https://github.com/nlohmann/json/issues/1461)
- Substantial performance penalty caused by polymorphic input adapter [\#1457](https://github.com/nlohmann/json/issues/1457)
- Null bytes in files are treated like EOF [\#1095](https://github.com/nlohmann/json/issues/1095) - 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) - 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) ([remyabel](https://github.com/remyabel)) - 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)) - 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)) - 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)) - 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))
...@@ -306,7 +637,12 @@ All notable changes to this project will be documented in this file. This projec ...@@ -306,7 +637,12 @@ All notable changes to this project will be documented in this file. This projec
- moved from Catch to doctest for unit tests [\#1439](https://github.com/nlohmann/json/pull/1439) ([onqtam](https://github.com/onqtam)) - 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) ## [v3.6.1](https://github.com/nlohmann/json/releases/tag/v3.6.1) (2019-03-20)
[Full Changelog](https://github.com/nlohmann/json/compare/v3.6.0...v3.6.1)
[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 \<Windows.h\> [\#1531](https://github.com/nlohmann/json/issues/1531) - Failed to build with \<Windows.h\> [\#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) - Compiling 3.6.0 with GCC \> 7, array vs std::array \#590 is back [\#1530](https://github.com/nlohmann/json/issues/1530)
...@@ -314,6 +650,7 @@ All notable changes to this project will be documented in this file. This projec ...@@ -314,6 +650,7 @@ All notable changes to this project will be documented in this file. This projec
- unable to parse json [\#1525](https://github.com/nlohmann/json/issues/1525) - 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) ## [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) [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) - How can I turn a string of a json array into a json array? [\#1526](https://github.com/nlohmann/json/issues/1526)
...@@ -332,7 +669,6 @@ All notable changes to this project will be documented in this file. This projec ...@@ -332,7 +669,6 @@ All notable changes to this project will be documented in this file. This projec
- Error compiling with clang and `JSON\_NOEXCEPTION`: need to include `cstdlib` [\#1500](https://github.com/nlohmann/json/issues/1500) - 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) - 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) - Cmake 3.1 in develop, when is it likely to make it into a stable release? [\#1498](https://github.com/nlohmann/json/issues/1498)
- Repository is almost 450MB [\#1497](https://github.com/nlohmann/json/issues/1497)
- Some Help please object inside array [\#1494](https://github.com/nlohmann/json/issues/1494) - 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 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) - how to find subelement without loop [\#1490](https://github.com/nlohmann/json/issues/1490)
...@@ -420,7 +756,7 @@ All notable changes to this project will be documented in this file. This projec ...@@ -420,7 +756,7 @@ All notable changes to this project will be documented in this file. This projec
- :rotating\_light: fixed unused variable warning [\#1435](https://github.com/nlohmann/json/pull/1435) ([pboettch](https://github.com/pboettch)) - :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)) - 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)) - 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) ([hijxf](https://github.com/hijxf)) - 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 [\#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)) - 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)) - docs: typo in README [\#1417](https://github.com/nlohmann/json/pull/1417) ([wythe](https://github.com/wythe))
...@@ -430,6 +766,7 @@ All notable changes to this project will be documented in this file. This projec ...@@ -430,6 +766,7 @@ All notable changes to this project will be documented in this file. This projec
- CMake: Optional Install if Embedded [\#1330](https://github.com/nlohmann/json/pull/1330) ([ax3l](https://github.com/ax3l)) - 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) ## [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) [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) - Copyconstructor inserts original into array with single element [\#1397](https://github.com/nlohmann/json/issues/1397)
...@@ -507,6 +844,7 @@ All notable changes to this project will be documented in this file. This projec ...@@ -507,6 +844,7 @@ All notable changes to this project will be documented in this file. This projec
- Fix EOL Whitespaces & CMake Spelling [\#1329](https://github.com/nlohmann/json/pull/1329) ([ax3l](https://github.com/ax3l)) - 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) ## [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) [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) - Big uint64\_t values are serialized wrong [\#1327](https://github.com/nlohmann/json/issues/1327)
...@@ -541,7 +879,6 @@ All notable changes to this project will be documented in this file. This projec ...@@ -541,7 +879,6 @@ All notable changes to this project will be documented in this file. This projec
- BSON support [\#1244](https://github.com/nlohmann/json/issues/1244) - BSON support [\#1244](https://github.com/nlohmann/json/issues/1244)
- enum to json mapping [\#1208](https://github.com/nlohmann/json/issues/1208) - 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) - Soften the landing when dumping non-UTF8 strings \(type\_error.316 exception\) [\#1198](https://github.com/nlohmann/json/issues/1198)
- CMakeLists.txt in release zips? [\#1184](https://github.com/nlohmann/json/issues/1184)
- Add macro to define enum/JSON mapping [\#1323](https://github.com/nlohmann/json/pull/1323) ([nlohmann](https://github.com/nlohmann)) - 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)) - Add BSON support [\#1320](https://github.com/nlohmann/json/pull/1320) ([nlohmann](https://github.com/nlohmann))
...@@ -556,7 +893,12 @@ All notable changes to this project will be documented in this file. This projec ...@@ -556,7 +893,12 @@ All notable changes to this project will be documented in this file. This projec
- Thirdparty benchmark: Fix Clang detection. [\#1277](https://github.com/nlohmann/json/pull/1277) ([Lord-Kamina](https://github.com/Lord-Kamina)) - 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) ## [v3.3.0](https://github.com/nlohmann/json/releases/tag/v3.3.0) (2018-10-05)
[Full Changelog](https://github.com/nlohmann/json/compare/v3.2.0...v3.3.0)
[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) - 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) - 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)
...@@ -574,7 +916,6 @@ All notable changes to this project will be documented in this file. This projec ...@@ -574,7 +916,6 @@ All notable changes to this project will be documented in this file. This projec
- Doesn't compile under C++17 [\#1239](https://github.com/nlohmann/json/issues/1239) - 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) - 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) - Custom deserialization of number\_float\_t [\#1236](https://github.com/nlohmann/json/issues/1236)
- Move tests to a separate repo [\#1235](https://github.com/nlohmann/json/issues/1235)
- deprecated-declarations warnings when compiling tests with GCC 8.2.1. [\#1233](https://github.com/nlohmann/json/issues/1233) - 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) - Incomplete type with json\_fwd.hpp [\#1232](https://github.com/nlohmann/json/issues/1232)
- Parse Error [\#1229](https://github.com/nlohmann/json/issues/1229) - Parse Error [\#1229](https://github.com/nlohmann/json/issues/1229)
...@@ -624,7 +965,12 @@ All notable changes to this project will be documented in this file. This projec ...@@ -624,7 +965,12 @@ All notable changes to this project will be documented in this file. This projec
- Export package to allow builds without installing [\#1202](https://github.com/nlohmann/json/pull/1202) ([dennisfischer](https://github.com/dennisfischer)) - 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) ## [v3.2.0](https://github.com/nlohmann/json/releases/tag/v3.2.0) (2018-08-20)
[Full Changelog](https://github.com/nlohmann/json/compare/v3.1.2...v3.2.0)
[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) - 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) - Incompatible Pointer Type [\#1196](https://github.com/nlohmann/json/issues/1196)
...@@ -634,7 +980,6 @@ All notable changes to this project will be documented in this file. This projec ...@@ -634,7 +980,6 @@ All notable changes to this project will be documented in this file. This projec
- Add key name when throwing type error [\#1189](https://github.com/nlohmann/json/issues/1189) - 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) - 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) - Get an Index or row number of an element [\#1186](https://github.com/nlohmann/json/issues/1186)
- reduce repos size [\#1185](https://github.com/nlohmann/json/issues/1185)
- Difference between `merge\_patch` and `update` [\#1183](https://github.com/nlohmann/json/issues/1183) - 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) - 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) - to\_string? [\#1181](https://github.com/nlohmann/json/issues/1181)
...@@ -723,7 +1068,6 @@ All notable changes to this project will be documented in this file. This projec ...@@ -723,7 +1068,6 @@ All notable changes to this project will be documented in this file. This projec
- Deserializing std::array doesn't compiler \(no insert\(\)\) [\#1071](https://github.com/nlohmann/json/issues/1071) - 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) - 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) - Compilation error with ICPC compiler [\#1068](https://github.com/nlohmann/json/issues/1068)
- Minimal branch? [\#1066](https://github.com/nlohmann/json/issues/1066)
- Not existing value, crash [\#1065](https://github.com/nlohmann/json/issues/1065) - Not existing value, crash [\#1065](https://github.com/nlohmann/json/issues/1065)
- cyryllic symbols [\#1064](https://github.com/nlohmann/json/issues/1064) - cyryllic symbols [\#1064](https://github.com/nlohmann/json/issues/1064)
- newbie usage question [\#1063](https://github.com/nlohmann/json/issues/1063) - newbie usage question [\#1063](https://github.com/nlohmann/json/issues/1063)
...@@ -802,7 +1146,12 @@ All notable changes to this project will be documented in this file. This projec ...@@ -802,7 +1146,12 @@ All notable changes to this project will be documented in this file. This projec
- Added public target\_compile\_features for auto and constexpr [\#1026](https://github.com/nlohmann/json/pull/1026) ([ktonon](https://github.com/ktonon)) - 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) ## [v3.1.2](https://github.com/nlohmann/json/releases/tag/v3.1.2) (2018-03-14)
[Full Changelog](https://github.com/nlohmann/json/compare/v3.1.1...v3.1.2)
[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) - 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) - The library doesn't want to insert an unordered\_map [\#1010](https://github.com/nlohmann/json/issues/1010)
...@@ -833,12 +1182,12 @@ All notable changes to this project will be documented in this file. This projec ...@@ -833,12 +1182,12 @@ All notable changes to this project will be documented in this file. This projec
- Allowing for user-defined string type in lexer/parser [\#1009](https://github.com/nlohmann/json/pull/1009) ([nlohmann](https://github.com/nlohmann)) - 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)) - 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)) - 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)) - 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)) - 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) ## [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) [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) - Updation of child object isn't reflected in parent Object [\#968](https://github.com/nlohmann/json/issues/968)
...@@ -856,13 +1205,19 @@ All notable changes to this project will be documented in this file. This projec ...@@ -856,13 +1205,19 @@ All notable changes to this project will be documented in this file. This projec
- \[Request\] Macro generating from\_json\(\) and to\_json\(\) [\#895](https://github.com/nlohmann/json/issues/895) - \[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) - basic\_json::value throws exception instead of returning default value [\#871](https://github.com/nlohmann/json/issues/871)
- Fix memory leak during parser callback [\#1001](https://github.com/nlohmann/json/pull/1001) ([nlohmann](https://github.com/nlohmann))
- Fix constraints on from\_json\(CompatibleArrayType\) [\#969](https://github.com/nlohmann/json/pull/969) ([theodelrieu](https://github.com/theodelrieu)) - 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)) - 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)) - 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)) - 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) ## [v3.1.0](https://github.com/nlohmann/json/releases/tag/v3.1.0) (2018-02-01)
[Full Changelog](https://github.com/nlohmann/json/compare/v3.0.1...v3.1.0)
[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)
- Order of the elements in JSON object [\#952](https://github.com/nlohmann/json/issues/952) - Order of the elements in JSON object [\#952](https://github.com/nlohmann/json/issues/952)
- I have a proposal [\#949](https://github.com/nlohmann/json/issues/949) - I have a proposal [\#949](https://github.com/nlohmann/json/issues/949)
...@@ -925,7 +1280,12 @@ All notable changes to this project will be documented in this file. This projec ...@@ -925,7 +1280,12 @@ All notable changes to this project will be documented in this file. This projec
- Refactor/split it [\#700](https://github.com/nlohmann/json/pull/700) ([theodelrieu](https://github.com/theodelrieu)) - 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) ## [v3.0.1](https://github.com/nlohmann/json/releases/tag/v3.0.1) (2017-12-29)
[Full Changelog](https://github.com/nlohmann/json/compare/v3.0.0...v3.0.1)
[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) - 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) - Invalid RFC6902 copy operation succeeds [\#894](https://github.com/nlohmann/json/issues/894)
...@@ -948,7 +1308,12 @@ All notable changes to this project will be documented in this file. This projec ...@@ -948,7 +1308,12 @@ All notable changes to this project will be documented in this file. This projec
- :wrench: Fix up a few more effc++ items [\#858](https://github.com/nlohmann/json/pull/858) ([mattismyname](https://github.com/mattismyname)) - :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) ## [v3.0.0](https://github.com/nlohmann/json/releases/tag/v3.0.0) (2017-12-17)
[Full Changelog](https://github.com/nlohmann/json/compare/v2.1.1...v3.0.0)
[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) - 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) - Visual Studio 2017 15.5 C++17 std::allocator deprecations [\#872](https://github.com/nlohmann/json/issues/872)
...@@ -1052,7 +1417,6 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1052,7 +1417,6 @@ All notable changes to this project will be documented in this file. This projec
- Compilation Error on Clang 5.0 Upgrade [\#735](https://github.com/nlohmann/json/issues/735) - Compilation Error on Clang 5.0 Upgrade [\#735](https://github.com/nlohmann/json/issues/735)
- Compilation error with std::map\<std::string, std::string\> on vs 2015 [\#734](https://github.com/nlohmann/json/issues/734) - Compilation error with std::map\<std::string, std::string\> on vs 2015 [\#734](https://github.com/nlohmann/json/issues/734)
- Benchmarks for Binary formats [\#733](https://github.com/nlohmann/json/issues/733) - Benchmarks for Binary formats [\#733](https://github.com/nlohmann/json/issues/733)
- Move test blobs to a submodule? [\#732](https://github.com/nlohmann/json/issues/732)
- Support \n symbols in json string. [\#731](https://github.com/nlohmann/json/issues/731) - 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) - 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) - Visual Studio 2015 IntelliTrace problems [\#729](https://github.com/nlohmann/json/issues/729)
...@@ -1137,7 +1501,6 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1137,7 +1501,6 @@ All notable changes to this project will be documented in this file. This projec
- Discussion: How to structure the parsing function families [\#623](https://github.com/nlohmann/json/issues/623) - 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) - 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) - Insertion into nested json field [\#621](https://github.com/nlohmann/json/issues/621)
- \[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)
- Question: return static json object from function [\#618](https://github.com/nlohmann/json/issues/618) - 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) - 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) - \[-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)
...@@ -1179,7 +1542,6 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1179,7 +1542,6 @@ All notable changes to this project will be documented in this file. This projec
- Request: Object.at\(\) with default return value [\#570](https://github.com/nlohmann/json/issues/570) - 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) - Internal structure gets corrupted while parsing [\#569](https://github.com/nlohmann/json/issues/569)
- create template \<typename Iter\> basic\_json from\_cbor\(Iter begin, Iter end\) [\#568](https://github.com/nlohmann/json/issues/568) - create template \<typename Iter\> basic\_json from\_cbor\(Iter begin, Iter end\) [\#568](https://github.com/nlohmann/json/issues/568)
- Need to improve ignores.. [\#567](https://github.com/nlohmann/json/issues/567)
- Conan.io [\#566](https://github.com/nlohmann/json/issues/566) - Conan.io [\#566](https://github.com/nlohmann/json/issues/566)
- contradictory documentation regarding json::find [\#565](https://github.com/nlohmann/json/issues/565) - 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) - Unexpected '\"' in middle of array [\#564](https://github.com/nlohmann/json/issues/564)
...@@ -1189,7 +1551,6 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1189,7 +1551,6 @@ All notable changes to this project will be documented in this file. This projec
- Tip: Don't upgrade to VS2017 if using json initializer list constructs [\#559](https://github.com/nlohmann/json/issues/559) - 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) - 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) - Cant modify existing numbers inside a json object [\#557](https://github.com/nlohmann/json/issues/557)
- Minimal repository \(current size very large\) [\#556](https://github.com/nlohmann/json/issues/556)
- Better support for SAX style serialize and deserialize in new version? [\#554](https://github.com/nlohmann/json/issues/554) - 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) - 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) - Do not define an unnamed namespace in a header file \(DCL59-CPP\) [\#552](https://github.com/nlohmann/json/issues/552)
...@@ -1250,7 +1611,6 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1250,7 +1611,6 @@ All notable changes to this project will be documented in this file. This projec
- Using fifo\_map [\#485](https://github.com/nlohmann/json/issues/485) - 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) - 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) - byte string support [\#483](https://github.com/nlohmann/json/issues/483)
- For a header-only library you have to clone 214MB [\#482](https://github.com/nlohmann/json/issues/482)
- https://github.com/nlohmann/json\#execute-unit-tests [\#481](https://github.com/nlohmann/json/issues/481) - 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) - 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) - writing the binary json file? [\#479](https://github.com/nlohmann/json/issues/479)
...@@ -1311,38 +1671,14 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1311,38 +1671,14 @@ All notable changes to this project will be documented in this file. This projec
- Digraph warning [\#679](https://github.com/nlohmann/json/pull/679) ([traits](https://github.com/traits)) - 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)) - 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)) - 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 \<iostream\>, 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) ([krzysztofwos](https://github.com/krzysztofwos))
- :art: Namespace `uint8\_t` from the C++ stdlib [\#510](https://github.com/nlohmann/json/pull/510) ([alex-weej](https://github.com/alex-weej))
- 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) ## [v2.1.1](https://github.com/nlohmann/json/releases/tag/v2.1.1) (2017-02-25)
[Full Changelog](https://github.com/nlohmann/json/compare/v2.1.0...v2.1.1)
[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) - 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) - How to create an array of Objects? [\#470](https://github.com/nlohmann/json/issues/470)
...@@ -1374,9 +1710,15 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1374,9 +1710,15 @@ All notable changes to this project will be documented in this file. This projec
- TurpentineDistillery feature/locale independent str to num [\#450](https://github.com/nlohmann/json/pull/450) ([nlohmann](https://github.com/nlohmann)) - 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)) - 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)) - 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) ## [v2.1.0](https://github.com/nlohmann/json/releases/tag/v2.1.0) (2017-01-28)
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.10...v2.1.0)
[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) - 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) - Use-of-uninitialized-value \(OSS-Fuzz issue 477\) [\#437](https://github.com/nlohmann/json/issues/437)
...@@ -1397,6 +1739,7 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1397,6 +1739,7 @@ All notable changes to this project will be documented in this file. This projec
- comparing to 0 literal [\#414](https://github.com/nlohmann/json/issues/414) - 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) - 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) - How to know if a string was parsed as utf-8? [\#406](https://github.com/nlohmann/json/issues/406)
- Heap-buffer-overflow \(OSS-Fuzz issue 342\) [\#405](https://github.com/nlohmann/json/issues/405)
- Overloaded += to add objects to an array makes no sense? [\#404](https://github.com/nlohmann/json/issues/404) - 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) - 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) - add release information in static function [\#397](https://github.com/nlohmann/json/issues/397)
...@@ -1412,17 +1755,20 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1412,17 +1755,20 @@ All notable changes to this project will be documented in this file. This projec
- conversion from/to user-defined types [\#435](https://github.com/nlohmann/json/pull/435) ([nlohmann](https://github.com/nlohmann)) - 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)) - Fix documentation error [\#430](https://github.com/nlohmann/json/pull/430) ([vjon](https://github.com/vjon))
- locale-independent num-to-str [\#378](https://github.com/nlohmann/json/pull/378) ([TurpentineDistillery](https://github.com/TurpentineDistillery))
## [v2.0.10](https://github.com/nlohmann/json/releases/tag/v2.0.10) (2017-01-02) ## [v2.0.10](https://github.com/nlohmann/json/releases/tag/v2.0.10) (2017-01-02)
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.9...v2.0.10)
[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 367\) [\#412](https://github.com/nlohmann/json/issues/412)
- Heap-buffer-overflow \(OSS-Fuzz issue 366\) [\#411](https://github.com/nlohmann/json/issues/411) - 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) - 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 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 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) - 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) - 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) - Explicitly getting string without .dump\(\) [\#401](https://github.com/nlohmann/json/issues/401)
...@@ -1435,7 +1781,12 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1435,7 +1781,12 @@ All notable changes to this project will be documented in this file. This projec
- Add Doozer build badge [\#400](https://github.com/nlohmann/json/pull/400) ([andoma](https://github.com/andoma)) - 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) ## [v2.0.9](https://github.com/nlohmann/json/releases/tag/v2.0.9) (2016-12-16)
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.8...v2.0.9)
[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) - \#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) - How to parse this json file and write separate sub object as json files? [\#392](https://github.com/nlohmann/json/issues/392)
...@@ -1458,7 +1809,12 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1458,7 +1809,12 @@ All notable changes to this project will be documented in this file. This projec
- Fix issue \#380: Signed integer overflow check [\#390](https://github.com/nlohmann/json/pull/390) ([qwename](https://github.com/qwename)) - 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) ## [v2.0.8](https://github.com/nlohmann/json/releases/tag/v2.0.8) (2016-12-02)
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.7...v2.0.8)
[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) - Reading from file [\#374](https://github.com/nlohmann/json/issues/374)
- Compiler warnings? [\#372](https://github.com/nlohmann/json/issues/372) - Compiler warnings? [\#372](https://github.com/nlohmann/json/issues/372)
...@@ -1485,6 +1841,7 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1485,6 +1841,7 @@ All notable changes to this project will be documented in this file. This projec
- Using QString as string type [\#274](https://github.com/nlohmann/json/issues/274) - 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) ## [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) [Full Changelog](https://github.com/nlohmann/json/compare/v2.0.6...v2.0.7)
- JSON5 [\#348](https://github.com/nlohmann/json/issues/348) - JSON5 [\#348](https://github.com/nlohmann/json/issues/348)
...@@ -1504,6 +1861,7 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1504,6 +1861,7 @@ All notable changes to this project will be documented in this file. This projec
- fix minor grammar/style issue in README.md [\#336](https://github.com/nlohmann/json/pull/336) ([seeekr](https://github.com/seeekr)) - 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) ## [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) [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) - How to handle json files? [\#333](https://github.com/nlohmann/json/issues/333)
...@@ -1523,6 +1881,7 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1523,6 +1881,7 @@ All notable changes to this project will be documented in this file. This projec
- trivial documentation fix [\#313](https://github.com/nlohmann/json/pull/313) ([5tefan](https://github.com/5tefan)) - 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) ## [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) [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) - \[feature request\]: schema validator and comments [\#311](https://github.com/nlohmann/json/issues/311)
...@@ -1531,6 +1890,7 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1531,6 +1890,7 @@ All notable changes to this project will be documented in this file. This projec
- No matching member function for call to 'get\_impl' [\#308](https://github.com/nlohmann/json/issues/308) - 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) ## [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) [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) - Parsing fails without space at end of file [\#306](https://github.com/nlohmann/json/issues/306)
...@@ -1538,6 +1898,7 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1538,6 +1898,7 @@ All notable changes to this project will be documented in this file. This projec
- Unused variable warning [\#304](https://github.com/nlohmann/json/issues/304) - 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) ## [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) [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) - warning C4706: assignment within conditional expression [\#295](https://github.com/nlohmann/json/issues/295)
...@@ -1554,6 +1915,7 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1554,6 +1915,7 @@ All notable changes to this project will be documented in this file. This projec
- unit-constructor1.cpp: Fix floating point truncation warning [\#300](https://github.com/nlohmann/json/pull/300) ([t-b](https://github.com/t-b)) - 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) ## [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) [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) - can function dump\(\) return string in the order I push in the json object ? [\#286](https://github.com/nlohmann/json/issues/286)
...@@ -1569,6 +1931,7 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1569,6 +1931,7 @@ All notable changes to this project will be documented in this file. This projec
- Update hexify to use array lookup instead of ternary \(\#270\) [\#275](https://github.com/nlohmann/json/pull/275) ([dtoma](https://github.com/dtoma)) - 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) ## [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) [Full Changelog](https://github.com/nlohmann/json/compare/v2.0.0...v2.0.1)
- Compilation error. [\#273](https://github.com/nlohmann/json/issues/273) - Compilation error. [\#273](https://github.com/nlohmann/json/issues/273)
...@@ -1577,6 +1940,7 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1577,6 +1940,7 @@ All notable changes to this project will be documented in this file. This projec
- fixed a tiny typo [\#271](https://github.com/nlohmann/json/pull/271) ([feroldi](https://github.com/feroldi)) - 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) ## [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) [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) - json::diff generates incorrect patch when removing multiple array elements. [\#269](https://github.com/nlohmann/json/issues/269)
...@@ -1651,6 +2015,7 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1651,6 +2015,7 @@ All notable changes to this project will be documented in this file. This projec
- 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)) - 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) ## [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) [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) - Small error in pull \#185 [\#194](https://github.com/nlohmann/json/issues/194)
...@@ -1679,6 +2044,7 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1679,6 +2044,7 @@ All notable changes to this project will be documented in this file. This projec
- Fixed some typos in CONTRIBUTING.md [\#182](https://github.com/nlohmann/json/pull/182) ([nibroc](https://github.com/nibroc)) - 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) ## [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) [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) - add key name to exception [\#160](https://github.com/nlohmann/json/issues/160)
...@@ -1731,13 +2097,15 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1731,13 +2097,15 @@ All notable changes to this project will be documented in this file. This projec
- Use the right variable name in doc string [\#115](https://github.com/nlohmann/json/pull/115) ([whoshuu](https://github.com/whoshuu)) - 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) ## [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) - 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) - 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) - 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) - 'noexcept' : unknown override specifier [\#99](https://github.com/nlohmann/json/issues/99)
- json float parsing problem [\#98](https://github.com/nlohmann/json/issues/98) - 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) - Adjust wording to JSON RFC [\#97](https://github.com/nlohmann/json/issues/97)
- 17 MB / 90 MB repo size!? [\#96](https://github.com/nlohmann/json/issues/96)
- static analysis warnings [\#94](https://github.com/nlohmann/json/issues/94) - static analysis warnings [\#94](https://github.com/nlohmann/json/issues/94)
- reverse\_iterator operator inheritance problem [\#93](https://github.com/nlohmann/json/issues/93) - reverse\_iterator operator inheritance problem [\#93](https://github.com/nlohmann/json/issues/93)
- init error [\#92](https://github.com/nlohmann/json/issues/92) - init error [\#92](https://github.com/nlohmann/json/issues/92)
...@@ -1808,19 +2176,7 @@ All notable changes to this project will be documented in this file. This projec ...@@ -1808,19 +2176,7 @@ All notable changes to this project will be documented in this file. This projec
- Fix compilation of json\_unit with GCC 5 [\#59](https://github.com/nlohmann/json/pull/59) ([dkopecek](https://github.com/dkopecek)) - 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)) - 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)) - 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)) \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
- 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 Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
\ No newline at end of file
MIT License MIT License
Copyright (c) 2013-2019 Niels Lohmann Copyright (c) 2013-2020 Niels Lohmann
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
......
...@@ -32,10 +32,8 @@ all: ...@@ -32,10 +32,8 @@ all:
@echo "ChangeLog.md - generate ChangeLog file" @echo "ChangeLog.md - generate ChangeLog file"
@echo "check - compile and execute test suite" @echo "check - compile and execute test suite"
@echo "check-amalgamation - check whether sources have been amalgamated" @echo "check-amalgamation - check whether sources have been amalgamated"
@echo "check-fast - compile and execute test suite (skip long-running tests)"
@echo "clean - remove built files" @echo "clean - remove built files"
@echo "coverage - create coverage information with lcov" @echo "coverage - create coverage information with lcov"
@echo "coverage-fast - create coverage information with fastcov"
@echo "cppcheck - analyze code with cppcheck" @echo "cppcheck - analyze code with cppcheck"
@echo "cpplint - analyze code with cpplint" @echo "cpplint - analyze code with cpplint"
@echo "clang_tidy - analyze code with Clang-Tidy" @echo "clang_tidy - analyze code with Clang-Tidy"
...@@ -65,10 +63,6 @@ json_unit: ...@@ -65,10 +63,6 @@ json_unit:
check: check:
$(MAKE) check -C test $(MAKE) check -C test
# run unit tests and skip expensive tests
check-fast:
$(MAKE) check -C test TEST_PATTERN=""
########################################################################## ##########################################################################
# coverage # coverage
...@@ -77,21 +71,12 @@ check-fast: ...@@ -77,21 +71,12 @@ check-fast:
coverage: coverage:
rm -fr build_coverage rm -fr build_coverage
mkdir build_coverage mkdir build_coverage
cd build_coverage ; CXX=g++-8 cmake .. -GNinja -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON cd build_coverage ; cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON
cd build_coverage ; ninja cd build_coverage ; ninja
cd build_coverage ; ctest -E '.*_default' -j10 cd build_coverage ; ctest -j10
cd build_coverage ; ninja lcov_html cd build_coverage ; ninja lcov_html
open build_coverage/test/html/index.html open build_coverage/test/html/index.html
coverage-fast:
rm -fr build_coverage
mkdir build_coverage
cd build_coverage ; CXX=g++-9 cmake .. -GNinja -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON
cd build_coverage ; ninja
cd build_coverage ; ctest -E '.*_default' -j10
cd build_coverage ; ninja fastcov_html
open build_coverage/test/html/index.html
########################################################################## ##########################################################################
# documentation tests # documentation tests
########################################################################## ##########################################################################
...@@ -117,7 +102,8 @@ doctest: ...@@ -117,7 +102,8 @@ doctest:
# -Wno-switch-enum -Wno-covered-switch-default: pedantic/contradicting warnings about switches # -Wno-switch-enum -Wno-covered-switch-default: pedantic/contradicting warnings about switches
# -Wno-weak-vtables: exception class is defined inline, but has virtual method # -Wno-weak-vtables: exception class is defined inline, but has virtual method
pedantic_clang: pedantic_clang:
$(MAKE) json_unit CXX=c++ CXXFLAGS=" \ rm -fr build_pedantic
CXXFLAGS=" \
-std=c++11 -Wno-c++98-compat -Wno-c++98-compat-pedantic \ -std=c++11 -Wno-c++98-compat -Wno-c++98-compat-pedantic \
-Werror \ -Werror \
-Weverything \ -Weverything \
...@@ -130,232 +116,271 @@ pedantic_clang: ...@@ -130,232 +116,271 @@ pedantic_clang:
-Wno-padded \ -Wno-padded \
-Wno-range-loop-analysis \ -Wno-range-loop-analysis \
-Wno-switch-enum -Wno-covered-switch-default \ -Wno-switch-enum -Wno-covered-switch-default \
-Wno-weak-vtables" -Wno-weak-vtables" cmake -S . -B build_pedantic -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On
cmake --build build_pedantic
# calling GCC with most warnings # calling GCC with most warnings
pedantic_gcc: pedantic_gcc:
$(MAKE) json_unit CXX=/usr/local/bin/g++-9 CXXFLAGS=" \ rm -fr build_pedantic
CXXFLAGS=" \
-std=c++11 \ -std=c++11 \
-Waddress \ -pedantic \
-Waddress-of-packed-member \
-Waggressive-loop-optimizations \
-Waligned-new=all \
-Wall \
-Walloc-zero \
-Walloca \
-Warray-bounds \
-Warray-bounds=2 \
-Wattribute-alias=2 \
-Wattribute-warning \
-Wattributes \
-Wbool-compare \
-Wbool-operation \
-Wbuiltin-declaration-mismatch \
-Wbuiltin-macro-redefined \
-Wcannot-profile \
-Wcast-align \
-Wcast-function-type \
-Wcast-qual \
-Wcatch-value=3 \
-Wchar-subscripts \
-Wclass-conversion \
-Wclass-memaccess \
-Wclobbered \
-Wcomment \
-Wcomments \
-Wconditionally-supported \
-Wconversion \
-Wconversion-null \
-Wcoverage-mismatch \
-Wcpp \
-Wctor-dtor-privacy \
-Wdangling-else \
-Wdate-time \
-Wdelete-incomplete \
-Wdelete-non-virtual-dtor \
-Wdeprecated \
-Wdeprecated-copy \
-Wdeprecated-copy-dtor \
-Wdeprecated-declarations \
-Wdisabled-optimization \
-Wdiv-by-zero \
-Wdouble-promotion \
-Wduplicated-branches \
-Wduplicated-cond \
-Weffc++ \
-Wempty-body \
-Wendif-labels \
-Wenum-compare \
-Wexpansion-to-defined \
-Werror \ -Werror \
-Wextra \ --all-warnings \
-Wextra-semi \ --extra-warnings \
-Wfloat-conversion \ -W \
-Wformat \ -Wno-abi-tag \
-Wformat-contains-nul \ -Waddress \
-Wformat-extra-args \ -Waddress-of-packed-member \
-Wformat-nonliteral \ -Wno-aggregate-return \
-Wformat-overflow=2 \ -Waggressive-loop-optimizations \
-Wformat-security \ -Waligned-new=all \
-Wformat-signedness \ -Wall \
-Wformat-truncation=2 \ -Walloc-zero \
-Wformat-y2k \ -Walloca \
-Wformat-zero-length \ -Wanalyzer-double-fclose \
-Wformat=2 \ -Wanalyzer-double-free \
-Wframe-address \ -Wanalyzer-exposure-through-output-file \
-Wfree-nonheap-object \ -Wanalyzer-file-leak \
-Whsa \ -Wanalyzer-free-of-non-heap \
-Wif-not-aligned \ -Wanalyzer-malloc-leak \
-Wignored-attributes \ -Wanalyzer-null-argument \
-Wignored-qualifiers \ -Wanalyzer-null-dereference \
-Wimplicit-fallthrough=5 \ -Wanalyzer-possible-null-argument \
-Winherited-variadic-ctor \ -Wanalyzer-possible-null-dereference \
-Winit-list-lifetime \ -Wanalyzer-stale-setjmp-buffer \
-Winit-self \ -Wanalyzer-tainted-array-index \
-Winline \ -Wanalyzer-too-complex \
-Wint-in-bool-context \ -Wanalyzer-unsafe-call-within-signal-handler \
-Wint-to-pointer-cast \ -Wanalyzer-use-after-free \
-Winvalid-memory-model \ -Wanalyzer-use-of-pointer-in-stale-stack-frame \
-Winvalid-offsetof \ -Warith-conversion \
-Winvalid-pch \ -Warray-bounds \
-Wliteral-suffix \ -Warray-bounds=2 \
-Wlogical-not-parentheses \ -Wattribute-alias=2 \
-Wlogical-op \ -Wattribute-warning \
-Wlto-type-mismatch \ -Wattributes \
-Wmain \ -Wbool-compare \
-Wmaybe-uninitialized \ -Wbool-operation \
-Wmemset-elt-size \ -Wbuiltin-declaration-mismatch \
-Wmemset-transposed-args \ -Wbuiltin-macro-redefined \
-Wmisleading-indentation \ -Wc++0x-compat \
-Wmissing-attributes \ -Wc++11-compat \
-Wmissing-braces \ -Wc++14-compat \
-Wmissing-declarations \ -Wc++17-compat \
-Wmissing-field-initializers \ -Wc++1z-compat \
-Wmissing-format-attribute \ -Wc++20-compat \
-Wmissing-include-dirs \ -Wc++2a-compat \
-Wmissing-noreturn \ -Wcannot-profile \
-Wmissing-profile \ -Wcast-align \
-Wmultichar \ -Wcast-align=strict \
-Wmultiple-inheritance \ -Wcast-function-type \
-Wmultistatement-macros \ -Wcast-qual \
-Wnarrowing \ -Wcatch-value=3 \
-Wno-deprecated-declarations \ -Wchar-subscripts \
-Wno-float-equal \ -Wclass-conversion \
-Wno-long-long \ -Wclass-memaccess \
-Wno-namespaces \ -Wclobbered \
-Wno-padded \ -Wcomma-subscript \
-Wno-switch-enum \ -Wcomment \
-Wno-system-headers \ -Wcomments \
-Wno-templates \ -Wconditionally-supported \
-Wno-undef \ -Wconversion \
-Wnoexcept \ -Wconversion-null \
-Wnoexcept-type \ -Wcoverage-mismatch \
-Wnon-template-friend \ -Wcpp \
-Wnon-virtual-dtor \ -Wctor-dtor-privacy \
-Wnonnull \ -Wdangling-else \
-Wnonnull-compare \ -Wdate-time \
-Wnonportable-cfstrings \ -Wdelete-incomplete \
-Wnormalized \ -Wdelete-non-virtual-dtor \
-Wnull-dereference \ -Wdeprecated \
-Wodr \ -Wdeprecated-copy \
-Wold-style-cast \ -Wdeprecated-copy-dtor \
-Wopenmp-simd \ -Wdeprecated-declarations \
-Woverflow \ -Wdisabled-optimization \
-Woverlength-strings \ -Wdiv-by-zero \
-Woverloaded-virtual \ -Wdouble-promotion \
-Wpacked \ -Wduplicated-branches \
-Wpacked-bitfield-compat \ -Wduplicated-cond \
-Wpacked-not-aligned \ -Weffc++ \
-Wparentheses \ -Wempty-body \
-Wpedantic \ -Wendif-labels \
-Wpessimizing-move \ -Wenum-compare \
-Wplacement-new=2 \ -Wexpansion-to-defined \
-Wpmf-conversions \ -Wextra \
-Wpointer-arith \ -Wextra-semi \
-Wpointer-compare \ -Wfloat-conversion \
-Wpragmas \ -Wfloat-equal \
-Wprio-ctor-dtor \ -Wformat -Wformat-contains-nul \
-Wpsabi \ -Wformat -Wformat-extra-args \
-Wredundant-decls \ -Wformat -Wformat-nonliteral \
-Wredundant-move \ -Wformat -Wformat-security \
-Wregister \ -Wformat -Wformat-y2k \
-Wreorder \ -Wformat -Wformat-zero-length \
-Wrestrict \ -Wformat-diag \
-Wreturn-local-addr \ -Wformat-overflow=2 \
-Wreturn-type \ -Wformat-signedness \
-Wscalar-storage-order \ -Wformat-truncation=2 \
-Wsequence-point \ -Wformat=2 \
-Wshadow \ -Wframe-address \
-Wshadow-compatible-local \ -Wfree-nonheap-object \
-Wshadow-local \ -Whsa \
-Wshadow=compatible-local \ -Wif-not-aligned \
-Wshadow=global \ -Wignored-attributes \
-Wshadow=local \ -Wignored-qualifiers \
-Wshift-count-negative \ -Wimplicit-fallthrough=5 \
-Wshift-count-overflow \ -Winaccessible-base \
-Wshift-negative-value \ -Winherited-variadic-ctor \
-Wshift-overflow=2 \ -Winit-list-lifetime \
-Wsign-compare \ -Winit-self \
-Wsign-conversion \ -Winline \
-Wsign-promo \ -Wint-in-bool-context \
-Wsized-deallocation \ -Wint-to-pointer-cast \
-Wsizeof-array-argument \ -Winvalid-memory-model \
-Wsizeof-pointer-div \ -Winvalid-offsetof \
-Wsizeof-pointer-memaccess \ -Winvalid-pch \
-Wstack-protector \ -Wliteral-suffix \
-Wstrict-aliasing=3 \ -Wlogical-not-parentheses \
-Wstrict-null-sentinel \ -Wlogical-op \
-Wstrict-overflow=5 \ -Wno-long-long \
-Wstringop-overflow=4 \ -Wlto-type-mismatch \
-Wstringop-truncation \ -Wmain \
-Wsubobject-linkage \ -Wmaybe-uninitialized \
-Wsuggest-attribute=cold \ -Wmemset-elt-size \
-Wsuggest-attribute=const \ -Wmemset-transposed-args \
-Wsuggest-attribute=format \ -Wmisleading-indentation \
-Wsuggest-attribute=malloc \ -Wmismatched-tags \
-Wsuggest-attribute=noreturn \ -Wmissing-attributes \
-Wsuggest-attribute=pure \ -Wmissing-braces \
-Wsuggest-final-methods \ -Wmissing-declarations \
-Wsuggest-final-types \ -Wmissing-field-initializers \
-Wsuggest-override \ -Wmissing-include-dirs \
-Wswitch \ -Wmissing-profile \
-Wswitch-bool \ -Wmultichar \
-Wswitch-default \ -Wmultiple-inheritance \
-Wswitch-unreachable \ -Wmultistatement-macros \
-Wsync-nand \ -Wno-namespaces \
-Wsynth \ -Wnarrowing \
-Wtautological-compare \ -Wno-noexcept \
-Wterminate \ -Wnoexcept-type \
-Wtrampolines \ -Wnon-template-friend \
-Wtrigraphs \ -Wnon-virtual-dtor \
-Wtype-limits \ -Wnonnull \
-Wuninitialized \ -Wnonnull-compare \
-Wunknown-pragmas \ -Wnonportable-cfstrings \
-Wunreachable-code \ -Wnormalized=nfkc \
-Wunsafe-loop-optimizations \ -Wnull-dereference \
-Wunused \ -Wodr \
-Wunused-but-set-parameter \ -Wold-style-cast \
-Wunused-but-set-variable \ -Wopenmp-simd \
-Wunused-const-variable=2 \ -Woverflow \
-Wunused-function \ -Woverlength-strings \
-Wunused-label \ -Woverloaded-virtual \
-Wunused-local-typedefs \ -Wpacked \
-Wunused-macros \ -Wpacked-bitfield-compat \
-Wunused-parameter \ -Wpacked-not-aligned \
-Wunused-result \ -Wno-padded \
-Wunused-value \ -Wparentheses \
-Wunused-variable \ -Wpedantic \
-Wuseless-cast \ -Wpessimizing-move \
-Wvarargs \ -Wplacement-new=2 \
-Wvariadic-macros \ -Wpmf-conversions \
-Wvector-operation-performance \ -Wpointer-arith \
-Wvirtual-inheritance \ -Wpointer-compare \
-Wvirtual-move-assign \ -Wpragmas \
-Wvla \ -Wprio-ctor-dtor \
-Wvolatile-register-var \ -Wpsabi \
-Wwrite-strings \ -Wredundant-decls \
-Wzero-as-null-pointer-constant \ -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-pointer-div \
-Wsizeof-pointer-memaccess \
-Wstack-protector \
-Wstrict-aliasing \
-Wstrict-aliasing=3 \
-Wstrict-null-sentinel \
-Wstrict-overflow \
-Wstrict-overflow=5 \
-Wstring-compare \
-Wstringop-overflow \
-Wstringop-overflow=4 \
-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 \
-Wno-switch-enum \
-Wswitch-outside-range \
-Wswitch-unreachable \
-Wsync-nand \
-Wsynth \
-Wno-system-headers \
-Wtautological-compare \
-Wno-templates \
-Wterminate \
-Wtrampolines \
-Wtrigraphs \
-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 \
-Wno-unused-local-typedefs \
-Wunused-macros \
-Wunused-parameter \
-Wunused-result \
-Wunused-value \
-Wunused-variable \
-Wuseless-cast \
-Wvarargs \
-Wvariadic-macros \
-Wvector-operation-performance \
-Wvirtual-inheritance \
-Wvirtual-move-assign \
-Wvla \
-Wvolatile \
-Wvolatile-register-var \
-Wwrite-strings \
-Wzero-as-null-pointer-constant \
-Wzero-length-bounds \
" cmake -S . -B build_pedantic -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On
cmake --build build_pedantic
########################################################################## ##########################################################################
# benchmarks # benchmarks
...@@ -364,7 +389,7 @@ pedantic_gcc: ...@@ -364,7 +389,7 @@ pedantic_gcc:
run_benchmarks: run_benchmarks:
rm -fr build_benchmarks rm -fr build_benchmarks
mkdir build_benchmarks mkdir build_benchmarks
cd build_benchmarks ; cmake ../benchmarks -GNinja -DCMAKE_BUILD_TYPE=Release cd build_benchmarks ; cmake ../benchmarks -GNinja -DCMAKE_BUILD_TYPE=Release -DJSON_BuildTests=On
cd build_benchmarks ; ninja cd build_benchmarks ; ninja
cd build_benchmarks ; ./json_benchmarks cd build_benchmarks ; ./json_benchmarks
...@@ -441,7 +466,7 @@ cppcheck: ...@@ -441,7 +466,7 @@ cppcheck:
clang_analyze: clang_analyze:
rm -fr clang_analyze_build rm -fr clang_analyze_build
mkdir clang_analyze_build mkdir clang_analyze_build
cd clang_analyze_build ; CCC_CXX=$(COMPILER_DIR)/clang++ CXX=$(COMPILER_DIR)/clang++ $(COMPILER_DIR)/scan-build cmake .. -GNinja cd clang_analyze_build ; CCC_CXX=$(COMPILER_DIR)/clang++ CXX=$(COMPILER_DIR)/clang++ $(COMPILER_DIR)/scan-build cmake .. -GNinja -DJSON_BuildTests=On
cd clang_analyze_build ; \ cd clang_analyze_build ; \
$(COMPILER_DIR)/scan-build \ $(COMPILER_DIR)/scan-build \
-enable-checker alpha.core.BoolAssignment,alpha.core.CallAndMessageUnInitRefArg,alpha.core.CastSize,alpha.core.CastToStruct,alpha.core.Conversion,alpha.core.DynamicTypeChecker,alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,alpha.core.SizeofPtr,alpha.core.StackAddressAsyncEscape,alpha.core.TestAfterDivZero,alpha.deadcode.UnreachableCode,core.builtin.BuiltinFunctions,core.builtin.NoReturnFunctions,core.CallAndMessage,core.DivideZero,core.DynamicTypePropagation,core.NonnilStringConstants,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.UndefReturn,core.VLASize,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.SelfAssignment,deadcode.DeadStores,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull \ -enable-checker alpha.core.BoolAssignment,alpha.core.CallAndMessageUnInitRefArg,alpha.core.CastSize,alpha.core.CastToStruct,alpha.core.Conversion,alpha.core.DynamicTypeChecker,alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,alpha.core.SizeofPtr,alpha.core.StackAddressAsyncEscape,alpha.core.TestAfterDivZero,alpha.deadcode.UnreachableCode,core.builtin.BuiltinFunctions,core.builtin.NoReturnFunctions,core.CallAndMessage,core.DivideZero,core.DynamicTypePropagation,core.NonnilStringConstants,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.UndefReturn,core.VLASize,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.SelfAssignment,deadcode.DeadStores,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull \
...@@ -483,9 +508,9 @@ oclint: ...@@ -483,9 +508,9 @@ oclint:
clang_sanitize: clang_sanitize:
rm -fr clang_sanitize_build rm -fr clang_sanitize_build
mkdir clang_sanitize_build mkdir clang_sanitize_build
cd clang_sanitize_build ; CXX=$(COMPILER_DIR)/clang++ cmake .. -DJSON_Sanitizer=On -DJSON_MultipleHeaders=ON -GNinja cd clang_sanitize_build ; CXX=$(COMPILER_DIR)/clang++ cmake .. -DJSON_Sanitizer=On -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On -GNinja
cd clang_sanitize_build ; ninja cd clang_sanitize_build ; ninja
cd clang_sanitize_build ; ctest -E '.*_default' -j10 cd clang_sanitize_build ; ctest -j10
########################################################################## ##########################################################################
...@@ -579,7 +604,7 @@ check_cmake_flags: ...@@ -579,7 +604,7 @@ check_cmake_flags:
NEXT_VERSION ?= "unreleased" NEXT_VERSION ?= "unreleased"
ChangeLog.md: ChangeLog.md:
github_changelog_generator -o ChangeLog.md --simple-list --release-url https://github.com/nlohmann/json/releases/tag/%s --future-release $(NEXT_VERSION) 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 '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 $(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
......
...@@ -2,21 +2,28 @@ ...@@ -2,21 +2,28 @@
[![Build Status](https://travis-ci.org/nlohmann/json.svg?branch=master)](https://travis-ci.org/nlohmann/json) [![Build Status](https://travis-ci.org/nlohmann/json.svg?branch=master)](https://travis-ci.org/nlohmann/json)
[![Build Status](https://ci.appveyor.com/api/projects/status/1acb366xfyg3qybk/branch/develop?svg=true)](https://ci.appveyor.com/project/nlohmann/json) [![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)
[![Build Status](https://circleci.com/gh/nlohmann/json.svg?style=svg)](https://circleci.com/gh/nlohmann/json) [![Build Status](https://circleci.com/gh/nlohmann/json.svg?style=svg)](https://circleci.com/gh/nlohmann/json)
[![Coverage Status](https://img.shields.io/coveralls/nlohmann/json.svg)](https://coveralls.io/r/nlohmann/json) [![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) [![Coverity Scan Build Status](https://scan.coverity.com/projects/5550/badge.svg)](https://scan.coverity.com/projects/nlohmann-json)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f3732b3327e34358a0e9d1fe9f661f08)](https://www.codacy.com/app/nlohmann/json?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=nlohmann/json&amp;utm_campaign=Badge_Grade) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/f3732b3327e34358a0e9d1fe9f661f08)](https://www.codacy.com/app/nlohmann/json?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=nlohmann/json&amp;utm_campaign=Badge_Grade)
[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/nlohmann/json.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/nlohmann/json/context:cpp) [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/nlohmann/json.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/nlohmann/json/context:cpp)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/json.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:json) [![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/TarF5pPn9NtHQjhf) [![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/3lCHrFUZANONKv7a)
[![Documentation](https://img.shields.io/badge/docs-doxygen-blue.svg)](http://nlohmann.github.io/json) [![Documentation](https://img.shields.io/badge/docs-doxygen-blue.svg)](https://nlohmann.github.io/json/doxygen/index.html)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nlohmann/json/master/LICENSE.MIT) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nlohmann/json/master/LICENSE.MIT)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fnlohmann%2Fjson.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fnlohmann%2Fjson?ref=badge_shield)
[![GitHub Releases](https://img.shields.io/github/release/nlohmann/json.svg)](https://github.com/nlohmann/json/releases) [![GitHub Releases](https://img.shields.io/github/release/nlohmann/json.svg)](https://github.com/nlohmann/json/releases)
[![GitHub Issues](https://img.shields.io/github/issues/nlohmann/json.svg)](http://github.com/nlohmann/json/issues) [![GitHub Downloads](https://img.shields.io/github/downloads/nlohmann/json/total)](https://github.com/nlohmann/json/releases)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/nlohmann/json.svg)](http://isitmaintained.com/project/nlohmann/json "Average time to resolve an issue") [![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) [![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)
- [Design goals](#design-goals) - [Design goals](#design-goals)
- [Sponsors](#sponsors)
- [Integration](#integration) - [Integration](#integration)
- [CMake](#cmake) - [CMake](#cmake)
- [Package Managers](#package-managers) - [Package Managers](#package-managers)
...@@ -42,13 +49,13 @@ ...@@ -42,13 +49,13 @@
## Design goals ## Design goals
There are myriads of [JSON](http://json.org) libraries out there, and each may even have its reason to exist. Our class had these 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. - **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. - **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). - **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](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: Other aspects were not so important to us:
...@@ -59,6 +66,19 @@ Other aspects were not so important to us: ...@@ -59,6 +66,19 @@ Other aspects were not so important to us:
See the [contribution guidelines](https://github.com/nlohmann/json/blob/master/.github/CONTRIBUTING.md#please-dont) for more information. 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).
### :label: Named Sponsors
- [Michael Hartmann](https://github.com/reFX-Mike)
- [Stefan Hagen](https://github.com/sthagen)
- [Steve Sperandeo](https://github.com/homer6)
Thanks everyone!
## Integration ## 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 [`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
...@@ -117,6 +137,34 @@ add_library(foo ...) ...@@ -117,6 +137,34 @@ add_library(foo ...)
target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json) 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 the repository as a dependency at configure type.
Example:
```cmake
include(FetchContent)
FetchContent_Declare(json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.7.3)
FetchContent_GetProperties(json)
if(NOT json_POPULATED)
FetchContent_Populate(json)
add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json)
```
**Note**: The repository https://github.com/nlohmann/json download size is huge.
It contains all the dataset used for the benchmarks. You might want to depend on
a smaller repository. For instance, you might want to replace the URL above by
https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent
#### Supporting Both #### 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: To allow your project to support either an externally supplied or an embedded JSON library, you can use a pattern akin to the following:
...@@ -151,23 +199,23 @@ endif() ...@@ -151,23 +199,23 @@ endif()
### Package Managers ### Package Managers
:beer: If you are using OS X and [Homebrew](http://brew.sh), just type `brew tap nlohmann/json` and `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`. :beer: If you are using OS X and [Homebrew](https://brew.sh), just type `brew tap nlohmann/json` and `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`.
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. 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. The provided meson.build can also be used as an alternative to cmake for installing `nlohmann_json` system-wide in which case a pkg-config file is installed. To use it, simply have your build system require the `nlohmann_json` pkg-config dependency. In Meson, it is preferred to use the [`dependency()`](https://mesonbuild.com/Reference-manual.html#dependency) object with a subproject fallback, rather than using the subproject directly.
If you are using [Conan](https://www.conan.io/) to manage your dependencies, merely add `jsonformoderncpp/x.y.z@vthiery/stable` to your `conanfile.py`'s requires, where `x.y.z` is the release version you want to use. Please file issues [here](https://github.com/vthiery/conan-jsonformoderncpp/issues) if you experience problems with the packages. 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.
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 [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/ruslo/hunter/) on your project for external dependencies, then you can use the [nlohmann_json package](https://docs.hunter.sh/en/latest/packages/pkg/nlohmann_json.html). Please see the hunter project 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 [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 use the [nlohmann-json package](https://github.com/Microsoft/vcpkg/tree/master/ports/nlohmann-json). Please see the vcpkg project for any issues regarding the packaging. If you are using [vcpkg](https://github.com/Microsoft/vcpkg/) on your project for external dependencies, then you can use the [nlohmann-json package](https://github.com/Microsoft/vcpkg/tree/master/ports/nlohmann-json). Please see the vcpkg project for any issues regarding the packaging.
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`). 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 [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).
...@@ -175,7 +223,12 @@ If you are using [NuGet](https://www.nuget.org), you can use the package [nlohma ...@@ -175,7 +223,12 @@ If you are using [NuGet](https://www.nuget.org), you can use the package [nlohma
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 [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](http://www.msys2.org/), your 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 [MSYS2](https://www.msys2.org/), your 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 [`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.
## Examples ## Examples
...@@ -283,7 +336,7 @@ auto j2 = R"( ...@@ -283,7 +336,7 @@ auto j2 = R"(
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. 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 above example can also be expressed explicitly using [`json::parse()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_afd4ef1ac8ad50a5894a9afebca69140a.html#afd4ef1ac8ad50a5894a9afebca69140a): The above example can also be expressed explicitly using [`json::parse()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a265a473e939184aa42655c9ccdf34e58.html#a265a473e939184aa42655c9ccdf34e58):
```cpp ```cpp
// parse explicitly // parse explicitly
...@@ -294,7 +347,7 @@ You can also get a string representation of a JSON value (serialize): ...@@ -294,7 +347,7 @@ You can also get a string representation of a JSON value (serialize):
```cpp ```cpp
// explicit conversion to string // explicit conversion to string
std::string s = j.dump(); // {\"happy\":true,\"pi\":3.141} std::string s = j.dump(); // {"happy":true,"pi":3.141}
// serialization with pretty printing // serialization with pretty printing
// pass in the amount of spaces to indent // pass in the amount of spaces to indent
...@@ -363,7 +416,7 @@ Please note that setting the exception bit for `failbit` is inappropriate for th ...@@ -363,7 +416,7 @@ Please note that setting the exception bit for `failbit` is inappropriate for th
#### Read from iterator range #### Read from iterator range
You can also parse JSON from an iterator range; that is, from any container accessible by iterators whose content is stored as contiguous byte sequence, for instance a `std::vector<std::uint8_t>`: 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<std::uint8_t>`, or a `std::list<std::uint16_t>`:
```cpp ```cpp
std::vector<std::uint8_t> v = {'t', 'r', 'u', 'e'}; std::vector<std::uint8_t> v = {'t', 'r', 'u', 'e'};
...@@ -377,6 +430,53 @@ std::vector<std::uint8_t> v = {'t', 'r', 'u', 'e'}; ...@@ -377,6 +430,53 @@ std::vector<std::uint8_t> v = {'t', 'r', 'u', 'e'};
json j = json::parse(v); 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 #### SAX interface
The library uses a SAX-like interface with the following functions: The library uses a SAX-like interface with the following functions:
...@@ -450,7 +550,7 @@ j[1] = 42; ...@@ -450,7 +550,7 @@ j[1] = 42;
bool foo = j.at(2); bool foo = j.at(2);
// comparison // comparison
j == "[\"foo\", 1, true]"_json; // true j == "[\"foo\", 42, true]"_json; // true
// other stuff // other stuff
j.size(); // 3 entries j.size(); // 3 entries
...@@ -491,6 +591,11 @@ for (auto& [key, value] : o.items()) { ...@@ -491,6 +591,11 @@ for (auto& [key, value] : o.items()) {
} }
// find an entry // find an entry
if (o.contains("foo")) {
// there is an entry with key "foo"
}
// or via find and an iterator
if (o.find("foo") != o.end()) { if (o.find("foo") != o.end()) {
// there is an entry with key "foo" // there is an entry with key "foo"
} }
...@@ -958,7 +1063,7 @@ Other Important points: ...@@ -958,7 +1063,7 @@ Other Important points:
### Binary formats (BSON, CBOR, MessagePack, and UBJSON) ### Binary formats (BSON, CBOR, MessagePack, and UBJSON)
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](http://bsonspec.org) (Binary JSON), [CBOR](http://cbor.io) (Concise Binary Object Representation), [MessagePack](http://msgpack.org), and [UBJSON](http://ubjson.org) (Universal Binary JSON Specification) to efficiently encode JSON values to byte vectors and to decode such vectors. 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](http://bsonspec.org) (Binary JSON), [CBOR](https://cbor.io) (Concise Binary Object Representation), [MessagePack](https://msgpack.org), and [UBJSON](http://ubjson.org) (Universal Binary JSON Specification) to efficiently encode JSON values to byte vectors and to decode such vectors.
```cpp ```cpp
// create a JSON value // create a JSON value
...@@ -997,13 +1102,43 @@ std::vector<std::uint8_t> v_ubjson = json::to_ubjson(j); ...@@ -997,13 +1102,43 @@ std::vector<std::uint8_t> v_ubjson = json::to_ubjson(j);
json j_from_ubjson = json::from_ubjson(v_ubjson); 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<std::uint8_t>` to be processed outside of the library.
```cpp
// CBOR byte string with payload 0xCAFE
std::vector<std::uint8_t> 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<std::uint8_t> 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 ## Supported compilers
Though it's 2019 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work: Though it's 2020 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work:
- GCC 4.8 - 9.2 (and possibly later) - GCC 4.8 - 10.1 (and possibly later)
- Clang 3.4 - 9.0 (and possibly later) - Clang 3.4 - 10.0 (and possibly later)
- Intel C++ Compiler 17.0.2 (and possibly later) - Intel C++ Compiler 17.0.2 (and possibly later)
- Microsoft Visual C++ 2015 / Build Tools 14.0.25123.0 (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++ 2017 / Build Tools 15.5.180.51428 (and possibly later)
...@@ -1024,47 +1159,46 @@ Please note: ...@@ -1024,47 +1159,46 @@ Please note:
The code compiles successfully with [Android NDK](https://developer.android.com/ndk/index.html?hl=ml), Revision 9 - 11 (and possibly later) and [CrystaX's Android NDK](https://www.crystax.net/en/android/ndk) version 10. 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`) 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](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). - 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. - 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 [Travis](https://travis-ci.org/nlohmann/json), [AppVeyor](https://ci.appveyor.com/project/nlohmann/json), [CircleCI](https://circleci.com/gh/nlohmann/json), and [Doozer](https://doozer.io): The following compilers are currently used in continuous integration at [Travis](https://travis-ci.org/nlohmann/json), [AppVeyor](https://ci.appveyor.com/project/nlohmann/json), [GitHub Actions](https://github.com/nlohmann/json/actions), and [CircleCI](https://circleci.com/gh/nlohmann/json):
| Compiler | Operating System | Version String | | Compiler | Operating System | CI Provider |
|-----------------------|------------------------------|----------------| |-----------------------------------------------------------------|--------------------|----------------|
| GCC 4.8.5 | Ubuntu 14.04.5 LTS | g++-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.2) 4.8.5 | | Apple Clang 9.1.0 (clang-902.0.39.1); Xcode 9.3 | macOS 10.13.3 | Travis |
| GCC 4.8.5 | CentOS Release-7-6.1810.2.el7.centos.x86_64 | g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36) | | Apple Clang 9.1.0 (clang-902.0.39.2); Xcode 9.4.1 | macOS 10.13.6 | Travis |
| GCC 4.9.2 (armv7l) | Raspbian GNU/Linux 8 (jessie) | g++ (Raspbian 4.9.2-10+deb8u2) 4.9.2 | | Apple Clang 10.0.0 (clang-1000.11.45.2); Xcode 10.0 | macOS 10.13.6 | Travis |
| GCC 4.9.4 | Ubuntu 14.04.1 LTS | g++-4.9 (Ubuntu 4.9.4-2ubuntu1~14.04.1) 4.9.4 | | Apple Clang 10.0.0 (clang-1000.11.45.5); Xcode 10.1 | macOS 10.13.6 | Travis |
| GCC 5.3.1 (armv7l) | Ubuntu 16.04 LTS | g++ (Ubuntu/Linaro 5.3.1-14ubuntu2) 5.3.1 20160413 | | Apple Clang 10.0.1 (clang-1001.0.46.4); Xcode 10.2.1 | macOS 10.14.4 | Travis |
| GCC 5.5.0 | Ubuntu 14.04.1 LTS | g++-5 (Ubuntu 5.5.0-12ubuntu1~14.04) 5.5.0 20171010 | | Apple Clang 11.0.0 (clang-1100.0.33.12); Xcode 11.2.1 | macOS 10.14.6 | Travis |
| GCC 6.3.0 | Debian 9 (stretch) | g++ (Debian 6.3.0-18+deb9u1) 6.3.0 20170516 | | Apple Clang 11.0.3 (clang-1103.0.32.59); Xcode 11.4.1 | macOS 10.15.4 | GitHub Actions |
| GCC 6.3.1 | Fedora release 24 (Twenty Four) | g++ (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1) | | Clang 3.5.0 (3.5.0-4ubuntu2~trusty2) | Ubuntu 14.04.5 LTS | Travis |
| GCC 6.4.0 | Ubuntu 14.04.1 LTS | g++-6 (Ubuntu 6.4.0-17ubuntu1~14.04) 6.4.0 20180424 | | Clang 3.6.2 (3.6.2-svn240577-1~exp1) | Ubuntu 14.04.5 LTS | Travis |
| GCC 7.3.0 | Ubuntu 14.04.1 LTS | g++-7 (Ubuntu 7.3.0-21ubuntu1~14.04) 7.3.0 | | Clang 3.7.1 (3.7.1-svn253571-1~exp1) | Ubuntu 14.04.5 LTS | Travis |
| GCC 7.3.0 | Windows Server 2012 R2 (x64) | g++ (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 7.3.0 | | Clang 3.8.0 (3.8.0-2ubuntu3~trusty5) | Ubuntu 14.04.5 LTS | Travis |
| GCC 8.1.0 | Ubuntu 14.04.1 LTS | g++-8 (Ubuntu 8.1.0-5ubuntu1~14.04) 8.1.0 | | Clang 3.9.1 (3.9.1-4ubuntu3~14.04.3) | Ubuntu 14.04.5 LTS | Travis |
| GCC 9.2.1 | Ubuntu 14.05.1 LTS | g++-9 (Ubuntu 9.2.1-16ubuntu1~14.04.1) 9.2.1 20191030 | | Clang 4.0.1 (4.0.1-svn305264-1~exp1) | Ubuntu 14.04.5 LTS | Travis |
| Clang 3.5.0 | Ubuntu 14.04.1 LTS | clang version 3.5.0-4ubuntu2~trusty2 (tags/RELEASE_350/final) (based on LLVM 3.5.0) | | Clang 5.0.2 (version 5.0.2-svn328729-1~exp1~20180509123505.100) | Ubuntu 14.04.5 LTS | Travis |
| Clang 3.6.2 | Ubuntu 14.04.1 LTS | clang version 3.6.2-svn240577-1~exp1 (branches/release_36) (based on LLVM 3.6.2) | | Clang 6.0.1 (6.0.1-svn334776-1~exp1~20190309042707.121) | Ubuntu 14.04.5 LTS | Travis |
| Clang 3.7.1 | Ubuntu 14.04.1 LTS | clang version 3.7.1-svn253571-1~exp1 (branches/release_37) (based on LLVM 3.7.1) | | Clang 7.1.0 (7.1.0-svn353565-1~exp1~20190419134007.64) | Ubuntu 14.04.5 LTS | Travis |
| Clang 3.8.0 | Ubuntu 14.04.1 LTS | clang version 3.8.0-2ubuntu3~trusty5 (tags/RELEASE_380/final) | | Clang 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) | Ubuntu 18.04.4 LTS | Travis |
| Clang 3.9.1 | Ubuntu 14.04.1 LTS | clang version 3.9.1-4ubuntu3~14.04.3 (tags/RELEASE_391/rc2) | | GCC 4.8.5 (Ubuntu 4.8.5-4ubuntu8~14.04.2) | Ubuntu 14.04.5 LTS | Travis |
| Clang 4.0.1 | Ubuntu 14.04.1 LTS | clang version 4.0.1-svn305264-1~exp1 (branches/release_40) | | GCC 4.9.4 (Ubuntu 4.9.4-2ubuntu1~14.04.1) | Ubuntu 14.04.5 LTS | Travis |
| Clang 5.0.2 | Ubuntu 14.04.1 LTS | clang version 5.0.2-svn328729-1~exp1~20180509123505.100 (branches/release_50) | | GCC 5.5.0 (Ubuntu 5.5.0-12ubuntu1~14.04) | Ubuntu 14.04.5 LTS | Travis |
| Clang 6.0.1 | Ubuntu 14.04.1 LTS | clang version 6.0.1-svn334776-1~exp1~20180726133705.85 (branches/release_60) | | GCC 6.3.0 (Debian 6.3.0-18+deb9u1) | Debian 9 | Circle CI |
| Clang 7.0.1 | Ubuntu 14.04.1 LTS | clang version 7.0.1-svn348686-1~exp1~20181213084532.54 (branches/release_70) | | GCC 6.5.0 (Ubuntu 6.5.0-2ubuntu1~14.04.1) | Ubuntu 14.04.5 LTS | Travis |
| Clang Xcode 8.3 | OSX 10.11.6 | Apple LLVM version 8.1.0 (clang-802.0.38) | | GCC 7.3.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) | Windows-6.3.9600 | AppVeyor |
| Clang Xcode 9.0 | OSX 10.12.6 | Apple LLVM version 9.0.0 (clang-900.0.37) | | GCC 7.5.0 (Ubuntu 7.5.0-3ubuntu1~14.04.1) | Ubuntu 14.04.5 LTS | Travis |
| Clang Xcode 9.1 | OSX 10.12.6 | Apple LLVM version 9.0.0 (clang-900.0.38) | | GCC 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) | Ubuntu 18.04.4 LTS | GitHub Actions |
| Clang Xcode 9.2 | OSX 10.13.3 | Apple LLVM version 9.1.0 (clang-902.0.39.1) | | GCC 8.4.0 (Ubuntu 8.4.0-1ubuntu1~14.04) | Ubuntu 14.04.5 LTS | Travis |
| Clang Xcode 9.3 | OSX 10.13.3 | Apple LLVM version 9.1.0 (clang-902.0.39.2) | | GCC 9.3.0 (Ubuntu 9.3.0-11ubuntu0~14.04) | Ubuntu 14.04.5 LTS | Travis |
| Clang Xcode 10.0 | OSX 10.13.3 | Apple LLVM version 10.0.0 (clang-1000.11.45.2) | | GCC 10.1.0 (Arch Linux latest) | Arch Linux | Circle CI |
| Clang Xcode 10.1 | OSX 10.13.3 | Apple LLVM version 10.0.0 (clang-1000.11.45.5) | | MSVC 19.0.24241.7 (Build Engine version 14.0.25420.1) | Windows-6.3.9600 | AppVeyor |
| Clang Xcode 10.2 | OSX 10.14.4 | Apple LLVM version 10.0.1 (clang-1001.0.46.4) | | MSVC 19.16.27035.0 (15.9.21+g9802d43bc3 for .NET Framework) | Windows-10.0.14393 | AppVeyor |
| Visual Studio 14 2015 | Windows Server 2012 R2 (x64) | Microsoft (R) Build Engine version 14.0.25420.1, MSVC 19.0.24215.1 | | MSVC 19.25.28614.0 (Build Engine version 16.5.0+d4cbfca49 for .NET Framework) | Windows-10.0.17763 | AppVeyor |
| Visual Studio 15 2017 | Windows Server 2012 R2 (x64) | Microsoft (R) Build Engine version 15.9.21+g9802d43bc3, MSVC 19.16.27032.1 | | MSVC 19.25.28614.0 (Build Engine version 16.5.0+d4cbfca49 for .NET Framework) | Windows-10.0.17763 | GitHub Actions |
| Visual Studio 16 2019 | Windows Server 2012 R2 (x64) | Microsoft (R) Build Engine version 16.3.1+1def00d3d, MSVC 19.23.28106.4 |
## License ## License
...@@ -1082,11 +1216,11 @@ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR I ...@@ -1082,11 +1216,11 @@ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR I
* * * * * *
The class contains the UTF-8 Decoder from Bjoern Hoehrmann which is licensed under the [MIT License](http://opensource.org/licenses/MIT) (see above). Copyright &copy; 2008-2009 [Björn Hoehrmann](http://bjoern.hoehrmann.de/) <bjoern@hoehrmann.de> The class contains the UTF-8 Decoder from Bjoern Hoehrmann which is licensed under the [MIT License](http://opensource.org/licenses/MIT) (see above). Copyright &copy; 2008-2009 [Björn Hoehrmann](https://bjoern.hoehrmann.de/) <bjoern@hoehrmann.de>
The class contains a slightly modified version of the Grisu2 algorithm from Florian Loitsch which is licensed under the [MIT License](http://opensource.org/licenses/MIT) (see above). Copyright &copy; 2009 [Florian Loitsch](http://florian.loitsch.com/) The class contains a slightly modified version of the Grisu2 algorithm from Florian Loitsch which is licensed under the [MIT License](http://opensource.org/licenses/MIT) (see above). Copyright &copy; 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](http://creativecommons.org/publicdomain/zero/1.0/). 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/).
## Contact ## Contact
...@@ -1143,7 +1277,7 @@ I deeply appreciate the help of the following people. ...@@ -1143,7 +1277,7 @@ I deeply appreciate the help of the following people.
- [Mário Feroldi](https://github.com/thelostt) fixed a small typo. - [Mário Feroldi](https://github.com/thelostt) fixed a small typo.
- [duncanwerner](https://github.com/duncanwerner) found a really embarrassing performance regression in the 2.0.0 release. - [duncanwerner](https://github.com/duncanwerner) found a really embarrassing performance regression in the 2.0.0 release.
- [Damien](https://github.com/dtoma) fixed one of the last conversion warnings. - [Damien](https://github.com/dtoma) fixed one of the last conversion warnings.
- [Thomas Braun](https://github.com/t-b) fixed a warning in a test case. - [Thomas Braun](https://github.com/t-b) fixed a warning in a test case and adjusted MSVC calls in the CI.
- [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. - [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.
- [Stefan](https://github.com/5tefan) fixed a minor issue in the documentation. - [Stefan](https://github.com/5tefan) fixed a minor issue in the documentation.
- [Vasil Dimov](https://github.com/vasild) fixed the documentation regarding conversions from `std::multiset`. - [Vasil Dimov](https://github.com/vasild) fixed the documentation regarding conversions from `std::multiset`.
...@@ -1287,6 +1421,37 @@ I deeply appreciate the help of the following people. ...@@ -1287,6 +1421,37 @@ I deeply appreciate the help of the following people.
- [Florian Pigorsch](https://github.com/flopp) fixed a lot of typos. - [Florian Pigorsch](https://github.com/flopp) fixed a lot of typos.
- [Camille Bégué](https://github.com/cbegue) fixed an issue in the conversion from `std::pair` and `std::tuple` to `json`. - [Camille Bégué](https://github.com/cbegue) fixed an issue in the conversion from `std::pair` and `std::tuple` to `json`.
- [Anthony VH](https://github.com/AnthonyVH) fixed a compile error in an enum deserialization. - [Anthony VH](https://github.com/AnthonyVH) fixed a compile error in an enum deserialization.
- [Yuriy Vountesmery](https://github.com/ua-code-dragon) noted a subtle bug in a preprocessor check.
- [Chen](https://github.com/dota17) fixed numerous issues in the library.
- [Antony Kellermann](https://github.com/aokellermann) added a CI step for GCC 10.1.
- [Alex](https://github.com/gistrec) fixed an MSVC warning.
- [Rainer](https://github.com/rvjr) proposed an improvement in the floating-point serialization in CBOR.
- [Francois Chabot](https://github.com/FrancoisChabot) made performance improvements in the input adapters.
- [Arthur Sonzogni](https://github.com/ArthurSonzogni) documented how the library can be included via `FetchContent`.
- [Rimas Misevičius](https://github.com/rmisev) fixed an error message.
- [Alexander Myasnikov](https://github.com/alexandermyasnikov) fixed some examples and a link in the README.
- [Hubert Chathi](https://github.com/uhoreg) made CMake's version config file architecture-independent.
- [OmnipotentEntity](https://github.com/OmnipotentEntity) implemented the binary values for CBOR, MessagePack, BSON, and UBJSON.
- [ArtemSarmini](https://github.com/ArtemSarmini) fixed a compilation issue with GCC 10 and fixed a leak.
- [Evgenii Sopov](https://github.com/sea-kg) integrated the library to the wsjcpp package manager.
- [Sergey Linev](https://github.com/linev) fixed a compiler warning.
- [Miguel Magalhães](https://github.com/magamig) fixed the year in the copyright.
- [Gareth Sylvester-Bradley](https://github.com/garethsb-sony) fixed a compilation issue with MSVC.
- [Alexander “weej” Jones](https://github.com/alex-weej) fixed an example in the README.
- [Antoine Cœur](https://github.com/Coeur) fixed some typos in the documentation.
- [jothepro](https://github.com/jothepro) updated links to the Hunter package.
- [Dave Lee](https://github.com/kastiglione) fixed link in the README.
- [Joël Lamotte](https://github.com/Klaim) added instruction for using Build2's package manager.
- [Paul Jurczak](https://github.com/pauljurczak) fixed an example in the README.
- [Sonu Lohani](https://github.com/sonulohani) fixed a warning.
- [Carlos Gomes Martinho](https://github.com/gocarlos) updated the Conan package source.
- [Konstantin Podsvirov](https://github.com/podsvirov) fixed the MSYS2 package documentation.
- [Tridacnid](https://github.com/Tridacnid) improved the CMake tests.
- [Michael](https://github.com/MBalszun) fixed MSVC warnings.
- [Quentin Barbarat](https://github.com/quentin-dev) fixed an example in the documentation.
- [XyFreak](https://github.com/XyFreak) fixed a compiler warning.
- [TotalCaesar659](https://github.com/TotalCaesar659) fixed links in the README.
- [Tanuj Garg](https://github.com/tanuj208) improved the fuzzer coverage for UBSAN input.
Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I forgot someone. Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I forgot someone.
...@@ -1296,32 +1461,30 @@ Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I ...@@ -1296,32 +1461,30 @@ Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I
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! 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 - [**amalgamate.py - Amalgamate C source and header files**](https://github.com/edlund/amalgamate) to create a single header file
- [**American fuzzy lop**](http://lcamtuf.coredump.cx/afl/) for fuzz testing - [**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 - [**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 - [**Artistic Style**](http://astyle.sourceforge.net) for automatic source code indentation
- [**CircleCI**](http://circleci.com) for [continuous integration](https://circleci.com/gh/nlohmann/json). - [**CircleCI**](https://circleci.com) for [continuous integration](https://circleci.com/gh/nlohmann/json).
- [**Clang**](http://clang.llvm.org) for compilation with code sanitizers - [**Clang**](https://clang.llvm.org) for compilation with code sanitizers
- [**CMake**](https://cmake.org) for build automation - [**CMake**](https://cmake.org) for build automation
- [**Codacity**](https://www.codacy.com) for further [code analysis](https://www.codacy.com/app/nlohmann/json) - [**Codacity**](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) - [**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) - [**Coverity Scan**](https://scan.coverity.com) for [static analysis](https://scan.coverity.com/projects/nlohmann-json)
- [**cppcheck**](http://cppcheck.sourceforge.net) for static analysis - [**cppcheck**](http://cppcheck.sourceforge.net) for static analysis
- [**doctest**](https://github.com/onqtam/doctest) for the unit tests - [**doctest**](https://github.com/onqtam/doctest) for the unit tests
- [**Doozer**](https://doozer.io) for [continuous integration](https://doozer.io/nlohmann/json) on Linux (CentOS, Raspbian, Fedora) - [**Doxygen**](https://www.doxygen.nl/index.html) to generate [documentation](https://nlohmann.github.io/json/doxygen/index.html)
- [**Doxygen**](http://www.stack.nl/~dimitri/doxygen/) to generate [documentation](https://nlohmann.github.io/json/)
- [**fastcov**](https://github.com/RPGillespie6/fastcov) to process coverage information
- [**git-update-ghpages**](https://github.com/rstacruz/git-update-ghpages) to upload the documentation to gh-pages - [**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) - [**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 - [**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 - [**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 a HTML view - [**lcov**](http://ltp.sourceforge.net/coverage/lcov.php) to process coverage information and create a HTML view
- [**libFuzzer**](http://llvm.org/docs/LibFuzzer.html) to implement fuzz testing for OSS-Fuzz - [**libFuzzer**](https://llvm.org/docs/LibFuzzer.html) to implement fuzz testing for OSS-Fuzz
- [**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)) - [**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. - [**Probot**](https://probot.github.io) for automating maintainer tasks such as closing stale issues, requesting missing information, or detecting toxic comments.
- [**send_to_wandbox**](https://github.com/nlohmann/json/blob/develop/doc/scripts/send_to_wandbox.py) to send code examples to [Wandbox](http://melpon.org/wandbox) - [**send_to_wandbox**](https://github.com/nlohmann/json/blob/develop/doc/scripts/send_to_wandbox.py) to send code examples to [Wandbox](http://melpon.org/wandbox)
- [**Travis**](https://travis-ci.org) for [continuous integration](https://travis-ci.org/nlohmann/json) on Linux and macOS - [**Travis**](https://travis-ci.org) for [continuous integration](https://travis-ci.org/nlohmann/json) on Linux and macOS
- [**Valgrind**](http://valgrind.org) to check for correct memory management - [**Valgrind**](https://valgrind.org) to check for correct memory management
- [**Wandbox**](http://melpon.org/wandbox) for [online examples](https://wandbox.org/permlink/TarF5pPn9NtHQjhf) - [**Wandbox**](https://wandbox.org) for [online examples](https://wandbox.org/permlink/3lCHrFUZANONKv7a)
## Projects using JSON for Modern C++ ## Projects using JSON for Modern C++
...@@ -1338,7 +1501,7 @@ The library supports **Unicode input** as follows: ...@@ -1338,7 +1501,7 @@ The library supports **Unicode input** as follows:
- Only **UTF-8** encoded input is supported which is the default encoding for JSON according to [RFC 8259](https://tools.ietf.org/html/rfc8259.html#section-8.1). - Only **UTF-8** encoded input is supported which is the default encoding for JSON according to [RFC 8259](https://tools.ietf.org/html/rfc8259.html#section-8.1).
- `std::u16string` and `std::u32string` can be parsed, assuming UTF-16 and UTF-32 encoding, respectively. These encodings are not supported when reading from files or other input containers. - `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. - 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. - [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. - 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. - 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. - 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.
...@@ -1366,6 +1529,15 @@ This library will not support comments in the future. If you wish to use comment ...@@ -1366,6 +1529,15 @@ This library will not support comments in the future. If you wish to use comment
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 specialize the object type with containers 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)). 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 specialize the object type with containers 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 maybe 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 ### 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://nlohmann.github.io/json/classnlohmann_1_1basic__json_a233b02b0839ef798942dd46157cc0fe6.html#a233b02b0839ef798942dd46157cc0fe6) 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://nlohmann.github.io/json/classnlohmann_1_1basic__json_a73ae333487310e3302135189ce8ff5d8.html#a73ae333487310e3302135189ce8ff5d8). - 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://nlohmann.github.io/json/classnlohmann_1_1basic__json_a233b02b0839ef798942dd46157cc0fe6.html#a233b02b0839ef798942dd46157cc0fe6) 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://nlohmann.github.io/json/classnlohmann_1_1basic__json_a73ae333487310e3302135189ce8ff5d8.html#a73ae333487310e3302135189ce8ff5d8).
...@@ -1380,7 +1552,7 @@ To compile and run the tests, you need to execute ...@@ -1380,7 +1552,7 @@ To compile and run the tests, you need to execute
```sh ```sh
$ mkdir build $ mkdir build
$ cd build $ cd build
$ cmake .. $ cmake .. -DJSON_BuildTests=On
$ cmake --build . $ cmake --build .
$ ctest --output-on-failure $ ctest --output-on-failure
``` ```
......
...@@ -85,7 +85,7 @@ environment: ...@@ -85,7 +85,7 @@ environment:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
configuration: Release configuration: Release
platform: x64 platform: x64
CXX_FLAGS: "/permissive- /std:c++latest /utf-8 /F4000000" CXX_FLAGS: "/permissive- /std:c++latest /Zc:__cplusplus /utf-8 /F4000000"
LINKER_FLAGS: "/STACK:4000000" LINKER_FLAGS: "/STACK:4000000"
GENERATOR: Visual Studio 15 2017 GENERATOR: Visual Studio 15 2017
...@@ -112,7 +112,7 @@ before_build: ...@@ -112,7 +112,7 @@ before_build:
# for with_win_header build, inject the inclusion of Windows.h to the single-header library # 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") { $header_path = "single_include\nlohmann\json.hpp" }
- ps: if ($env:name -Eq "with_win_header") { "#include <Windows.h>`n" + (Get-Content $header_path | Out-String) | Set-Content $header_path } - ps: if ($env:name -Eq "with_win_header") { "#include <Windows.h>`n" + (Get-Content $header_path | Out-String) | Set-Content $header_path }
- if "%GENERATOR%"=="Ninja" (cmake . -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%configuration%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin") else (cmake . -G "%GENERATOR%" -A "%GENERATOR_PLATFORM%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin") - if "%GENERATOR%"=="Ninja" (cmake . -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%configuration%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On) else (cmake . -G "%GENERATOR%" -A "%GENERATOR_PLATFORM%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On)
build_script: build_script:
- cmake --build . --config "%configuration%" - cmake --build . --config "%configuration%"
...@@ -123,4 +123,4 @@ test_script: ...@@ -123,4 +123,4 @@ test_script:
# as it is extremely slow to run and cause # as it is extremely slow to run and cause
# occasional timeouts on AppVeyor. # occasional timeouts on AppVeyor.
# More info: https://github.com/nlohmann/json/pull/1570 # More info: https://github.com/nlohmann/json/pull/1570
- if "%configuration%"=="Debug" ctest --exclude-regex "test-unicode_all" -C "%configuration%" -V -j - if "%configuration%"=="Debug" ctest --exclude-regex "test-unicode" -C "%configuration%" -V -j
find_package(Git)
set(JSON_TEST_DATA_URL https://github.com/nlohmann/json_test_data)
set(JSON_TEST_DATA_VERSION 2.0.0)
# 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")
# 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(CMAKE_CXX_COMPILER "${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}")
# 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()
#pragma once
#include <cstdint> // uint8_t
#include <tuple> // tie
#include <utility> // move
namespace nlohmann
{
/*!
@brief an internal type for a backed binary type
This type extends the template parameter @a BinaryType provided to `basic_json`
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.
@tparam BinaryType container to store bytes (`std::vector<std::uint8_t>` by
default)
@since version 3.8.0
*/
template<typename BinaryType>
class byte_container_with_subtype : public BinaryType
{
public:
/// the type of the underlying container
using container_type = BinaryType;
byte_container_with_subtype() noexcept(noexcept(container_type()))
: container_type()
{}
byte_container_with_subtype(const container_type& b) noexcept(noexcept(container_type(b)))
: container_type(b)
{}
byte_container_with_subtype(container_type&& b) noexcept(noexcept(container_type(std::move(b))))
: container_type(std::move(b))
{}
byte_container_with_subtype(const container_type& b, std::uint8_t subtype) noexcept(noexcept(container_type(b)))
: container_type(b)
, m_subtype(subtype)
, m_has_subtype(true)
{}
byte_container_with_subtype(container_type&& b, std::uint8_t 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<const BinaryType&>(*this), m_subtype, m_has_subtype) ==
std::tie(static_cast<const BinaryType&>(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
Sets the binary subtype of the value, also flags a binary JSON value as
having a subtype, which has implications for serialization.
@complexity Constant.
@exceptionsafety No-throw guarantee: this member function never throws
exceptions.
@sa @ref subtype() -- return the binary subtype
@sa @ref clear_subtype() -- clears the binary subtype
@sa @ref has_subtype() -- returns whether or not the binary value has a
subtype
@since version 3.8.0
*/
void set_subtype(std::uint8_t subtype) noexcept
{
m_subtype = subtype;
m_has_subtype = true;
}
/*!
@brief return the binary subtype
Returns the numerical subtype of the value if it has a subtype. If it does
not have a subtype, this function will return size_t(-1) as a sentinel
value.
@return the numerical subtype of the binary value
@complexity Constant.
@exceptionsafety No-throw guarantee: this member function never throws
exceptions.
@sa @ref set_subtype() -- sets the binary subtype
@sa @ref clear_subtype() -- clears the binary subtype
@sa @ref has_subtype() -- returns whether or not the binary value has a
subtype
@since version 3.8.0
*/
constexpr std::uint8_t subtype() const noexcept
{
return m_subtype;
}
/*!
@brief return whether the value has a subtype
@return whether the value has a subtype
@complexity Constant.
@exceptionsafety No-throw guarantee: this member function never throws
exceptions.
@sa @ref subtype() -- return the binary subtype
@sa @ref set_subtype() -- sets the binary subtype
@sa @ref clear_subtype() -- clears the binary subtype
@since version 3.8.0
*/
constexpr bool has_subtype() const noexcept
{
return m_has_subtype;
}
/*!
@brief clears the binary subtype
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.
@complexity Constant.
@exceptionsafety No-throw guarantee: this member function never throws
exceptions.
@sa @ref subtype() -- return the binary subtype
@sa @ref set_subtype() -- sets the binary subtype
@sa @ref has_subtype() -- returns whether or not the binary value has a
subtype
@since version 3.8.0
*/
void clear_subtype() noexcept
{
m_subtype = 0;
m_has_subtype = false;
}
private:
std::uint8_t m_subtype = 0;
bool m_has_subtype = false;
};
} // namespace nlohmann
#pragma once
// Header <ciso646> is removed in C++20.
// See <https://github.com/nlohmann/json/issues/2089> for more information.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#include <algorithm> // transform #include <algorithm> // transform
#include <array> // array #include <array> // array
#include <ciso646> // and, not
#include <forward_list> // forward_list #include <forward_list> // forward_list
#include <iterator> // inserter, front_inserter, end #include <iterator> // inserter, front_inserter, end
#include <map> // map #include <map> // map
...@@ -13,6 +12,7 @@ ...@@ -13,6 +12,7 @@
#include <utility> // pair, declval #include <utility> // pair, declval
#include <valarray> // valarray #include <valarray> // valarray
#include <nlohmann/detail/boolean_operators.hpp>
#include <nlohmann/detail/exceptions.hpp> #include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/macro_scope.hpp> #include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta/cpp_future.hpp> #include <nlohmann/detail/meta/cpp_future.hpp>
...@@ -228,9 +228,9 @@ template <typename BasicJsonType, typename ConstructibleArrayType, ...@@ -228,9 +228,9 @@ template <typename BasicJsonType, typename ConstructibleArrayType,
is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value and is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value and
not is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value and not is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value and
not is_constructible_string_type<BasicJsonType, ConstructibleArrayType>::value and not is_constructible_string_type<BasicJsonType, ConstructibleArrayType>::value and
not std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value and
not is_basic_json<ConstructibleArrayType>::value, not is_basic_json<ConstructibleArrayType>::value,
int > = 0 > int > = 0 >
auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr)
-> decltype(from_json_array_impl(j, arr, priority_tag<3> {}), -> decltype(from_json_array_impl(j, arr, priority_tag<3> {}),
j.template get<typename ConstructibleArrayType::value_type>(), j.template get<typename ConstructibleArrayType::value_type>(),
...@@ -245,6 +245,17 @@ void()) ...@@ -245,6 +245,17 @@ void())
from_json_array_impl(j, arr, priority_tag<3> {}); from_json_array_impl(j, arr, priority_tag<3> {});
} }
template <typename BasicJsonType>
void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin)
{
if (JSON_HEDLEY_UNLIKELY(not j.is_binary()))
{
JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(j.type_name())));
}
bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
}
template<typename BasicJsonType, typename ConstructibleObjectType, template<typename BasicJsonType, typename ConstructibleObjectType,
enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value, int> = 0> enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value, int> = 0>
void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) void from_json(const BasicJsonType& j, ConstructibleObjectType& obj)
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
#include <array> // array #include <array> // array
#include <cassert> // assert #include <cassert> // assert
#include <ciso646> // or, and, not
#include <cmath> // signbit, isfinite #include <cmath> // signbit, isfinite
#include <cstdint> // intN_t, uintN_t #include <cstdint> // intN_t, uintN_t
#include <cstring> // memcpy, memmove #include <cstring> // memcpy, memmove
#include <limits> // numeric_limits #include <limits> // numeric_limits
#include <type_traits> // conditional #include <type_traits> // conditional
#include <nlohmann/detail/boolean_operators.hpp>
#include <nlohmann/detail/macro_scope.hpp> #include <nlohmann/detail/macro_scope.hpp>
namespace nlohmann namespace nlohmann
...@@ -990,11 +991,11 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent, ...@@ -990,11 +991,11 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent,
// digits[000] // digits[000]
// len <= max_exp + 2 // len <= max_exp + 2
std::memset(buf + k, '0', static_cast<size_t>(n - k)); std::memset(buf + k, '0', static_cast<size_t>(n) - static_cast<size_t>(k));
// Make it look like a floating-point number (#362, #378) // Make it look like a floating-point number (#362, #378)
buf[n + 0] = '.'; buf[n + 0] = '.';
buf[n + 1] = '0'; buf[n + 1] = '0';
return buf + (n + 2); return buf + (static_cast<size_t>(n) + 2);
} }
if (0 < n and n <= max_exp) if (0 < n and n <= max_exp)
...@@ -1004,9 +1005,9 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent, ...@@ -1004,9 +1005,9 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent,
assert(k > n); assert(k > n);
std::memmove(buf + (n + 1), buf + n, static_cast<size_t>(k - n)); std::memmove(buf + (static_cast<size_t>(n) + 1), buf + n, static_cast<size_t>(k) - static_cast<size_t>(n));
buf[n] = '.'; buf[n] = '.';
return buf + (k + 1); return buf + (static_cast<size_t>(k) + 1U);
} }
if (min_exp < n and n <= 0) if (min_exp < n and n <= 0)
...@@ -1014,11 +1015,11 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent, ...@@ -1014,11 +1015,11 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent,
// 0.[000]digits // 0.[000]digits
// len <= 2 + (-min_exp - 1) + max_digits10 // len <= 2 + (-min_exp - 1) + max_digits10
std::memmove(buf + (2 + -n), buf, static_cast<size_t>(k)); std::memmove(buf + (2 + static_cast<size_t>(-n)), buf, static_cast<size_t>(k));
buf[0] = '0'; buf[0] = '0';
buf[1] = '.'; buf[1] = '.';
std::memset(buf + 2, '0', static_cast<size_t>(-n)); std::memset(buf + 2, '0', static_cast<size_t>(-n));
return buf + (2 + (-n) + k); return buf + (2U + static_cast<size_t>(-n) + static_cast<size_t>(k));
} }
if (k == 1) if (k == 1)
...@@ -1033,9 +1034,9 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent, ...@@ -1033,9 +1034,9 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent,
// d.igitsE+123 // d.igitsE+123
// len <= max_digits10 + 1 + 5 // len <= max_digits10 + 1 + 5
std::memmove(buf + 2, buf + 1, static_cast<size_t>(k - 1)); std::memmove(buf + 2, buf + 1, static_cast<size_t>(k) - 1);
buf[1] = '.'; buf[1] = '.';
buf += 1 + k; buf += 1 + static_cast<size_t>(k);
} }
*buf++ = 'e'; *buf++ = 'e';
......
#pragma once #pragma once
#include <algorithm> // copy #include <algorithm> // copy
#include <ciso646> // or, and, not
#include <iterator> // begin, end #include <iterator> // begin, end
#include <string> // string #include <string> // string
#include <tuple> // tuple, get #include <tuple> // tuple, get
...@@ -10,6 +9,7 @@ ...@@ -10,6 +9,7 @@
#include <valarray> // valarray #include <valarray> // valarray
#include <vector> // vector #include <vector> // vector
#include <nlohmann/detail/boolean_operators.hpp>
#include <nlohmann/detail/iterators/iteration_proxy.hpp> #include <nlohmann/detail/iterators/iteration_proxy.hpp>
#include <nlohmann/detail/meta/cpp_future.hpp> #include <nlohmann/detail/meta/cpp_future.hpp>
#include <nlohmann/detail/meta/type_traits.hpp> #include <nlohmann/detail/meta/type_traits.hpp>
...@@ -67,6 +67,28 @@ struct external_constructor<value_t::string> ...@@ -67,6 +67,28 @@ struct external_constructor<value_t::string>
} }
}; };
template<>
struct external_constructor<value_t::binary>
{
template<typename BasicJsonType>
static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b)
{
j.m_type = value_t::binary;
typename BasicJsonType::binary_t value{b};
j.m_value = value;
j.assert_invariant();
}
template<typename BasicJsonType>
static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b)
{
j.m_type = value_t::binary;
typename BasicJsonType::binary_t value{std::move(b)};
j.m_value = value;
j.assert_invariant();
}
};
template<> template<>
struct external_constructor<value_t::number_float> struct external_constructor<value_t::number_float>
{ {
...@@ -256,9 +278,9 @@ void to_json(BasicJsonType& j, const std::vector<bool>& e) ...@@ -256,9 +278,9 @@ void to_json(BasicJsonType& j, const std::vector<bool>& e)
template <typename BasicJsonType, typename CompatibleArrayType, template <typename BasicJsonType, typename CompatibleArrayType,
enable_if_t<is_compatible_array_type<BasicJsonType, enable_if_t<is_compatible_array_type<BasicJsonType,
CompatibleArrayType>::value and CompatibleArrayType>::value and
not is_compatible_object_type< not is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value and
BasicJsonType, CompatibleArrayType>::value and
not is_compatible_string_type<BasicJsonType, CompatibleArrayType>::value and not is_compatible_string_type<BasicJsonType, CompatibleArrayType>::value and
not std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value and
not is_basic_json<CompatibleArrayType>::value, not is_basic_json<CompatibleArrayType>::value,
int> = 0> int> = 0>
void to_json(BasicJsonType& j, const CompatibleArrayType& arr) void to_json(BasicJsonType& j, const CompatibleArrayType& arr)
...@@ -266,6 +288,12 @@ void to_json(BasicJsonType& j, const CompatibleArrayType& arr) ...@@ -266,6 +288,12 @@ void to_json(BasicJsonType& j, const CompatibleArrayType& arr)
external_constructor<value_t::array>::construct(j, arr); external_constructor<value_t::array>::construct(j, arr);
} }
template <typename BasicJsonType>
void to_json(BasicJsonType& j, const typename BasicJsonType::binary_t& bin)
{
external_constructor<value_t::binary>::construct(j, bin);
}
template<typename BasicJsonType, typename T, template<typename BasicJsonType, typename T,
enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0> enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0>
void to_json(BasicJsonType& j, const std::valarray<T>& arr) void to_json(BasicJsonType& j, const std::valarray<T>& arr)
......
...@@ -24,6 +24,20 @@ namespace nlohmann ...@@ -24,6 +24,20 @@ namespace nlohmann
{ {
namespace detail namespace detail
{ {
/*!
@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_endianess(int num = 1) noexcept
{
return *reinterpret_cast<char*>(&num) == 1;
}
/////////////////// ///////////////////
// binary reader // // binary reader //
/////////////////// ///////////////////
...@@ -31,14 +45,17 @@ namespace detail ...@@ -31,14 +45,17 @@ namespace detail
/*! /*!
@brief deserialization of CBOR, MessagePack, and UBJSON values @brief deserialization of CBOR, MessagePack, and UBJSON values
*/ */
template<typename BasicJsonType, typename SAX = json_sax_dom_parser<BasicJsonType>> template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType>>
class binary_reader class binary_reader
{ {
using number_integer_t = typename BasicJsonType::number_integer_t; using number_integer_t = typename BasicJsonType::number_integer_t;
using number_unsigned_t = typename BasicJsonType::number_unsigned_t; using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
using number_float_t = typename BasicJsonType::number_float_t; using number_float_t = typename BasicJsonType::number_float_t;
using string_t = typename BasicJsonType::string_t; using string_t = typename BasicJsonType::string_t;
using binary_t = typename BasicJsonType::binary_t;
using json_sax_t = SAX; using json_sax_t = SAX;
using char_type = typename InputAdapterType::char_type;
using char_int_type = typename std::char_traits<char_type>::int_type;
public: public:
/*! /*!
...@@ -46,10 +63,9 @@ class binary_reader ...@@ -46,10 +63,9 @@ class binary_reader
@param[in] adapter input adapter to read from @param[in] adapter input adapter to read from
*/ */
explicit binary_reader(input_adapter_t adapter) : ia(std::move(adapter)) explicit binary_reader(InputAdapterType&& adapter) : ia(std::move(adapter))
{ {
(void)detail::is_sax_static_asserts<SAX, BasicJsonType> {}; (void)detail::is_sax_static_asserts<SAX, BasicJsonType> {};
assert(ia);
} }
// make class move-only // make class move-only
...@@ -108,7 +124,7 @@ class binary_reader ...@@ -108,7 +124,7 @@ class binary_reader
get(); get();
} }
if (JSON_HEDLEY_UNLIKELY(current != std::char_traits<char>::eof())) if (JSON_HEDLEY_UNLIKELY(current != std::char_traits<char_type>::eof()))
{ {
return sax->parse_error(chars_read, get_token_string(), return sax->parse_error(chars_read, get_token_string(),
parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value"))); parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value")));
...@@ -118,18 +134,6 @@ class binary_reader ...@@ -118,18 +134,6 @@ class binary_reader
return result; return result;
} }
/*!
@brief determine system byte order
@return true if and only if system's byte order is little endian
@note from http://stackoverflow.com/a/1001328/266378
*/
static constexpr bool little_endianess(int num = 1) noexcept
{
return *reinterpret_cast<char*>(&num) == 1;
}
private: private:
////////// //////////
// BSON // // BSON //
...@@ -178,7 +182,7 @@ class binary_reader ...@@ -178,7 +182,7 @@ class binary_reader
{ {
return true; return true;
} }
*out++ = static_cast<char>(current); *out++ = static_cast<typename string_t::value_type>(current);
} }
return true; return true;
...@@ -204,7 +208,33 @@ class binary_reader ...@@ -204,7 +208,33 @@ class binary_reader
return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string"))); return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string")));
} }
return get_string(input_format_t::bson, len - static_cast<NumberType>(1), result) and get() != std::char_traits<char>::eof(); return get_string(input_format_t::bson, len - static_cast<NumberType>(1), result) and get() != std::char_traits<char_type>::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<typename NumberType>
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, "byte array length cannot be negative, is " + std::to_string(len), "binary")));
}
// All BSON binary values have a subtype
std::uint8_t subtype;
get_number<std::uint8_t>(input_format_t::bson, subtype);
result.set_subtype(subtype);
return get_binary(input_format_t::bson, len, result);
} }
/*! /*!
...@@ -217,7 +247,7 @@ class binary_reader ...@@ -217,7 +247,7 @@ class binary_reader
Unsupported BSON record type 0x... Unsupported BSON record type 0x...
@return whether a valid BSON-object/array was passed to the SAX parser @return whether a valid BSON-object/array was passed to the SAX parser
*/ */
bool parse_bson_element_internal(const int element_type, bool parse_bson_element_internal(const char_int_type element_type,
const std::size_t element_type_parse_position) const std::size_t element_type_parse_position)
{ {
switch (element_type) switch (element_type)
...@@ -245,6 +275,13 @@ class binary_reader ...@@ -245,6 +275,13 @@ class binary_reader
return parse_bson_array(); return parse_bson_array();
} }
case 0x05: // binary
{
std::int32_t len;
binary_t value;
return get_number<std::int32_t, true>(input_format_t::bson, len) and get_bson_binary(len, value) and sax->binary(value);
}
case 0x08: // boolean case 0x08: // boolean
{ {
return sax->boolean(get() != 0); return sax->boolean(get() != 0);
...@@ -291,7 +328,8 @@ class binary_reader ...@@ -291,7 +328,8 @@ class binary_reader
bool parse_bson_element_list(const bool is_array) bool parse_bson_element_list(const bool is_array)
{ {
string_t key; string_t key;
while (int element_type = get())
while (auto element_type = get())
{ {
if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list"))) if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list")))
{ {
...@@ -359,7 +397,7 @@ class binary_reader ...@@ -359,7 +397,7 @@ class binary_reader
switch (get_char ? get() : current) switch (get_char ? get() : current)
{ {
// EOF // EOF
case std::char_traits<char>::eof(): case std::char_traits<char_type>::eof():
return unexpect_eof(input_format_t::cbor, "value"); return unexpect_eof(input_format_t::cbor, "value");
// Integer 0x00..0x17 (0..23) // Integer 0x00..0x17 (0..23)
...@@ -465,6 +503,41 @@ class binary_reader ...@@ -465,6 +503,41 @@ class binary_reader
- static_cast<number_integer_t>(number)); - static_cast<number_integer_t>(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) and sax->binary(b);
}
// UTF-8 string (0x00..0x17 bytes follow) // UTF-8 string (0x00..0x17 bytes follow)
case 0x60: case 0x60:
case 0x61: case 0x61:
...@@ -619,12 +692,12 @@ class binary_reader ...@@ -619,12 +692,12 @@ class binary_reader
case 0xF9: // Half-Precision Float (two-byte IEEE 754) case 0xF9: // Half-Precision Float (two-byte IEEE 754)
{ {
const int byte1_raw = get(); const auto byte1_raw = get();
if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number")))
{ {
return false; return false;
} }
const int byte2_raw = get(); const auto byte2_raw = get();
if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number")))
{ {
return false; return false;
...@@ -780,6 +853,105 @@ class binary_reader ...@@ -780,6 +853,105 @@ class binary_reader
} }
} }
/*!
@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(not 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<unsigned int>(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) and
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) and
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) and
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) and
get_binary(input_format_t::cbor, len, result);
}
case 0x5F: // Binary data (indefinite length)
{
while (get() != 0xFF)
{
binary_t chunk;
if (not 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, "expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x" + last_token, "binary")));
}
}
}
/*! /*!
@param[in] len the length of the array or std::size_t(-1) for an @param[in] len the length of the array or std::size_t(-1) for an
array of indefinite size array of indefinite size
...@@ -878,7 +1050,7 @@ class binary_reader ...@@ -878,7 +1050,7 @@ class binary_reader
switch (get()) switch (get())
{ {
// EOF // EOF
case std::char_traits<char>::eof(): case std::char_traits<char_type>::eof():
return unexpect_eof(input_format_t::msgpack, "value"); return unexpect_eof(input_format_t::msgpack, "value");
// positive fixint // positive fixint
...@@ -1100,6 +1272,22 @@ class binary_reader ...@@ -1100,6 +1272,22 @@ class binary_reader
case 0xC3: // true case 0xC3: // true
return sax->boolean(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) and sax->binary(b);
}
case 0xCA: // float 32 case 0xCA: // float 32
{ {
float number; float number;
...@@ -1309,6 +1497,123 @@ class binary_reader ...@@ -1309,6 +1497,123 @@ class binary_reader
} }
} }
/*!
@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<std::uint8_t>(subtype));
return true;
};
switch (current)
{
case 0xC4: // bin 8
{
std::uint8_t len;
return get_number(input_format_t::msgpack, len) and
get_binary(input_format_t::msgpack, len, result);
}
case 0xC5: // bin 16
{
std::uint16_t len;
return get_number(input_format_t::msgpack, len) and
get_binary(input_format_t::msgpack, len, result);
}
case 0xC6: // bin 32
{
std::uint32_t len;
return get_number(input_format_t::msgpack, len) and
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) and
get_number(input_format_t::msgpack, subtype) and
get_binary(input_format_t::msgpack, len, result) and
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) and
get_number(input_format_t::msgpack, subtype) and
get_binary(input_format_t::msgpack, len, result) and
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) and
get_number(input_format_t::msgpack, subtype) and
get_binary(input_format_t::msgpack, len, result) and
assign_and_return_true(subtype);
}
case 0xD4: // fixext 1
{
std::int8_t subtype;
return get_number(input_format_t::msgpack, subtype) and
get_binary(input_format_t::msgpack, 1, result) and
assign_and_return_true(subtype);
}
case 0xD5: // fixext 2
{
std::int8_t subtype;
return get_number(input_format_t::msgpack, subtype) and
get_binary(input_format_t::msgpack, 2, result) and
assign_and_return_true(subtype);
}
case 0xD6: // fixext 4
{
std::int8_t subtype;
return get_number(input_format_t::msgpack, subtype) and
get_binary(input_format_t::msgpack, 4, result) and
assign_and_return_true(subtype);
}
case 0xD7: // fixext 8
{
std::int8_t subtype;
return get_number(input_format_t::msgpack, subtype) and
get_binary(input_format_t::msgpack, 8, result) and
assign_and_return_true(subtype);
}
case 0xD8: // fixext 16
{
std::int8_t subtype;
return get_number(input_format_t::msgpack, subtype) and
get_binary(input_format_t::msgpack, 16, result) and
assign_and_return_true(subtype);
}
default: // LCOV_EXCL_LINE
return false; // LCOV_EXCL_LINE
}
}
/*! /*!
@param[in] len the length of the array @param[in] len the length of the array
@return whether array creation completed @return whether array creation completed
...@@ -1522,7 +1827,7 @@ class binary_reader ...@@ -1522,7 +1827,7 @@ class binary_reader
@return whether pair creation completed @return whether pair creation completed
*/ */
bool get_ubjson_size_type(std::pair<std::size_t, int>& result) bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result)
{ {
result.first = string_t::npos; // size result.first = string_t::npos; // size
result.second = 0; // type result.second = 0; // type
...@@ -1563,11 +1868,11 @@ class binary_reader ...@@ -1563,11 +1868,11 @@ class binary_reader
@param prefix the previously read or set type prefix @param prefix the previously read or set type prefix
@return whether value creation completed @return whether value creation completed
*/ */
bool get_ubjson_value(const int prefix) bool get_ubjson_value(const char_int_type prefix)
{ {
switch (prefix) switch (prefix)
{ {
case std::char_traits<char>::eof(): // EOF case std::char_traits<char_type>::eof(): // EOF
return unexpect_eof(input_format_t::ubjson, "value"); return unexpect_eof(input_format_t::ubjson, "value");
case 'T': // true case 'T': // true
...@@ -1632,7 +1937,7 @@ class binary_reader ...@@ -1632,7 +1937,7 @@ class binary_reader
auto last_token = get_token_string(); 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::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char"))); return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char")));
} }
string_t s(1, static_cast<char>(current)); string_t s(1, static_cast<typename string_t::value_type>(current));
return sax->string(s); return sax->string(s);
} }
...@@ -1661,7 +1966,7 @@ class binary_reader ...@@ -1661,7 +1966,7 @@ class binary_reader
*/ */
bool get_ubjson_array() bool get_ubjson_array()
{ {
std::pair<std::size_t, int> size_and_type; std::pair<std::size_t, char_int_type> size_and_type;
if (JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) if (JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type)))
{ {
return false; return false;
...@@ -1723,7 +2028,7 @@ class binary_reader ...@@ -1723,7 +2028,7 @@ class binary_reader
*/ */
bool get_ubjson_object() bool get_ubjson_object()
{ {
std::pair<std::size_t, int> size_and_type; std::pair<std::size_t, char_int_type> size_and_type;
if (JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) if (JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type)))
{ {
return false; return false;
...@@ -1793,6 +2098,9 @@ class binary_reader ...@@ -1793,6 +2098,9 @@ class binary_reader
return sax->end_object(); return sax->end_object();
} }
// Note, no reader for UBJSON binary types is implemented because they do
// not exist
/////////////////////// ///////////////////////
// Utility functions // // Utility functions //
/////////////////////// ///////////////////////
...@@ -1802,20 +2110,20 @@ class binary_reader ...@@ -1802,20 +2110,20 @@ class binary_reader
This function provides the interface to the used input adapter. It does 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 not throw in case the input reached EOF, but returns a -'ve valued
`std::char_traits<char>::eof()` in that case. `std::char_traits<char_type>::eof()` in that case.
@return character read from the input @return character read from the input
*/ */
int get() char_int_type get()
{ {
++chars_read; ++chars_read;
return current = ia->get_character(); return current = ia.get_character();
} }
/*! /*!
@return character read from the input after ignoring all 'N' entries @return character read from the input after ignoring all 'N' entries
*/ */
int get_ignore_noop() char_int_type get_ignore_noop()
{ {
do do
{ {
...@@ -1895,7 +2203,39 @@ class binary_reader ...@@ -1895,7 +2203,39 @@ class binary_reader
{ {
success = false; success = false;
} }
return static_cast<char>(current); return std::char_traits<char_type>::to_char_type(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<typename NumberType>
bool get_binary(const input_format_t format,
const NumberType len,
binary_t& result)
{
bool success = true;
std::generate_n(std::back_inserter(result), len, [this, &success, &format]()
{
get();
if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "binary")))
{
success = false;
}
return static_cast<std::uint8_t>(current);
}); });
return success; return success;
} }
...@@ -1908,7 +2248,7 @@ class binary_reader ...@@ -1908,7 +2248,7 @@ class binary_reader
JSON_HEDLEY_NON_NULL(3) JSON_HEDLEY_NON_NULL(3)
bool unexpect_eof(const input_format_t format, const char* context) const bool unexpect_eof(const input_format_t format, const char* context) const
{ {
if (JSON_HEDLEY_UNLIKELY(current == std::char_traits<char>::eof())) if (JSON_HEDLEY_UNLIKELY(current == std::char_traits<char_type>::eof()))
{ {
return sax->parse_error(chars_read, "<end of file>", return sax->parse_error(chars_read, "<end of file>",
parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context))); parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context)));
...@@ -1965,10 +2305,10 @@ class binary_reader ...@@ -1965,10 +2305,10 @@ class binary_reader
private: private:
/// input adapter /// input adapter
input_adapter_t ia = nullptr; InputAdapterType ia;
/// the current character /// the current character
int current = std::char_traits<char>::eof(); char_int_type current = std::char_traits<char_type>::eof();
/// the number of characters read /// the number of characters read
std::size_t chars_read = 0; std::size_t chars_read = 0;
......
...@@ -27,34 +27,15 @@ enum class input_format_t { json, cbor, msgpack, ubjson, bson }; ...@@ -27,34 +27,15 @@ enum class input_format_t { json, cbor, msgpack, ubjson, bson };
// input adapters // // input adapters //
//////////////////// ////////////////////
/*!
@brief abstract input adapter interface
Produces a stream of std::char_traits<char>::int_type characters from a
std::istream, a buffer, or some other input type. Accepts the return of
exactly one non-EOF character for future input. The int_type characters
returned consist of all valid char values as positive values (typically
unsigned char), plus an EOF value outside that range, specified by the value
of the function std::char_traits<char>::eof(). This value is typically -1, but
could be any arbitrary value which is not a valid char value.
*/
struct input_adapter_protocol
{
/// get a character [0,255] or std::char_traits<char>::eof().
virtual std::char_traits<char>::int_type get_character() = 0;
virtual ~input_adapter_protocol() = default;
};
/// a type to simplify interfaces
using input_adapter_t = std::shared_ptr<input_adapter_protocol>;
/*! /*!
Input adapter for stdio file access. This adapter read only 1 byte and do not use any 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. buffer. This adapter is a very low level adapter.
*/ */
class file_input_adapter : public input_adapter_protocol class file_input_adapter
{ {
public: public:
using char_type = char;
JSON_HEDLEY_NON_NULL(2) JSON_HEDLEY_NON_NULL(2)
explicit file_input_adapter(std::FILE* f) noexcept explicit file_input_adapter(std::FILE* f) noexcept
: m_file(f) : m_file(f)
...@@ -64,10 +45,9 @@ class file_input_adapter : public input_adapter_protocol ...@@ -64,10 +45,9 @@ class file_input_adapter : public input_adapter_protocol
file_input_adapter(const file_input_adapter&) = delete; file_input_adapter(const file_input_adapter&) = delete;
file_input_adapter(file_input_adapter&&) = default; file_input_adapter(file_input_adapter&&) = default;
file_input_adapter& operator=(const file_input_adapter&) = delete; file_input_adapter& operator=(const file_input_adapter&) = delete;
file_input_adapter& operator=(file_input_adapter&&) = default; file_input_adapter& operator=(file_input_adapter&&) = delete;
~file_input_adapter() override = default;
std::char_traits<char>::int_type get_character() noexcept override std::char_traits<char>::int_type get_character() noexcept
{ {
return std::fgetc(m_file); return std::fgetc(m_file);
} }
...@@ -87,92 +67,111 @@ characters following those used in parsing the JSON input. Clears the ...@@ -87,92 +67,111 @@ 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 std::istream flags; any input errors (e.g., EOF) will be detected by the first
subsequent call for input from the std::istream. subsequent call for input from the std::istream.
*/ */
class input_stream_adapter : public input_adapter_protocol class input_stream_adapter
{ {
public: public:
~input_stream_adapter() override using char_type = char;
~input_stream_adapter()
{ {
// clear stream flags; we use underlying streambuf I/O, do not // clear stream flags; we use underlying streambuf I/O, do not
// maintain ifstream flags, except eof // maintain ifstream flags, except eof
is.clear(is.rdstate() & std::ios::eofbit); if (is)
{
is->clear(is->rdstate() & std::ios::eofbit);
}
} }
explicit input_stream_adapter(std::istream& i) explicit input_stream_adapter(std::istream& i)
: is(i), sb(*i.rdbuf()) : is(&i), sb(i.rdbuf())
{} {}
// delete because of pointer members // delete because of pointer members
input_stream_adapter(const input_stream_adapter&) = delete; 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&&) = delete; input_stream_adapter& operator=(input_stream_adapter&& rhs) = delete;
input_stream_adapter& operator=(input_stream_adapter&&) = delete;
input_stream_adapter(input_stream_adapter&& rhs) : is(rhs.is), sb(rhs.sb)
{
rhs.is = nullptr;
rhs.sb = nullptr;
}
// std::istream/std::streambuf use std::char_traits<char>::to_int_type, to // std::istream/std::streambuf use std::char_traits<char>::to_int_type, to
// ensure that std::char_traits<char>::eof() and the character 0xFF do not // ensure that std::char_traits<char>::eof() and the character 0xFF do not
// end up as the same value, eg. 0xFFFFFFFF. // end up as the same value, eg. 0xFFFFFFFF.
std::char_traits<char>::int_type get_character() override std::char_traits<char>::int_type get_character()
{ {
auto res = sb.sbumpc(); auto res = sb->sbumpc();
// set eof manually, as we don't use the istream interface. // set eof manually, as we don't use the istream interface.
if (res == EOF) if (JSON_HEDLEY_UNLIKELY(res == EOF))
{ {
is.clear(is.rdstate() | std::ios::eofbit); is->clear(is->rdstate() | std::ios::eofbit);
} }
return res; return res;
} }
private: private:
/// the associated input stream /// the associated input stream
std::istream& is; std::istream* is = nullptr;
std::streambuf& sb; std::streambuf* sb = nullptr;
}; };
/// input adapter for buffer input // General-purpose iterator-based adapter. It might not be as fast as
class input_buffer_adapter : public input_adapter_protocol // theoretically possible for some containers, but it is extremely versatile.
template<typename IteratorType>
class iterator_input_adapter
{ {
public: public:
input_buffer_adapter(const char* b, const std::size_t l) noexcept using char_type = typename std::iterator_traits<IteratorType>::value_type;
: cursor(b), limit(b == nullptr ? nullptr : (b + l))
{}
// delete because of pointer members iterator_input_adapter(IteratorType first, IteratorType last)
input_buffer_adapter(const input_buffer_adapter&) = delete; : current(std::move(first)), end(std::move(last)) {}
input_buffer_adapter& operator=(input_buffer_adapter&) = delete;
input_buffer_adapter(input_buffer_adapter&&) = delete;
input_buffer_adapter& operator=(input_buffer_adapter&&) = delete;
~input_buffer_adapter() override = default;
std::char_traits<char>::int_type get_character() noexcept override typename std::char_traits<char_type>::int_type get_character()
{ {
if (JSON_HEDLEY_LIKELY(cursor < limit)) if (JSON_HEDLEY_LIKELY(current != end))
{ {
assert(cursor != nullptr and limit != nullptr); auto result = std::char_traits<char_type>::to_int_type(*current);
return std::char_traits<char>::to_int_type(*(cursor++)); std::advance(current, 1);
return result;
}
else
{
return std::char_traits<char_type>::eof();
} }
return std::char_traits<char>::eof();
} }
private: private:
/// pointer to the current character IteratorType current;
const char* cursor; IteratorType end;
/// pointer past the last character
const char* const limit; template<typename BaseInputAdapter, size_t T>
friend struct wide_string_input_helper;
bool empty() const
{
return current == end;
}
}; };
template<typename WideStringType, size_t T>
struct wide_string_input_helper template<typename BaseInputAdapter, size_t T>
struct wide_string_input_helper;
template<typename BaseInputAdapter>
struct wide_string_input_helper<BaseInputAdapter, 4>
{ {
// UTF-32 // UTF-32
static void fill_buffer(const WideStringType& str, static void fill_buffer(BaseInputAdapter& input,
size_t& current_wchar,
std::array<std::char_traits<char>::int_type, 4>& utf8_bytes, std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
size_t& utf8_bytes_index, size_t& utf8_bytes_index,
size_t& utf8_bytes_filled) size_t& utf8_bytes_filled)
{ {
utf8_bytes_index = 0; utf8_bytes_index = 0;
if (current_wchar == str.size()) if (JSON_HEDLEY_UNLIKELY(input.empty()))
{ {
utf8_bytes[0] = std::char_traits<char>::eof(); utf8_bytes[0] = std::char_traits<char>::eof();
utf8_bytes_filled = 1; utf8_bytes_filled = 1;
...@@ -180,7 +179,7 @@ struct wide_string_input_helper ...@@ -180,7 +179,7 @@ struct wide_string_input_helper
else else
{ {
// get the current character // get the current character
const auto wc = static_cast<unsigned int>(str[current_wchar++]); const auto wc = input.get_character();
// UTF-32 to UTF-8 encoding // UTF-32 to UTF-8 encoding
if (wc < 0x80) if (wc < 0x80)
...@@ -190,23 +189,23 @@ struct wide_string_input_helper ...@@ -190,23 +189,23 @@ struct wide_string_input_helper
} }
else if (wc <= 0x7FF) else if (wc <= 0x7FF)
{ {
utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((wc >> 6u) & 0x1Fu)); utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu)); utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
utf8_bytes_filled = 2; utf8_bytes_filled = 2;
} }
else if (wc <= 0xFFFF) else if (wc <= 0xFFFF)
{ {
utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((wc >> 12u) & 0x0Fu)); utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((wc >> 6u) & 0x3Fu)); utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu)); utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
utf8_bytes_filled = 3; utf8_bytes_filled = 3;
} }
else if (wc <= 0x10FFFF) else if (wc <= 0x10FFFF)
{ {
utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | ((wc >> 18u) & 0x07u)); utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | ((static_cast<unsigned int>(wc) >> 18u) & 0x07u));
utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((wc >> 12u) & 0x3Fu)); utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | ((wc >> 6u) & 0x3Fu)); utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu)); utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
utf8_bytes_filled = 4; utf8_bytes_filled = 4;
} }
else else
...@@ -219,19 +218,18 @@ struct wide_string_input_helper ...@@ -219,19 +218,18 @@ struct wide_string_input_helper
} }
}; };
template<typename WideStringType> template<typename BaseInputAdapter>
struct wide_string_input_helper<WideStringType, 2> struct wide_string_input_helper<BaseInputAdapter, 2>
{ {
// UTF-16 // UTF-16
static void fill_buffer(const WideStringType& str, static void fill_buffer(BaseInputAdapter& input,
size_t& current_wchar,
std::array<std::char_traits<char>::int_type, 4>& utf8_bytes, std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
size_t& utf8_bytes_index, size_t& utf8_bytes_index,
size_t& utf8_bytes_filled) size_t& utf8_bytes_filled)
{ {
utf8_bytes_index = 0; utf8_bytes_index = 0;
if (current_wchar == str.size()) if (JSON_HEDLEY_UNLIKELY(input.empty()))
{ {
utf8_bytes[0] = std::char_traits<char>::eof(); utf8_bytes[0] = std::char_traits<char>::eof();
utf8_bytes_filled = 1; utf8_bytes_filled = 1;
...@@ -239,7 +237,7 @@ struct wide_string_input_helper<WideStringType, 2> ...@@ -239,7 +237,7 @@ struct wide_string_input_helper<WideStringType, 2>
else else
{ {
// get the current character // get the current character
const auto wc = static_cast<unsigned int>(str[current_wchar++]); const auto wc = input.get_character();
// UTF-16 to UTF-8 encoding // UTF-16 to UTF-8 encoding
if (wc < 0x80) if (wc < 0x80)
...@@ -249,23 +247,23 @@ struct wide_string_input_helper<WideStringType, 2> ...@@ -249,23 +247,23 @@ struct wide_string_input_helper<WideStringType, 2>
} }
else if (wc <= 0x7FF) else if (wc <= 0x7FF)
{ {
utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((wc >> 6u))); utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((static_cast<unsigned int>(wc) >> 6u)));
utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu)); utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
utf8_bytes_filled = 2; utf8_bytes_filled = 2;
} }
else if (0xD800 > wc or wc >= 0xE000) else if (0xD800 > wc or wc >= 0xE000)
{ {
utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((wc >> 12u))); utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((static_cast<unsigned int>(wc) >> 12u)));
utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((wc >> 6u) & 0x3Fu)); utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu)); utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
utf8_bytes_filled = 3; utf8_bytes_filled = 3;
} }
else else
{ {
if (current_wchar < str.size()) if (JSON_HEDLEY_UNLIKELY(not input.empty()))
{ {
const auto wc2 = static_cast<unsigned int>(str[current_wchar++]); const auto wc2 = static_cast<unsigned int>(input.get_character());
const auto charcode = 0x10000u + (((wc & 0x3FFu) << 10u) | (wc2 & 0x3FFu)); const auto charcode = 0x10000u + (((static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | (charcode >> 18u)); utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | (charcode >> 18u));
utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((charcode >> 12u) & 0x3Fu)); utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((charcode >> 12u) & 0x3Fu));
utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | ((charcode >> 6u) & 0x3Fu)); utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | ((charcode >> 6u) & 0x3Fu));
...@@ -274,8 +272,6 @@ struct wide_string_input_helper<WideStringType, 2> ...@@ -274,8 +272,6 @@ struct wide_string_input_helper<WideStringType, 2>
} }
else else
{ {
// unknown character
++current_wchar;
utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc); utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
utf8_bytes_filled = 1; utf8_bytes_filled = 1;
} }
...@@ -284,20 +280,22 @@ struct wide_string_input_helper<WideStringType, 2> ...@@ -284,20 +280,22 @@ struct wide_string_input_helper<WideStringType, 2>
} }
}; };
template<typename WideStringType> // Wraps another input apdater to convert wide character types into individual bytes.
class wide_string_input_adapter : public input_adapter_protocol template<typename BaseInputAdapter, typename WideCharType>
class wide_string_input_adapter
{ {
public: public:
explicit wide_string_input_adapter(const WideStringType& w) noexcept using char_type = char;
: str(w)
{} wide_string_input_adapter(BaseInputAdapter base)
: base_adapter(base) {}
std::char_traits<char>::int_type get_character() noexcept override typename std::char_traits<char>::int_type get_character() noexcept
{ {
// check if buffer needs to be filled // check if buffer needs to be filled
if (utf8_bytes_index == utf8_bytes_filled) if (utf8_bytes_index == utf8_bytes_filled)
{ {
fill_buffer<sizeof(typename WideStringType::value_type)>(); fill_buffer<sizeof(WideCharType)>();
assert(utf8_bytes_filled > 0); assert(utf8_bytes_filled > 0);
assert(utf8_bytes_index == 0); assert(utf8_bytes_index == 0);
...@@ -310,18 +308,14 @@ class wide_string_input_adapter : public input_adapter_protocol ...@@ -310,18 +308,14 @@ class wide_string_input_adapter : public input_adapter_protocol
} }
private: private:
BaseInputAdapter base_adapter;
template<size_t T> template<size_t T>
void fill_buffer() void fill_buffer()
{ {
wide_string_input_helper<WideStringType, T>::fill_buffer(str, current_wchar, utf8_bytes, utf8_bytes_index, utf8_bytes_filled); wide_string_input_helper<BaseInputAdapter, T>::fill_buffer(base_adapter, utf8_bytes, utf8_bytes_index, utf8_bytes_filled);
} }
/// the wstring to process
const WideStringType& str;
/// index of the current wchar in str
std::size_t current_wchar = 0;
/// a buffer for UTF-8 bytes /// a buffer for UTF-8 bytes
std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}}; std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
...@@ -331,112 +325,131 @@ class wide_string_input_adapter : public input_adapter_protocol ...@@ -331,112 +325,131 @@ class wide_string_input_adapter : public input_adapter_protocol
std::size_t utf8_bytes_filled = 0; std::size_t utf8_bytes_filled = 0;
}; };
class input_adapter
template<typename IteratorType, typename Enable = void>
struct iterator_input_adapter_factory
{ {
public: using iterator_type = IteratorType;
// native support using char_type = typename std::iterator_traits<iterator_type>::value_type;
JSON_HEDLEY_NON_NULL(2) using adapter_type = iterator_input_adapter<iterator_type>;
input_adapter(std::FILE* file)
: ia(std::make_shared<file_input_adapter>(file)) {} static adapter_type create(IteratorType first, IteratorType last)
/// input adapter for input stream {
input_adapter(std::istream& i) return adapter_type(std::move(first), std::move(last));
: ia(std::make_shared<input_stream_adapter>(i)) {} }
};
/// input adapter for input stream template<typename T>
input_adapter(std::istream&& i) struct is_iterator_of_multibyte
: ia(std::make_shared<input_stream_adapter>(i)) {} {
using value_type = typename std::iterator_traits<T>::value_type;
enum
{
value = sizeof(value_type) > 1
};
};
input_adapter(const std::wstring& ws) template<typename IteratorType>
: ia(std::make_shared<wide_string_input_adapter<std::wstring>>(ws)) {} struct iterator_input_adapter_factory<IteratorType, enable_if_t<is_iterator_of_multibyte<IteratorType>::value>>
{
using iterator_type = IteratorType;
using char_type = typename std::iterator_traits<iterator_type>::value_type;
using base_adapter_type = iterator_input_adapter<iterator_type>;
using adapter_type = wide_string_input_adapter<base_adapter_type, char_type>;
input_adapter(const std::u16string& ws) static adapter_type create(IteratorType first, IteratorType last)
: ia(std::make_shared<wide_string_input_adapter<std::u16string>>(ws)) {} {
return adapter_type(base_adapter_type(std::move(first), std::move(last)));
}
};
input_adapter(const std::u32string& ws) // General purpose iterator-based input
: ia(std::make_shared<wide_string_input_adapter<std::u32string>>(ws)) {} template<typename IteratorType>
typename iterator_input_adapter_factory<IteratorType>::adapter_type input_adapter(IteratorType first, IteratorType last)
{
using factory_type = iterator_input_adapter_factory<IteratorType>;
return factory_type::create(first, last);
}
/// input adapter for buffer // Convenience shorthand from container to iterator
template<typename CharT, template<typename ContainerType>
typename std::enable_if< auto input_adapter(const ContainerType& container) -> decltype(input_adapter(begin(container), end(container)))
std::is_pointer<CharT>::value and {
std::is_integral<typename std::remove_pointer<CharT>::type>::value and // Enable ADL
sizeof(typename std::remove_pointer<CharT>::type) == 1, using std::begin;
int>::type = 0> using std::end;
input_adapter(CharT b, std::size_t l)
: ia(std::make_shared<input_buffer_adapter>(reinterpret_cast<const char*>(b), l)) {} return input_adapter(begin(container), end(container));
}
// derived support // Special cases with fast paths
inline file_input_adapter input_adapter(std::FILE* file)
{
return file_input_adapter(file);
}
/// input adapter for string literal 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);
}
using contiguous_bytes_input_adapter = decltype(input_adapter(std::declval<const char*>(), std::declval<const char*>()));
// Null-delimited strings, and the like.
template < typename CharT,
typename std::enable_if <
std::is_pointer<CharT>::value and
not std::is_array<CharT>::value and
std::is_integral<typename std::remove_pointer<CharT>::type>::value and
sizeof(typename std::remove_pointer<CharT>::type) == 1,
int >::type = 0 >
contiguous_bytes_input_adapter input_adapter(CharT b)
{
auto length = std::strlen(reinterpret_cast<const char*>(b));
auto ptr = reinterpret_cast<const char*>(b);
return input_adapter(ptr, ptr + length);
}
template<typename T, std::size_t N>
auto input_adapter(T (&array)[N]) -> decltype(input_adapter(array, array + N))
{
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 implicitely casted
// to the correct adapter.
class span_input_adapter
{
public:
template<typename CharT, template<typename CharT,
typename std::enable_if< typename std::enable_if<
std::is_pointer<CharT>::value and std::is_pointer<CharT>::value and
std::is_integral<typename std::remove_pointer<CharT>::type>::value and std::is_integral<typename std::remove_pointer<CharT>::type>::value and
sizeof(typename std::remove_pointer<CharT>::type) == 1, sizeof(typename std::remove_pointer<CharT>::type) == 1,
int>::type = 0> int>::type = 0>
input_adapter(CharT b) span_input_adapter(CharT b, std::size_t l)
: input_adapter(reinterpret_cast<const char*>(b), : ia(reinterpret_cast<const char*>(b), reinterpret_cast<const char*>(b) + l) {}
std::strlen(reinterpret_cast<const char*>(b))) {}
/// input adapter for iterator range with contiguous storage
template<class IteratorType, template<class IteratorType,
typename std::enable_if< typename std::enable_if<
std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value, std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value,
int>::type = 0> int>::type = 0>
input_adapter(IteratorType first, IteratorType last) span_input_adapter(IteratorType first, IteratorType last)
{ : ia(input_adapter(first, last)) {}
#ifndef NDEBUG
// assertion to check that the iterator range is indeed contiguous,
// see http://stackoverflow.com/a/35008842/266378 for more discussion
const auto is_contiguous = std::accumulate(
first, last, std::pair<bool, int>(true, 0),
[&first](std::pair<bool, int> res, decltype(*first) val)
{
res.first &= (val == *(std::next(std::addressof(*first), res.second++)));
return res;
}).first;
assert(is_contiguous);
#endif
// assertion to check that each element is 1 byte long
static_assert(
sizeof(typename iterator_traits<IteratorType>::value_type) == 1,
"each element in the iterator range must have the size of 1 byte");
const auto len = static_cast<size_t>(std::distance(first, last));
if (JSON_HEDLEY_LIKELY(len > 0))
{
// there is at least one element: use the address of first
ia = std::make_shared<input_buffer_adapter>(reinterpret_cast<const char*>(&(*first)), len);
}
else
{
// the address of first cannot be used: use nullptr
ia = std::make_shared<input_buffer_adapter>(nullptr, len);
}
}
/// input adapter for array
template<class T, std::size_t N>
input_adapter(T (&array)[N])
: input_adapter(std::begin(array), std::end(array)) {}
/// input adapter for contiguous container
template<class ContiguousContainer, typename
std::enable_if<not std::is_pointer<ContiguousContainer>::value and
std::is_base_of<std::random_access_iterator_tag, typename iterator_traits<decltype(std::begin(std::declval<ContiguousContainer const>()))>::iterator_category>::value,
int>::type = 0>
input_adapter(const ContiguousContainer& c)
: input_adapter(std::begin(c), std::end(c)) {}
operator input_adapter_t() contiguous_bytes_input_adapter&& get()
{ {
return ia; return std::move(ia);
} }
private: private:
/// the actual adapter contiguous_bytes_input_adapter ia;
input_adapter_t ia = nullptr;
}; };
} // namespace detail } // namespace detail
} // namespace nlohmann } // namespace nlohmann
...@@ -23,14 +23,11 @@ input. ...@@ -23,14 +23,11 @@ input.
template<typename BasicJsonType> template<typename BasicJsonType>
struct json_sax struct json_sax
{ {
/// type for (signed) integers
using number_integer_t = typename BasicJsonType::number_integer_t; using number_integer_t = typename BasicJsonType::number_integer_t;
/// type for unsigned integers
using number_unsigned_t = typename BasicJsonType::number_unsigned_t; using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
/// type for floating-point numbers
using number_float_t = typename BasicJsonType::number_float_t; using number_float_t = typename BasicJsonType::number_float_t;
/// type for strings
using string_t = typename BasicJsonType::string_t; using string_t = typename BasicJsonType::string_t;
using binary_t = typename BasicJsonType::binary_t;
/*! /*!
@brief a null value was read @brief a null value was read
...@@ -75,6 +72,14 @@ struct json_sax ...@@ -75,6 +72,14 @@ struct json_sax
*/ */
virtual bool string(string_t& val) = 0; virtual bool string(string_t& val) = 0;
/*!
@brief a binary string was read
@param[in] val binary value
@return whether parsing should proceed
@note It is safe to move the passed binary.
*/
virtual bool binary(binary_t& val) = 0;
/*! /*!
@brief the beginning of an object was read @brief the beginning of an object was read
@param[in] elements number of object elements or -1 if unknown @param[in] elements number of object elements or -1 if unknown
...@@ -149,6 +154,7 @@ class json_sax_dom_parser ...@@ -149,6 +154,7 @@ class json_sax_dom_parser
using number_unsigned_t = typename BasicJsonType::number_unsigned_t; using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
using number_float_t = typename BasicJsonType::number_float_t; using number_float_t = typename BasicJsonType::number_float_t;
using string_t = typename BasicJsonType::string_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 @param[in, out] r reference to a JSON value that is manipulated while
...@@ -202,6 +208,12 @@ class json_sax_dom_parser ...@@ -202,6 +208,12 @@ class json_sax_dom_parser
return true; return true;
} }
bool binary(binary_t& val)
{
handle_value(std::move(val));
return true;
}
bool start_object(std::size_t len) bool start_object(std::size_t len)
{ {
ref_stack.push_back(handle_value(BasicJsonType::value_t::object)); ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
...@@ -331,6 +343,7 @@ class json_sax_dom_callback_parser ...@@ -331,6 +343,7 @@ class json_sax_dom_callback_parser
using number_unsigned_t = typename BasicJsonType::number_unsigned_t; using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
using number_float_t = typename BasicJsonType::number_float_t; using number_float_t = typename BasicJsonType::number_float_t;
using string_t = typename BasicJsonType::string_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 parser_callback_t = typename BasicJsonType::parser_callback_t;
using parse_event_t = typename BasicJsonType::parse_event_t; using parse_event_t = typename BasicJsonType::parse_event_t;
...@@ -385,6 +398,12 @@ class json_sax_dom_callback_parser ...@@ -385,6 +398,12 @@ class json_sax_dom_callback_parser
return true; return true;
} }
bool binary(binary_t& val)
{
handle_value(std::move(val));
return true;
}
bool start_object(std::size_t len) bool start_object(std::size_t len)
{ {
// check callback for object start // check callback for object start
...@@ -433,7 +452,7 @@ class json_sax_dom_callback_parser ...@@ -433,7 +452,7 @@ class json_sax_dom_callback_parser
ref_stack.pop_back(); ref_stack.pop_back();
keep_stack.pop_back(); keep_stack.pop_back();
if (not ref_stack.empty() and ref_stack.back() and ref_stack.back()->is_object()) if (not ref_stack.empty() and ref_stack.back() and ref_stack.back()->is_structured())
{ {
// remove discarded value // remove discarded value
for (auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it) for (auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
...@@ -635,6 +654,7 @@ class json_sax_acceptor ...@@ -635,6 +654,7 @@ class json_sax_acceptor
using number_unsigned_t = typename BasicJsonType::number_unsigned_t; using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
using number_float_t = typename BasicJsonType::number_float_t; using number_float_t = typename BasicJsonType::number_float_t;
using string_t = typename BasicJsonType::string_t; using string_t = typename BasicJsonType::string_t;
using binary_t = typename BasicJsonType::binary_t;
bool null() bool null()
{ {
...@@ -666,7 +686,12 @@ class json_sax_acceptor ...@@ -666,7 +686,12 @@ class json_sax_acceptor
return true; return true;
} }
bool start_object(std::size_t /*unused*/ = std::size_t(-1)) bool binary(binary_t& /*unused*/)
{
return true;
}
bool start_object(std::size_t /*unused*/ = std::size_t(-1))
{ {
return true; return true;
} }
...@@ -681,7 +706,7 @@ class json_sax_acceptor ...@@ -681,7 +706,7 @@ class json_sax_acceptor
return true; return true;
} }
bool start_array(std::size_t /*unused*/ = std::size_t(-1)) bool start_array(std::size_t /*unused*/ = std::size_t(-1))
{ {
return true; return true;
} }
......
...@@ -22,19 +22,9 @@ namespace detail ...@@ -22,19 +22,9 @@ namespace detail
// lexer // // lexer //
/////////// ///////////
/*!
@brief lexical analysis
This class organizes the lexical analysis during JSON deserialization.
*/
template<typename BasicJsonType> template<typename BasicJsonType>
class lexer class 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;
public: public:
/// token types for the parser /// token types for the parser
enum class token_type enum class token_type
...@@ -75,9 +65,9 @@ class lexer ...@@ -75,9 +65,9 @@ class lexer
return "null literal"; return "null literal";
case token_type::value_string: case token_type::value_string:
return "string literal"; return "string literal";
case lexer::token_type::value_unsigned: case token_type::value_unsigned:
case lexer::token_type::value_integer: case token_type::value_integer:
case lexer::token_type::value_float: case token_type::value_float:
return "number literal"; return "number literal";
case token_type::begin_array: case token_type::begin_array:
return "'['"; return "'['";
...@@ -103,15 +93,33 @@ class lexer ...@@ -103,15 +93,33 @@ class lexer
// LCOV_EXCL_STOP // LCOV_EXCL_STOP
} }
} }
};
/*!
@brief lexical analysis
explicit lexer(detail::input_adapter_t&& adapter) This class organizes the lexical analysis during JSON deserialization.
: ia(std::move(adapter)), decimal_point_char(get_decimal_point()) {} */
template<typename BasicJsonType, typename InputAdapterType>
class lexer : public lexer_base<BasicJsonType>
{
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<char_type>::int_type;
public:
using token_type = typename lexer_base<BasicJsonType>::token_type;
explicit lexer(InputAdapterType&& adapter)
: ia(std::move(adapter)), decimal_point_char(static_cast<char_int_type>(get_decimal_point())) {}
// delete because of pointer members // delete because of pointer members
lexer(const lexer&) = delete; lexer(const lexer&) = delete;
lexer(lexer&&) = delete; lexer(lexer&&) = default;
lexer& operator=(lexer&) = delete; lexer& operator=(lexer&) = delete;
lexer& operator=(lexer&&) = delete; lexer& operator=(lexer&&) = default;
~lexer() = default; ~lexer() = default;
private: private:
...@@ -195,7 +203,7 @@ class lexer ...@@ -195,7 +203,7 @@ class lexer
@return true if and only if no range violation was detected @return true if and only if no range violation was detected
*/ */
bool next_byte_in_range(std::initializer_list<int> ranges) bool next_byte_in_range(std::initializer_list<char_int_type> ranges)
{ {
assert(ranges.size() == 2 or ranges.size() == 4 or ranges.size() == 6); assert(ranges.size() == 2 or ranges.size() == 4 or ranges.size() == 6);
add(current); add(current);
...@@ -246,7 +254,7 @@ class lexer ...@@ -246,7 +254,7 @@ class lexer
switch (get()) switch (get())
{ {
// end of file while parsing string // end of file while parsing string
case std::char_traits<char>::eof(): case std::char_traits<char_type>::eof():
{ {
error_message = "invalid string: missing closing quote"; error_message = "invalid string: missing closing quote";
return token_type::parse_error; return token_type::parse_error;
...@@ -338,13 +346,13 @@ class lexer ...@@ -338,13 +346,13 @@ class lexer
} }
else else
{ {
error_message = "invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF"; error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
return token_type::parse_error; return token_type::parse_error;
} }
} }
else else
{ {
error_message = "invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF"; error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
return token_type::parse_error; return token_type::parse_error;
} }
} }
...@@ -364,28 +372,28 @@ class lexer ...@@ -364,28 +372,28 @@ class lexer
if (codepoint < 0x80) if (codepoint < 0x80)
{ {
// 1-byte characters: 0xxxxxxx (ASCII) // 1-byte characters: 0xxxxxxx (ASCII)
add(codepoint); add(static_cast<char_int_type>(codepoint));
} }
else if (codepoint <= 0x7FF) else if (codepoint <= 0x7FF)
{ {
// 2-byte characters: 110xxxxx 10xxxxxx // 2-byte characters: 110xxxxx 10xxxxxx
add(static_cast<int>(0xC0u | (static_cast<unsigned int>(codepoint) >> 6u))); add(static_cast<char_int_type>(0xC0u | (static_cast<unsigned int>(codepoint) >> 6u)));
add(static_cast<int>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu))); add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
} }
else if (codepoint <= 0xFFFF) else if (codepoint <= 0xFFFF)
{ {
// 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
add(static_cast<int>(0xE0u | (static_cast<unsigned int>(codepoint) >> 12u))); add(static_cast<char_int_type>(0xE0u | (static_cast<unsigned int>(codepoint) >> 12u)));
add(static_cast<int>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu))); add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
add(static_cast<int>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu))); add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
} }
else else
{ {
// 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
add(static_cast<int>(0xF0u | (static_cast<unsigned int>(codepoint) >> 18u))); add(static_cast<char_int_type>(0xF0u | (static_cast<unsigned int>(codepoint) >> 18u)));
add(static_cast<int>(0x80u | ((static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu))); add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
add(static_cast<int>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu))); add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
add(static_cast<int>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu))); add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
} }
break; break;
...@@ -853,7 +861,7 @@ class lexer ...@@ -853,7 +861,7 @@ class lexer
minus | zero | any1 | [error] | [error] | [error] | [error] | [error] minus | zero | any1 | [error] | [error] | [error] | [error] | [error]
zero | done | done | exponent | done | done | decimal1 | done zero | done | done | exponent | done | done | decimal1 | done
any1 | any1 | any1 | exponent | done | done | decimal1 | done any1 | any1 | any1 | exponent | done | done | decimal1 | done
decimal1 | decimal2 | [error] | [error] | [error] | [error] | [error] | [error] decimal1 | decimal2 | decimal2 | [error] | [error] | [error] | [error] | [error]
decimal2 | decimal2 | decimal2 | exponent | done | done | done | done decimal2 | decimal2 | decimal2 | exponent | done | done | done | done
exponent | any2 | any2 | [error] | sign | sign | [error] | [error] exponent | any2 | any2 | [error] | sign | sign | [error] | [error]
sign | any2 | any2 | [error] | [error] | [error] | [error] | [error] sign | any2 | any2 | [error] | [error] | [error] | [error] | [error]
...@@ -1207,13 +1215,13 @@ scan_number_done: ...@@ -1207,13 +1215,13 @@ scan_number_done:
@param[in] return_type the token type to return on success @param[in] return_type the token type to return on success
*/ */
JSON_HEDLEY_NON_NULL(2) JSON_HEDLEY_NON_NULL(2)
token_type scan_literal(const char* literal_text, const std::size_t length, token_type scan_literal(const char_type* literal_text, const std::size_t length,
token_type return_type) token_type return_type)
{ {
assert(current == literal_text[0]); assert(std::char_traits<char_type>::to_char_type(current) == literal_text[0]);
for (std::size_t i = 1; i < length; ++i) for (std::size_t i = 1; i < length; ++i)
{ {
if (JSON_HEDLEY_UNLIKELY(get() != literal_text[i])) if (JSON_HEDLEY_UNLIKELY(std::char_traits<char_type>::to_char_type(get()) != literal_text[i]))
{ {
error_message = "invalid literal"; error_message = "invalid literal";
return token_type::parse_error; return token_type::parse_error;
...@@ -1231,7 +1239,7 @@ scan_number_done: ...@@ -1231,7 +1239,7 @@ scan_number_done:
{ {
token_buffer.clear(); token_buffer.clear();
token_string.clear(); token_string.clear();
token_string.push_back(std::char_traits<char>::to_char_type(current)); token_string.push_back(std::char_traits<char_type>::to_char_type(current));
} }
/* /*
...@@ -1244,7 +1252,7 @@ scan_number_done: ...@@ -1244,7 +1252,7 @@ scan_number_done:
@return character read from the input @return character read from the input
*/ */
std::char_traits<char>::int_type get() char_int_type get()
{ {
++position.chars_read_total; ++position.chars_read_total;
++position.chars_read_current_line; ++position.chars_read_current_line;
...@@ -1256,12 +1264,12 @@ scan_number_done: ...@@ -1256,12 +1264,12 @@ scan_number_done:
} }
else else
{ {
current = ia->get_character(); current = ia.get_character();
} }
if (JSON_HEDLEY_LIKELY(current != std::char_traits<char>::eof())) if (JSON_HEDLEY_LIKELY(current != std::char_traits<char_type>::eof()))
{ {
token_string.push_back(std::char_traits<char>::to_char_type(current)); token_string.push_back(std::char_traits<char_type>::to_char_type(current));
} }
if (current == '\n') if (current == '\n')
...@@ -1300,7 +1308,7 @@ scan_number_done: ...@@ -1300,7 +1308,7 @@ scan_number_done:
--position.chars_read_current_line; --position.chars_read_current_line;
} }
if (JSON_HEDLEY_LIKELY(current != std::char_traits<char>::eof())) if (JSON_HEDLEY_LIKELY(current != std::char_traits<char_type>::eof()))
{ {
assert(not token_string.empty()); assert(not token_string.empty());
token_string.pop_back(); token_string.pop_back();
...@@ -1308,9 +1316,9 @@ scan_number_done: ...@@ -1308,9 +1316,9 @@ scan_number_done:
} }
/// add a character to token_buffer /// add a character to token_buffer
void add(int c) void add(char_int_type c)
{ {
token_buffer.push_back(std::char_traits<char>::to_char_type(c)); token_buffer.push_back(static_cast<typename string_t::value_type>(c));
} }
public: public:
...@@ -1361,7 +1369,7 @@ scan_number_done: ...@@ -1361,7 +1369,7 @@ scan_number_done:
std::string result; std::string result;
for (const auto c : token_string) for (const auto c : token_string)
{ {
if ('\x00' <= c and c <= '\x1F') if (static_cast<unsigned char>(c) <= '\x1F')
{ {
// escape control characters // escape control characters
std::array<char, 9> cs{{}}; std::array<char, 9> cs{{}};
...@@ -1371,7 +1379,7 @@ scan_number_done: ...@@ -1371,7 +1379,7 @@ scan_number_done:
else else
{ {
// add character as is // add character as is
result.push_back(c); result.push_back(static_cast<std::string::value_type>(c));
} }
} }
...@@ -1441,11 +1449,20 @@ scan_number_done: ...@@ -1441,11 +1449,20 @@ scan_number_done:
// literals // literals
case 't': case 't':
return scan_literal("true", 4, token_type::literal_true); {
std::array<char_type, 4> true_literal = {{'t', 'r', 'u', 'e'}};
return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
}
case 'f': case 'f':
return scan_literal("false", 5, token_type::literal_false); {
std::array<char_type, 5> false_literal = {{'f', 'a', 'l', 's', 'e'}};
return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
}
case 'n': case 'n':
return scan_literal("null", 4, token_type::literal_null); {
std::array<char_type, 4> null_literal = {{'n', 'u', 'l', 'l'}};
return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
}
// string // string
case '\"': case '\"':
...@@ -1468,7 +1485,7 @@ scan_number_done: ...@@ -1468,7 +1485,7 @@ scan_number_done:
// end of input (the null byte is needed when parsing from // end of input (the null byte is needed when parsing from
// string literals) // string literals)
case '\0': case '\0':
case std::char_traits<char>::eof(): case std::char_traits<char_type>::eof():
return token_type::end_of_input; return token_type::end_of_input;
// error // error
...@@ -1480,10 +1497,10 @@ scan_number_done: ...@@ -1480,10 +1497,10 @@ scan_number_done:
private: private:
/// input adapter /// input adapter
detail::input_adapter_t ia = nullptr; InputAdapterType ia;
/// the current character /// the current character
std::char_traits<char>::int_type current = std::char_traits<char>::eof(); char_int_type current = std::char_traits<char_type>::eof();
/// whether the next get() call should just return current /// whether the next get() call should just return current
bool next_unget = false; bool next_unget = false;
...@@ -1492,7 +1509,7 @@ scan_number_done: ...@@ -1492,7 +1509,7 @@ scan_number_done:
position_t position {}; position_t position {};
/// raw input token string (for error messages) /// raw input token string (for error messages)
std::vector<char> token_string {}; std::vector<char_type> token_string {};
/// buffer for variable-length tokens (numbers, strings) /// buffer for variable-length tokens (numbers, strings)
string_t token_buffer {}; string_t token_buffer {};
...@@ -1506,7 +1523,7 @@ scan_number_done: ...@@ -1506,7 +1523,7 @@ scan_number_done:
number_float_t value_float = 0; number_float_t value_float = 0;
/// the decimal point /// the decimal point
const char decimal_point_char = '.'; const char_int_type decimal_point_char = '.';
}; };
} // namespace detail } // namespace detail
} // namespace nlohmann } // namespace nlohmann
...@@ -24,44 +24,45 @@ namespace detail ...@@ -24,44 +24,45 @@ namespace detail
// parser // // parser //
//////////// ////////////
enum class parse_event_t : 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<typename BasicJsonType>
using parser_callback_t =
std::function<bool(int depth, parse_event_t event, BasicJsonType& parsed)>;
/*! /*!
@brief syntax analysis @brief syntax analysis
This class implements a recursive decent parser. This class implements a recursive descent parser.
*/ */
template<typename BasicJsonType> template<typename BasicJsonType, typename InputAdapterType>
class parser class parser
{ {
using number_integer_t = typename BasicJsonType::number_integer_t; using number_integer_t = typename BasicJsonType::number_integer_t;
using number_unsigned_t = typename BasicJsonType::number_unsigned_t; using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
using number_float_t = typename BasicJsonType::number_float_t; using number_float_t = typename BasicJsonType::number_float_t;
using string_t = typename BasicJsonType::string_t; using string_t = typename BasicJsonType::string_t;
using lexer_t = lexer<BasicJsonType>; using lexer_t = lexer<BasicJsonType, InputAdapterType>;
using token_type = typename lexer_t::token_type; using token_type = typename lexer_t::token_type;
public: public:
enum class parse_event_t : 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
};
using parser_callback_t =
std::function<bool(int depth, parse_event_t event, BasicJsonType& parsed)>;
/// a parser reading from an input adapter /// a parser reading from an input adapter
explicit parser(detail::input_adapter_t&& adapter, explicit parser(InputAdapterType&& adapter,
const parser_callback_t cb = nullptr, const parser_callback_t<BasicJsonType> cb = nullptr,
const bool allow_exceptions_ = true) const bool allow_exceptions_ = true)
: callback(cb), m_lexer(std::move(adapter)), allow_exceptions(allow_exceptions_) : callback(cb), m_lexer(std::move(adapter)), allow_exceptions(allow_exceptions_)
{ {
...@@ -486,7 +487,7 @@ class parser ...@@ -486,7 +487,7 @@ class parser
private: private:
/// callback function /// callback function
const parser_callback_t callback = nullptr; const parser_callback_t<BasicJsonType> callback = nullptr;
/// the type of the last read token /// the type of the last read token
token_type last_token = token_type::uninitialized; token_type last_token = token_type::uninitialized;
/// the lexer /// the lexer
......
...@@ -18,6 +18,8 @@ template<typename BasicJsonType> struct internal_iterator ...@@ -18,6 +18,8 @@ template<typename BasicJsonType> struct internal_iterator
typename BasicJsonType::object_t::iterator object_iterator {}; typename BasicJsonType::object_t::iterator object_iterator {};
/// iterator for JSON arrays /// iterator for JSON arrays
typename BasicJsonType::array_t::iterator array_iterator {}; typename BasicJsonType::array_t::iterator array_iterator {};
/// iterator for JSON binary arrays
typename BasicJsonType::binary_t::container_type::iterator binary_iterator {};
/// generic iterator for all other types /// generic iterator for all other types
primitive_iterator_t primitive_iterator {}; primitive_iterator_t primitive_iterator {};
}; };
......
#pragma once #pragma once
#include <ciso646> // not
#include <iterator> // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next #include <iterator> // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next
#include <type_traits> // conditional, is_const, remove_const #include <type_traits> // conditional, is_const, remove_const
#include <nlohmann/detail/boolean_operators.hpp>
#include <nlohmann/detail/exceptions.hpp> #include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/iterators/internal_iterator.hpp> #include <nlohmann/detail/iterators/internal_iterator.hpp>
#include <nlohmann/detail/iterators/primitive_iterator.hpp> #include <nlohmann/detail/iterators/primitive_iterator.hpp>
......
...@@ -126,8 +126,8 @@ class json_pointer ...@@ -126,8 +126,8 @@ class json_pointer
/*! /*!
@brief append an array index at the end of this JSON pointer @brief append an array index at the end of this JSON pointer
@param[in] array_index array index to append @param[in] array_idx array index to append
@return JSON pointer with @a array_index appended @return JSON pointer with @a array_idx appended
@liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add} @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add}
...@@ -139,9 +139,9 @@ class json_pointer ...@@ -139,9 +139,9 @@ class json_pointer
@since version 3.6.0 @since version 3.6.0
*/ */
json_pointer& operator/=(std::size_t array_index) json_pointer& operator/=(std::size_t array_idx)
{ {
return *this /= std::to_string(array_index); return *this /= std::to_string(array_idx);
} }
/*! /*!
...@@ -189,8 +189,8 @@ class json_pointer ...@@ -189,8 +189,8 @@ class json_pointer
@brief create a new JSON pointer by appending the array-index-token at the end of the JSON pointer @brief create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
@param[in] ptr JSON pointer @param[in] ptr JSON pointer
@param[in] array_index array index @param[in] array_idx array index
@return a new JSON pointer with @a array_index appended to @a ptr @return a new JSON pointer with @a array_idx appended to @a ptr
@liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary} @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary}
...@@ -200,9 +200,9 @@ class json_pointer ...@@ -200,9 +200,9 @@ class json_pointer
@since version 3.6.0 @since version 3.6.0
*/ */
friend json_pointer operator/(const json_pointer& ptr, std::size_t array_index) friend json_pointer operator/(const json_pointer& ptr, std::size_t array_idx)
{ {
return json_pointer(ptr) /= array_index; return json_pointer(ptr) /= array_idx;
} }
/*! /*!
...@@ -329,8 +329,30 @@ class json_pointer ...@@ -329,8 +329,30 @@ class json_pointer
*/ */
static int array_index(const std::string& s) static int array_index(const std::string& s)
{ {
// error condition (cf. RFC 6901, Sect. 4)
if (JSON_HEDLEY_UNLIKELY(s.size() > 1 and s[0] == '0'))
{
JSON_THROW(detail::parse_error::create(106, 0,
"array index '" + s +
"' must not begin with '0'"));
}
// error condition (cf. RFC 6901, Sect. 4)
if (JSON_HEDLEY_UNLIKELY(s.size() > 1 and not (s[0] >= '1' and s[0] <= '9')))
{
JSON_THROW(detail::parse_error::create(109, 0, "array index '" + s + "' is not a number"));
}
std::size_t processed_chars = 0; std::size_t processed_chars = 0;
const int res = std::stoi(s, &processed_chars); int res = 0;
JSON_TRY
{
res = std::stoi(s, &processed_chars);
}
JSON_CATCH(std::out_of_range&)
{
JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'"));
}
// check if the string was completely read // check if the string was completely read
if (JSON_HEDLEY_UNLIKELY(processed_chars != s.size())) if (JSON_HEDLEY_UNLIKELY(processed_chars != s.size()))
...@@ -397,14 +419,7 @@ class json_pointer ...@@ -397,14 +419,7 @@ class json_pointer
case detail::value_t::array: case detail::value_t::array:
{ {
// create an entry in the array // create an entry in the array
JSON_TRY result = &result->operator[](static_cast<size_type>(array_index(reference_token)));
{
result = &result->operator[](static_cast<size_type>(array_index(reference_token)));
}
JSON_CATCH(std::invalid_argument&)
{
JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
}
break; break;
} }
...@@ -474,14 +489,6 @@ class json_pointer ...@@ -474,14 +489,6 @@ class json_pointer
case detail::value_t::array: case detail::value_t::array:
{ {
// error condition (cf. RFC 6901, Sect. 4)
if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0'))
{
JSON_THROW(detail::parse_error::create(106, 0,
"array index '" + reference_token +
"' must not begin with '0'"));
}
if (reference_token == "-") if (reference_token == "-")
{ {
// explicitly treat "-" as index beyond the end // explicitly treat "-" as index beyond the end
...@@ -490,15 +497,8 @@ class json_pointer ...@@ -490,15 +497,8 @@ class json_pointer
else else
{ {
// convert array index to number; unchecked access // convert array index to number; unchecked access
JSON_TRY ptr = &ptr->operator[](
{ static_cast<size_type>(array_index(reference_token)));
ptr = &ptr->operator[](
static_cast<size_type>(array_index(reference_token)));
}
JSON_CATCH(std::invalid_argument&)
{
JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
}
} }
break; break;
} }
...@@ -541,23 +541,8 @@ class json_pointer ...@@ -541,23 +541,8 @@ class json_pointer
") is out of range")); ") is out of range"));
} }
// error condition (cf. RFC 6901, Sect. 4)
if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0'))
{
JSON_THROW(detail::parse_error::create(106, 0,
"array index '" + reference_token +
"' must not begin with '0'"));
}
// note: at performs range check // note: at performs range check
JSON_TRY ptr = &ptr->at(static_cast<size_type>(array_index(reference_token)));
{
ptr = &ptr->at(static_cast<size_type>(array_index(reference_token)));
}
JSON_CATCH(std::invalid_argument&)
{
JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
}
break; break;
} }
...@@ -606,24 +591,9 @@ class json_pointer ...@@ -606,24 +591,9 @@ class json_pointer
") is out of range")); ") is out of range"));
} }
// error condition (cf. RFC 6901, Sect. 4)
if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0'))
{
JSON_THROW(detail::parse_error::create(106, 0,
"array index '" + reference_token +
"' must not begin with '0'"));
}
// use unchecked array access // use unchecked array access
JSON_TRY ptr = &ptr->operator[](
{ static_cast<size_type>(array_index(reference_token)));
ptr = &ptr->operator[](
static_cast<size_type>(array_index(reference_token)));
}
JSON_CATCH(std::invalid_argument&)
{
JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
}
break; break;
} }
...@@ -665,23 +635,8 @@ class json_pointer ...@@ -665,23 +635,8 @@ class json_pointer
") is out of range")); ") is out of range"));
} }
// error condition (cf. RFC 6901, Sect. 4)
if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0'))
{
JSON_THROW(detail::parse_error::create(106, 0,
"array index '" + reference_token +
"' must not begin with '0'"));
}
// note: at performs range check // note: at performs range check
JSON_TRY ptr = &ptr->at(static_cast<size_type>(array_index(reference_token)));
{
ptr = &ptr->at(static_cast<size_type>(array_index(reference_token)));
}
JSON_CATCH(std::invalid_argument&)
{
JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
}
break; break;
} }
...@@ -723,31 +678,36 @@ class json_pointer ...@@ -723,31 +678,36 @@ class json_pointer
// "-" always fails the range check // "-" always fails the range check
return false; return false;
} }
if (JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 and not ("0" <= reference_token and reference_token <= "9")))
// error condition (cf. RFC 6901, Sect. 4)
if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0'))
{ {
JSON_THROW(detail::parse_error::create(106, 0, // invalid char
"array index '" + reference_token + return false;
"' must not begin with '0'"));
} }
if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1))
JSON_TRY
{ {
const auto idx = static_cast<size_type>(array_index(reference_token)); if (JSON_HEDLEY_UNLIKELY(not ('1' <= reference_token[0] and reference_token[0] <= '9')))
if (idx >= ptr->size())
{ {
// index out of range // first char should be between '1' and '9'
return false; return false;
} }
for (std::size_t i = 1; i < reference_token.size(); i++)
ptr = &ptr->operator[](idx); {
break; if (JSON_HEDLEY_UNLIKELY(not ('0' <= reference_token[i] and reference_token[i] <= '9')))
{
// other char should be between '0' and '9'
return false;
}
}
} }
JSON_CATCH(std::invalid_argument&)
const auto idx = static_cast<size_type>(array_index(reference_token));
if (idx >= ptr->size())
{ {
JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); // index out of range
return false;
} }
ptr = &ptr->operator[](idx);
break; break;
} }
......
...@@ -113,9 +113,10 @@ ...@@ -113,9 +113,10 @@
class StringType, class BooleanType, class NumberIntegerType, \ class StringType, class BooleanType, class NumberIntegerType, \
class NumberUnsignedType, class NumberFloatType, \ class NumberUnsignedType, class NumberFloatType, \
template<typename> class AllocatorType, \ template<typename> class AllocatorType, \
template<typename, typename = void> class JSONSerializer> template<typename, typename = void> class JSONSerializer, \
class BinaryType>
#define NLOHMANN_BASIC_JSON_TPL \ #define NLOHMANN_BASIC_JSON_TPL \
basic_json<ObjectType, ArrayType, StringType, BooleanType, \ basic_json<ObjectType, ArrayType, StringType, BooleanType, \
NumberIntegerType, NumberUnsignedType, NumberFloatType, \ NumberIntegerType, NumberUnsignedType, NumberFloatType, \
AllocatorType, JSONSerializer> AllocatorType, JSONSerializer, BinaryType>
#pragma once #pragma once
#include <ciso646> // not
#include <cstddef> // size_t #include <cstddef> // size_t
#include <type_traits> // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type #include <type_traits> // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type
#include <nlohmann/detail/boolean_operators.hpp>
namespace nlohmann namespace nlohmann
{ {
namespace detail namespace detail
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <nlohmann/detail/meta/void_t.hpp> #include <nlohmann/detail/meta/void_t.hpp>
// http://en.cppreference.com/w/cpp/experimental/is_detected // https://en.cppreference.com/w/cpp/experimental/is_detected
namespace nlohmann namespace nlohmann
{ {
namespace detail namespace detail
......
#pragma once #pragma once
#include <ciso646> // not
#include <limits> // numeric_limits #include <limits> // numeric_limits
#include <type_traits> // false_type, is_constructible, is_integral, is_same, true_type #include <type_traits> // false_type, is_constructible, is_integral, is_same, true_type
#include <utility> // declval #include <utility> // declval
#include <nlohmann/detail/boolean_operators.hpp>
#include <nlohmann/detail/iterators/iterator_traits.hpp> #include <nlohmann/detail/iterators/iterator_traits.hpp>
#include <nlohmann/detail/macro_scope.hpp> #include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta/cpp_future.hpp> #include <nlohmann/detail/meta/cpp_future.hpp>
...@@ -41,6 +41,19 @@ template<typename> struct is_basic_json : std::false_type {}; ...@@ -41,6 +41,19 @@ template<typename> struct is_basic_json : std::false_type {};
NLOHMANN_BASIC_JSON_TPL_DECLARATION NLOHMANN_BASIC_JSON_TPL_DECLARATION
struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : std::true_type {}; struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : std::true_type {};
//////////////////////
// json_ref helpers //
//////////////////////
template <typename>
class json_ref;
template<typename>
struct is_json_ref : std::false_type {};
template <typename T>
struct is_json_ref<json_ref<T>> : std::true_type {};
////////////////////////// //////////////////////////
// aliases for detected // // aliases for detected //
////////////////////////// //////////////////////////
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <cstring> // memcpy #include <cstring> // memcpy
#include <limits> // numeric_limits #include <limits> // numeric_limits
#include <string> // string #include <string> // string
#include <cmath> // isnan, isinf
#include <nlohmann/detail/input/binary_reader.hpp> #include <nlohmann/detail/input/binary_reader.hpp>
#include <nlohmann/detail/macro_scope.hpp> #include <nlohmann/detail/macro_scope.hpp>
...@@ -26,6 +27,7 @@ template<typename BasicJsonType, typename CharType> ...@@ -26,6 +27,7 @@ template<typename BasicJsonType, typename CharType>
class binary_writer class binary_writer
{ {
using string_t = typename BasicJsonType::string_t; using string_t = typename BasicJsonType::string_t;
using binary_t = typename BasicJsonType::binary_t;
public: public:
/*! /*!
...@@ -176,8 +178,35 @@ class binary_writer ...@@ -176,8 +178,35 @@ class binary_writer
case value_t::number_float: case value_t::number_float:
{ {
oa->write_character(get_cbor_float_prefix(j.m_value.number_float)); if (std::isnan(j.m_value.number_float))
write_number(j.m_value.number_float); {
// NaN is 0xf97e00 in CBOR
oa->write_character(to_char_type(0xF9));
oa->write_character(to_char_type(0x7E));
oa->write_character(to_char_type(0x00));
}
else if (std::isinf(j.m_value.number_float))
{
// Infinity is 0xf97c00, -Infinity is 0xf9fc00
oa->write_character(to_char_type(0xf9));
oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
oa->write_character(to_char_type(0x00));
}
else
{
if (static_cast<double>(j.m_value.number_float) >= static_cast<double>(std::numeric_limits<float>::lowest()) and
static_cast<double>(j.m_value.number_float) <= static_cast<double>((std::numeric_limits<float>::max)()) and
static_cast<double>(static_cast<float>(j.m_value.number_float)) == static_cast<double>(j.m_value.number_float))
{
oa->write_character(get_cbor_float_prefix(static_cast<float>(j.m_value.number_float)));
write_number(static_cast<float>(j.m_value.number_float));
}
else
{
oa->write_character(get_cbor_float_prefix(j.m_value.number_float));
write_number(j.m_value.number_float);
}
}
break; break;
} }
...@@ -258,6 +287,45 @@ class binary_writer ...@@ -258,6 +287,45 @@ class binary_writer
break; break;
} }
case value_t::binary:
{
// step 1: write control byte and the binary array size
const auto N = j.m_value.binary->size();
if (N <= 0x17)
{
write_number(static_cast<std::uint8_t>(0x40 + N));
}
else if (N <= (std::numeric_limits<std::uint8_t>::max)())
{
oa->write_character(to_char_type(0x58));
write_number(static_cast<std::uint8_t>(N));
}
else if (N <= (std::numeric_limits<std::uint16_t>::max)())
{
oa->write_character(to_char_type(0x59));
write_number(static_cast<std::uint16_t>(N));
}
else if (N <= (std::numeric_limits<std::uint32_t>::max)())
{
oa->write_character(to_char_type(0x5A));
write_number(static_cast<std::uint32_t>(N));
}
// LCOV_EXCL_START
else if (N <= (std::numeric_limits<std::uint64_t>::max)())
{
oa->write_character(to_char_type(0x5B));
write_number(static_cast<std::uint64_t>(N));
}
// LCOV_EXCL_STOP
// step 2: write each element
oa->write_characters(
reinterpret_cast<const CharType*>(j.m_value.binary->data()),
N);
break;
}
case value_t::object: case value_t::object:
{ {
// step 1: write control byte and the object size // step 1: write control byte and the object size
...@@ -506,6 +574,101 @@ class binary_writer ...@@ -506,6 +574,101 @@ class binary_writer
break; break;
} }
case value_t::binary:
{
// step 0: determine if the binary type has a set subtype to
// determine whether or not to use the ext or fixext types
const bool use_ext = j.m_value.binary->has_subtype();
// step 1: write control byte and the byte string length
const auto N = j.m_value.binary->size();
if (N <= (std::numeric_limits<std::uint8_t>::max)())
{
std::uint8_t output_type;
bool fixed = true;
if (use_ext)
{
switch (N)
{
case 1:
output_type = 0xD4; // fixext 1
break;
case 2:
output_type = 0xD5; // fixext 2
break;
case 4:
output_type = 0xD6; // fixext 4
break;
case 8:
output_type = 0xD7; // fixext 8
break;
case 16:
output_type = 0xD8; // fixext 16
break;
default:
output_type = 0xC7; // ext 8
fixed = false;
break;
}
}
else
{
output_type = 0xC4; // bin 8
fixed = false;
}
oa->write_character(to_char_type(output_type));
if (not fixed)
{
write_number(static_cast<std::uint8_t>(N));
}
}
else if (N <= (std::numeric_limits<std::uint16_t>::max)())
{
std::uint8_t output_type;
if (use_ext)
{
output_type = 0xC8; // ext 16
}
else
{
output_type = 0xC5; // bin 16
}
oa->write_character(to_char_type(output_type));
write_number(static_cast<std::uint16_t>(N));
}
else if (N <= (std::numeric_limits<std::uint32_t>::max)())
{
std::uint8_t output_type;
if (use_ext)
{
output_type = 0xC9; // ext 32
}
else
{
output_type = 0xC6; // bin 32
}
oa->write_character(to_char_type(output_type));
write_number(static_cast<std::uint32_t>(N));
}
// step 1.5: if this is an ext type, write the subtype
if (use_ext)
{
write_number(static_cast<std::int8_t>(j.m_value.binary->subtype()));
}
// step 2: write the byte string
oa->write_characters(
reinterpret_cast<const CharType*>(j.m_value.binary->data()),
N);
break;
}
case value_t::object: case value_t::object:
{ {
// step 1: write control byte and the object size // step 1: write control byte and the object size
...@@ -649,6 +812,49 @@ class binary_writer ...@@ -649,6 +812,49 @@ class binary_writer
break; break;
} }
case value_t::binary:
{
if (add_prefix)
{
oa->write_character(to_char_type('['));
}
if (use_type and not j.m_value.binary->empty())
{
assert(use_count);
oa->write_character(to_char_type('$'));
oa->write_character('U');
}
if (use_count)
{
oa->write_character(to_char_type('#'));
write_number_with_ubjson_prefix(j.m_value.binary->size(), true);
}
if (use_type)
{
oa->write_characters(
reinterpret_cast<const CharType*>(j.m_value.binary->data()),
j.m_value.binary->size());
}
else
{
for (size_t i = 0; i < j.m_value.binary->size(); ++i)
{
oa->write_character(to_char_type('U'));
oa->write_character(j.m_value.binary->data()[i]);
}
}
if (not use_count)
{
oa->write_character(to_char_type(']'));
}
break;
}
case value_t::object: case value_t::object:
{ {
if (add_prefix) if (add_prefix)
...@@ -863,7 +1069,7 @@ class binary_writer ...@@ -863,7 +1069,7 @@ class binary_writer
{ {
std::size_t array_index = 0ul; std::size_t array_index = 0ul;
const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), 0ul, [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type & el) const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), std::size_t(0), [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type & el)
{ {
return result + calc_bson_element_size(std::to_string(array_index++), el); return result + calc_bson_element_size(std::to_string(array_index++), el);
}); });
...@@ -871,6 +1077,14 @@ class binary_writer ...@@ -871,6 +1077,14 @@ class binary_writer
return sizeof(std::int32_t) + embedded_document_size + 1ul; return sizeof(std::int32_t) + embedded_document_size + 1ul;
} }
/*!
@return The size of the BSON-encoded binary array @a value
*/
static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t& value)
{
return sizeof(std::int32_t) + value.size() + 1ul;
}
/*! /*!
@brief Writes a BSON element with key @a name and array @a value @brief Writes a BSON element with key @a name and array @a value
*/ */
...@@ -890,6 +1104,20 @@ class binary_writer ...@@ -890,6 +1104,20 @@ class binary_writer
oa->write_character(to_char_type(0x00)); oa->write_character(to_char_type(0x00));
} }
/*!
@brief Writes a BSON element with key @a name and binary value @a value
*/
void write_bson_binary(const string_t& name,
const binary_t& value)
{
write_bson_entry_header(name, 0x05);
write_number<std::int32_t, true>(static_cast<std::int32_t>(value.size()));
write_number(value.has_subtype() ? value.subtype() : std::uint8_t(0x00));
oa->write_characters(reinterpret_cast<const CharType*>(value.data()), value.size());
}
/*! /*!
@brief Calculates the size necessary to serialize the JSON value @a j with its @a name @brief Calculates the size necessary to serialize the JSON value @a j with its @a name
@return The calculated size for the BSON document entry for @a j with the given @a name. @return The calculated size for the BSON document entry for @a j with the given @a name.
...@@ -906,6 +1134,9 @@ class binary_writer ...@@ -906,6 +1134,9 @@ class binary_writer
case value_t::array: case value_t::array:
return header_size + calc_bson_array_size(*j.m_value.array); return header_size + calc_bson_array_size(*j.m_value.array);
case value_t::binary:
return header_size + calc_bson_binary_size(*j.m_value.binary);
case value_t::boolean: case value_t::boolean:
return header_size + 1ul; return header_size + 1ul;
...@@ -950,6 +1181,9 @@ class binary_writer ...@@ -950,6 +1181,9 @@ class binary_writer
case value_t::array: case value_t::array:
return write_bson_array(name, *j.m_value.array); return write_bson_array(name, *j.m_value.array);
case value_t::binary:
return write_bson_binary(name, *j.m_value.binary);
case value_t::boolean: case value_t::boolean:
return write_bson_boolean(name, j.m_value.boolean); return write_bson_boolean(name, j.m_value.boolean);
...@@ -984,7 +1218,7 @@ class binary_writer ...@@ -984,7 +1218,7 @@ class binary_writer
*/ */
static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t& value) static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t& value)
{ {
std::size_t document_size = std::accumulate(value.begin(), value.end(), 0ul, std::size_t document_size = std::accumulate(value.begin(), value.end(), std::size_t(0),
[](size_t result, const typename BasicJsonType::object_t::value_type & el) [](size_t result, const typename BasicJsonType::object_t::value_type & el)
{ {
return result += calc_bson_element_size(el.first, el.second); return result += calc_bson_element_size(el.first, el.second);
...@@ -1230,7 +1464,8 @@ class binary_writer ...@@ -1230,7 +1464,8 @@ class binary_writer
case value_t::string: case value_t::string:
return 'S'; return 'S';
case value_t::array: case value_t::array: // fallthrough
case value_t::binary:
return '['; return '[';
case value_t::object: case value_t::object:
...@@ -1300,7 +1535,7 @@ class binary_writer ...@@ -1300,7 +1535,7 @@ class binary_writer
static CharType to_char_type(std::uint8_t x) noexcept static CharType to_char_type(std::uint8_t x) noexcept
{ {
static_assert(sizeof(std::uint8_t) == sizeof(CharType), "size of CharType must be equal to std::uint8_t"); static_assert(sizeof(std::uint8_t) == sizeof(CharType), "size of CharType must be equal to std::uint8_t");
static_assert(std::is_pod<CharType>::value, "CharType must be POD"); static_assert(std::is_trivial<CharType>::value, "CharType must be trivial");
CharType result; CharType result;
std::memcpy(&result, &x, sizeof(x)); std::memcpy(&result, &x, sizeof(x));
return result; return result;
...@@ -1326,7 +1561,7 @@ class binary_writer ...@@ -1326,7 +1561,7 @@ class binary_writer
private: private:
/// whether we can assume little endianess /// whether we can assume little endianess
const bool is_little_endian = binary_reader<BasicJsonType>::little_endianess(); const bool is_little_endian = little_endianess();
/// the output /// the output
output_adapter_t<CharType> oa = nullptr; output_adapter_t<CharType> oa = nullptr;
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include <algorithm> // reverse, remove, fill, find, none_of #include <algorithm> // reverse, remove, fill, find, none_of
#include <array> // array #include <array> // array
#include <cassert> // assert #include <cassert> // assert
#include <ciso646> // and, or
#include <clocale> // localeconv, lconv #include <clocale> // localeconv, lconv
#include <cmath> // labs, isfinite, isnan, signbit #include <cmath> // labs, isfinite, isnan, signbit
#include <cstddef> // size_t, ptrdiff_t #include <cstddef> // size_t, ptrdiff_t
...@@ -14,6 +13,7 @@ ...@@ -14,6 +13,7 @@
#include <type_traits> // is_same #include <type_traits> // is_same
#include <utility> // move #include <utility> // move
#include <nlohmann/detail/boolean_operators.hpp>
#include <nlohmann/detail/conversions/to_chars.hpp> #include <nlohmann/detail/conversions/to_chars.hpp>
#include <nlohmann/detail/exceptions.hpp> #include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/macro_scope.hpp> #include <nlohmann/detail/macro_scope.hpp>
...@@ -45,6 +45,7 @@ class serializer ...@@ -45,6 +45,7 @@ class serializer
using number_float_t = typename BasicJsonType::number_float_t; using number_float_t = typename BasicJsonType::number_float_t;
using number_integer_t = typename BasicJsonType::number_integer_t; using number_integer_t = typename BasicJsonType::number_integer_t;
using number_unsigned_t = typename BasicJsonType::number_unsigned_t; using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
using binary_char_t = typename BasicJsonType::binary_t::value_type;
static constexpr std::uint8_t UTF8_ACCEPT = 0; static constexpr std::uint8_t UTF8_ACCEPT = 0;
static constexpr std::uint8_t UTF8_REJECT = 1; static constexpr std::uint8_t UTF8_REJECT = 1;
...@@ -83,13 +84,19 @@ class serializer ...@@ -83,13 +84,19 @@ class serializer
- strings and object keys are escaped using `escape_string()` - strings and object keys are escaped using `escape_string()`
- integer numbers are converted implicitly via `operator<<` - integer numbers are converted implicitly via `operator<<`
- floating-point numbers are converted to a string using `"%g"` format - floating-point numbers are converted to a string using `"%g"` format
- binary values are serialized as objects containing the subtype and the
@param[in] val value to serialize byte array
@param[in] pretty_print whether the output shall be pretty-printed
@param[in] indent_step the indent level @param[in] val value to serialize
@param[in] current_indent the current indent level (only used internally) @param[in] pretty_print whether the output shall be pretty-printed
@param[in] ensure_ascii If @a ensure_ascii is true, all non-ASCII characters
in the output are escaped with `\uXXXX` sequences, and the result consists
of ASCII characters only.
@param[in] indent_step the indent level
@param[in] current_indent the current indent level (only used internally)
*/ */
void dump(const BasicJsonType& val, const bool pretty_print, void dump(const BasicJsonType& val,
const bool pretty_print,
const bool ensure_ascii, const bool ensure_ascii,
const unsigned int indent_step, const unsigned int indent_step,
const unsigned int current_indent = 0) const unsigned int current_indent = 0)
...@@ -236,6 +243,79 @@ class serializer ...@@ -236,6 +243,79 @@ class serializer
return; return;
} }
case value_t::binary:
{
if (pretty_print)
{
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 (not val.m_value.binary->empty())
{
for (auto i = val.m_value.binary->cbegin();
i != val.m_value.binary->cend() - 1; ++i)
{
dump_integer(*i);
o->write_characters(", ", 2);
}
dump_integer(val.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_value.binary->has_subtype())
{
dump_integer(val.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('}');
}
else
{
o->write_characters("{\"bytes\":[", 10);
if (not val.m_value.binary->empty())
{
for (auto i = val.m_value.binary->cbegin();
i != val.m_value.binary->cend() - 1; ++i)
{
dump_integer(*i);
o->write_character(',');
}
dump_integer(val.m_value.binary->back());
}
o->write_characters("],\"subtype\":", 12);
if (val.m_value.binary->has_subtype())
{
dump_integer(val.m_value.binary->subtype());
o->write_character('}');
}
else
{
o->write_characters("null}", 5);
}
}
return;
}
case value_t::boolean: case value_t::boolean:
{ {
if (val.m_value.boolean) if (val.m_value.boolean)
...@@ -592,7 +672,8 @@ class serializer ...@@ -592,7 +672,8 @@ class serializer
*/ */
template<typename NumberType, detail::enable_if_t< template<typename NumberType, detail::enable_if_t<
std::is_same<NumberType, number_unsigned_t>::value or std::is_same<NumberType, number_unsigned_t>::value or
std::is_same<NumberType, number_integer_t>::value, std::is_same<NumberType, number_integer_t>::value or
std::is_same<NumberType, binary_char_t>::value,
int> = 0> int> = 0>
void dump_integer(NumberType x) void dump_integer(NumberType x)
{ {
...@@ -630,7 +711,7 @@ class serializer ...@@ -630,7 +711,7 @@ class serializer
if (is_negative) if (is_negative)
{ {
*buffer_ptr = '-'; *buffer_ptr = '-';
abs_value = remove_sign(x); abs_value = remove_sign(static_cast<number_integer_t>(x));
// account one more byte for the minus sign // account one more byte for the minus sign
n_chars = 1 + count_digits(abs_value); n_chars = 1 + count_digits(abs_value);
...@@ -807,7 +888,9 @@ class serializer ...@@ -807,7 +888,9 @@ class serializer
? (byte & 0x3fu) | (codep << 6u) ? (byte & 0x3fu) | (codep << 6u)
: (0xFFu >> type) & (byte); : (0xFFu >> type) & (byte);
state = utf8d[256u + state * 16u + type]; std::size_t index = 256u + static_cast<size_t>(state) * 16u + static_cast<size_t>(type);
assert(index < 400);
state = utf8d[index];
return state; return state;
} }
......
#pragma once #pragma once
#include <array> // array #include <array> // array
#include <ciso646> // and
#include <cstddef> // size_t #include <cstddef> // size_t
#include <cstdint> // uint8_t #include <cstdint> // uint8_t
#include <string> // string #include <string> // string
#include <nlohmann/detail/boolean_operators.hpp>
namespace nlohmann namespace nlohmann
{ {
namespace detail namespace detail
...@@ -48,24 +49,29 @@ enum class value_t : std::uint8_t ...@@ -48,24 +49,29 @@ enum class value_t : std::uint8_t
number_integer, ///< number value (signed integer) number_integer, ///< number value (signed integer)
number_unsigned, ///< number value (unsigned integer) number_unsigned, ///< number value (unsigned integer)
number_float, ///< number value (floating-point) number_float, ///< number value (floating-point)
discarded ///< discarded by the the parser callback function binary, ///< binary array (ordered collection of bytes)
discarded ///< discarded by the parser callback function
}; };
/*! /*!
@brief comparison operator for JSON types @brief comparison operator for JSON types
Returns an ordering that is similar to Python: Returns an ordering that is similar to Python:
- order: null < boolean < number < object < array < string - order: null < boolean < number < object < array < string < binary
- furthermore, each type is not smaller than itself - furthermore, each type is not smaller than itself
- discarded values are not comparable - discarded values are not comparable
- binary is represented as a b"" string in python and directly comparable to a
string; however, making a binary array directly comparable with a string would
be surprising behavior in a JSON file.
@since version 1.0.0 @since version 1.0.0
*/ */
inline bool operator<(const value_t lhs, const value_t rhs) noexcept inline bool operator<(const value_t lhs, const value_t rhs) noexcept
{ {
static constexpr std::array<std::uint8_t, 8> order = {{ static constexpr std::array<std::uint8_t, 9> order = {{
0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */, 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */,
1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */ 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */,
6 /* binary */
} }
}; };
......
/* /*
__ _____ _____ _____ __ _____ _____ _____
__| | __| | | | JSON for Modern C++ __| | __| | | | JSON for Modern C++
| | |__ | | | | | | version 3.7.3 | | |__ | | | | | | version 3.8.0
|_____|_____|_____|_|___| https://github.com/nlohmann/json |_____|_____|_____|_|___| https://github.com/nlohmann/json
Licensed under the MIT License <http://opensource.org/licenses/MIT>. Licensed under the MIT License <http://opensource.org/licenses/MIT>.
...@@ -31,12 +31,11 @@ SOFTWARE. ...@@ -31,12 +31,11 @@ SOFTWARE.
#define INCLUDE_NLOHMANN_JSON_HPP_ #define INCLUDE_NLOHMANN_JSON_HPP_
#define NLOHMANN_JSON_VERSION_MAJOR 3 #define NLOHMANN_JSON_VERSION_MAJOR 3
#define NLOHMANN_JSON_VERSION_MINOR 7 #define NLOHMANN_JSON_VERSION_MINOR 8
#define NLOHMANN_JSON_VERSION_PATCH 3 #define NLOHMANN_JSON_VERSION_PATCH 0
#include <algorithm> // all_of, find, for_each #include <algorithm> // all_of, find, for_each
#include <cassert> // assert #include <cassert> // assert
#include <ciso646> // and, not, or
#include <cstddef> // nullptr_t, ptrdiff_t, size_t #include <cstddef> // nullptr_t, ptrdiff_t, size_t
#include <functional> // hash, less #include <functional> // hash, less
#include <initializer_list> // initializer_list #include <initializer_list> // initializer_list
...@@ -49,6 +48,8 @@ SOFTWARE. ...@@ -49,6 +48,8 @@ SOFTWARE.
#include <vector> // vector #include <vector> // vector
#include <nlohmann/adl_serializer.hpp> #include <nlohmann/adl_serializer.hpp>
#include <nlohmann/byte_container_with_subtype.hpp>
#include <nlohmann/detail/boolean_operators.hpp>
#include <nlohmann/detail/conversions/from_json.hpp> #include <nlohmann/detail/conversions/from_json.hpp>
#include <nlohmann/detail/conversions/to_json.hpp> #include <nlohmann/detail/conversions/to_json.hpp>
#include <nlohmann/detail/exceptions.hpp> #include <nlohmann/detail/exceptions.hpp>
...@@ -97,6 +98,9 @@ default; will be used in @ref number_integer_t) ...@@ -97,6 +98,9 @@ default; will be used in @ref number_integer_t)
`uint64_t` by default; will be used in @ref number_unsigned_t) `uint64_t` by default; will be used in @ref number_unsigned_t)
@tparam NumberFloatType type for JSON floating-point numbers (`double` by @tparam NumberFloatType type for JSON floating-point numbers (`double` by
default; will be used in @ref number_float_t) default; will be used in @ref number_float_t)
@tparam BinaryType type for packed binary data for compatibility with binary
serialization formats (`std::vector<std::uint8_t>` by default; will be used in
@ref binary_t)
@tparam AllocatorType type of the allocator to use (`std::allocator` by @tparam AllocatorType type of the allocator to use (`std::allocator` by
default) default)
@tparam JSONSerializer the serializer to resolve internal calls to `to_json()` @tparam JSONSerializer the serializer to resolve internal calls to `to_json()`
...@@ -151,7 +155,7 @@ relationship: ...@@ -151,7 +155,7 @@ relationship:
The invariants are checked by member function assert_invariant(). The invariants are checked by member function assert_invariant().
@internal @internal
@note ObjectType trick from http://stackoverflow.com/a/9860911 @note ObjectType trick from https://stackoverflow.com/a/9860911
@endinternal @endinternal
@see [RFC 7159: The JavaScript Object Notation (JSON) Data Interchange @see [RFC 7159: The JavaScript Object Notation (JSON) Data Interchange
...@@ -167,13 +171,15 @@ class basic_json ...@@ -167,13 +171,15 @@ class basic_json
private: private:
template<detail::value_t> friend struct detail::external_constructor; template<detail::value_t> friend struct detail::external_constructor;
friend ::nlohmann::json_pointer<basic_json>; friend ::nlohmann::json_pointer<basic_json>;
friend ::nlohmann::detail::parser<basic_json>;
template<typename BasicJsonType, typename InputType>
friend class ::nlohmann::detail::parser;
friend ::nlohmann::detail::serializer<basic_json>; friend ::nlohmann::detail::serializer<basic_json>;
template<typename BasicJsonType> template<typename BasicJsonType>
friend class ::nlohmann::detail::iter_impl; friend class ::nlohmann::detail::iter_impl;
template<typename BasicJsonType, typename CharType> template<typename BasicJsonType, typename CharType>
friend class ::nlohmann::detail::binary_writer; friend class ::nlohmann::detail::binary_writer;
template<typename BasicJsonType, typename SAX> template<typename BasicJsonType, typename InputType, typename SAX>
friend class ::nlohmann::detail::binary_reader; friend class ::nlohmann::detail::binary_reader;
template<typename BasicJsonType> template<typename BasicJsonType>
friend class ::nlohmann::detail::json_sax_dom_parser; friend class ::nlohmann::detail::json_sax_dom_parser;
...@@ -184,8 +190,17 @@ class basic_json ...@@ -184,8 +190,17 @@ class basic_json
using basic_json_t = NLOHMANN_BASIC_JSON_TPL; using basic_json_t = NLOHMANN_BASIC_JSON_TPL;
// convenience aliases for types residing in namespace detail; // convenience aliases for types residing in namespace detail;
using lexer = ::nlohmann::detail::lexer<basic_json>; using lexer = ::nlohmann::detail::lexer_base<basic_json>;
using parser = ::nlohmann::detail::parser<basic_json>;
template<typename InputAdapterType>
static ::nlohmann::detail::parser<basic_json, InputAdapterType> parser(
InputAdapterType adapter,
detail::parser_callback_t<basic_json>cb = nullptr,
bool allow_exceptions = true
)
{
return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter), std::move(cb), allow_exceptions);
}
using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t; using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t;
template<typename BasicJsonType> template<typename BasicJsonType>
...@@ -199,7 +214,8 @@ class basic_json ...@@ -199,7 +214,8 @@ class basic_json
template<typename CharType> template<typename CharType>
using output_adapter_t = ::nlohmann::detail::output_adapter_t<CharType>; using output_adapter_t = ::nlohmann::detail::output_adapter_t<CharType>;
using binary_reader = ::nlohmann::detail::binary_reader<basic_json>; template<typename InputType>
using binary_reader = ::nlohmann::detail::binary_reader<basic_json, InputType>;
template<typename CharType> using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>; template<typename CharType> using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
using serializer = ::nlohmann::detail::serializer<basic_json>; using serializer = ::nlohmann::detail::serializer<basic_json>;
...@@ -818,6 +834,76 @@ class basic_json ...@@ -818,6 +834,76 @@ class basic_json
*/ */
using number_float_t = NumberFloatType; using number_float_t = NumberFloatType;
/*!
@brief a type for a packed binary type
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::uint8_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).
[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 an 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
`std::vector<std::uint8_t>`, which is a very common way to represent a byte
array in modern C++.
#### Default type
The default values for @a BinaryType is `std::vector<std::uint8_t>`
#### Storage
Binary Arrays are stored as pointers in a @ref basic_json type. That is,
for any access to array values, a pointer of the type `binary_t*` must be
dereferenced.
#### Notes on subtypes
- CBOR
- Binary values are represented as byte strings. No subtypes are
supported and will be ignored when CBOR is written.
- 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 singed 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.
@sa @ref binary -- create a binary array
@since version 3.8.0
*/
using binary_t = nlohmann::byte_container_with_subtype<BinaryType>;
/// @} /// @}
private: private:
...@@ -860,6 +946,7 @@ class basic_json ...@@ -860,6 +946,7 @@ class basic_json
number | number_integer | @ref number_integer_t number | number_integer | @ref number_integer_t
number | number_unsigned | @ref number_unsigned_t number | number_unsigned | @ref number_unsigned_t
number | number_float | @ref number_float_t number | number_float | @ref number_float_t
binary | binary | pointer to @ref binary_t
null | null | *no value is stored* null | null | *no value is stored*
@note Variable-length types (objects, arrays, and strings) are stored as @note Variable-length types (objects, arrays, and strings) are stored as
...@@ -876,6 +963,8 @@ class basic_json ...@@ -876,6 +963,8 @@ class basic_json
array_t* array; array_t* array;
/// string (stored with pointer to save storage) /// string (stored with pointer to save storage)
string_t* string; string_t* string;
/// binary (stored with pointer to save storage)
binary_t* binary;
/// boolean /// boolean
boolean_t boolean; boolean_t boolean;
/// number (integer) /// number (integer)
...@@ -918,6 +1007,12 @@ class basic_json ...@@ -918,6 +1007,12 @@ class basic_json
break; break;
} }
case value_t::binary:
{
binary = create<binary_t>();
break;
}
case value_t::boolean: case value_t::boolean:
{ {
boolean = boolean_t(false); boolean = boolean_t(false);
...@@ -953,7 +1048,7 @@ class basic_json ...@@ -953,7 +1048,7 @@ class basic_json
object = nullptr; // silence warning, see #821 object = nullptr; // silence warning, see #821
if (JSON_HEDLEY_UNLIKELY(t == value_t::null)) if (JSON_HEDLEY_UNLIKELY(t == value_t::null))
{ {
JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.7.3")); // LCOV_EXCL_LINE JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.8.0")); // LCOV_EXCL_LINE
} }
break; break;
} }
...@@ -996,6 +1091,30 @@ class basic_json ...@@ -996,6 +1091,30 @@ class basic_json
array = create<array_t>(std::move(value)); array = create<array_t>(std::move(value));
} }
/// constructor for binary arrays
json_value(const typename binary_t::container_type& value)
{
binary = create<binary_t>(value);
}
/// constructor for rvalue binary arrays
json_value(typename binary_t::container_type&& value)
{
binary = create<binary_t>(std::move(value));
}
/// constructor for binary arrays (internal type)
json_value(const binary_t& value)
{
binary = create<binary_t>(value);
}
/// constructor for rvalue binary arrays (internal type)
json_value(binary_t&& value)
{
binary = create<binary_t>(std::move(value));
}
void destroy(value_t t) noexcept void destroy(value_t t) noexcept
{ {
// flatten the current json_value to a heap-allocated stack // flatten the current json_value to a heap-allocated stack
...@@ -1071,6 +1190,14 @@ class basic_json ...@@ -1071,6 +1190,14 @@ class basic_json
break; break;
} }
case value_t::binary:
{
AllocatorType<binary_t> alloc;
std::allocator_traits<decltype(alloc)>::destroy(alloc, binary);
std::allocator_traits<decltype(alloc)>::deallocate(alloc, binary, 1);
break;
}
default: default:
{ {
break; break;
...@@ -1093,6 +1220,7 @@ class basic_json ...@@ -1093,6 +1220,7 @@ class basic_json
assert(m_type != value_t::object or m_value.object != nullptr); assert(m_type != value_t::object or m_value.object != nullptr);
assert(m_type != value_t::array or m_value.array != nullptr); assert(m_type != value_t::array or m_value.array != nullptr);
assert(m_type != value_t::string or m_value.string != nullptr); assert(m_type != value_t::string or m_value.string != nullptr);
assert(m_type != value_t::binary or m_value.binary != nullptr);
} }
public: public:
...@@ -1115,7 +1243,7 @@ class basic_json ...@@ -1115,7 +1243,7 @@ class basic_json
@sa @ref parser_callback_t for more information and examples @sa @ref parser_callback_t for more information and examples
*/ */
using parse_event_t = typename parser::parse_event_t; using parse_event_t = detail::parse_event_t;
/*! /*!
@brief per-element parser callback type @brief per-element parser callback type
...@@ -1166,7 +1294,7 @@ class basic_json ...@@ -1166,7 +1294,7 @@ class basic_json
@since version 1.0.0 @since version 1.0.0
*/ */
using parser_callback_t = typename parser::parser_callback_t; using parser_callback_t = detail::parser_callback_t<basic_json>;
////////////////// //////////////////
// constructors // // constructors //
...@@ -1191,6 +1319,7 @@ class basic_json ...@@ -1191,6 +1319,7 @@ class basic_json
number | `0` number | `0`
object | `{}` object | `{}`
array | `[]` array | `[]`
binary | empty array
@param[in] v the type of the value to create @param[in] v the type of the value to create
...@@ -1262,6 +1391,12 @@ class basic_json ...@@ -1262,6 +1391,12 @@ class basic_json
@ref number_float_t, and all convertible number types such as `int`, @ref number_float_t, and all convertible number types such as `int`,
`size_t`, `int64_t`, `float` or `double` can be used. `size_t`, `int64_t`, `float` or `double` can be used.
- **boolean**: @ref boolean_t / `bool` can be used. - **boolean**: @ref boolean_t / `bool` can be used.
- **binary**: @ref binary_t / `std::vector<uint8_t>` 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. See the examples below.
...@@ -1343,6 +1478,7 @@ class basic_json ...@@ -1343,6 +1478,7 @@ class basic_json
using other_string_t = typename BasicJsonType::string_t; using other_string_t = typename BasicJsonType::string_t;
using other_object_t = typename BasicJsonType::object_t; using other_object_t = typename BasicJsonType::object_t;
using other_array_t = typename BasicJsonType::array_t; using other_array_t = typename BasicJsonType::array_t;
using other_binary_t = typename BasicJsonType::binary_t;
switch (val.type()) switch (val.type())
{ {
...@@ -1367,6 +1503,9 @@ class basic_json ...@@ -1367,6 +1503,9 @@ class basic_json
case value_t::array: case value_t::array:
JSONSerializer<other_array_t>::to_json(*this, val.template get_ref<const other_array_t&>()); JSONSerializer<other_array_t>::to_json(*this, val.template get_ref<const other_array_t&>());
break; break;
case value_t::binary:
JSONSerializer<other_binary_t>::to_json(*this, val.template get_ref<const other_binary_t&>());
break;
case value_t::null: case value_t::null:
*this = nullptr; *this = nullptr;
break; break;
...@@ -1505,6 +1644,99 @@ class basic_json ...@@ -1505,6 +1644,99 @@ class basic_json
assert_invariant(); assert_invariant();
} }
/*!
@brief explicitly create a binary array (without subtype)
Creates a JSON binary array value from a given binary container. 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.
@note 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.
@param[in] init container containing bytes to use as binary type
@return JSON binary array value
@complexity Linear in the size of @a init.
@exceptionsafety Strong guarantee: if an exception is thrown, there are no
changes to any JSON value.
@since version 3.8.0
*/
JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json binary(const typename binary_t::container_type& init)
{
auto res = basic_json();
res.m_type = value_t::binary;
res.m_value = init;
return res;
}
/*!
@brief explicitly create a binary array (with subtype)
Creates a JSON binary array value from a given binary container. 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.
@note 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.
@param[in] init container containing bytes to use as binary type
@param[in] subtype subtype to use in MessagePack and BSON
@return JSON binary array value
@complexity Linear in the size of @a init.
@exceptionsafety Strong guarantee: if an exception is thrown, there are no
changes to any JSON value.
@since version 3.8.0
*/
JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json binary(const typename binary_t::container_type& init, std::uint8_t subtype)
{
auto res = basic_json();
res.m_type = value_t::binary;
res.m_value = binary_t(init, subtype);
return res;
}
/// @copydoc binary(const typename binary_t::container_type&)
JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json binary(typename binary_t::container_type&& init)
{
auto res = basic_json();
res.m_type = value_t::binary;
res.m_value = std::move(init);
return res;
}
/// @copydoc binary(const typename binary_t::container_type&, std::uint8_t)
JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json binary(typename binary_t::container_type&& init, std::uint8_t subtype)
{
auto res = basic_json();
res.m_type = value_t::binary;
res.m_value = binary_t(std::move(init), subtype);
return res;
}
/*! /*!
@brief explicitly create an array from an initializer list @brief explicitly create an array from an initializer list
...@@ -1760,6 +1992,12 @@ class basic_json ...@@ -1760,6 +1992,12 @@ class basic_json
break; break;
} }
case value_t::binary:
{
m_value = *first.m_object->m_value.binary;
break;
}
default: default:
JSON_THROW(invalid_iterator::create(206, "cannot construct with iterators from " + JSON_THROW(invalid_iterator::create(206, "cannot construct with iterators from " +
std::string(first.m_object->type_name()))); std::string(first.m_object->type_name())));
...@@ -1773,10 +2011,10 @@ class basic_json ...@@ -1773,10 +2011,10 @@ class basic_json
// other constructors and destructor // // other constructors and destructor //
/////////////////////////////////////// ///////////////////////////////////////
/// @private template <typename JsonRef,
basic_json(const detail::json_ref<basic_json>& ref) detail::enable_if_t<detail::conjunction<detail::is_json_ref<JsonRef>,
: basic_json(ref.moved_or_copied()) std::is_same<typename JsonRef::value_type, basic_json>>::value, int> = 0 >
{} basic_json(const JsonRef& ref) : basic_json(ref.moved_or_copied()) {}
/*! /*!
@brief copy constructor @brief copy constructor
...@@ -1853,6 +2091,12 @@ class basic_json ...@@ -1853,6 +2091,12 @@ class basic_json
break; break;
} }
case value_t::binary:
{
m_value = *other.m_value.binary;
break;
}
default: default:
break; break;
} }
...@@ -1997,7 +2241,11 @@ class basic_json ...@@ -1997,7 +2241,11 @@ class basic_json
@return string containing the serialization of the JSON value @return string containing the serialization of the JSON value
@throw type_error.316 if a string stored inside the JSON value is not @throw type_error.316 if a string stored inside the JSON value is not
UTF-8 encoded UTF-8 encoded and @a error_handler is set to strict
@note Binary values are serialized as object containing two keys:
- "bytes": an array of bytes as integers
- "subtype": the subtype as integer or "null" if the binary has no subtype
@complexity Linear. @complexity Linear.
...@@ -2012,7 +2260,8 @@ class basic_json ...@@ -2012,7 +2260,8 @@ class basic_json
@since version 1.0.0; indentation character @a indent_char, option @since version 1.0.0; indentation character @a indent_char, option
@a ensure_ascii and exceptions added in version 3.0.0; error @a ensure_ascii and exceptions added in version 3.0.0; error
handlers added in version 3.4.0. handlers added in version 3.4.0; serialization of binary values added
in version 3.8.0.
*/ */
string_t dump(const int indent = -1, string_t dump(const int indent = -1,
const char indent_char = ' ', const char indent_char = ' ',
...@@ -2051,6 +2300,7 @@ class basic_json ...@@ -2051,6 +2300,7 @@ class basic_json
number (floating-point) | value_t::number_float number (floating-point) | value_t::number_float
object | value_t::object object | value_t::object
array | value_t::array array | value_t::array
binary | value_t::binary
discarded | value_t::discarded discarded | value_t::discarded
@complexity Constant. @complexity Constant.
...@@ -2093,12 +2343,13 @@ class basic_json ...@@ -2093,12 +2343,13 @@ class basic_json
@sa @ref is_string() -- returns whether JSON value is a string @sa @ref is_string() -- returns whether JSON value is a string
@sa @ref is_boolean() -- returns whether JSON value is a boolean @sa @ref is_boolean() -- returns whether JSON value is a boolean
@sa @ref is_number() -- returns whether JSON value is a number @sa @ref is_number() -- returns whether JSON value is a number
@sa @ref is_binary() -- returns whether JSON value is a binary array
@since version 1.0.0 @since version 1.0.0
*/ */
constexpr bool is_primitive() const noexcept constexpr bool is_primitive() const noexcept
{ {
return is_null() or is_string() or is_boolean() or is_number(); return is_null() or is_string() or is_boolean() or is_number() or is_binary();
} }
/*! /*!
...@@ -2353,6 +2604,28 @@ class basic_json ...@@ -2353,6 +2604,28 @@ class basic_json
return m_type == value_t::string; return m_type == value_t::string;
} }
/*!
@brief return whether value is a binary array
This function returns true if and only if the JSON value is a binary array.
@return `true` if type is binary array, `false` otherwise.
@complexity Constant.
@exceptionsafety No-throw guarantee: this member function never throws
exceptions.
@liveexample{The following code exemplifies `is_binary()` for all JSON
types.,is_binary}
@since version 3.8.0
*/
constexpr bool is_binary() const noexcept
{
return m_type == value_t::binary;
}
/*! /*!
@brief return whether value is discarded @brief return whether value is discarded
...@@ -2508,6 +2781,18 @@ class basic_json ...@@ -2508,6 +2781,18 @@ class basic_json
return is_number_float() ? &m_value.number_float : nullptr; return is_number_float() ? &m_value.number_float : nullptr;
} }
/// get a pointer to the value (binary)
binary_t* get_impl_ptr(binary_t* /*unused*/) noexcept
{
return is_binary() ? m_value.binary : nullptr;
}
/// get a pointer to the value (binary)
constexpr const binary_t* get_impl_ptr(const binary_t* /*unused*/) const noexcept
{
return is_binary() ? m_value.binary : nullptr;
}
/*! /*!
@brief helper function to implement get_ref() @brief helper function to implement get_ref()
...@@ -2921,12 +3206,9 @@ class basic_json ...@@ -2921,12 +3206,9 @@ class basic_json
not std::is_same<ValueType, detail::json_ref<basic_json>>::value and not std::is_same<ValueType, detail::json_ref<basic_json>>::value and
not std::is_same<ValueType, typename string_t::value_type>::value and not std::is_same<ValueType, typename string_t::value_type>::value and
not detail::is_basic_json<ValueType>::value not detail::is_basic_json<ValueType>::value
#ifndef _MSC_VER // fix for issue #167 operator<< ambiguity under VS2015
and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) and _MSC_VER <= 1914)) #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) and _MSC_VER >= 1910 and _MSC_VER <= 1914))
and not std::is_same<ValueType, typename std::string_view>::value and not std::is_same<ValueType, typename std::string_view>::value
#endif
#endif #endif
and detail::is_detected<detail::get_template_function, const basic_json_t&, ValueType>::value and detail::is_detected<detail::get_template_function, const basic_json_t&, ValueType>::value
, int >::type = 0 > , int >::type = 0 >
...@@ -2936,6 +3218,36 @@ class basic_json ...@@ -2936,6 +3218,36 @@ class basic_json
return get<ValueType>(); return get<ValueType>();
} }
/*!
@return reference to the binary value
@throw type_error.302 if the value is not binary
@sa @ref is_binary() to check if the value is binary
@since version 3.8.0
*/
binary_t& get_binary()
{
if (not is_binary())
{
JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(type_name())));
}
return *get_ptr<binary_t*>();
}
/// @copydoc get_binary()
const binary_t& get_binary() const
{
if (not is_binary())
{
JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(type_name())));
}
return *get_ptr<const binary_t*>();
}
/// @} /// @}
...@@ -3456,7 +3768,8 @@ class basic_json ...@@ -3456,7 +3768,8 @@ class basic_json
@since version 1.0.0 @since version 1.0.0
*/ */
template<class ValueType, typename std::enable_if< template<class ValueType, typename std::enable_if<
std::is_convertible<basic_json_t, ValueType>::value, int>::type = 0> std::is_convertible<basic_json_t, ValueType>::value
and not std::is_same<value_t, ValueType>::value, int>::type = 0>
ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const
{ {
// at only works for objects // at only works for objects
...@@ -3565,8 +3878,8 @@ class basic_json ...@@ -3565,8 +3878,8 @@ class basic_json
container `c`, the expression `c.front()` is equivalent to `*c.begin()`. container `c`, the expression `c.front()` is equivalent to `*c.begin()`.
@return In case of a structured type (array or object), a reference to the @return In case of a structured type (array or object), a reference to the
first element is returned. In case of number, string, or boolean values, a first element is returned. In case of number, string, boolean, or binary
reference to the value is returned. values, a reference to the value is returned.
@complexity Constant. @complexity Constant.
...@@ -3608,8 +3921,8 @@ class basic_json ...@@ -3608,8 +3921,8 @@ class basic_json
@endcode @endcode
@return In case of a structured type (array or object), a reference to the @return In case of a structured type (array or object), a reference to the
last element is returned. In case of number, string, or boolean values, a last element is returned. In case of number, string, boolean, or binary
reference to the value is returned. values, a reference to the value is returned.
@complexity Constant. @complexity Constant.
...@@ -3675,7 +3988,7 @@ class basic_json ...@@ -3675,7 +3988,7 @@ class basic_json
@complexity The complexity depends on the type: @complexity The complexity depends on the type:
- objects: amortized constant - objects: amortized constant
- arrays: linear in distance between @a pos and the end of the container - arrays: linear in distance between @a pos and the end of the container
- strings: linear in the length of the string - strings and binary: linear in the length of the member
- other types: constant - other types: constant
@liveexample{The example shows the result of `erase()` for different JSON @liveexample{The example shows the result of `erase()` for different JSON
...@@ -3711,6 +4024,7 @@ class basic_json ...@@ -3711,6 +4024,7 @@ class basic_json
case value_t::number_integer: case value_t::number_integer:
case value_t::number_unsigned: case value_t::number_unsigned:
case value_t::string: case value_t::string:
case value_t::binary:
{ {
if (JSON_HEDLEY_UNLIKELY(not pos.m_it.primitive_iterator.is_begin())) if (JSON_HEDLEY_UNLIKELY(not pos.m_it.primitive_iterator.is_begin()))
{ {
...@@ -3724,6 +4038,13 @@ class basic_json ...@@ -3724,6 +4038,13 @@ class basic_json
std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1); std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1);
m_value.string = nullptr; m_value.string = nullptr;
} }
else if (is_binary())
{
AllocatorType<binary_t> alloc;
std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binary);
std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.binary, 1);
m_value.binary = nullptr;
}
m_type = value_t::null; m_type = value_t::null;
assert_invariant(); assert_invariant();
...@@ -3781,7 +4102,7 @@ class basic_json ...@@ -3781,7 +4102,7 @@ class basic_json
- objects: `log(size()) + std::distance(first, last)` - objects: `log(size()) + std::distance(first, last)`
- arrays: linear in the distance between @a first and @a last, plus linear - arrays: linear in the distance between @a first and @a last, plus linear
in the distance between @a last and end of the container in the distance between @a last and end of the container
- strings: linear in the length of the string - strings and binary: linear in the length of the member
- other types: constant - other types: constant
@liveexample{The example shows the result of `erase()` for different JSON @liveexample{The example shows the result of `erase()` for different JSON
...@@ -3816,6 +4137,7 @@ class basic_json ...@@ -3816,6 +4137,7 @@ class basic_json
case value_t::number_integer: case value_t::number_integer:
case value_t::number_unsigned: case value_t::number_unsigned:
case value_t::string: case value_t::string:
case value_t::binary:
{ {
if (JSON_HEDLEY_LIKELY(not first.m_it.primitive_iterator.is_begin() if (JSON_HEDLEY_LIKELY(not first.m_it.primitive_iterator.is_begin()
or not last.m_it.primitive_iterator.is_end())) or not last.m_it.primitive_iterator.is_end()))
...@@ -3830,6 +4152,13 @@ class basic_json ...@@ -3830,6 +4152,13 @@ class basic_json
std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1); std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1);
m_value.string = nullptr; m_value.string = nullptr;
} }
else if (is_binary())
{
AllocatorType<binary_t> alloc;
std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binary);
std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.binary, 1);
m_value.binary = nullptr;
}
m_type = value_t::null; m_type = value_t::null;
assert_invariant(); assert_invariant();
...@@ -4435,7 +4764,7 @@ class basic_json ...@@ -4435,7 +4764,7 @@ class basic_json
future 4.0.0 of the library. Please use @ref items() instead; future 4.0.0 of the library. Please use @ref items() instead;
that is, replace `json::iterator_wrapper(j)` with `j.items()`. that is, replace `json::iterator_wrapper(j)` with `j.items()`.
*/ */
JSON_HEDLEY_DEPRECATED(3.1.0) JSON_HEDLEY_DEPRECATED_FOR(3.1.0, items())
static iteration_proxy<iterator> iterator_wrapper(reference ref) noexcept static iteration_proxy<iterator> iterator_wrapper(reference ref) noexcept
{ {
return ref.items(); return ref.items();
...@@ -4444,7 +4773,7 @@ class basic_json ...@@ -4444,7 +4773,7 @@ class basic_json
/*! /*!
@copydoc iterator_wrapper(reference) @copydoc iterator_wrapper(reference)
*/ */
JSON_HEDLEY_DEPRECATED(3.1.0) JSON_HEDLEY_DEPRECATED_FOR(3.1.0, items())
static iteration_proxy<const_iterator> iterator_wrapper(const_reference ref) noexcept static iteration_proxy<const_iterator> iterator_wrapper(const_reference ref) noexcept
{ {
return ref.items(); return ref.items();
...@@ -4501,6 +4830,11 @@ class basic_json ...@@ -4501,6 +4830,11 @@ class basic_json
element as string (see example). For primitive types (e.g., numbers), element as string (see example). For primitive types (e.g., numbers),
`key()` returns an empty string. `key()` returns an empty string.
@warning Using `items()` on temporary objects is dangerous. Make sure the
object's lifetime exeeds the iteration. See
<https://github.com/nlohmann/json/issues/2040> for more
information.
@return iteration proxy object wrapping @a ref with an interface to use in @return iteration proxy object wrapping @a ref with an interface to use in
range-based for loops range-based for loops
...@@ -4549,6 +4883,7 @@ class basic_json ...@@ -4549,6 +4883,7 @@ class basic_json
boolean | `false` boolean | `false`
string | `false` string | `false`
number | `false` number | `false`
binary | `false`
object | result of function `object_t::empty()` object | result of function `object_t::empty()`
array | result of function `array_t::empty()` array | result of function `array_t::empty()`
...@@ -4620,6 +4955,7 @@ class basic_json ...@@ -4620,6 +4955,7 @@ class basic_json
boolean | `1` boolean | `1`
string | `1` string | `1`
number | `1` number | `1`
binary | `1`
object | result of function object_t::size() object | result of function object_t::size()
array | result of function array_t::size() array | result of function array_t::size()
...@@ -4694,6 +5030,7 @@ class basic_json ...@@ -4694,6 +5030,7 @@ class basic_json
boolean | `1` (same as `size()`) boolean | `1` (same as `size()`)
string | `1` (same as `size()`) string | `1` (same as `size()`)
number | `1` (same as `size()`) number | `1` (same as `size()`)
binary | `1` (same as `size()`)
object | result of function `object_t::max_size()` object | result of function `object_t::max_size()`
array | result of function `array_t::max_size()` array | result of function `array_t::max_size()`
...@@ -4766,6 +5103,7 @@ class basic_json ...@@ -4766,6 +5103,7 @@ class basic_json
boolean | `false` boolean | `false`
string | `""` string | `""`
number | `0` number | `0`
binary | An empty byte vector
object | `{}` object | `{}`
array | `[]` array | `[]`
...@@ -4823,6 +5161,12 @@ class basic_json ...@@ -4823,6 +5161,12 @@ class basic_json
break; break;
} }
case value_t::binary:
{
m_value.binary->clear();
break;
}
case value_t::array: case value_t::array:
{ {
m_value.array->clear(); m_value.array->clear();
...@@ -4878,9 +5222,7 @@ class basic_json ...@@ -4878,9 +5222,7 @@ class basic_json
// add element to array (move semantics) // add element to array (move semantics)
m_value.array->push_back(std::move(val)); m_value.array->push_back(std::move(val));
// invalidate object: mark it null so we do not call the destructor // if val is moved from, basic_json move constructor marks it null so we do not call the destructor
// cppcheck-suppress accessMoved
val.m_type = value_t::null;
} }
/*! /*!
...@@ -5619,6 +5961,53 @@ class basic_json ...@@ -5619,6 +5961,53 @@ class basic_json
} }
} }
/*!
@brief exchanges the values
Exchanges the contents of a JSON string with those of @a 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.
@param[in,out] other binary to exchange the contents with
@throw type_error.310 when JSON value is not a string; example: `"cannot
use swap() with boolean"`
@complexity Constant.
@liveexample{The example below shows how strings can be swapped with
`swap()`.,swap__binary_t}
@since version 3.8.0
*/
void swap(binary_t& other)
{
// swap only works for strings
if (JSON_HEDLEY_LIKELY(is_binary()))
{
std::swap(*(m_value.binary), other);
}
else
{
JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name())));
}
}
/// @copydoc swap(binary_t)
void swap(typename binary_t::container_type& other)
{
// swap only works for strings
if (JSON_HEDLEY_LIKELY(is_binary()))
{
std::swap(*(m_value.binary), other);
}
else
{
JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name())));
}
}
/// @} /// @}
public: public:
...@@ -5637,13 +6026,13 @@ class basic_json ...@@ -5637,13 +6026,13 @@ class basic_json
their stored values are the same according to their respective their stored values are the same according to their respective
`operator==`. `operator==`.
- Integer and floating-point numbers are automatically converted before - Integer and floating-point numbers are automatically converted before
comparison. Note than two NaN values are always treated as unequal. comparison. Note that two NaN values are always treated as unequal.
- Two JSON null values are equal. - Two JSON null values are equal.
@note Floating-point inside JSON values numbers are compared with @note Floating-point inside JSON values numbers are compared with
`json::number_float_t::operator==` which is `double::operator==` by `json::number_float_t::operator==` which is `double::operator==` by
default. To compare floating-point while respecting an epsilon, an alternative default. To compare floating-point while respecting an epsilon, an alternative
[comparison function](https://github.com/mariokonrad/marnav/blob/master/src/marnav/math/floatingpoint.hpp#L34-#L39) [comparison function](https://github.com/mariokonrad/marnav/blob/master/include/marnav/math/floatingpoint.hpp#L34-#L39)
could be used, for instance could be used, for instance
@code {.cpp} @code {.cpp}
template<typename T, typename = typename std::enable_if<std::is_floating_point<T>::value, T>::type> template<typename T, typename = typename std::enable_if<std::is_floating_point<T>::value, T>::type>
...@@ -5652,6 +6041,22 @@ class basic_json ...@@ -5652,6 +6041,22 @@ class basic_json
return std::abs(a - b) <= epsilon; return std::abs(a - b) <= epsilon;
} }
@endcode @endcode
Or you can self-defined operator equal function like this:
@code {.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<float>::epsilon();
// other cases remain the same with the original
...
}
...
}
@endcode
@note NaN values never compare equal to themselves or to other NaN values. @note NaN values never compare equal to themselves or to other NaN values.
...@@ -5701,6 +6106,9 @@ class basic_json ...@@ -5701,6 +6106,9 @@ class basic_json
case value_t::number_float: case value_t::number_float:
return lhs.m_value.number_float == rhs.m_value.number_float; return lhs.m_value.number_float == rhs.m_value.number_float;
case value_t::binary:
return *lhs.m_value.binary == *rhs.m_value.binary;
default: default:
return false; return false;
} }
...@@ -5861,6 +6269,9 @@ class basic_json ...@@ -5861,6 +6269,9 @@ class basic_json
case value_t::number_float: case value_t::number_float:
return (lhs.m_value.number_float) < (rhs.m_value.number_float); return (lhs.m_value.number_float) < (rhs.m_value.number_float);
case value_t::binary:
return (*lhs.m_value.binary) < (*rhs.m_value.binary);
default: default:
return false; return false;
} }
...@@ -6119,7 +6530,7 @@ class basic_json ...@@ -6119,7 +6530,7 @@ class basic_json
instead; that is, replace calls like `j >> o;` with `o << j;`. instead; that is, replace calls like `j >> o;` with `o << j;`.
@since version 1.0.0; deprecated since version 3.0.0 @since version 1.0.0; deprecated since version 3.0.0
*/ */
JSON_HEDLEY_DEPRECATED(3.0.0) JSON_HEDLEY_DEPRECATED_FOR(3.0.0, operator<<(std::ostream&, const basic_json&))
friend std::ostream& operator>>(const basic_json& j, std::ostream& o) friend std::ostream& operator>>(const basic_json& j, std::ostream& o)
{ {
return o << j; return o << j;
...@@ -6138,29 +6549,13 @@ class basic_json ...@@ -6138,29 +6549,13 @@ class basic_json
/*! /*!
@brief deserialize from a compatible input @brief deserialize from a compatible input
This function reads from a compatible input. Examples are: @tparam InputType A compatible input, for instance
- an array of 1-byte values - an std::istream object
- strings with character/literal type with size of 1 byte - a FILE pointer
- input streams - a C-style array of characters
- container with contiguous storage of 1-byte values. Compatible container - a pointer to a null-terminated string of single byte characters
types include `std::vector`, `std::string`, `std::array`, - an object obj for which begin(obj) and end(obj) produces a valid pair of
`std::valarray`, and `std::initializer_list`. Furthermore, C-style iterators.
arrays can be used with `std::begin()`/`std::end()`. User-defined
containers can be used as long as they implement random-access iterators
and a contiguous storage.
@pre Each element of the container has a size of 1 byte. Violating this
precondition yields undefined behavior. **This precondition is enforced
with a static assertion.**
@pre The container storage is contiguous. Violating this precondition
yields undefined behavior. **This precondition is enforced with an
assertion.**
@warning There is no way to enforce all preconditions at compile-time. If
the function is called with a noncompliant container and with
assertions switched off, the behavior is undefined and will most
likely yield segmentation violation.
@param[in] i input to read from @param[in] i input to read from
@param[in] cb a parser callback function of type @ref parser_callback_t @param[in] cb a parser callback function of type @ref parser_callback_t
...@@ -6180,7 +6575,7 @@ class basic_json ...@@ -6180,7 +6575,7 @@ class basic_json
@complexity Linear in the length of the input. The parser is a predictive @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 LL(1) parser. The complexity can be higher if the parser callback function
@a cb has a super-linear complexity. @a cb or reading from the input @a i has a super-linear complexity.
@note A UTF-8 byte order mark is silently ignored. @note A UTF-8 byte order mark is silently ignored.
...@@ -6198,19 +6593,107 @@ class basic_json ...@@ -6198,19 +6593,107 @@ class basic_json
@since version 2.0.3 (contiguous containers) @since version 2.0.3 (contiguous containers)
*/ */
template<typename InputType>
JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json parse(InputType&& i,
const parser_callback_t cb = nullptr,
const bool allow_exceptions = true)
{
basic_json result;
parser(detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions).parse(true, result);
return result;
}
/*!
@brief deserialize from a pair of character iterators
The value_type of the iterator must be a integral type with size of 1, 2 or
4 bytes, which will be interpreted respectively as UTF-8, UTF-16 and UTF-32.
@param[in] first iterator to start of character range
@param[in] last iterator to end of character range
@param[in] cb a parser callback function of type @ref parser_callback_t
which is used to control the deserialization by filtering unwanted values
(optional)
@param[in] allow_exceptions whether to throw exceptions in case of a
parse error (optional, true by default)
@return deserialized JSON value; in case of a parse error and
@a allow_exceptions set to `false`, the return value will be
value_t::discarded.
@throw parse_error.101 if a parse error occurs; example: `""unexpected end
of input; expected string literal""`
@throw parse_error.102 if to_unicode fails or surrogate error
@throw parse_error.103 if to_unicode fails
*/
template<typename IteratorType>
JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json parse(detail::input_adapter&& i, static basic_json parse(IteratorType first,
IteratorType last,
const parser_callback_t cb = nullptr, const parser_callback_t cb = nullptr,
const bool allow_exceptions = true) const bool allow_exceptions = true)
{ {
basic_json result; basic_json result;
parser(i, cb, allow_exceptions).parse(true, result); parser(detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions).parse(true, result);
return result; return result;
} }
static bool accept(detail::input_adapter&& i) JSON_HEDLEY_WARN_UNUSED_RESULT
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, parse(ptr, ptr + len))
static basic_json parse(detail::span_input_adapter&& i,
const parser_callback_t cb = nullptr,
const bool allow_exceptions = true)
{ {
return parser(i).accept(true); basic_json result;
parser(i.get(), cb, allow_exceptions).parse(true, result);
return result;
}
/*!
@brief check if the input is valid JSON
Unlike the @ref parse(InputType&&, const parser_callback_t,const bool)
function, this function neither throws an exception in case of invalid JSON
input (i.e., a parse error) nor creates diagnostic information.
@tparam 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.
@param[in] i input to read from
@return Whether the input read from @a i is valid JSON.
@complexity Linear in the length of the input. The parser is a predictive
LL(1) parser.
@note A UTF-8 byte order mark is silently ignored.
@liveexample{The example below demonstrates the `accept()` function reading
from a string.,accept__string}
*/
template<typename InputType>
static bool accept(InputType&& i)
{
return parser(detail::input_adapter(std::forward<InputType>(i))).accept(true);
}
template<typename IteratorType>
static bool accept(IteratorType first, IteratorType last)
{
return parser(detail::input_adapter(std::move(first), std::move(last))).accept(true);
}
JSON_HEDLEY_WARN_UNUSED_RESULT
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, accept(ptr, ptr + len))
static bool accept(detail::span_input_adapter&& i)
{
return parser(i.get()).accept(true);
} }
/*! /*!
...@@ -6219,28 +6702,12 @@ class basic_json ...@@ -6219,28 +6702,12 @@ class basic_json
The SAX event lister must follow the interface of @ref json_sax. The SAX event lister must follow the interface of @ref json_sax.
This function reads from a compatible input. Examples are: This function reads from a compatible input. Examples are:
- an array of 1-byte values - an std::istream object
- strings with character/literal type with size of 1 byte - a FILE pointer
- input streams - a C-style array of characters
- container with contiguous storage of 1-byte values. Compatible container - a pointer to a null-terminated string of single byte characters
types include `std::vector`, `std::string`, `std::array`, - an object obj for which begin(obj) and end(obj) produces a valid pair of
`std::valarray`, and `std::initializer_list`. Furthermore, C-style iterators.
arrays can be used with `std::begin()`/`std::end()`. User-defined
containers can be used as long as they implement random-access iterators
and a contiguous storage.
@pre Each element of the container has a size of 1 byte. Violating this
precondition yields undefined behavior. **This precondition is enforced
with a static assertion.**
@pre The container storage is contiguous. Violating this precondition
yields undefined behavior. **This precondition is enforced with an
assertion.**
@warning There is no way to enforce all preconditions at compile-time. If
the function is called with a noncompliant container and with
assertions switched off, the behavior is undefined and will most
likely yield segmentation violation.
@param[in] i input to read from @param[in] i input to read from
@param[in,out] sax SAX event listener @param[in,out] sax SAX event listener
...@@ -6266,97 +6733,41 @@ class basic_json ...@@ -6266,97 +6733,41 @@ class basic_json
@since version 3.2.0 @since version 3.2.0
*/ */
template <typename SAX> template <typename InputType, typename SAX>
JSON_HEDLEY_NON_NULL(2) JSON_HEDLEY_NON_NULL(2)
static bool sax_parse(detail::input_adapter&& i, SAX* sax, static bool sax_parse(InputType&& i, SAX* sax,
input_format_t format = input_format_t::json, input_format_t format = input_format_t::json,
const bool strict = true) const bool strict = true)
{ {
assert(sax); auto ia = detail::input_adapter(std::forward<InputType>(i));
return format == input_format_t::json return format == input_format_t::json
? parser(std::move(i)).sax_parse(sax, strict) ? parser(std::move(ia)).sax_parse(sax, strict)
: detail::binary_reader<basic_json, SAX>(std::move(i)).sax_parse(format, sax, strict); : detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia)).sax_parse(format, sax, strict);
}
/*!
@brief deserialize from an iterator range with contiguous storage
This function reads from an iterator range of a container with contiguous
storage of 1-byte values. Compatible container types include
`std::vector`, `std::string`, `std::array`, `std::valarray`, and
`std::initializer_list`. Furthermore, C-style arrays can be used with
`std::begin()`/`std::end()`. User-defined containers can be used as long
as they implement random-access iterators and a contiguous storage.
@pre The iterator range is contiguous. Violating this precondition yields
undefined behavior. **This precondition is enforced with an assertion.**
@pre Each element in the range has a size of 1 byte. Violating this
precondition yields undefined behavior. **This precondition is enforced
with a static assertion.**
@warning There is no way to enforce all preconditions at compile-time. If
the function is called with noncompliant iterators and with
assertions switched off, the behavior is undefined and will most
likely yield segmentation violation.
@tparam IteratorType iterator of container with contiguous storage
@param[in] first begin of the range to parse (included)
@param[in] last end of the range to parse (excluded)
@param[in] cb a parser callback function of type @ref parser_callback_t
which is used to control the deserialization by filtering unwanted values
(optional)
@param[in] allow_exceptions whether to throw exceptions in case of a
parse error (optional, true by default)
@return deserialized JSON value; in case of a parse error and
@a allow_exceptions set to `false`, the return value will be
value_t::discarded.
@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
@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
@a cb has a super-linear complexity.
@note A UTF-8 byte order mark is silently ignored.
@liveexample{The example below demonstrates the `parse()` function reading
from an iterator range.,parse__iteratortype__parser_callback_t}
@since version 2.0.3
*/
template<class IteratorType, typename std::enable_if<
std::is_base_of<
std::random_access_iterator_tag,
typename std::iterator_traits<IteratorType>::iterator_category>::value, int>::type = 0>
static basic_json parse(IteratorType first, IteratorType last,
const parser_callback_t cb = nullptr,
const bool allow_exceptions = true)
{
basic_json result;
parser(detail::input_adapter(first, last), cb, allow_exceptions).parse(true, result);
return result;
} }
template<class IteratorType, typename std::enable_if< template<class IteratorType, class SAX>
std::is_base_of< JSON_HEDLEY_NON_NULL(3)
std::random_access_iterator_tag, static bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
typename std::iterator_traits<IteratorType>::iterator_category>::value, int>::type = 0> input_format_t format = input_format_t::json,
static bool accept(IteratorType first, IteratorType last) const bool strict = true)
{ {
return parser(detail::input_adapter(first, last)).accept(true); auto ia = detail::input_adapter(std::move(first), std::move(last));
return format == input_format_t::json
? parser(std::move(ia)).sax_parse(sax, strict)
: detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia)).sax_parse(format, sax, strict);
} }
template<class IteratorType, class SAX, typename std::enable_if< template <typename SAX>
std::is_base_of< JSON_HEDLEY_DEPRECATED_FOR(3.8.0, sax_parse(ptr, ptr + len, ...))
std::random_access_iterator_tag, JSON_HEDLEY_NON_NULL(2)
typename std::iterator_traits<IteratorType>::iterator_category>::value, int>::type = 0> static bool sax_parse(detail::span_input_adapter&& i, SAX* sax,
JSON_HEDLEY_NON_NULL(3) input_format_t format = input_format_t::json,
static bool sax_parse(IteratorType first, IteratorType last, SAX* sax) const bool strict = true)
{ {
return parser(detail::input_adapter(first, last)).sax_parse(sax); auto ia = i.get();
return format == input_format_t::json
? parser(std::move(ia)).sax_parse(sax, strict)
: detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia)).sax_parse(format, sax, strict);
} }
/*! /*!
...@@ -6367,7 +6778,7 @@ class basic_json ...@@ -6367,7 +6778,7 @@ class basic_json
instead; that is, replace calls like `j << i;` with `i >> j;`. instead; that is, replace calls like `j << i;` with `i >> j;`.
@since version 1.0.0; deprecated since version 3.0.0 @since version 1.0.0; deprecated since version 3.0.0
*/ */
JSON_HEDLEY_DEPRECATED(3.0.0) JSON_HEDLEY_DEPRECATED_FOR(3.0.0, operator>>(std::istream&, basic_json&))
friend std::istream& operator<<(basic_json& j, std::istream& i) friend std::istream& operator<<(basic_json& j, std::istream& i)
{ {
return operator>>(i, j); return operator>>(i, j);
...@@ -6425,6 +6836,7 @@ class basic_json ...@@ -6425,6 +6836,7 @@ class basic_json
number | `"number"` (for all number types) number | `"number"` (for all number types)
object | `"object"` object | `"object"`
array | `"array"` array | `"array"`
binary | `"binary"`
discarded | `"discarded"` discarded | `"discarded"`
@exceptionsafety No-throw guarantee: this function never throws exceptions. @exceptionsafety No-throw guarantee: this function never throws exceptions.
...@@ -6456,6 +6868,8 @@ class basic_json ...@@ -6456,6 +6868,8 @@ class basic_json
return "string"; return "string";
case value_t::boolean: case value_t::boolean:
return "boolean"; return "boolean";
case value_t::binary:
return "binary";
case value_t::discarded: case value_t::discarded:
return "discarded"; return "discarded";
default: default:
...@@ -6515,7 +6929,8 @@ class basic_json ...@@ -6515,7 +6929,8 @@ class basic_json
number_unsigned | 256..65535 | Unsigned integer (2 bytes follow) | 0x19 number_unsigned | 256..65535 | Unsigned integer (2 bytes follow) | 0x19
number_unsigned | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A number_unsigned | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A
number_unsigned | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B number_unsigned | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B
number_float | *any value* | Double-Precision Float | 0xFB 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*: 0..23 | UTF-8 string | 0x60..0x77
string | *length*: 23..255 | UTF-8 string (1 byte follow) | 0x78 string | *length*: 23..255 | UTF-8 string (1 byte follow) | 0x78
string | *length*: 256..65535 | UTF-8 string (2 bytes follow) | 0x79 string | *length*: 256..65535 | UTF-8 string (2 bytes follow) | 0x79
...@@ -6531,6 +6946,11 @@ class basic_json ...@@ -6531,6 +6946,11 @@ class basic_json
object | *size*: 256..65535 | map (2 bytes follow) | 0xB9 object | *size*: 256..65535 | map (2 bytes follow) | 0xB9
object | *size*: 65536..4294967295 | map (4 bytes follow) | 0xBA object | *size*: 65536..4294967295 | map (4 bytes follow) | 0xBA
object | *size*: 4294967296..18446744073709551615 | map (8 bytes follow) | 0xBB 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
@note The mapping is **complete** in the sense that any JSON value type @note The mapping is **complete** in the sense that any JSON value type
can be converted to a CBOR value. can be converted to a CBOR value.
...@@ -6540,10 +6960,10 @@ class basic_json ...@@ -6540,10 +6960,10 @@ class basic_json
function which serializes NaN or Infinity to `null`. function which serializes NaN or Infinity to `null`.
@note The following CBOR types are not used in the conversion: @note The following CBOR types are not used in the conversion:
- byte strings (0x40..0x5F)
- UTF-8 strings terminated by "break" (0x7F) - UTF-8 strings terminated by "break" (0x7F)
- arrays terminated by "break" (0x9F) - arrays terminated by "break" (0x9F)
- maps terminated by "break" (0xBF) - maps terminated by "break" (0xBF)
- byte strings terminated by "break" (0x5F)
- date/time (0xC0..0xC1) - date/time (0xC0..0xC1)
- bignum (0xC2..0xC3) - bignum (0xC2..0xC3)
- decimal fraction (0xC4) - decimal fraction (0xC4)
...@@ -6552,11 +6972,11 @@ class basic_json ...@@ -6552,11 +6972,11 @@ class basic_json
- expected conversions (0xD5..0xD7) - expected conversions (0xD5..0xD7)
- simple values (0xE0..0xF3, 0xF8) - simple values (0xE0..0xF3, 0xF8)
- undefined (0xF7) - undefined (0xF7)
- half and single-precision floats (0xF9-0xFA) - half-precision floats (0xF9)
- break (0xFF) - break (0xFF)
@param[in] j JSON value to serialize @param[in] j JSON value to serialize
@return MessagePack serialization as byte vector @return CBOR serialization as byte vector
@complexity Linear in the size of the JSON value @a j. @complexity Linear in the size of the JSON value @a j.
...@@ -6570,7 +6990,8 @@ class basic_json ...@@ -6570,7 +6990,8 @@ class basic_json
@sa @ref to_ubjson(const basic_json&, const bool, const bool) for the @sa @ref to_ubjson(const basic_json&, const bool, const bool) for the
related UBJSON format related UBJSON format
@since version 2.0.9 @since version 2.0.9; compact representation of floating-point numbers
since version 3.8.0
*/ */
static std::vector<uint8_t> to_cbor(const basic_json& j) static std::vector<uint8_t> to_cbor(const basic_json& j)
{ {
...@@ -6630,20 +7051,21 @@ class basic_json ...@@ -6630,20 +7051,21 @@ class basic_json
object | *size*: 0..15 | fix map | 0x80..0x8F object | *size*: 0..15 | fix map | 0x80..0x8F
object | *size*: 16..65535 | map 16 | 0xDE object | *size*: 16..65535 | map 16 | 0xDE
object | *size*: 65536..4294967295 | map 32 | 0xDF 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
@note The mapping is **complete** in the sense that any JSON value type @note The mapping is **complete** in the sense that any JSON value type
can be converted to a MessagePack value. can be converted to a MessagePack value.
@note The following values can **not** be converted to a MessagePack value: @note The following values can **not** be converted to a MessagePack value:
- strings with more than 4294967295 bytes - strings with more than 4294967295 bytes
- byte strings with more than 4294967295 bytes
- arrays with more than 4294967295 elements - arrays with more than 4294967295 elements
- objects with more than 4294967295 elements - objects with more than 4294967295 elements
@note The following MessagePack types are not used in the conversion: @note The following MessagePack types are not used in the conversion:
- bin 8 - bin 32 (0xC4..0xC6)
- ext 8 - ext 32 (0xC7..0xC9)
- float 32 (0xCA) - float 32 (0xCA)
- fixext 1 - fixext 16 (0xD4..0xD8)
@note Any MessagePack output created @ref to_msgpack can be successfully @note Any MessagePack output created @ref to_msgpack can be successfully
parsed by @ref from_msgpack. parsed by @ref from_msgpack.
...@@ -6746,6 +7168,12 @@ class basic_json ...@@ -6746,6 +7168,12 @@ class basic_json
the benefit of this parameter is that the receiving side is the benefit of this parameter is that the receiving side is
immediately informed on the number of elements of the container. immediately informed on the number of elements of the container.
@note 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.
@param[in] j JSON value to serialize @param[in] j JSON value to serialize
@param[in] use_size whether to add size annotations to container types @param[in] use_size whether to add size annotations to container types
@param[in] use_type whether to add type annotations to container types @param[in] use_type whether to add type annotations to container types
...@@ -6810,6 +7238,7 @@ class basic_json ...@@ -6810,6 +7238,7 @@ class basic_json
string | *any value* | string | 0x02 string | *any value* | string | 0x02
array | *any value* | document | 0x04 array | *any value* | document | 0x04
object | *any value* | document | 0x03 object | *any value* | document | 0x03
binary | *any value* | binary | 0x05
@warning The mapping is **incomplete**, since only JSON-objects (and things @warning The mapping is **incomplete**, since only JSON-objects (and things
contained therein) can be serialized to BSON. contained therein) can be serialized to BSON.
...@@ -6891,7 +7320,11 @@ class basic_json ...@@ -6891,7 +7320,11 @@ class basic_json
Negative integer | number_integer | 0x39 Negative integer | number_integer | 0x39
Negative integer | number_integer | 0x3A Negative integer | number_integer | 0x3A
Negative integer | number_integer | 0x3B Negative integer | number_integer | 0x3B
Negative integer | number_integer | 0x40..0x57 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 | 0x60..0x77
UTF-8 string | string | 0x78 UTF-8 string | string | 0x78
UTF-8 string | string | 0x79 UTF-8 string | string | 0x79
...@@ -6920,7 +7353,6 @@ class basic_json ...@@ -6920,7 +7353,6 @@ class basic_json
@warning The mapping is **incomplete** in the sense that not all CBOR @warning The mapping is **incomplete** in the sense that not all CBOR
types can be converted to a JSON value. The following CBOR types types can be converted to a JSON value. The following CBOR types
are not supported and will yield parse errors (parse_error.112): are not supported and will yield parse errors (parse_error.112):
- byte strings (0x40..0x5F)
- date/time (0xC0..0xC1) - date/time (0xC0..0xC1)
- bignum (0xC2..0xC3) - bignum (0xC2..0xC3)
- decimal fraction (0xC4) - decimal fraction (0xC4)
...@@ -6970,30 +7402,56 @@ class basic_json ...@@ -6970,30 +7402,56 @@ class basic_json
@a strict parameter since 3.0.0; added @a allow_exceptions parameter @a strict parameter since 3.0.0; added @a allow_exceptions parameter
since 3.2.0 since 3.2.0
*/ */
template<typename InputType>
JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json from_cbor(detail::input_adapter&& i, static basic_json from_cbor(InputType&& i,
const bool strict = true, const bool strict = true,
const bool allow_exceptions = true) const bool allow_exceptions = true)
{ {
basic_json result; basic_json result;
detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions); detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
const bool res = binary_reader(detail::input_adapter(i)).sax_parse(input_format_t::cbor, &sdp, strict); auto ia = detail::input_adapter(std::forward<InputType>(i));
const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict);
return res ? result : basic_json(value_t::discarded); return res ? result : basic_json(value_t::discarded);
} }
/*! /*!
@copydoc from_cbor(detail::input_adapter&&, const bool, const bool) @copydoc from_cbor(detail::input_adapter&&, const bool, const bool)
*/ */
template<typename A1, typename A2, template<typename IteratorType>
detail::enable_if_t<std::is_constructible<detail::input_adapter, A1, A2>::value, int> = 0>
JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json from_cbor(A1 && a1, A2 && a2, static basic_json from_cbor(IteratorType first, IteratorType last,
const bool strict = true, const bool strict = true,
const bool allow_exceptions = true) const bool allow_exceptions = true)
{ {
basic_json result; basic_json result;
detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions); detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
const bool res = binary_reader(detail::input_adapter(std::forward<A1>(a1), std::forward<A2>(a2))).sax_parse(input_format_t::cbor, &sdp, strict); auto ia = detail::input_adapter(std::move(first), std::move(last));
const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict);
return res ? result : basic_json(value_t::discarded);
}
template<typename T>
JSON_HEDLEY_WARN_UNUSED_RESULT
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len))
static basic_json from_cbor(const T* ptr, std::size_t len,
const bool strict = true,
const bool allow_exceptions = true)
{
return from_cbor(ptr, ptr + len, strict, allow_exceptions);
}
JSON_HEDLEY_WARN_UNUSED_RESULT
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len))
static basic_json from_cbor(detail::span_input_adapter&& i,
const bool strict = true,
const bool allow_exceptions = true)
{
basic_json result;
detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
auto ia = i.get();
const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict);
return res ? result : basic_json(value_t::discarded); return res ? result : basic_json(value_t::discarded);
} }
...@@ -7031,15 +7489,19 @@ class basic_json ...@@ -7031,15 +7489,19 @@ class basic_json
array 32 | array | 0xDD array 32 | array | 0xDD
map 16 | object | 0xDE map 16 | object | 0xDE
map 32 | object | 0xDF 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 negative fixint | number_integer | 0xE0-0xFF
@warning The mapping is **incomplete** in the sense that not all
MessagePack types can be converted to a JSON value. The following
MessagePack types are not supported and will yield parse errors:
- bin 8 - bin 32 (0xC4..0xC6)
- ext 8 - ext 32 (0xC7..0xC9)
- fixext 1 - fixext 16 (0xD4..0xD8)
@note Any MessagePack output created @ref to_msgpack can be successfully @note Any MessagePack output created @ref to_msgpack can be successfully
parsed by @ref from_msgpack. parsed by @ref from_msgpack.
...@@ -7079,33 +7541,60 @@ class basic_json ...@@ -7079,33 +7541,60 @@ class basic_json
@a strict parameter since 3.0.0; added @a allow_exceptions parameter @a strict parameter since 3.0.0; added @a allow_exceptions parameter
since 3.2.0 since 3.2.0
*/ */
template<typename InputType>
JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json from_msgpack(detail::input_adapter&& i, static basic_json from_msgpack(InputType&& i,
const bool strict = true, const bool strict = true,
const bool allow_exceptions = true) const bool allow_exceptions = true)
{ {
basic_json result; basic_json result;
detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions); detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
const bool res = binary_reader(detail::input_adapter(i)).sax_parse(input_format_t::msgpack, &sdp, strict); auto ia = detail::input_adapter(std::forward<InputType>(i));
const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict);
return res ? result : basic_json(value_t::discarded); return res ? result : basic_json(value_t::discarded);
} }
/*! /*!
@copydoc from_msgpack(detail::input_adapter&&, const bool, const bool) @copydoc from_msgpack(detail::input_adapter&&, const bool, const bool)
*/ */
template<typename A1, typename A2, template<typename IteratorType>
detail::enable_if_t<std::is_constructible<detail::input_adapter, A1, A2>::value, int> = 0>
JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json from_msgpack(A1 && a1, A2 && a2, static basic_json from_msgpack(IteratorType first, IteratorType last,
const bool strict = true, const bool strict = true,
const bool allow_exceptions = true) const bool allow_exceptions = true)
{ {
basic_json result; basic_json result;
detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions); detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
const bool res = binary_reader(detail::input_adapter(std::forward<A1>(a1), std::forward<A2>(a2))).sax_parse(input_format_t::msgpack, &sdp, strict); auto ia = detail::input_adapter(std::move(first), std::move(last));
const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict);
return res ? result : basic_json(value_t::discarded); return res ? result : basic_json(value_t::discarded);
} }
template<typename T>
JSON_HEDLEY_WARN_UNUSED_RESULT
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len))
static basic_json from_msgpack(const T* ptr, std::size_t len,
const bool strict = true,
const bool allow_exceptions = true)
{
return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
}
JSON_HEDLEY_WARN_UNUSED_RESULT
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len))
static basic_json from_msgpack(detail::span_input_adapter&& i,
const bool strict = true,
const bool allow_exceptions = true)
{
basic_json result;
detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
auto ia = i.get();
const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict);
return res ? result : basic_json(value_t::discarded);
}
/*! /*!
@brief create a JSON value from an input in UBJSON format @brief create a JSON value from an input in UBJSON format
...@@ -7167,33 +7656,59 @@ class basic_json ...@@ -7167,33 +7656,59 @@ class basic_json
@since version 3.1.0; added @a allow_exceptions parameter since 3.2.0 @since version 3.1.0; added @a allow_exceptions parameter since 3.2.0
*/ */
template<typename InputType>
JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json from_ubjson(detail::input_adapter&& i, static basic_json from_ubjson(InputType&& i,
const bool strict = true, const bool strict = true,
const bool allow_exceptions = true) const bool allow_exceptions = true)
{ {
basic_json result; basic_json result;
detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions); detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
const bool res = binary_reader(detail::input_adapter(i)).sax_parse(input_format_t::ubjson, &sdp, strict); auto ia = detail::input_adapter(std::forward<InputType>(i));
const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict);
return res ? result : basic_json(value_t::discarded); return res ? result : basic_json(value_t::discarded);
} }
/*! /*!
@copydoc from_ubjson(detail::input_adapter&&, const bool, const bool) @copydoc from_ubjson(detail::input_adapter&&, const bool, const bool)
*/ */
template<typename A1, typename A2, template<typename IteratorType>
detail::enable_if_t<std::is_constructible<detail::input_adapter, A1, A2>::value, int> = 0>
JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json from_ubjson(A1 && a1, A2 && a2, static basic_json from_ubjson(IteratorType first, IteratorType last,
const bool strict = true, const bool strict = true,
const bool allow_exceptions = true) const bool allow_exceptions = true)
{ {
basic_json result; basic_json result;
detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions); detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
const bool res = binary_reader(detail::input_adapter(std::forward<A1>(a1), std::forward<A2>(a2))).sax_parse(input_format_t::ubjson, &sdp, strict); auto ia = detail::input_adapter(std::move(first), std::move(last));
const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict);
return res ? result : basic_json(value_t::discarded); return res ? result : basic_json(value_t::discarded);
} }
template<typename T>
JSON_HEDLEY_WARN_UNUSED_RESULT
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len))
static basic_json from_ubjson(const T* ptr, std::size_t len,
const bool strict = true,
const bool allow_exceptions = true)
{
return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
}
JSON_HEDLEY_WARN_UNUSED_RESULT
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len))
static basic_json from_ubjson(detail::span_input_adapter&& i,
const bool strict = true,
const bool allow_exceptions = true)
{
basic_json result;
detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
auto ia = i.get();
const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict);
return res ? result : basic_json(value_t::discarded);
}
/*! /*!
@brief Create a JSON value from an input in BSON format @brief Create a JSON value from an input in BSON format
...@@ -7254,35 +7769,57 @@ class basic_json ...@@ -7254,35 +7769,57 @@ class basic_json
@sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the
related UBJSON format related UBJSON format
*/ */
template<typename InputType>
JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json from_bson(detail::input_adapter&& i, static basic_json from_bson(InputType&& i,
const bool strict = true, const bool strict = true,
const bool allow_exceptions = true) const bool allow_exceptions = true)
{ {
basic_json result; basic_json result;
detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions); detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
const bool res = binary_reader(detail::input_adapter(i)).sax_parse(input_format_t::bson, &sdp, strict); auto ia = detail::input_adapter(std::forward<InputType>(i));
const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict);
return res ? result : basic_json(value_t::discarded); return res ? result : basic_json(value_t::discarded);
} }
/*! /*!
@copydoc from_bson(detail::input_adapter&&, const bool, const bool) @copydoc from_bson(detail::input_adapter&&, const bool, const bool)
*/ */
template<typename A1, typename A2, template<typename IteratorType>
detail::enable_if_t<std::is_constructible<detail::input_adapter, A1, A2>::value, int> = 0>
JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json from_bson(A1 && a1, A2 && a2, static basic_json from_bson(IteratorType first, IteratorType last,
const bool strict = true, const bool strict = true,
const bool allow_exceptions = true) const bool allow_exceptions = true)
{ {
basic_json result; basic_json result;
detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions); detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
const bool res = binary_reader(detail::input_adapter(std::forward<A1>(a1), std::forward<A2>(a2))).sax_parse(input_format_t::bson, &sdp, strict); auto ia = detail::input_adapter(std::move(first), std::move(last));
const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict);
return res ? result : basic_json(value_t::discarded); return res ? result : basic_json(value_t::discarded);
} }
template<typename T>
JSON_HEDLEY_WARN_UNUSED_RESULT
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len))
static basic_json from_bson(const T* ptr, std::size_t len,
const bool strict = true,
const bool allow_exceptions = true)
{
return from_bson(ptr, ptr + len, strict, allow_exceptions);
}
JSON_HEDLEY_WARN_UNUSED_RESULT
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len))
static basic_json from_bson(detail::span_input_adapter&& i,
const bool strict = true,
const bool allow_exceptions = true)
{
basic_json result;
detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
auto ia = i.get();
const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict);
return res ? result : basic_json(value_t::discarded);
}
/// @} /// @}
////////////////////////// //////////////////////////
...@@ -7335,7 +7872,7 @@ class basic_json ...@@ -7335,7 +7872,7 @@ class basic_json
Uses a JSON pointer to retrieve a reference to the respective JSON value. Uses a JSON pointer to retrieve a reference to the respective JSON value.
No bound checking is performed. The function does not change the JSON No bound checking is performed. The function does not change the JSON
value; no `null` values are created. In particular, the the special value value; no `null` values are created. In particular, the special value
`-` yields an exception. `-` yields an exception.
@param[in] ptr JSON pointer to the desired element @param[in] ptr JSON pointer to the desired element
...@@ -7919,7 +8456,7 @@ class basic_json ...@@ -7919,7 +8456,7 @@ class basic_json
result.push_back( result.push_back(
{ {
{"op", "add"}, {"op", "add"},
{"path", path + "/" + std::to_string(i)}, {"path", path + "/-"},
{"value", target[i]} {"value", target[i]}
}); });
++i; ++i;
......
...@@ -33,7 +33,8 @@ template<template<typename U, typename V, typename... Args> class ObjectType = ...@@ -33,7 +33,8 @@ template<template<typename U, typename V, typename... Args> class ObjectType =
class NumberFloatType = double, class NumberFloatType = double,
template<typename U> class AllocatorType = std::allocator, template<typename U> class AllocatorType = std::allocator,
template<typename T, typename SFINAE = void> class JSONSerializer = template<typename T, typename SFINAE = void> class JSONSerializer =
adl_serializer> adl_serializer,
class BinaryType = std::vector<std::uint8_t>>
class basic_json; class basic_json;
/*! /*!
......
...@@ -10,11 +10,11 @@ ...@@ -10,11 +10,11 @@
* SPDX-License-Identifier: CC0-1.0 * SPDX-License-Identifier: CC0-1.0
*/ */
#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 11) #if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 13)
#if defined(JSON_HEDLEY_VERSION) #if defined(JSON_HEDLEY_VERSION)
#undef JSON_HEDLEY_VERSION #undef JSON_HEDLEY_VERSION
#endif #endif
#define JSON_HEDLEY_VERSION 11 #define JSON_HEDLEY_VERSION 13
#if defined(JSON_HEDLEY_STRINGIFY_EX) #if defined(JSON_HEDLEY_STRINGIFY_EX)
#undef JSON_HEDLEY_STRINGIFY_EX #undef JSON_HEDLEY_STRINGIFY_EX
...@@ -36,6 +36,16 @@ ...@@ -36,6 +36,16 @@
#endif #endif
#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b) #define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
#if defined(JSON_HEDLEY_CONCAT3_EX)
#undef JSON_HEDLEY_CONCAT3_EX
#endif
#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
#if defined(JSON_HEDLEY_CONCAT3)
#undef JSON_HEDLEY_CONCAT3
#endif
#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
#if defined(JSON_HEDLEY_VERSION_ENCODE) #if defined(JSON_HEDLEY_VERSION_ENCODE)
#undef JSON_HEDLEY_VERSION_ENCODE #undef JSON_HEDLEY_VERSION_ENCODE
#endif #endif
...@@ -211,9 +221,17 @@ ...@@ -211,9 +221,17 @@
#if defined(JSON_HEDLEY_TI_VERSION) #if defined(JSON_HEDLEY_TI_VERSION)
#undef JSON_HEDLEY_TI_VERSION #undef JSON_HEDLEY_TI_VERSION
#endif #endif
#if defined(__TI_COMPILER_VERSION__) #if \
defined(__TI_COMPILER_VERSION__) && \
( \
defined(__TMS470__) || defined(__TI_ARM__) || \
defined(__MSP430__) || \
defined(__TMS320C2000__) \
)
#if (__TI_COMPILER_VERSION__ >= 16000000)
#define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
#endif #endif
#endif
#if defined(JSON_HEDLEY_TI_VERSION_CHECK) #if defined(JSON_HEDLEY_TI_VERSION_CHECK)
#undef JSON_HEDLEY_TI_VERSION_CHECK #undef JSON_HEDLEY_TI_VERSION_CHECK
...@@ -224,6 +242,102 @@ ...@@ -224,6 +242,102 @@
#define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
#endif #endif
#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
#undef JSON_HEDLEY_TI_CL2000_VERSION
#endif
#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
#define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
#endif
#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
#endif
#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
#define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
#else
#define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
#endif
#if defined(JSON_HEDLEY_TI_CL430_VERSION)
#undef JSON_HEDLEY_TI_CL430_VERSION
#endif
#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
#define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
#endif
#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
#endif
#if defined(JSON_HEDLEY_TI_CL430_VERSION)
#define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
#else
#define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
#endif
#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
#undef JSON_HEDLEY_TI_ARMCL_VERSION
#endif
#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
#define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
#endif
#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
#endif
#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
#define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
#else
#define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
#endif
#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
#undef JSON_HEDLEY_TI_CL6X_VERSION
#endif
#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
#define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
#endif
#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
#endif
#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
#define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
#else
#define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
#endif
#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
#undef JSON_HEDLEY_TI_CL7X_VERSION
#endif
#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
#define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
#endif
#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
#endif
#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
#define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
#else
#define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
#endif
#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
#undef JSON_HEDLEY_TI_CLPRU_VERSION
#endif
#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
#define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
#endif
#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
#endif
#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
#define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
#else
#define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
#endif
#if defined(JSON_HEDLEY_CRAY_VERSION) #if defined(JSON_HEDLEY_CRAY_VERSION)
#undef JSON_HEDLEY_CRAY_VERSION #undef JSON_HEDLEY_CRAY_VERSION
#endif #endif
...@@ -338,6 +452,12 @@ ...@@ -338,6 +452,12 @@
!defined(JSON_HEDLEY_PGI_VERSION) && \ !defined(JSON_HEDLEY_PGI_VERSION) && \
!defined(JSON_HEDLEY_ARM_VERSION) && \ !defined(JSON_HEDLEY_ARM_VERSION) && \
!defined(JSON_HEDLEY_TI_VERSION) && \ !defined(JSON_HEDLEY_TI_VERSION) && \
!defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
!defined(JSON_HEDLEY_TI_CL430_VERSION) && \
!defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
!defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
!defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
!defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
!defined(__COMPCERT__) !defined(__COMPCERT__)
#define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
#endif #endif
...@@ -397,6 +517,7 @@ ...@@ -397,6 +517,7 @@
#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
#elif \ #elif \
!defined(JSON_HEDLEY_PGI_VERSION) && \ !defined(JSON_HEDLEY_PGI_VERSION) && \
!defined(JSON_HEDLEY_IAR_VERSION) && \
(!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
(!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0)) (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute) #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
...@@ -562,14 +683,85 @@ ...@@ -562,14 +683,85 @@
#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
#endif #endif
#if defined(__cplusplus) && JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") #if defined(__cplusplus)
# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ # if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
JSON_HEDLEY_DIAGNOSTIC_PUSH \
_Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
_Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
xpr \
JSON_HEDLEY_DIAGNOSTIC_POP
# else
# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
JSON_HEDLEY_DIAGNOSTIC_PUSH \ JSON_HEDLEY_DIAGNOSTIC_PUSH \
_Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
xpr \ xpr \
JSON_HEDLEY_DIAGNOSTIC_POP JSON_HEDLEY_DIAGNOSTIC_POP
# endif
# endif
#endif
#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
#endif
#if defined(JSON_HEDLEY_CONST_CAST)
#undef JSON_HEDLEY_CONST_CAST
#endif
#if defined(__cplusplus)
# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
#elif \
JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
JSON_HEDLEY_DIAGNOSTIC_PUSH \
JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
((T) (expr)); \
JSON_HEDLEY_DIAGNOSTIC_POP \
}))
#else
# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
#endif
#if defined(JSON_HEDLEY_REINTERPRET_CAST)
#undef JSON_HEDLEY_REINTERPRET_CAST
#endif
#if defined(__cplusplus)
#define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
#else
#define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
#endif
#if defined(JSON_HEDLEY_STATIC_CAST)
#undef JSON_HEDLEY_STATIC_CAST
#endif
#if defined(__cplusplus)
#define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
#else
#define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
#endif
#if defined(JSON_HEDLEY_CPP_CAST)
#undef JSON_HEDLEY_CPP_CAST
#endif
#if defined(__cplusplus)
# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
# define JSON_HEDLEY_CPP_CAST(T, expr) \
JSON_HEDLEY_DIAGNOSTIC_PUSH \
_Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
((T) (expr)) \
JSON_HEDLEY_DIAGNOSTIC_POP
# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
# define JSON_HEDLEY_CPP_CAST(T, expr) \
JSON_HEDLEY_DIAGNOSTIC_PUSH \
_Pragma("diag_suppress=Pe137") \
JSON_HEDLEY_DIAGNOSTIC_POP \
# else
# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
# endif
#else #else
# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x # define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
#endif #endif
#if \ #if \
...@@ -580,7 +772,13 @@ ...@@ -580,7 +772,13 @@
JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) || \ JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
...@@ -613,7 +811,13 @@ ...@@ -613,7 +811,13 @@
#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) #elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
#elif JSON_HEDLEY_TI_VERSION_CHECK(8,1,0) #elif \
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
...@@ -637,7 +841,18 @@ ...@@ -637,7 +841,18 @@
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
#elif JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) #elif \
JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
...@@ -664,7 +879,13 @@ ...@@ -664,7 +879,13 @@
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
#elif JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) #elif \
JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
...@@ -687,8 +908,13 @@ ...@@ -687,8 +908,13 @@
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus) #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)") #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
#elif JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) #elif \
JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
#else #else
#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
#endif #endif
...@@ -712,7 +938,10 @@ ...@@ -712,7 +938,10 @@
#if defined(JSON_HEDLEY_DEPRECATED_FOR) #if defined(JSON_HEDLEY_DEPRECATED_FOR)
#undef JSON_HEDLEY_DEPRECATED_FOR #undef JSON_HEDLEY_DEPRECATED_FOR
#endif #endif
#if defined(__cplusplus) && (__cplusplus >= 201402L) #if JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0)
#define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
#elif defined(__cplusplus) && (__cplusplus >= 201402L)
#define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
#elif \ #elif \
...@@ -722,20 +951,30 @@ ...@@ -722,20 +951,30 @@
JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
JSON_HEDLEY_TI_VERSION_CHECK(8,3,0) JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
#define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
#elif \ #elif \
JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
#define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0)
#define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
#elif \ #elif \
JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0)
...@@ -764,21 +1003,40 @@ ...@@ -764,21 +1003,40 @@
#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT) #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
#undef JSON_HEDLEY_WARN_UNUSED_RESULT #undef JSON_HEDLEY_WARN_UNUSED_RESULT
#endif #endif
#if defined(__cplusplus) && (__cplusplus >= 201703L) #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
#endif
#if (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
#define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
#define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
#elif \ #elif \
JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
(JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
#define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
#elif defined(_Check_return_) /* SAL */ #elif defined(_Check_return_) /* SAL */
#define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
#else #else
#define JSON_HEDLEY_WARN_UNUSED_RESULT #define JSON_HEDLEY_WARN_UNUSED_RESULT
#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
#endif #endif
#if defined(JSON_HEDLEY_SENTINEL) #if defined(JSON_HEDLEY_SENTINEL)
...@@ -811,14 +1069,23 @@ ...@@ -811,14 +1069,23 @@
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
JSON_HEDLEY_TI_VERSION_CHECK(18,0,0) || \ JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
(JSON_HEDLEY_TI_VERSION_CHECK(17,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
#define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
#define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0)
#define JSON_HEDLEY_NO_RETURN __declspec(noreturn) #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
#define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
#define JSON_HEDLEY_NO_RETURN __attribute((noreturn)) #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
...@@ -843,31 +1110,6 @@ ...@@ -843,31 +1110,6 @@
#if defined(JSON_HEDLEY_UNREACHABLE_RETURN) #if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
#undef JSON_HEDLEY_UNREACHABLE_RETURN #undef JSON_HEDLEY_UNREACHABLE_RETURN
#endif #endif
#if \
(JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5)
#define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0)
#define JSON_HEDLEY_UNREACHABLE() __assume(0)
#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0)
#if defined(__cplusplus)
#define JSON_HEDLEY_UNREACHABLE() std::_nassert(0)
#else
#define JSON_HEDLEY_UNREACHABLE() _nassert(0)
#endif
#define JSON_HEDLEY_UNREACHABLE_RETURN(value) return value
#elif defined(EXIT_FAILURE)
#define JSON_HEDLEY_UNREACHABLE() abort()
#else
#define JSON_HEDLEY_UNREACHABLE()
#define JSON_HEDLEY_UNREACHABLE_RETURN(value) return value
#endif
#if !defined(JSON_HEDLEY_UNREACHABLE_RETURN)
#define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
#endif
#if defined(JSON_HEDLEY_ASSUME) #if defined(JSON_HEDLEY_ASSUME)
#undef JSON_HEDLEY_ASSUME #undef JSON_HEDLEY_ASSUME
#endif #endif
...@@ -877,20 +1119,45 @@ ...@@ -877,20 +1119,45 @@
#define JSON_HEDLEY_ASSUME(expr) __assume(expr) #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) #elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
#define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) #elif \
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
#if defined(__cplusplus) #if defined(__cplusplus)
#define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
#else #else
#define JSON_HEDLEY_ASSUME(expr) _nassert(expr) #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
#endif #endif
#elif \ #endif
(JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && !defined(JSON_HEDLEY_ARM_VERSION)) || \ #if \
(JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5)
#define JSON_HEDLEY_ASSUME(expr) ((void) ((expr) ? 1 : (__builtin_unreachable(), 1))) #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
#elif defined(JSON_HEDLEY_ASSUME)
#define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
#endif
#if !defined(JSON_HEDLEY_ASSUME)
#if defined(JSON_HEDLEY_UNREACHABLE)
#define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
#else
#define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
#endif
#endif
#if defined(JSON_HEDLEY_UNREACHABLE)
#if \
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
#define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
#else
#define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
#endif
#else #else
#define JSON_HEDLEY_ASSUME(expr) ((void) (expr)) #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
#endif
#if !defined(JSON_HEDLEY_UNREACHABLE)
#define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
#endif #endif
JSON_HEDLEY_DIAGNOSTIC_PUSH JSON_HEDLEY_DIAGNOSTIC_PUSH
...@@ -934,8 +1201,17 @@ JSON_HEDLEY_DIAGNOSTIC_POP ...@@ -934,8 +1201,17 @@ JSON_HEDLEY_DIAGNOSTIC_POP
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
#define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) #elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
#define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
...@@ -968,19 +1244,16 @@ JSON_HEDLEY_DIAGNOSTIC_POP ...@@ -968,19 +1244,16 @@ JSON_HEDLEY_DIAGNOSTIC_POP
#undef JSON_HEDLEY_UNPREDICTABLE #undef JSON_HEDLEY_UNPREDICTABLE
#endif #endif
#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) #if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
#define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable(!!(expr)) #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
#endif #endif
#if \ #if \
JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \ JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \
JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0)
# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability(expr, value, probability) # define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1, probability) # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0, probability) # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) # define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
#if !defined(JSON_HEDLEY_BUILTIN_UNPREDICTABLE)
#define JSON_HEDLEY_BUILTIN_UNPREDICTABLE(expr) __builtin_expect_with_probability(!!(expr), 1, 0.5)
#endif
#elif \ #elif \
JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) || \ JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) || \
JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
...@@ -988,24 +1261,31 @@ JSON_HEDLEY_DIAGNOSTIC_POP ...@@ -988,24 +1261,31 @@ JSON_HEDLEY_DIAGNOSTIC_POP
(JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
JSON_HEDLEY_TI_VERSION_CHECK(6,1,0) || \ JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0)
# define JSON_HEDLEY_PREDICT(expr, expected, probability) \ # define JSON_HEDLEY_PREDICT(expr, expected, probability) \
(((probability) >= 0.9) ? __builtin_expect(!!(expr), (expected)) : (((void) (expected)), !!(expr))) (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
(__extension__ ({ \ (__extension__ ({ \
JSON_HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ double hedley_probability_ = (probability); \
((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
})) }))
# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
(__extension__ ({ \ (__extension__ ({ \
JSON_HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ double hedley_probability_ = (probability); \
((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
})) }))
# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) # define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
#else #else
# define JSON_HEDLEY_PREDICT(expr, expected, probability) (((void) (expected)), !!(expr)) # define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
# define JSON_HEDLEY_LIKELY(expr) (!!(expr)) # define JSON_HEDLEY_LIKELY(expr) (!!(expr))
...@@ -1025,8 +1305,17 @@ JSON_HEDLEY_DIAGNOSTIC_POP ...@@ -1025,8 +1305,17 @@ JSON_HEDLEY_DIAGNOSTIC_POP
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
#define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
#define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
...@@ -1040,22 +1329,36 @@ JSON_HEDLEY_DIAGNOSTIC_POP ...@@ -1040,22 +1329,36 @@ JSON_HEDLEY_DIAGNOSTIC_POP
#undef JSON_HEDLEY_PURE #undef JSON_HEDLEY_PURE
#endif #endif
#if \ #if \
JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
#define JSON_HEDLEY_PURE __attribute__((__pure__)) (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
# define JSON_HEDLEY_PURE __attribute__((__pure__))
#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
#define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") # define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) #elif defined(__cplusplus) && \
#define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") ( \
JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
)
# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
#else #else
#define JSON_HEDLEY_PURE # define JSON_HEDLEY_PURE
#endif #endif
#if defined(JSON_HEDLEY_CONST) #if defined(JSON_HEDLEY_CONST)
...@@ -1068,8 +1371,17 @@ JSON_HEDLEY_DIAGNOSTIC_POP ...@@ -1068,8 +1371,17 @@ JSON_HEDLEY_DIAGNOSTIC_POP
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
#define JSON_HEDLEY_CONST __attribute__((__const__)) #define JSON_HEDLEY_CONST __attribute__((__const__))
#elif \ #elif \
...@@ -1091,7 +1403,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP ...@@ -1091,7 +1403,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
(JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
defined(__clang__) defined(__clang__)
...@@ -1116,7 +1431,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP ...@@ -1116,7 +1431,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP
#elif \ #elif \
JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
#define JSON_HEDLEY_INLINE __inline #define JSON_HEDLEY_INLINE __inline
#else #else
#define JSON_HEDLEY_INLINE #define JSON_HEDLEY_INLINE
...@@ -1126,23 +1446,40 @@ JSON_HEDLEY_DIAGNOSTIC_POP ...@@ -1126,23 +1446,40 @@ JSON_HEDLEY_DIAGNOSTIC_POP
#undef JSON_HEDLEY_ALWAYS_INLINE #undef JSON_HEDLEY_ALWAYS_INLINE
#endif #endif
#if \ #if \
JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
#define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) #elif JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0)
#define JSON_HEDLEY_ALWAYS_INLINE __forceinline # define JSON_HEDLEY_ALWAYS_INLINE __forceinline
#elif JSON_HEDLEY_TI_VERSION_CHECK(7,0,0) && defined(__cplusplus) #elif defined(__cplusplus) && \
#define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") ( \
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
)
# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
#define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") # define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
#else #else
#define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE # define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
#endif #endif
#if defined(JSON_HEDLEY_NEVER_INLINE) #if defined(JSON_HEDLEY_NEVER_INLINE)
...@@ -1155,14 +1492,23 @@ JSON_HEDLEY_DIAGNOSTIC_POP ...@@ -1155,14 +1492,23 @@ JSON_HEDLEY_DIAGNOSTIC_POP
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
(JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
(JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
(JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
#define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0)
#define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) #elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
#define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
#define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
#define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
...@@ -1184,26 +1530,31 @@ JSON_HEDLEY_DIAGNOSTIC_POP ...@@ -1184,26 +1530,31 @@ JSON_HEDLEY_DIAGNOSTIC_POP
#undef JSON_HEDLEY_IMPORT #undef JSON_HEDLEY_IMPORT
#endif #endif
#if defined(_WIN32) || defined(__CYGWIN__) #if defined(_WIN32) || defined(__CYGWIN__)
#define JSON_HEDLEY_PRIVATE # define JSON_HEDLEY_PRIVATE
#define JSON_HEDLEY_PUBLIC __declspec(dllexport) # define JSON_HEDLEY_PUBLIC __declspec(dllexport)
#define JSON_HEDLEY_IMPORT __declspec(dllimport) # define JSON_HEDLEY_IMPORT __declspec(dllimport)
#else #else
#if \ # if \
JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ ( \
(JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_EABI__) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) defined(__TI_EABI__) && \
#define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) ( \
#define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
#else JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
#define JSON_HEDLEY_PRIVATE ) \
#define JSON_HEDLEY_PUBLIC )
#endif # define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
#define JSON_HEDLEY_IMPORT extern # define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
# else
# define JSON_HEDLEY_PRIVATE
# define JSON_HEDLEY_PUBLIC
# endif
# define JSON_HEDLEY_IMPORT extern
#endif #endif
#if defined(JSON_HEDLEY_NO_THROW) #if defined(JSON_HEDLEY_NO_THROW)
...@@ -1225,7 +1576,9 @@ JSON_HEDLEY_DIAGNOSTIC_POP ...@@ -1225,7 +1576,9 @@ JSON_HEDLEY_DIAGNOSTIC_POP
#if defined(JSON_HEDLEY_FALL_THROUGH) #if defined(JSON_HEDLEY_FALL_THROUGH)
#undef JSON_HEDLEY_FALL_THROUGH #undef JSON_HEDLEY_FALL_THROUGH
#endif #endif
#if JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(fallthrough,7,0,0) && !defined(JSON_HEDLEY_PGI_VERSION) #if \
JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0)
#define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough) #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
#define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
...@@ -1282,7 +1635,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP ...@@ -1282,7 +1635,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP
JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
JSON_HEDLEY_TI_VERSION_CHECK(6,1,0) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
(JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0)
#define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
...@@ -1303,7 +1656,11 @@ JSON_HEDLEY_DIAGNOSTIC_POP ...@@ -1303,7 +1656,11 @@ JSON_HEDLEY_DIAGNOSTIC_POP
#define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
#endif #endif
# elif \ # elif \
(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(JSON_HEDLEY_SUNPRO_VERSION) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ ( \
defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
!defined(JSON_HEDLEY_SUNPRO_VERSION) && \
!defined(JSON_HEDLEY_PGI_VERSION) && \
!defined(JSON_HEDLEY_IAR_VERSION)) || \
JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) || \ JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) || \
JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
...@@ -1319,7 +1676,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP ...@@ -1319,7 +1676,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP
defined(JSON_HEDLEY_GCC_VERSION) || \ defined(JSON_HEDLEY_GCC_VERSION) || \
defined(JSON_HEDLEY_INTEL_VERSION) || \ defined(JSON_HEDLEY_INTEL_VERSION) || \
defined(JSON_HEDLEY_TINYC_VERSION) || \ defined(JSON_HEDLEY_TINYC_VERSION) || \
defined(JSON_HEDLEY_TI_VERSION) || \ defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
defined(__clang__) defined(__clang__)
# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \ # define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
sizeof(void) != \ sizeof(void) != \
...@@ -1377,59 +1739,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP ...@@ -1377,59 +1739,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP
# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) # define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
#elif \ #elif \
(defined(__cplusplus) && (__cplusplus >= 201103L)) || \ (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0)
(defined(__cplusplus) && JSON_HEDLEY_TI_VERSION_CHECK(8,3,0))
# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) # define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
#else #else
# define JSON_HEDLEY_STATIC_ASSERT(expr, message) # define JSON_HEDLEY_STATIC_ASSERT(expr, message)
#endif #endif
#if defined(JSON_HEDLEY_CONST_CAST)
#undef JSON_HEDLEY_CONST_CAST
#endif
#if defined(__cplusplus)
# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
#elif \
JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
JSON_HEDLEY_DIAGNOSTIC_PUSH \
JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
((T) (expr)); \
JSON_HEDLEY_DIAGNOSTIC_POP \
}))
#else
# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
#endif
#if defined(JSON_HEDLEY_REINTERPRET_CAST)
#undef JSON_HEDLEY_REINTERPRET_CAST
#endif
#if defined(__cplusplus)
#define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
#else
#define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (*((T*) &(expr)))
#endif
#if defined(JSON_HEDLEY_STATIC_CAST)
#undef JSON_HEDLEY_STATIC_CAST
#endif
#if defined(__cplusplus)
#define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
#else
#define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
#endif
#if defined(JSON_HEDLEY_CPP_CAST)
#undef JSON_HEDLEY_CPP_CAST
#endif
#if defined(__cplusplus)
#define JSON_HEDLEY_CPP_CAST(T, expr) static_cast<T>(expr)
#else
#define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
#endif
#if defined(JSON_HEDLEY_NULL) #if defined(JSON_HEDLEY_NULL)
#undef JSON_HEDLEY_NULL #undef JSON_HEDLEY_NULL
#endif #endif
...@@ -1481,7 +1796,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP ...@@ -1481,7 +1796,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP
JSON_HEDLEY_DIAGNOSTIC_POP JSON_HEDLEY_DIAGNOSTIC_POP
#elif \ #elif \
JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#undef JSON_HEDLEY_ARRAY_PARAM #undef JSON_HEDLEY_ARRAY_PARAM
#undef JSON_HEDLEY_ASSUME #undef JSON_HEDLEY_ASSUME
#undef JSON_HEDLEY_BEGIN_C_DECLS #undef JSON_HEDLEY_BEGIN_C_DECLS
#undef JSON_HEDLEY_C_DECL
#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
#undef JSON_HEDLEY_CLANG_HAS_BUILTIN #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
...@@ -15,13 +14,16 @@ ...@@ -15,13 +14,16 @@
#undef JSON_HEDLEY_COMPCERT_VERSION #undef JSON_HEDLEY_COMPCERT_VERSION
#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
#undef JSON_HEDLEY_CONCAT #undef JSON_HEDLEY_CONCAT
#undef JSON_HEDLEY_CONCAT3
#undef JSON_HEDLEY_CONCAT3_EX
#undef JSON_HEDLEY_CONCAT_EX #undef JSON_HEDLEY_CONCAT_EX
#undef JSON_HEDLEY_CONST #undef JSON_HEDLEY_CONST
#undef JSON_HEDLEY_CONST_CAST
#undef JSON_HEDLEY_CONSTEXPR #undef JSON_HEDLEY_CONSTEXPR
#undef JSON_HEDLEY_CONST_CAST
#undef JSON_HEDLEY_CPP_CAST #undef JSON_HEDLEY_CPP_CAST
#undef JSON_HEDLEY_CRAY_VERSION #undef JSON_HEDLEY_CRAY_VERSION
#undef JSON_HEDLEY_CRAY_VERSION_CHECK #undef JSON_HEDLEY_CRAY_VERSION_CHECK
#undef JSON_HEDLEY_C_DECL
#undef JSON_HEDLEY_DEPRECATED #undef JSON_HEDLEY_DEPRECATED
#undef JSON_HEDLEY_DEPRECATED_FOR #undef JSON_HEDLEY_DEPRECATED_FOR
#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
...@@ -37,7 +39,6 @@ ...@@ -37,7 +39,6 @@
#undef JSON_HEDLEY_EMSCRIPTEN_VERSION #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
#undef JSON_HEDLEY_END_C_DECLS #undef JSON_HEDLEY_END_C_DECLS
#undef JSON_HEDLEY_FALL_THROUGH
#undef JSON_HEDLEY_FLAGS #undef JSON_HEDLEY_FLAGS
#undef JSON_HEDLEY_FLAGS_CAST #undef JSON_HEDLEY_FLAGS_CAST
#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
...@@ -83,8 +84,8 @@ ...@@ -83,8 +84,8 @@
#undef JSON_HEDLEY_MSVC_VERSION #undef JSON_HEDLEY_MSVC_VERSION
#undef JSON_HEDLEY_MSVC_VERSION_CHECK #undef JSON_HEDLEY_MSVC_VERSION_CHECK
#undef JSON_HEDLEY_NEVER_INLINE #undef JSON_HEDLEY_NEVER_INLINE
#undef JSON_HEDLEY_NO_ESCAPE
#undef JSON_HEDLEY_NON_NULL #undef JSON_HEDLEY_NON_NULL
#undef JSON_HEDLEY_NO_ESCAPE
#undef JSON_HEDLEY_NO_RETURN #undef JSON_HEDLEY_NO_RETURN
#undef JSON_HEDLEY_NO_THROW #undef JSON_HEDLEY_NO_THROW
#undef JSON_HEDLEY_NULL #undef JSON_HEDLEY_NULL
...@@ -112,6 +113,18 @@ ...@@ -112,6 +113,18 @@
#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
#undef JSON_HEDLEY_TINYC_VERSION #undef JSON_HEDLEY_TINYC_VERSION
#undef JSON_HEDLEY_TINYC_VERSION_CHECK #undef JSON_HEDLEY_TINYC_VERSION_CHECK
#undef JSON_HEDLEY_TI_ARMCL_VERSION
#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
#undef JSON_HEDLEY_TI_CL2000_VERSION
#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
#undef JSON_HEDLEY_TI_CL430_VERSION
#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
#undef JSON_HEDLEY_TI_CL6X_VERSION
#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
#undef JSON_HEDLEY_TI_CL7X_VERSION
#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
#undef JSON_HEDLEY_TI_CLPRU_VERSION
#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
#undef JSON_HEDLEY_TI_VERSION #undef JSON_HEDLEY_TI_VERSION
#undef JSON_HEDLEY_TI_VERSION_CHECK #undef JSON_HEDLEY_TI_VERSION_CHECK
#undef JSON_HEDLEY_UNAVAILABLE #undef JSON_HEDLEY_UNAVAILABLE
...@@ -126,3 +139,5 @@ ...@@ -126,3 +139,5 @@
#undef JSON_HEDLEY_VERSION_ENCODE #undef JSON_HEDLEY_VERSION_ENCODE
#undef JSON_HEDLEY_WARNING #undef JSON_HEDLEY_WARNING
#undef JSON_HEDLEY_WARN_UNUSED_RESULT #undef JSON_HEDLEY_WARN_UNUSED_RESULT
#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
#undef JSON_HEDLEY_FALL_THROUGH
project('nlohmann_json', project('nlohmann_json',
'cpp', 'cpp',
version : '3.7.3', version : '3.8.0',
license : 'MIT', license : 'MIT',
) )
......
This source diff could not be displayed because it is too large. You can view the blob instead.
wsjcpp_version: "v0.1.1"
cmake_minimum_required: "3.0"
cmake_cxx_standard: "11"
name: "nlohmann/json"
version: "v3.7.3"
description: "JSON for Modern C++"
issues: "https://github.com/nlohmann/json/issues"
keywords:
- "c++"
- "json"
repositories:
- type: main
url: "https://github.com/nlohmann/json"
authors:
- name: "Niels Lohmann"
email: "mail@nlohmann.me"
distribution:
- source-file: "single_include/nlohmann/json.hpp"
target-file: "json.hpp"
type: "source-code"
...@@ -55,7 +55,7 @@ function get_gyp() ...@@ -55,7 +55,7 @@ function get_gyp()
function get_json() function get_json()
{ {
GIT_REPO="https://github.com/nlohmann/json.git" GIT_REPO="https://github.com/nlohmann/json.git"
GIT_TAG="v3.7.3" GIT_TAG="v3.8.0"
DEST="deps/json" DEST="deps/json"
get_dep "${GIT_REPO}" "${GIT_TAG}" "${DEST}" get_dep "${GIT_REPO}" "${GIT_TAG}" "${DEST}"
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论