mirror of
https://github.com/nlohmann/json.git
synced 2025-01-04 12:37:57 +08:00
Merge branch 'release/3.0.0'
This commit is contained in:
commit
9f81beb5e2
28
.github/CONTRIBUTING.md
vendored
28
.github/CONTRIBUTING.md
vendored
@ -14,8 +14,6 @@ Usually, all issues are tracked publicly on [Github](https://github.com/nlohmann
|
||||
|
||||
Please [create an issue](https://github.com/nlohmann/json/issues/new), assuming one does not already exist, and describe your concern. Note you need a [GitHub account](https://github.com/signup/free) for this.
|
||||
|
||||
If you want propose changes to the code, you need to download the [`re2c`](http://re2c.org) tool.
|
||||
|
||||
## Describe your issue
|
||||
|
||||
Clearly describe the issue:
|
||||
@ -24,33 +22,28 @@ Clearly describe the issue:
|
||||
- If you propose a change or addition, try to give an **example** how the improved code could look like or how to use it.
|
||||
- If you found a compilation error, please tell us which **compiler** (version and operating system) you used and paste the (relevant part of) the error messages to the ticket.
|
||||
|
||||
Please stick to the [issue template](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE.md) if possible.
|
||||
|
||||
## Files to change
|
||||
|
||||
There are currently two files which need to be edited:
|
||||
|
||||
1. [`src/json.hpp.re2c`](https://github.com/nlohmann/json/blob/master/src/json.hpp.re2c) (note the `.re2c` suffix) - This file contains a comment section which describes the JSON lexic. This section is translated by [`re2c`](http://re2c.org) into file [`src/json.hpp`](https://github.com/nlohmann/json/blob/master/src/json.hpp) which is plain "vanilla" C++11 code. (In fact, the generated lexer consists of some hundred lines of `goto`s, which is a hint you never want to edit this file...).
|
||||
1. [`src/json.hpp`](https://github.com/nlohmann/json/blob/master/src/json.hpp)
|
||||
|
||||
If you only edit file `src/json.hpp` (without the `.re2c` suffix), your changes will be overwritten as soon as the lexer is touched again. To generate the `src/json.hpp` file which is actually used during compilation of the tests and all other code, please execute
|
||||
|
||||
```sh
|
||||
make re2c
|
||||
```
|
||||
|
||||
To run [`re2c`](http://re2c.org) and generate/overwrite file `src/json.hpp` with your changes in file `src/json.hpp.re2c`. We currently use re2c version 0.16. Please also use this version, because other re2c versions tend to create code that differs a lot from which makes diffs unusable.
|
||||
|
||||
|
||||
2. [`test/src/unit.cpp`](https://github.com/nlohmann/json/blob/master/test/unit.cpp) - This contains the [Catch](https://github.com/philsquared/Catch) unit tests which currently cover [100 %](https://coveralls.io/github/nlohmann/json) of the library's code.
|
||||
2. [`test/src/unit-*.cpp`](https://github.com/nlohmann/json/tree/develop/test/src) - These files contain the [Catch](https://github.com/philsquared/Catch) unit tests which currently cover [100 %](https://coveralls.io/github/nlohmann/json) of the library's code.
|
||||
|
||||
If you add or change a feature, please also add a unit test to this file. The unit tests can be compiled and executed with
|
||||
|
||||
```sh
|
||||
make check
|
||||
$ mkdir build
|
||||
$ cd build
|
||||
$ cmake ..
|
||||
$ cmake --build .
|
||||
$ ctest
|
||||
```
|
||||
|
||||
The test cases are also executed with several different compilers on [Travis](https://travis-ci.org/nlohmann/json) once you open a pull request.
|
||||
|
||||
Please understand that I cannot accept pull requests changing only file `src/json.hpp`.
|
||||
|
||||
|
||||
## Note
|
||||
|
||||
@ -59,12 +52,11 @@ Please understand that I cannot accept pull requests changing only file `src/jso
|
||||
|
||||
## Please don't
|
||||
|
||||
- Please do not only make changes to file `src/json.hpp` -- please read the paragraph above and understand why `src/json.hpp.re2c` exists.
|
||||
- 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.8 (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.
|
||||
- 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.
|
||||
- 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 it to any other order.
|
||||
- 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).
|
||||
|
||||
- Please do not open pull requests that address **multiple issues**.
|
||||
|
||||
|
22
.github/ISSUE_TEMPLATE.md
vendored
Normal file
22
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
**Bug Report**
|
||||
|
||||
- What is the issue you have?
|
||||
|
||||
- Please describe the steps to reproduce the issue. Can you provide a small but working code example?
|
||||
|
||||
- What is the expected behavior?
|
||||
|
||||
- And what is the actual behavior instead?
|
||||
|
||||
- Which compiler and operating system are you using? Is it a [supported compiler](https://github.com/nlohmann/json#supported-compilers)?
|
||||
|
||||
- Did you use a released version of the library or the version from 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)?
|
||||
|
||||
|
||||
**Feature Request**
|
||||
|
||||
- Describe the feature in as much detail as possible.
|
||||
|
||||
- Include sample usage where appropriate.
|
42
.github/PULL_REQUEST_TEMPLATE.md
vendored
42
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -1,45 +1,15 @@
|
||||
[Describe your pull request here. Please read the text below the line, and make sure you follow the checklist.]
|
||||
|
||||
## Files to change
|
||||
* * *
|
||||
|
||||
There are currently two files which need to be edited:
|
||||
## Pull request checklist
|
||||
|
||||
1. [`src/json.hpp.re2c`](https://github.com/nlohmann/json/blob/master/src/json.hpp.re2c) (note the `.re2c` suffix) - This file contains a comment section which describes the JSON lexic. This section is translated by [`re2c`](http://re2c.org) into file [`src/json.hpp`](https://github.com/nlohmann/json/blob/master/src/json.hpp) which is plain "vanilla" C++11 code. (In fact, the generated lexer consists of some hundred lines of `goto`s, which is a hint you never want to edit this file...).
|
||||
|
||||
If you only edit file `src/json.hpp` (without the `.re2c` suffix), your changes will be overwritten as soon as the lexer is touched again. To generate the `src/json.hpp` file which is actually used during compilation of the tests and all other code, please execute
|
||||
|
||||
```sh
|
||||
make re2c
|
||||
```
|
||||
|
||||
To run [`re2c`](http://re2c.org) and generate/overwrite file `src/json.hpp` with your changes in file `src/json.hpp.re2c`.
|
||||
|
||||
|
||||
2. [`test/src/unit.cpp`](https://github.com/nlohmann/json/blob/master/test/unit.cpp) - This contains the [Catch](https://github.com/philsquared/Catch) unit tests which currently cover [100 %](https://coveralls.io/github/nlohmann/json) of the library's code.
|
||||
|
||||
If you add or change a feature, please also add a unit test to this file. The unit tests can be compiled with
|
||||
|
||||
```sh
|
||||
make
|
||||
```
|
||||
|
||||
and can be executed with
|
||||
|
||||
```sh
|
||||
./json_unit
|
||||
```
|
||||
|
||||
The test cases are also executed with several different compilers on [Travis](https://travis-ci.org/nlohmann/json) once you open a pull request.
|
||||
|
||||
Please understand that I cannot accept pull requests changing only file `src/json.hpp`.
|
||||
|
||||
|
||||
## Note
|
||||
|
||||
- If you open a pull request, the code will be automatically tested with [Valgrind](http://valgrind.org)'s Memcheck tool to detect memory leaks. Please be aware that the execution with Valgrind _may_ in rare cases yield different behavior than running the code directly. This can result in failing unit tests which run successfully without Valgrind.
|
||||
- [ ] Changes are described in the pull request, or an [existing issue is referenced](https://github.com/nlohmann/json/issues).
|
||||
- [ ] The test suite [compiles and runs](https://github.com/nlohmann/json/blob/develop/README.md#execute-unit-tests) without error.
|
||||
- [ ] [Code coverage](https://coveralls.io/github/nlohmann/json) is 100%. Test cases can be added by editing the [test suite](https://github.com/nlohmann/json/tree/develop/test/src).
|
||||
|
||||
## Please don't
|
||||
|
||||
- Only make changes to file `src/json.hpp` -- please read the paragraph above and understand why `src/json.hpp.re2c` exists.
|
||||
- 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.8 (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.
|
||||
- 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.
|
||||
|
19
.github/config.yml
vendored
Normal file
19
.github/config.yml
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
# Configuration for sentiment-bot - https://github.com/behaviorbot/sentiment-bot
|
||||
|
||||
# *Required* toxicity threshold between 0 and .99 with the higher numbers being the most toxic
|
||||
# Anything higher than this threshold will be marked as toxic and commented on
|
||||
sentimentBotToxicityThreshold: .7
|
||||
|
||||
# *Required* Comment to reply with
|
||||
sentimentBotReplyComment: >
|
||||
Please be sure to review the [code of conduct](https://github.com/nlohmann/json/blob/develop/CODE_OF_CONDUCT.md) and be respectful of other users. cc/ @nlohmann
|
||||
|
||||
|
||||
# Configuration for request-info - https://github.com/behaviorbot/request-info
|
||||
|
||||
# *Required* Comment to reply with
|
||||
requestInfoReplyComment: >
|
||||
We would appreciate it if you could provide us with more info about this issue or pull request! Please check the [issue template](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE.md) and the [pull request template](https://github.com/nlohmann/json/blob/develop/.github/PULL_REQUEST_TEMPLATE.md).
|
||||
|
||||
# *OPTIONAL* Label to be added to Issues and Pull Requests with insufficient information given
|
||||
requestInfoLabelToAdd: "state: needs more info"
|
17
.github/stale.yml
vendored
Normal file
17
.github/stale.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 30
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 7
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- pinned
|
||||
- security
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: "state: stale"
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
recent activity. It will be closed if no further activity occurs. Thank you
|
||||
for your contributions.
|
||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||
closeComment: false
|
13
.gitignore
vendored
13
.gitignore
vendored
@ -1,5 +1,6 @@
|
||||
json_unit
|
||||
json_benchmarks
|
||||
json_benchmarks_simple
|
||||
fuzz-testing
|
||||
|
||||
*.dSYM
|
||||
@ -8,7 +9,7 @@ fuzz-testing
|
||||
*.gcda
|
||||
|
||||
build
|
||||
working
|
||||
build_coverage
|
||||
|
||||
doc/xml
|
||||
doc/html
|
||||
@ -19,14 +20,4 @@ benchmarks/files/numbers/*.json
|
||||
.idea
|
||||
cmake-build-debug
|
||||
|
||||
|
||||
test/test-*
|
||||
.svn
|
||||
|
||||
test/thirdparty/Fuzzer/libFuzzer.a
|
||||
|
||||
test/parse_afl_fuzzer
|
||||
|
||||
test/parse_cbor_fuzzer
|
||||
|
||||
test/parse_msgpack_fuzzer
|
||||
|
223
.travis.yml
223
.travis.yml
@ -7,6 +7,7 @@ language: cpp
|
||||
|
||||
dist: trusty
|
||||
sudo: required
|
||||
group: edge
|
||||
|
||||
|
||||
###################
|
||||
@ -28,37 +29,28 @@ matrix:
|
||||
include:
|
||||
|
||||
# Valgrind
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env:
|
||||
- COMPILER=g++-4.9
|
||||
- SPECIAL=valgrind
|
||||
- CMAKE_OPTIONS=-DJSON_Valgrind=ON
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: [g++-4.9, valgrind]
|
||||
after_success:
|
||||
- make check TEST_PREFIX="valgrind --error-exitcode=1 --leak-check=full " TEST_PATTERN=""
|
||||
packages: ['g++-4.9', 'valgrind', 'ninja-build']
|
||||
|
||||
# cLang sanitizer
|
||||
# note: sadly clang's libc++ has errors when running with sanitize,
|
||||
# so we use clang with gcc's libstdc++ which doesn't give those error.
|
||||
# that's why we need to install g++-6 to get the lastest version
|
||||
# clang sanitizer
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env:
|
||||
- LLVM_VERSION=3.8.1
|
||||
- SPECIAL=sanitizer
|
||||
- COMPILER=clang++-5.0
|
||||
- CMAKE_OPTIONS=-DJSON_Sanitizer=ON
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: g++-6
|
||||
compiler: clang
|
||||
before_script:
|
||||
- make clang_sanitize
|
||||
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
|
||||
packages: ['g++-6', 'clang-5.0', 'ninja-build']
|
||||
|
||||
# cppcheck
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env:
|
||||
@ -67,24 +59,20 @@ matrix:
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: [g++-4.9, cppcheck]
|
||||
packages: ['g++-4.9', 'cppcheck', 'ninja-build']
|
||||
after_success:
|
||||
- make cppcheck
|
||||
|
||||
# no exceptions
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env:
|
||||
- COMPILER=g++-4.9
|
||||
- SPECIAL=no_exceptions
|
||||
- TEST_PATTERN=-e \"*\"
|
||||
- CMAKE_OPTIONS=-DJSON_NoExceptions=ON
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: [g++-4.9, cppcheck]
|
||||
before_script:
|
||||
- CPPFLAGS="-DJSON_NOEXCEPTION" make
|
||||
packages: ['g++-4.9', 'ninja-build']
|
||||
|
||||
# Coveralls (http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/)
|
||||
|
||||
@ -93,25 +81,14 @@ matrix:
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-4.9', 'ruby']
|
||||
packages: ['g++-4.9', 'ninja-build']
|
||||
before_script:
|
||||
- wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.11.orig.tar.gz
|
||||
- tar xf lcov_1.11.orig.tar.gz
|
||||
- sudo make -C lcov-1.11/ install
|
||||
- gem install coveralls-lcov
|
||||
- pip install --user cpp-coveralls
|
||||
after_success:
|
||||
- make clean
|
||||
- CXXFLAGS="--coverage -g -O0" CPPFLAGS="-DNDEBUG" make json_unit
|
||||
- test/json_unit "*"
|
||||
- coveralls --build-root test --exclude src/catch.hpp --exclude src/unit-algorithms.cpp --exclude src/unit-allocator.cpp --exclude src/unit-capacity.cpp --exclude src/unit-class_const_iterator.cpp --exclude src/unit-class_iterator.cpp --exclude src/unit-class_lexer.cpp --exclude src/unit-class_parser.cpp --exclude src/unit-comparison.cpp --exclude src/unit-concepts.cpp --exclude src/unit-constructor1.cpp --exclude src/unit-constructor2.cpp --exclude src/unit-convenience.cpp --exclude src/unit-conversions.cpp --exclude src/unit-deserialization.cpp --exclude src/unit-element_access1.cpp --exclude src/unit-element_access2.cpp --exclude src/unit-inspection.cpp --exclude src/unit-iterator_wrapper.cpp --exclude src/unit-iterators1.cpp --exclude src/unit-iterators2.cpp --exclude src/unit-json_patch.cpp --exclude src/unit-json_pointer.cpp --exclude src/unit-modifiers.cpp --exclude src/unit-pointer_access.cpp --exclude src/unit-readme.cpp --exclude src/unit-reference_access.cpp --exclude src/unit-regression.cpp --exclude src/unit-serialization.cpp --exclude src/unit-testsuites.cpp --exclude src/unit-unicode.cpp --include ../src/json.hpp --gcov-options '\-lp' --gcov 'gcov-4.9'
|
||||
- lcov --directory src --directory test/src --capture --output-file coverage.info --rc lcov_branch_coverage=1 --no-external
|
||||
- lcov --remove coverage.info 'test/src/*' --output-file coverage.info --rc lcov_branch_coverage=1
|
||||
- lcov --list coverage.info --rc lcov_branch_coverage=1
|
||||
- coveralls-lcov --repo-token F9bs4Nop10JRgqPQXRcifyQKYhb3FczkS coverage.info
|
||||
- coveralls --build-root test --include src --gcov 'gcov-4.9' --gcov-options '\-lp'
|
||||
env:
|
||||
- COMPILER=g++-4.9
|
||||
- SPECIAL=coveralls
|
||||
- CMAKE_OPTIONS=-DJSON_Coverage=ON
|
||||
|
||||
# Coverity (only for branch coverity_scan)
|
||||
|
||||
@ -119,17 +96,20 @@ matrix:
|
||||
compiler: clang
|
||||
before_install: echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
|
||||
packages: ['g++-6', 'clang-3.6', 'ninja-build']
|
||||
coverity_scan:
|
||||
project:
|
||||
name: "nlohmann/json"
|
||||
description: "Build submitted via Travis CI"
|
||||
notification_email: niels.lohmann@gmail.com
|
||||
build_command_prepend: "make clean"
|
||||
build_command: "make"
|
||||
build_command_prepend: "mkdir coverity_build ; cd coverity_build ; cmake .. ; cd .."
|
||||
build_command: "make -C coverity_build"
|
||||
branch_pattern: coverity_scan
|
||||
env:
|
||||
- LLVM_VERSION=3.6.0
|
||||
- SPECIAL=coverity
|
||||
- COMPILER=clang++-3.6
|
||||
|
||||
# OSX / Clang
|
||||
|
||||
@ -148,6 +128,18 @@ matrix:
|
||||
- os: osx
|
||||
osx_image: xcode8.2
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode8.3
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode9
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode9.1
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode9.2
|
||||
|
||||
# Linux / GCC
|
||||
|
||||
- os: linux
|
||||
@ -156,7 +148,7 @@ matrix:
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: g++-4.9
|
||||
packages: ['g++-4.9', 'ninja-build']
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
@ -164,7 +156,7 @@ matrix:
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: g++-5
|
||||
packages: ['g++-5', 'ninja-build']
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
@ -172,111 +164,118 @@ matrix:
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: g++-6
|
||||
packages: ['g++-6', 'ninja-build']
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: COMPILER=g++-7
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-7', 'ninja-build']
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env:
|
||||
- COMPILER=g++-7
|
||||
- CXXFLAGS=-std=c++17
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-7', 'ninja-build']
|
||||
|
||||
# Linux / Clang
|
||||
|
||||
- os: linux
|
||||
env: LLVM_VERSION=3.6.0
|
||||
compiler: clang
|
||||
env: COMPILER=clang++-3.5
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5']
|
||||
packages: ['g++-6', 'clang-3.5', 'ninja-build']
|
||||
|
||||
- os: linux
|
||||
env: LLVM_VERSION=3.6.1
|
||||
compiler: clang
|
||||
env: COMPILER=clang++-3.6
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
|
||||
packages: ['g++-6', 'clang-3.6', 'ninja-build']
|
||||
|
||||
- os: linux
|
||||
env: LLVM_VERSION=3.6.2
|
||||
compiler: clang
|
||||
env: COMPILER=clang++-3.7
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7']
|
||||
packages: ['g++-6', 'clang-3.7', 'ninja-build']
|
||||
|
||||
- os: linux
|
||||
env: LLVM_VERSION=3.7.0
|
||||
compiler: clang
|
||||
env: COMPILER=clang++-3.8
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-6', 'clang-3.8', 'ninja-build']
|
||||
|
||||
- os: linux
|
||||
env: LLVM_VERSION=3.7.1
|
||||
compiler: clang
|
||||
env: COMPILER=clang++-3.9
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-6', 'clang-3.9', 'ninja-build']
|
||||
|
||||
- os: linux
|
||||
env: LLVM_VERSION=3.8.0
|
||||
compiler: clang
|
||||
env: COMPILER=clang++-4.0
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0']
|
||||
packages: ['g++-6', 'clang-4.0', 'ninja-build']
|
||||
|
||||
- os: linux
|
||||
env: LLVM_VERSION=3.8.1
|
||||
compiler: clang
|
||||
env: COMPILER=clang++-5.0
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
|
||||
packages: ['g++-6', 'clang-5.0', 'ninja-build']
|
||||
|
||||
#####################
|
||||
# installation step #
|
||||
#####################
|
||||
|
||||
# set directories to cache
|
||||
cache:
|
||||
directories:
|
||||
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.6.2
|
||||
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.6.1
|
||||
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.6.0
|
||||
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.7.0
|
||||
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.7.1
|
||||
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.8.0
|
||||
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.8.1
|
||||
|
||||
|
||||
install:
|
||||
# create deps dir if not existing
|
||||
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
|
||||
- mkdir -p ${DEPS_DIR}
|
||||
|
||||
# make sure CXX is correctly set
|
||||
- if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi
|
||||
|
||||
# get CMake (only for systems with brew - macOS)
|
||||
- |
|
||||
if [[ !(-x $(which cmake)) && (-x $(which brew)) ]]; then
|
||||
brew update
|
||||
brew install cmake
|
||||
cmake --version
|
||||
fi
|
||||
|
||||
# install LLVM/clang when LLVM_VERSION is set
|
||||
- |
|
||||
if [[ "${LLVM_VERSION}" != "" ]]; then
|
||||
LLVM_DIR=${DEPS_DIR}/llvm-${LLVM_VERSION}
|
||||
if [[ -z "$(ls -A ${LLVM_DIR})" ]]; then
|
||||
travis_retry wget --quiet https://cmake.org/files/v3.6/cmake-3.6.1.tar.gz
|
||||
tar xfz cmake-3.6.1.tar.gz
|
||||
(cd cmake-3.6.1 && ./configure --prefix=${LLVM_DIR}/cmake && make install)
|
||||
export PATH="${LLVM_DIR}/cmake/bin:${PATH}"
|
||||
LLVM_URL="http://llvm.org/releases/${LLVM_VERSION}/llvm-${LLVM_VERSION}.src.tar.xz"
|
||||
LIBCXX_URL="http://llvm.org/releases/${LLVM_VERSION}/libcxx-${LLVM_VERSION}.src.tar.xz"
|
||||
LIBCXXABI_URL="http://llvm.org/releases/${LLVM_VERSION}/libcxxabi-${LLVM_VERSION}.src.tar.xz"
|
||||
CLANG_URL="http://llvm.org/releases/${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-14.04.tar.xz"
|
||||
mkdir -p ${LLVM_DIR} ${LLVM_DIR}/build ${LLVM_DIR}/projects/libcxx ${LLVM_DIR}/projects/libcxxabi ${LLVM_DIR}/clang
|
||||
travis_retry wget --quiet -O - ${LLVM_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR}
|
||||
travis_retry wget --quiet -O - ${LIBCXX_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR}/projects/libcxx
|
||||
travis_retry wget --quiet -O - ${LIBCXXABI_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR}/projects/libcxxabi
|
||||
travis_retry wget --quiet -O - ${CLANG_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR}/clang
|
||||
(cd ${LLVM_DIR}/build && cmake .. -DCMAKE_INSTALL_PREFIX=${LLVM_DIR}/install -DCMAKE_CXX_COMPILER=clang++)
|
||||
(cd ${LLVM_DIR}/build/projects/libcxx && make install -j2)
|
||||
(cd ${LLVM_DIR}/build/projects/libcxxabi && make install -j2)
|
||||
fi
|
||||
export CXXFLAGS="-nostdinc++ -isystem ${LLVM_DIR}/install/include/c++/v1"
|
||||
export LDFLAGS="-L ${LLVM_DIR}/install/lib -l c++ -l c++abi"
|
||||
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${LLVM_DIR}/install/lib"
|
||||
export PATH="${LLVM_DIR}/clang/bin:${PATH}"
|
||||
fi
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env:
|
||||
- COMPILER=clang++-5.0
|
||||
- CXXFLAGS=-std=c++1z
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
|
||||
packages: ['g++-6', 'clang-5.0', 'ninja-build']
|
||||
|
||||
################
|
||||
# build script #
|
||||
################
|
||||
|
||||
script:
|
||||
# get CMake and Ninja (only for systems with brew - macOS)
|
||||
- |
|
||||
if [[ (-x $(which brew)) ]]; then
|
||||
brew update
|
||||
brew install cmake ninja
|
||||
cmake --version
|
||||
fi
|
||||
|
||||
# make sure CXX is correctly set
|
||||
- if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi
|
||||
|
||||
# show OS/compiler version
|
||||
- uname -a
|
||||
- $CXX --version
|
||||
|
||||
# compile and execute unit tests
|
||||
- mkdir -p build && cd build
|
||||
- cmake .. && cmake --build . --config Release -- -j4
|
||||
- ctest -C Release -V
|
||||
- cmake .. ${CMAKE_OPTIONS} -GNinja && cmake --build . --config Release
|
||||
- ctest -C Release -V -j
|
||||
- cd ..
|
||||
|
||||
# check if homebrew works (only checks develop branch)
|
||||
|
135
CMakeLists.txt
135
CMakeLists.txt
@ -1,57 +1,98 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_minimum_required(VERSION 3.0.0)
|
||||
|
||||
# define the project
|
||||
project(nlohmann_json VERSION 2.1.1 LANGUAGES CXX)
|
||||
##
|
||||
## PROJECT
|
||||
## name and version
|
||||
##
|
||||
project(nlohmann_json VERSION 3.0.0 LANGUAGES CXX)
|
||||
|
||||
enable_testing()
|
||||
##
|
||||
## OPTIONS
|
||||
##
|
||||
option(JSON_BuildTests "Build the unit tests" ON)
|
||||
|
||||
option(BuildTests "Build the unit tests" ON)
|
||||
##
|
||||
## CONFIGURATION
|
||||
##
|
||||
set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME})
|
||||
set(NLOHMANN_JSON_SOURCE_DIR "src/")
|
||||
set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "lib/cmake/${PROJECT_NAME}")
|
||||
set(NLOHMANN_JSON_INCLUDE_INSTALL_DIR "include")
|
||||
set(NLOHMANN_JSON_HEADER_INSTALL_DIR "${NLOHMANN_JSON_INCLUDE_INSTALL_DIR}/nlohmann")
|
||||
set(NLOHMANN_JSON_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
|
||||
set(NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE "cmake/config.cmake.in")
|
||||
set(NLOHMANN_JSON_CMAKE_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}/cmake_config")
|
||||
set(NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
|
||||
set(NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Config.cmake")
|
||||
|
||||
# define project variables
|
||||
set(JSON_TARGET_NAME ${PROJECT_NAME})
|
||||
set(JSON_PACKAGE_NAME ${JSON_TARGET_NAME})
|
||||
set(JSON_TARGETS_FILENAME "${JSON_PACKAGE_NAME}Targets.cmake")
|
||||
set(JSON_CONFIG_FILENAME "${JSON_PACKAGE_NAME}Config.cmake")
|
||||
set(JSON_CONFIGVERSION_FILENAME "${JSON_PACKAGE_NAME}ConfigVersion.cmake")
|
||||
set(JSON_CONFIG_DESTINATION "cmake")
|
||||
set(JSON_INCLUDE_DESTINATION "include/nlohmann")
|
||||
##
|
||||
## TARGET
|
||||
## create target and add include path
|
||||
##
|
||||
add_library(${NLOHMANN_JSON_TARGET_NAME} INTERFACE)
|
||||
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||
target_include_directories(
|
||||
${NLOHMANN_JSON_TARGET_NAME}
|
||||
INTERFACE
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
# create and configure the library target
|
||||
add_library(${JSON_TARGET_NAME} INTERFACE)
|
||||
target_include_directories(${JSON_TARGET_NAME} INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
||||
$<INSTALL_INTERFACE:${JSON_INCLUDE_DESTINATION}>)
|
||||
|
||||
# create and configure the unit test target
|
||||
if(BuildTests)
|
||||
## add debug view defintion file for msvc (natvis) [cmake <= 3.2.2 does not support export of source files]
|
||||
if (MSVC AND CMAKE_VERSION VERSION_GREATER "3.2.2")
|
||||
set(NLOHMANN_ADD_NATVIS TRUE)
|
||||
set(NLOHMANN_NATVIS_FILE "nlohmann_json.natvis")
|
||||
target_sources(
|
||||
${NLOHMANN_JSON_TARGET_NAME}
|
||||
INTERFACE
|
||||
$<INSTALL_INTERFACE:${NLOHMANN_NATVIS_FILE}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${NLOHMANN_NATVIS_FILE}>
|
||||
)
|
||||
endif()
|
||||
|
||||
##
|
||||
## TESTS
|
||||
## create and configure the unit test target
|
||||
##
|
||||
if(JSON_BuildTests)
|
||||
enable_testing()
|
||||
include_directories(${NLOHMANN_JSON_SOURCE_DIR})
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
# generate a config and config version file for the package
|
||||
##
|
||||
## INSTALL
|
||||
## install header files, generate and install cmake config files for find_package()
|
||||
##
|
||||
include(CMakePackageConfigHelpers)
|
||||
configure_package_config_file("cmake/config.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIG_FILENAME}"
|
||||
INSTALL_DESTINATION ${JSON_CONFIG_DESTINATION}
|
||||
PATH_VARS JSON_INCLUDE_DESTINATION)
|
||||
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIGVERSION_FILENAME}"
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY SameMajorVersion)
|
||||
|
||||
# export the library target and store build directory in package registry
|
||||
export(TARGETS ${JSON_TARGET_NAME}
|
||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/${JSON_TARGETS_FILENAME}")
|
||||
export(PACKAGE ${JSON_PACKAGE_NAME})
|
||||
|
||||
# install library target and config files
|
||||
install(TARGETS ${JSON_TARGET_NAME}
|
||||
EXPORT ${JSON_PACKAGE_NAME})
|
||||
install(FILES "src/json.hpp"
|
||||
DESTINATION ${JSON_INCLUDE_DESTINATION})
|
||||
install(EXPORT ${JSON_PACKAGE_NAME}
|
||||
FILE ${JSON_TARGETS_FILENAME}
|
||||
DESTINATION ${JSON_CONFIG_DESTINATION})
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIG_FILENAME}"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIGVERSION_FILENAME}"
|
||||
DESTINATION ${JSON_CONFIG_DESTINATION})
|
||||
write_basic_package_version_file(
|
||||
${NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE} COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
configure_package_config_file(
|
||||
${NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE}
|
||||
${NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE}
|
||||
INSTALL_DESTINATION ${NLOHMANN_JSON_CONFIG_INSTALL_DIR}
|
||||
)
|
||||
install(
|
||||
DIRECTORY ${NLOHMANN_JSON_SOURCE_DIR}
|
||||
DESTINATION ${NLOHMANN_JSON_HEADER_INSTALL_DIR}
|
||||
)
|
||||
install(
|
||||
FILES ${NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE} ${NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE}
|
||||
DESTINATION ${NLOHMANN_JSON_CONFIG_INSTALL_DIR}
|
||||
)
|
||||
if (NLOHMANN_ADD_NATVIS)
|
||||
install(
|
||||
FILES ${NLOHMANN_NATVIS_FILE}
|
||||
DESTINATION .
|
||||
)
|
||||
endif()
|
||||
install(
|
||||
TARGETS ${NLOHMANN_JSON_TARGET_NAME}
|
||||
EXPORT ${NLOHMANN_JSON_TARGETS_EXPORT_NAME}
|
||||
INCLUDES DESTINATION ${NLOHMANN_JSON_INCLUDE_INSTALL_DIR}
|
||||
)
|
||||
install(
|
||||
EXPORT ${NLOHMANN_JSON_TARGETS_EXPORT_NAME}
|
||||
DESTINATION ${NLOHMANN_JSON_CONFIG_INSTALL_DIR}
|
||||
)
|
||||
|
46
CODE_OF_CONDUCT.md
Normal file
46
CODE_OF_CONDUCT.md
Normal file
@ -0,0 +1,46 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at mail@nlohmann.me. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
397
ChangeLog.md
397
ChangeLog.md
@ -1,6 +1,402 @@
|
||||
# Change Log
|
||||
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [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)
|
||||
|
||||
- unicode strings [\#878](https://github.com/nlohmann/json/issues/878)
|
||||
- Visual Studio 2017 15.5 C++17 std::allocator deprecations [\#872](https://github.com/nlohmann/json/issues/872)
|
||||
- Typo "excpetion" [\#869](https://github.com/nlohmann/json/issues/869)
|
||||
- Explicit array example in README.md incorrect [\#867](https://github.com/nlohmann/json/issues/867)
|
||||
- why don't you release this from Feb. ? [\#865](https://github.com/nlohmann/json/issues/865)
|
||||
- json::parse throws std::invalid\_argument when processing string generated by json::dump\(\) [\#863](https://github.com/nlohmann/json/issues/863)
|
||||
- code analysis: potential bug? [\#859](https://github.com/nlohmann/json/issues/859)
|
||||
- MSVC2017, 15.5 new issues. [\#857](https://github.com/nlohmann/json/issues/857)
|
||||
- very basic: fetching string value/content without quotes [\#853](https://github.com/nlohmann/json/issues/853)
|
||||
- Ambiguous function call to get with pointer type and constant json object in VS2015 \(15.4.4\) [\#852](https://github.com/nlohmann/json/issues/852)
|
||||
- How to put object in the array as a member? [\#850](https://github.com/nlohmann/json/issues/850)
|
||||
- misclick, please ignore [\#849](https://github.com/nlohmann/json/issues/849)
|
||||
- Make XML great again. [\#847](https://github.com/nlohmann/json/issues/847)
|
||||
- Converting to array not working [\#843](https://github.com/nlohmann/json/issues/843)
|
||||
- Iteration weirdness [\#842](https://github.com/nlohmann/json/issues/842)
|
||||
- Use reference or pointer as Object value [\#841](https://github.com/nlohmann/json/issues/841)
|
||||
- Ambiguity in parsing nested maps [\#840](https://github.com/nlohmann/json/issues/840)
|
||||
- could not find from\_json\(\) method in T's namespace [\#839](https://github.com/nlohmann/json/issues/839)
|
||||
- Incorrect parse error with binary data in keys? [\#838](https://github.com/nlohmann/json/issues/838)
|
||||
- using dump\(\) when std::wstring is StringType with VS2017 [\#836](https://github.com/nlohmann/json/issues/836)
|
||||
- Show the path of the currently parsed value when an error occurs [\#835](https://github.com/nlohmann/json/issues/835)
|
||||
- Repetitive data type while reading [\#833](https://github.com/nlohmann/json/issues/833)
|
||||
- Stack-overflow \(OSS-Fuzz 4234\) [\#832](https://github.com/nlohmann/json/issues/832)
|
||||
- Storing multiple types inside map [\#831](https://github.com/nlohmann/json/issues/831)
|
||||
- Application terminating [\#830](https://github.com/nlohmann/json/issues/830)
|
||||
- Missing CMake hunter package? [\#828](https://github.com/nlohmann/json/issues/828)
|
||||
- std::map\<std::string, std::string\> from json object yields C2665: 'std::pair\<const \_Kty,\_Ty\>::pair': none of the 2 overloads could convert all the argument types [\#827](https://github.com/nlohmann/json/issues/827)
|
||||
- object.dump gives quoted string, want to use .dump\(\) to generate javascripts. [\#826](https://github.com/nlohmann/json/issues/826)
|
||||
- Assertion failed on \["NoExistKey"\] of an not existing key of const json& [\#825](https://github.com/nlohmann/json/issues/825)
|
||||
- vs2015 error : static member will remain uninitialized at runtime but use in constant-expressions is supported [\#824](https://github.com/nlohmann/json/issues/824)
|
||||
- Code Checking Warnings from json.hpp on VS2017 Community [\#821](https://github.com/nlohmann/json/issues/821)
|
||||
- Missing iostream in try online [\#820](https://github.com/nlohmann/json/issues/820)
|
||||
- Floating point value loses decimal point during dump [\#818](https://github.com/nlohmann/json/issues/818)
|
||||
- Conan package for the library [\#817](https://github.com/nlohmann/json/issues/817)
|
||||
- stream error [\#815](https://github.com/nlohmann/json/issues/815)
|
||||
- Link error when using find\(\) on the latest commit [\#814](https://github.com/nlohmann/json/issues/814)
|
||||
- ABI issue with json object between 2 shared libraries [\#813](https://github.com/nlohmann/json/issues/813)
|
||||
- scan\_string\(\) return token\_type::parse\_error; when parse ansi file [\#812](https://github.com/nlohmann/json/issues/812)
|
||||
- segfault when using fifo\_map with json [\#810](https://github.com/nlohmann/json/issues/810)
|
||||
- This shit is shit [\#809](https://github.com/nlohmann/json/issues/809)
|
||||
- \_finite and \_isnan are no members of "std" [\#808](https://github.com/nlohmann/json/issues/808)
|
||||
- how to print out the line which causing exception? [\#806](https://github.com/nlohmann/json/issues/806)
|
||||
- {} uses copy constructor, while = does not [\#805](https://github.com/nlohmann/json/issues/805)
|
||||
- json.hpp:8955: multiple definition of function that is not defined twice or more. [\#804](https://github.com/nlohmann/json/issues/804)
|
||||
- \[question\] to\_json for base and derived class [\#803](https://github.com/nlohmann/json/issues/803)
|
||||
- Misleading error message - unexpected '"' - on incorrect utf-8 symbol [\#802](https://github.com/nlohmann/json/issues/802)
|
||||
- json data = std::string\_view\("hi"\); doesn't work? [\#801](https://github.com/nlohmann/json/issues/801)
|
||||
- Thread safety of parse\(\) [\#800](https://github.com/nlohmann/json/issues/800)
|
||||
- Numbers as strings [\#799](https://github.com/nlohmann/json/issues/799)
|
||||
- Tests failing on arm [\#797](https://github.com/nlohmann/json/issues/797)
|
||||
- Using your library \(without modification\) in another library [\#796](https://github.com/nlohmann/json/issues/796)
|
||||
- Iterating over sub-object [\#794](https://github.com/nlohmann/json/issues/794)
|
||||
- how to get the json object again from which printed by the method of dump\(\) [\#792](https://github.com/nlohmann/json/issues/792)
|
||||
- ppa to include source [\#791](https://github.com/nlohmann/json/issues/791)
|
||||
- Different include paths in macOS and Ubuntu [\#790](https://github.com/nlohmann/json/issues/790)
|
||||
- Missing break after line 12886 in switch/case [\#789](https://github.com/nlohmann/json/issues/789)
|
||||
- All unit tests fail? [\#787](https://github.com/nlohmann/json/issues/787)
|
||||
- More use of move semantics in deserialization [\#786](https://github.com/nlohmann/json/issues/786)
|
||||
- warning C4706 - Visual Studio 2017 \(/W4\) [\#784](https://github.com/nlohmann/json/issues/784)
|
||||
- Compile error in clang 5.0 [\#782](https://github.com/nlohmann/json/issues/782)
|
||||
- Error Installing appium\_lib with Ruby v2.4.2 Due to JSON [\#781](https://github.com/nlohmann/json/issues/781)
|
||||
- ::get\<int\>\(\) fails in new\(er\) release \[MSVC\] [\#780](https://github.com/nlohmann/json/issues/780)
|
||||
- Type Conversion [\#779](https://github.com/nlohmann/json/issues/779)
|
||||
- Segfault on nested parsing [\#778](https://github.com/nlohmann/json/issues/778)
|
||||
- Build warnings: shadowing exception id [\#776](https://github.com/nlohmann/json/issues/776)
|
||||
- multi-level JSON support. [\#775](https://github.com/nlohmann/json/issues/775)
|
||||
- SIGABRT on dump\(\) [\#773](https://github.com/nlohmann/json/issues/773)
|
||||
- \[Question\] Custom StringType template parameter \(possibility for a KeyType template parameter\) [\#772](https://github.com/nlohmann/json/issues/772)
|
||||
- constexpr ALL the Things! [\#771](https://github.com/nlohmann/json/issues/771)
|
||||
- error: ‘BasicJsonType’ in namespace ‘::’ does not name a type [\#770](https://github.com/nlohmann/json/issues/770)
|
||||
- Program calls abort function [\#769](https://github.com/nlohmann/json/issues/769)
|
||||
- \[Question\] Floating point resolution config during dump\(\) ? [\#768](https://github.com/nlohmann/json/issues/768)
|
||||
- make check - no test ran [\#767](https://github.com/nlohmann/json/issues/767)
|
||||
- The library cannot work properly with custom allocator based containers [\#766](https://github.com/nlohmann/json/issues/766)
|
||||
- Documentation or feature request. [\#763](https://github.com/nlohmann/json/issues/763)
|
||||
- warnings in msvc about mix/max macro while windows.h is used in the project [\#762](https://github.com/nlohmann/json/issues/762)
|
||||
- std::signbit ambiguous [\#761](https://github.com/nlohmann/json/issues/761)
|
||||
- How to use value for std::experimental::optional type? [\#760](https://github.com/nlohmann/json/issues/760)
|
||||
- Cannot load json file properly [\#759](https://github.com/nlohmann/json/issues/759)
|
||||
- Compilation error with unordered\_map\< int, int \> [\#758](https://github.com/nlohmann/json/issues/758)
|
||||
- CBOR string [\#757](https://github.com/nlohmann/json/issues/757)
|
||||
- Proposal: out\_of\_range should be a subclass of std::out\_of\_range [\#756](https://github.com/nlohmann/json/issues/756)
|
||||
- Compiling with icpc [\#755](https://github.com/nlohmann/json/issues/755)
|
||||
- Getter is setting the value to null if the key does not exist [\#754](https://github.com/nlohmann/json/issues/754)
|
||||
- parsing works sometimes and crashes others [\#752](https://github.com/nlohmann/json/issues/752)
|
||||
- Static\_assert failed "incompatible pointer type" with Xcode [\#751](https://github.com/nlohmann/json/issues/751)
|
||||
- user-defined literal operator not found [\#750](https://github.com/nlohmann/json/issues/750)
|
||||
- getting clean string from it.key\(\) [\#748](https://github.com/nlohmann/json/issues/748)
|
||||
- Best method for exploring and obtaining values of nested json objects when the names are not known beforehand? [\#747](https://github.com/nlohmann/json/issues/747)
|
||||
- null char at the end of string [\#746](https://github.com/nlohmann/json/issues/746)
|
||||
- Incorrect sample for operator \>\> in docs [\#745](https://github.com/nlohmann/json/issues/745)
|
||||
- User-friendly documentation [\#744](https://github.com/nlohmann/json/issues/744)
|
||||
- Retrieve all values that match a json path [\#743](https://github.com/nlohmann/json/issues/743)
|
||||
- Compilation issue with gcc 7.2 [\#742](https://github.com/nlohmann/json/issues/742)
|
||||
- CMake target nlohmann\_json does not have src into its interface includes [\#741](https://github.com/nlohmann/json/issues/741)
|
||||
- Error when serializing empty json: type must be string, but is object [\#740](https://github.com/nlohmann/json/issues/740)
|
||||
- Conversion error for std::map\<int, std::string\> [\#739](https://github.com/nlohmann/json/issues/739)
|
||||
- Dumping Json to file as array [\#738](https://github.com/nlohmann/json/issues/738)
|
||||
- nesting json objects [\#737](https://github.com/nlohmann/json/issues/737)
|
||||
- where to find general help? [\#736](https://github.com/nlohmann/json/issues/736)
|
||||
- Compilation Error on Clang 5.0 Upgrade [\#735](https://github.com/nlohmann/json/issues/735)
|
||||
- Compilation error with std::map\<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)
|
||||
- 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)
|
||||
- Project's name is too generic and hard to search for [\#730](https://github.com/nlohmann/json/issues/730)
|
||||
- Visual Studio 2015 IntelliTrace problems [\#729](https://github.com/nlohmann/json/issues/729)
|
||||
- How to erase nested objects inside other objects? [\#728](https://github.com/nlohmann/json/issues/728)
|
||||
- How to prevent alphabetical sorting of data? [\#727](https://github.com/nlohmann/json/issues/727)
|
||||
- Serialization for CBOR [\#726](https://github.com/nlohmann/json/issues/726)
|
||||
- Using json Object as value in a map [\#725](https://github.com/nlohmann/json/issues/725)
|
||||
- std::regex and nlohmann::json value [\#724](https://github.com/nlohmann/json/issues/724)
|
||||
- Warnings when compiling with VisualStudio 2015 [\#723](https://github.com/nlohmann/json/issues/723)
|
||||
- Has this lib the unicode \(wstring\) support? [\#722](https://github.com/nlohmann/json/issues/722)
|
||||
- When will be 3.0 in master? [\#721](https://github.com/nlohmann/json/issues/721)
|
||||
- Determine the type from error message. [\#720](https://github.com/nlohmann/json/issues/720)
|
||||
- Compile-Error C2100 \(MS VS2015\) in line 887 json.hpp [\#719](https://github.com/nlohmann/json/issues/719)
|
||||
- from\_json not working for boost::optional example [\#718](https://github.com/nlohmann/json/issues/718)
|
||||
- about from\_json and to\_json function [\#717](https://github.com/nlohmann/json/issues/717)
|
||||
- How to deserialize array with derived objects [\#716](https://github.com/nlohmann/json/issues/716)
|
||||
- How to detect parse failure? [\#715](https://github.com/nlohmann/json/issues/715)
|
||||
- Parse throw std::ios\_base::failure exception when failbit set to true [\#714](https://github.com/nlohmann/json/issues/714)
|
||||
- Is there a way of format just making a pretty print without changing the key's orders ? [\#713](https://github.com/nlohmann/json/issues/713)
|
||||
- Serialization of array of not same model items [\#712](https://github.com/nlohmann/json/issues/712)
|
||||
- pointer to json parse vector [\#711](https://github.com/nlohmann/json/issues/711)
|
||||
- Gtest SEH Exception [\#709](https://github.com/nlohmann/json/issues/709)
|
||||
- broken from\_json implementation for pair and tuple [\#707](https://github.com/nlohmann/json/issues/707)
|
||||
- Unevaluated lambda in assert breaks gcc 7 build [\#705](https://github.com/nlohmann/json/issues/705)
|
||||
- Issues when adding values to firebase database [\#704](https://github.com/nlohmann/json/issues/704)
|
||||
- Floating point equality - revisited [\#703](https://github.com/nlohmann/json/issues/703)
|
||||
- Conversion from valarray\<double\> to json fails to build [\#702](https://github.com/nlohmann/json/issues/702)
|
||||
- internal compiler error \(gcc7\) [\#701](https://github.com/nlohmann/json/issues/701)
|
||||
- One build system to rule them all [\#698](https://github.com/nlohmann/json/issues/698)
|
||||
- Generated nlohmann\_jsonConfig.cmake does not set JSON\_INCLUDE\_DIR [\#695](https://github.com/nlohmann/json/issues/695)
|
||||
- support the Chinese language in json string [\#694](https://github.com/nlohmann/json/issues/694)
|
||||
- NaN problem within develop branch [\#693](https://github.com/nlohmann/json/issues/693)
|
||||
- Please post example of specialization for boost::filesystem [\#692](https://github.com/nlohmann/json/issues/692)
|
||||
- Impossible to do an array of composite objects [\#691](https://github.com/nlohmann/json/issues/691)
|
||||
- How to save json to file? [\#690](https://github.com/nlohmann/json/issues/690)
|
||||
- my simple json parser [\#689](https://github.com/nlohmann/json/issues/689)
|
||||
- problem with new struct parsing syntax [\#688](https://github.com/nlohmann/json/issues/688)
|
||||
- Parse error while parse the json string contains UTF 8 encoded document bytes string [\#684](https://github.com/nlohmann/json/issues/684)
|
||||
- \[question\] how to get a string value by pointer [\#683](https://github.com/nlohmann/json/issues/683)
|
||||
- create json object from string variable [\#681](https://github.com/nlohmann/json/issues/681)
|
||||
- adl\_serializer and CRTP [\#680](https://github.com/nlohmann/json/issues/680)
|
||||
- Is there a way to control the precision of serialized floating point numbers? [\#677](https://github.com/nlohmann/json/issues/677)
|
||||
- Is there a way to get the path of a value? [\#676](https://github.com/nlohmann/json/issues/676)
|
||||
- Could the parser locate errors to line? [\#675](https://github.com/nlohmann/json/issues/675)
|
||||
- There is performance inefficiency found by coverity tool json2.1.1/include/nlohmann/json.hpp [\#673](https://github.com/nlohmann/json/issues/673)
|
||||
- include problem, when cmake on osx [\#672](https://github.com/nlohmann/json/issues/672)
|
||||
- Operator= ambiguous in C++1z and GCC 7.1.1 [\#670](https://github.com/nlohmann/json/issues/670)
|
||||
- should't the cmake install target be to nlohman/json.hpp [\#668](https://github.com/nlohmann/json/issues/668)
|
||||
- deserialise from `std::vector` [\#667](https://github.com/nlohmann/json/issues/667)
|
||||
- How to iterate? [\#665](https://github.com/nlohmann/json/issues/665)
|
||||
- could this json lib work on windows? [\#664](https://github.com/nlohmann/json/issues/664)
|
||||
- How does from\_json work? [\#662](https://github.com/nlohmann/json/issues/662)
|
||||
- insert\(or merge\) object should replace same key , not ignore [\#661](https://github.com/nlohmann/json/issues/661)
|
||||
- Why is an object ordering values by Alphabetical Order? [\#660](https://github.com/nlohmann/json/issues/660)
|
||||
- Parse method doesn't handle newlines. [\#659](https://github.com/nlohmann/json/issues/659)
|
||||
- Compilation "note" on GCC 6 ARM [\#658](https://github.com/nlohmann/json/issues/658)
|
||||
- Adding additional push\_back/operator+= rvalue overloads for JSON object [\#657](https://github.com/nlohmann/json/issues/657)
|
||||
- dump's parameter "ensure\_ascii" creates too long sequences [\#656](https://github.com/nlohmann/json/issues/656)
|
||||
- Question: parsing `void \*` [\#655](https://github.com/nlohmann/json/issues/655)
|
||||
- how should I check a string is valid JSON string ? [\#653](https://github.com/nlohmann/json/issues/653)
|
||||
- Question: thread safety of read only accesses [\#651](https://github.com/nlohmann/json/issues/651)
|
||||
- Eclipse: Method 'size' could not be resolved [\#649](https://github.com/nlohmann/json/issues/649)
|
||||
- Update/Add object fields [\#648](https://github.com/nlohmann/json/issues/648)
|
||||
- No exception raised for Out Of Range input of numbers [\#647](https://github.com/nlohmann/json/issues/647)
|
||||
- Package Name [\#646](https://github.com/nlohmann/json/issues/646)
|
||||
- What is the meaning of operator\[\]\(T\* key\) [\#645](https://github.com/nlohmann/json/issues/645)
|
||||
- Which is the correct way to json objects as parameters to functions? [\#644](https://github.com/nlohmann/json/issues/644)
|
||||
- Method to get string representations of values [\#642](https://github.com/nlohmann/json/issues/642)
|
||||
- CBOR serialization of a given JSON value does not serialize [\#641](https://github.com/nlohmann/json/issues/641)
|
||||
- Are we forced to use "-fexceptions" flag in android ndk project [\#640](https://github.com/nlohmann/json/issues/640)
|
||||
- Comparison of objects containing floats [\#639](https://github.com/nlohmann/json/issues/639)
|
||||
- 'localeconv' is not supported by NDK for SDK \<=20 [\#638](https://github.com/nlohmann/json/issues/638)
|
||||
- \[Question\] cLion integration [\#637](https://github.com/nlohmann/json/issues/637)
|
||||
- How to construct an iteratable usage in nlohmann json? [\#636](https://github.com/nlohmann/json/issues/636)
|
||||
- \[Question\] copy assign json-container to vector [\#635](https://github.com/nlohmann/json/issues/635)
|
||||
- Get size without .dump\(\) [\#634](https://github.com/nlohmann/json/issues/634)
|
||||
- Segmentation fault when parsing invalid json file [\#633](https://github.com/nlohmann/json/issues/633)
|
||||
- How to serialize from json to vector\<customType\>? [\#632](https://github.com/nlohmann/json/issues/632)
|
||||
- no member named 'thousands\_sep' in 'lconv' [\#631](https://github.com/nlohmann/json/issues/631)
|
||||
- \[Question\] Any fork for \(the unsupported\) Visual Studio 2012 version? [\#628](https://github.com/nlohmann/json/issues/628)
|
||||
- Dependency injection in serializer [\#627](https://github.com/nlohmann/json/issues/627)
|
||||
- from\_json for std::array [\#625](https://github.com/nlohmann/json/issues/625)
|
||||
- Discussion: How to structure the parsing function families [\#623](https://github.com/nlohmann/json/issues/623)
|
||||
- Question: How to erase subtree [\#622](https://github.com/nlohmann/json/issues/622)
|
||||
- Insertion into nested json field [\#621](https://github.com/nlohmann/json/issues/621)
|
||||
- \[Question\] 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)
|
||||
- icc16 error [\#617](https://github.com/nlohmann/json/issues/617)
|
||||
- \[-Wdeprecated-declarations\] in row `j \>\> ss;` in file `json.hpp:7405:26` and FAILED unit tests with MinGWx64! [\#616](https://github.com/nlohmann/json/issues/616)
|
||||
- to\_json for pairs, tuples [\#614](https://github.com/nlohmann/json/issues/614)
|
||||
- Using uninitialized memory 'buf' in line 11173 v2.1.1? [\#613](https://github.com/nlohmann/json/issues/613)
|
||||
- How to parse multiple same Keys of JSON and save them? [\#612](https://github.com/nlohmann/json/issues/612)
|
||||
- "Multiple declarations" error when using types defined with `typedef` [\#611](https://github.com/nlohmann/json/issues/611)
|
||||
- 2.1.1+ breaks compilation of shared\_ptr\<json\> == 0 [\#610](https://github.com/nlohmann/json/issues/610)
|
||||
- a bug of inheritance ? [\#608](https://github.com/nlohmann/json/issues/608)
|
||||
- std::map key conversion with to\_json [\#607](https://github.com/nlohmann/json/issues/607)
|
||||
- json.hpp:6384:62: error: wrong number of template arguments \(1, should be 2\) [\#606](https://github.com/nlohmann/json/issues/606)
|
||||
- Incremental parsing: Where's the push version? [\#605](https://github.com/nlohmann/json/issues/605)
|
||||
- Is there a way to validate the structure of a json object ? [\#604](https://github.com/nlohmann/json/issues/604)
|
||||
- \[Question\] Issue when using Appveyor when compiling library [\#603](https://github.com/nlohmann/json/issues/603)
|
||||
- BOM not skipped when using json:parse\(iterator\) [\#602](https://github.com/nlohmann/json/issues/602)
|
||||
- Use of the binary type in CBOR and Message Pack [\#601](https://github.com/nlohmann/json/issues/601)
|
||||
- Newbie issue: how does one convert a map in Json back to std::map? [\#600](https://github.com/nlohmann/json/issues/600)
|
||||
- Plugin system [\#599](https://github.com/nlohmann/json/issues/599)
|
||||
- Feature request: Comments [\#597](https://github.com/nlohmann/json/issues/597)
|
||||
- Using custom types for scalars? [\#596](https://github.com/nlohmann/json/issues/596)
|
||||
- Issues with the arithmetic in iterator and reverse iterator [\#593](https://github.com/nlohmann/json/issues/593)
|
||||
- not enough examples [\#592](https://github.com/nlohmann/json/issues/592)
|
||||
- in-class initialization for type 'const T' is not yet implemented [\#591](https://github.com/nlohmann/json/issues/591)
|
||||
- compiling with gcc 7 -\> error on bool operator \< [\#590](https://github.com/nlohmann/json/issues/590)
|
||||
- Parsing from stream leads to an array [\#589](https://github.com/nlohmann/json/issues/589)
|
||||
- Buggy support for binary string data [\#587](https://github.com/nlohmann/json/issues/587)
|
||||
- C++17's ambiguous conversion [\#586](https://github.com/nlohmann/json/issues/586)
|
||||
- How does the messagepack encoding/decoding compare to msgpack-cpp in terms of performance? [\#585](https://github.com/nlohmann/json/issues/585)
|
||||
- is it possible to check existence of a value deep in hierarchy? [\#584](https://github.com/nlohmann/json/issues/584)
|
||||
- loading from a stream and exceptions [\#582](https://github.com/nlohmann/json/issues/582)
|
||||
- Visual Studio seems not to have all min\(\) function versions [\#581](https://github.com/nlohmann/json/issues/581)
|
||||
- Supporting of the json schema [\#580](https://github.com/nlohmann/json/issues/580)
|
||||
- Stack-overflow \(OSS-Fuzz 1444\) [\#577](https://github.com/nlohmann/json/issues/577)
|
||||
- Heap-buffer-overflow \(OSS-Fuzz 1400\) [\#575](https://github.com/nlohmann/json/issues/575)
|
||||
- JSON escape quotes [\#574](https://github.com/nlohmann/json/issues/574)
|
||||
- error: static\_assert failed [\#573](https://github.com/nlohmann/json/issues/573)
|
||||
- Storing floats, and round trip serialisation/deserialisation diffs [\#572](https://github.com/nlohmann/json/issues/572)
|
||||
- JSON.getLong produces inconsistent results [\#571](https://github.com/nlohmann/json/issues/571)
|
||||
- Request: Object.at\(\) with default return value [\#570](https://github.com/nlohmann/json/issues/570)
|
||||
- Internal structure gets corrupted while parsing [\#569](https://github.com/nlohmann/json/issues/569)
|
||||
- create template \<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)
|
||||
- contradictory documentation regarding json::find [\#565](https://github.com/nlohmann/json/issues/565)
|
||||
- Unexpected '\"' in middle of array [\#564](https://github.com/nlohmann/json/issues/564)
|
||||
- Support parse std::pair to Json object [\#563](https://github.com/nlohmann/json/issues/563)
|
||||
- json and Microsoft Visual c++ Compiler Nov 2012 CTP [\#562](https://github.com/nlohmann/json/issues/562)
|
||||
- from\_json declaration order and exceptions [\#561](https://github.com/nlohmann/json/issues/561)
|
||||
- Tip: Don't upgrade to VS2017 if using json initializer list constructs [\#559](https://github.com/nlohmann/json/issues/559)
|
||||
- parse error - unexpected end of input [\#558](https://github.com/nlohmann/json/issues/558)
|
||||
- Cant modify existing numbers inside a json object [\#557](https://github.com/nlohmann/json/issues/557)
|
||||
- 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)
|
||||
- Cannot convert from json array to std::array [\#553](https://github.com/nlohmann/json/issues/553)
|
||||
- Do not define an unnamed namespace in a header file \(DCL59-CPP\) [\#552](https://github.com/nlohmann/json/issues/552)
|
||||
- Parse error on known good json file [\#551](https://github.com/nlohmann/json/issues/551)
|
||||
- Warning on Intel compiler \(icc 17\) [\#550](https://github.com/nlohmann/json/issues/550)
|
||||
- multiple versions of 'vsnprintf' [\#549](https://github.com/nlohmann/json/issues/549)
|
||||
- illegal indirection [\#548](https://github.com/nlohmann/json/issues/548)
|
||||
- Ambiguous compare operators with clang-5.0 [\#547](https://github.com/nlohmann/json/issues/547)
|
||||
- Using tsl::ordered\_map [\#546](https://github.com/nlohmann/json/issues/546)
|
||||
- Compiler support errors are inconvenient [\#544](https://github.com/nlohmann/json/issues/544)
|
||||
- Head Elements Sorting [\#543](https://github.com/nlohmann/json/issues/543)
|
||||
- Duplicate symbols error happens while to\_json/from\_json method implemented inside entity definition header file [\#542](https://github.com/nlohmann/json/issues/542)
|
||||
- consider adding a bool json::is\_valid\(std::string const&\) non-member function [\#541](https://github.com/nlohmann/json/issues/541)
|
||||
- Help request [\#539](https://github.com/nlohmann/json/issues/539)
|
||||
- How to deal with missing keys in `from\_json`? [\#538](https://github.com/nlohmann/json/issues/538)
|
||||
- recursive from\_msgpack implementation will stack overflow [\#537](https://github.com/nlohmann/json/issues/537)
|
||||
- Exception objects must be nothrow copy constructible \(ERR60-CPP\) [\#531](https://github.com/nlohmann/json/issues/531)
|
||||
- Support for multiple root elements [\#529](https://github.com/nlohmann/json/issues/529)
|
||||
- Port has\_shape from dropbox/json11 [\#528](https://github.com/nlohmann/json/issues/528)
|
||||
- dump\_float: truncation from ptrdiff\_t to long [\#527](https://github.com/nlohmann/json/issues/527)
|
||||
- Make exception base class visible in basic\_json [\#525](https://github.com/nlohmann/json/issues/525)
|
||||
- msgpack unit test failures on ppc64 arch [\#524](https://github.com/nlohmann/json/issues/524)
|
||||
- How about split the implementation out, and only leave the interface? [\#523](https://github.com/nlohmann/json/issues/523)
|
||||
- VC++2017 not enough actual parameters for macro 'max' [\#522](https://github.com/nlohmann/json/issues/522)
|
||||
- crash on empty ifstream [\#521](https://github.com/nlohmann/json/issues/521)
|
||||
- Suggestion: Support tabs for indentation when serializing to stream. [\#520](https://github.com/nlohmann/json/issues/520)
|
||||
- Abrt in get\_number \(OSS-Fuzz 885\) [\#519](https://github.com/nlohmann/json/issues/519)
|
||||
- Abrt on unknown address \(OSS-Fuzz 884\) [\#518](https://github.com/nlohmann/json/issues/518)
|
||||
- Stack-overflow \(OSS-Fuzz 869\) [\#517](https://github.com/nlohmann/json/issues/517)
|
||||
- Assertion error \(OSS-Fuzz 868\) [\#516](https://github.com/nlohmann/json/issues/516)
|
||||
- NaN to json and back [\#515](https://github.com/nlohmann/json/issues/515)
|
||||
- Comparison of NaN [\#514](https://github.com/nlohmann/json/issues/514)
|
||||
- why it's not possible to serialize c++11 enums directly [\#513](https://github.com/nlohmann/json/issues/513)
|
||||
- clang compile error: use of overloaded operator '\<=' is ambiguous with \(nlohmann::json{{"a", 5}}\)\["a"\] \<= 10 [\#512](https://github.com/nlohmann/json/issues/512)
|
||||
- Why not also look inside the type for \(static\) to\_json and from\_json funtions? [\#511](https://github.com/nlohmann/json/issues/511)
|
||||
- Parser issues [\#509](https://github.com/nlohmann/json/issues/509)
|
||||
- I may not understand [\#507](https://github.com/nlohmann/json/issues/507)
|
||||
- VS2017 min / max problem for 2.1.1 [\#506](https://github.com/nlohmann/json/issues/506)
|
||||
- CBOR/MessagePack is not read until the end [\#505](https://github.com/nlohmann/json/issues/505)
|
||||
- Assertion error \(OSS-Fuzz 856\) [\#504](https://github.com/nlohmann/json/issues/504)
|
||||
- Return position in parse error exceptions [\#503](https://github.com/nlohmann/json/issues/503)
|
||||
- conversion from/to C array is not supported [\#502](https://github.com/nlohmann/json/issues/502)
|
||||
- error C2338: could not find to\_json\(\) method in T's namespace [\#501](https://github.com/nlohmann/json/issues/501)
|
||||
- Test suite fails in en\_GB.UTF-8 [\#500](https://github.com/nlohmann/json/issues/500)
|
||||
- cannot use operator\[\] with number [\#499](https://github.com/nlohmann/json/issues/499)
|
||||
- consider using \_\_cpp\_exceptions and/or \_\_EXCEPTIONS to disable/enable exception support [\#498](https://github.com/nlohmann/json/issues/498)
|
||||
- Stack-overflow \(OSS-Fuzz issue 814\) [\#497](https://github.com/nlohmann/json/issues/497)
|
||||
- Using in Unreal Engine - handling custom types conversion [\#495](https://github.com/nlohmann/json/issues/495)
|
||||
- Conversion from vector\<bool\> to json fails to build [\#494](https://github.com/nlohmann/json/issues/494)
|
||||
- fill\_line\_buffer incorrectly tests m\_stream for eof but not fail or bad bits [\#493](https://github.com/nlohmann/json/issues/493)
|
||||
- Compiling with \_GLIBCXX\_DEBUG yields iterator-comparison warnings during tests [\#492](https://github.com/nlohmann/json/issues/492)
|
||||
- crapy interface [\#491](https://github.com/nlohmann/json/issues/491)
|
||||
- Fix Visual Studo 2013 builds. [\#490](https://github.com/nlohmann/json/issues/490)
|
||||
- Failed to compile with -D\_GLIBCXX\_PARALLEL [\#489](https://github.com/nlohmann/json/issues/489)
|
||||
- Input several field with the same name [\#488](https://github.com/nlohmann/json/issues/488)
|
||||
- read in .json file yields strange sizes [\#487](https://github.com/nlohmann/json/issues/487)
|
||||
- json::value\_t can't be a map's key type in VC++ 2015 [\#486](https://github.com/nlohmann/json/issues/486)
|
||||
- Using fifo\_map [\#485](https://github.com/nlohmann/json/issues/485)
|
||||
- Cannot get float pointer for value stored as `0` [\#484](https://github.com/nlohmann/json/issues/484)
|
||||
- byte string support [\#483](https://github.com/nlohmann/json/issues/483)
|
||||
- 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)
|
||||
- Remove deprecated constructor basic\_json\(std::istream&\) [\#480](https://github.com/nlohmann/json/issues/480)
|
||||
- writing the binary json file? [\#479](https://github.com/nlohmann/json/issues/479)
|
||||
- CBOR/MessagePack from uint8\_t \* and size [\#478](https://github.com/nlohmann/json/issues/478)
|
||||
- Streaming binary representations [\#477](https://github.com/nlohmann/json/issues/477)
|
||||
- Reuse memory in to\_cbor and to\_msgpack functions [\#476](https://github.com/nlohmann/json/issues/476)
|
||||
- Error Using JSON Library with arrays C++ [\#475](https://github.com/nlohmann/json/issues/475)
|
||||
- Moving forward to version 3.0.0 [\#474](https://github.com/nlohmann/json/issues/474)
|
||||
- Inconsistent behavior in conversion to array type [\#473](https://github.com/nlohmann/json/issues/473)
|
||||
- Create a \[key:member\_pointer\] map to ease parsing custom types [\#471](https://github.com/nlohmann/json/issues/471)
|
||||
- MSVC 2015 update 2 [\#469](https://github.com/nlohmann/json/issues/469)
|
||||
- VS2017 implicit to std::string conversion fix. [\#464](https://github.com/nlohmann/json/issues/464)
|
||||
- How to make sure a string or string literal is a valid JSON? [\#458](https://github.com/nlohmann/json/issues/458)
|
||||
- basic\_json templated on a "policy" class [\#456](https://github.com/nlohmann/json/issues/456)
|
||||
- json::value\(const json\_pointer&, ValueType\) requires exceptions to return the default value. [\#440](https://github.com/nlohmann/json/issues/440)
|
||||
- is it possible merge two json object [\#428](https://github.com/nlohmann/json/issues/428)
|
||||
- Is it possible to turn this into a shared library? [\#420](https://github.com/nlohmann/json/issues/420)
|
||||
- Further thoughts on performance improvements [\#418](https://github.com/nlohmann/json/issues/418)
|
||||
- nan number stored as null [\#388](https://github.com/nlohmann/json/issues/388)
|
||||
- Behavior of operator\>\> should more closely resemble that of built-in overloads. [\#367](https://github.com/nlohmann/json/issues/367)
|
||||
- Request: range-based-for over a json-object to expose .first/.second [\#350](https://github.com/nlohmann/json/issues/350)
|
||||
- feature wish: JSONPath [\#343](https://github.com/nlohmann/json/issues/343)
|
||||
- UTF-8/Unicode escape and dump [\#330](https://github.com/nlohmann/json/issues/330)
|
||||
- Serialized value not always can be parsed. [\#329](https://github.com/nlohmann/json/issues/329)
|
||||
- Is there a way to forward declare nlohmann::json? [\#314](https://github.com/nlohmann/json/issues/314)
|
||||
- Exception line [\#301](https://github.com/nlohmann/json/issues/301)
|
||||
- Do not throw exception when default\_value's type does not match the actual type [\#278](https://github.com/nlohmann/json/issues/278)
|
||||
- dump\(\) method doesn't work with a custom allocator [\#268](https://github.com/nlohmann/json/issues/268)
|
||||
- Readme documentation enhancements [\#248](https://github.com/nlohmann/json/issues/248)
|
||||
- Use user-defined exceptions [\#244](https://github.com/nlohmann/json/issues/244)
|
||||
- Incorrect C++11 allocator model support [\#161](https://github.com/nlohmann/json/issues/161)
|
||||
|
||||
- :white\_check\_mark: re-added tests for algorithms [\#879](https://github.com/nlohmann/json/pull/879) ([nlohmann](https://github.com/nlohmann))
|
||||
- Overworked library toward 3.0.0 release [\#875](https://github.com/nlohmann/json/pull/875) ([nlohmann](https://github.com/nlohmann))
|
||||
- :rotating\_light: remove C4996 warnings \#872 [\#873](https://github.com/nlohmann/json/pull/873) ([nlohmann](https://github.com/nlohmann))
|
||||
- :boom: throwing an exception in case dump encounters a non-UTF-8 string \#838 [\#870](https://github.com/nlohmann/json/pull/870) ([nlohmann](https://github.com/nlohmann))
|
||||
- :memo: fixing documentation \#867 [\#868](https://github.com/nlohmann/json/pull/868) ([nlohmann](https://github.com/nlohmann))
|
||||
- iter\_impl template conformance with C++17 [\#860](https://github.com/nlohmann/json/pull/860) ([bogemic](https://github.com/bogemic))
|
||||
- Std allocator conformance cpp17 [\#856](https://github.com/nlohmann/json/pull/856) ([bogemic](https://github.com/bogemic))
|
||||
- cmake: use BUILD\_INTERFACE/INSTALL\_INTERFACE [\#855](https://github.com/nlohmann/json/pull/855) ([theodelrieu](https://github.com/theodelrieu))
|
||||
- to/from\_json: add a MSVC-specific static\_assert to force a stacktrace [\#854](https://github.com/nlohmann/json/pull/854) ([theodelrieu](https://github.com/theodelrieu))
|
||||
- Add .natvis for MSVC debug view [\#844](https://github.com/nlohmann/json/pull/844) ([TinyTinni](https://github.com/TinyTinni))
|
||||
- Updated hunter package links [\#829](https://github.com/nlohmann/json/pull/829) ([jowr](https://github.com/jowr))
|
||||
- Typos README [\#811](https://github.com/nlohmann/json/pull/811) ([Itja](https://github.com/Itja))
|
||||
- add forwarding references to json\_ref constructor [\#807](https://github.com/nlohmann/json/pull/807) ([theodelrieu](https://github.com/theodelrieu))
|
||||
- Add transparent comparator and perfect forwarding support to find\(\) and count\(\) [\#795](https://github.com/nlohmann/json/pull/795) ([jseward](https://github.com/jseward))
|
||||
- Error : 'identifier "size\_t" is undefined' in linux [\#793](https://github.com/nlohmann/json/pull/793) ([sonulohani](https://github.com/sonulohani))
|
||||
- Fix Visual Studio 2017 warnings [\#788](https://github.com/nlohmann/json/pull/788) ([jseward](https://github.com/jseward))
|
||||
- Fix warning C4706 on Visual Studio 2017 [\#785](https://github.com/nlohmann/json/pull/785) ([jseward](https://github.com/jseward))
|
||||
- Set GENERATE\_TAGFILE in Doxyfile [\#783](https://github.com/nlohmann/json/pull/783) ([eld00d](https://github.com/eld00d))
|
||||
- using more CMake [\#765](https://github.com/nlohmann/json/pull/765) ([nlohmann](https://github.com/nlohmann))
|
||||
- Simplified istream handing \#367 [\#764](https://github.com/nlohmann/json/pull/764) ([pjkundert](https://github.com/pjkundert))
|
||||
- Add info for the vcpkg package. [\#753](https://github.com/nlohmann/json/pull/753) ([gregmarr](https://github.com/gregmarr))
|
||||
- fix from\_json implementation for pair/tuple [\#708](https://github.com/nlohmann/json/pull/708) ([theodelrieu](https://github.com/theodelrieu))
|
||||
- Update json.hpp [\#686](https://github.com/nlohmann/json/pull/686) ([GoWebProd](https://github.com/GoWebProd))
|
||||
- Remove duplicate word [\#685](https://github.com/nlohmann/json/pull/685) ([daixtrose](https://github.com/daixtrose))
|
||||
- To fix compilation issue for intel OSX compiler [\#682](https://github.com/nlohmann/json/pull/682) ([kbthomp1](https://github.com/kbthomp1))
|
||||
- Digraph warning [\#679](https://github.com/nlohmann/json/pull/679) ([traits](https://github.com/traits))
|
||||
- massage -\> message [\#678](https://github.com/nlohmann/json/pull/678) ([DmitryKuk](https://github.com/DmitryKuk))
|
||||
- Fix "not constraint" grammar in docs [\#674](https://github.com/nlohmann/json/pull/674) ([wincent](https://github.com/wincent))
|
||||
- Add documentation for integration with CMake and hunter [\#671](https://github.com/nlohmann/json/pull/671) ([dan-42](https://github.com/dan-42))
|
||||
- REFACTOR: rewrite CMakeLists.txt for better inlcude and reuse [\#669](https://github.com/nlohmann/json/pull/669) ([dan-42](https://github.com/dan-42))
|
||||
- enable\_testing only if the JSON\_BuildTests is ON [\#666](https://github.com/nlohmann/json/pull/666) ([effolkronium](https://github.com/effolkronium))
|
||||
- Support moving from rvalues in std::initializer\_list [\#663](https://github.com/nlohmann/json/pull/663) ([himikof](https://github.com/himikof))
|
||||
- add ensure\_ascii parameter to dump. \#330 [\#654](https://github.com/nlohmann/json/pull/654) ([ryanjmulder](https://github.com/ryanjmulder))
|
||||
- Rename BuildTests to JSON\_BuildTests [\#652](https://github.com/nlohmann/json/pull/652) ([olegendo](https://github.com/olegendo))
|
||||
- Don't include \<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)
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v2.1.0...v2.1.1)
|
||||
|
||||
@ -129,7 +525,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Performance improvements [\#365](https://github.com/nlohmann/json/issues/365)
|
||||
- 'to\_string' is not a member of 'std' [\#364](https://github.com/nlohmann/json/issues/364)
|
||||
- Optional comment support. [\#363](https://github.com/nlohmann/json/issues/363)
|
||||
- Loss of precision when serializing \<double\> [\#360](https://github.com/nlohmann/json/issues/360)
|
||||
- Crash in dump\(\) from a static object [\#359](https://github.com/nlohmann/json/issues/359)
|
||||
- json::parse\(...\) vs json j; j.parse\(...\) [\#357](https://github.com/nlohmann/json/issues/357)
|
||||
- Hi, is there any method to dump json to string with the insert order rather than alphabets [\#356](https://github.com/nlohmann/json/issues/356)
|
||||
|
151
Makefile
151
Makefile
@ -1,19 +1,20 @@
|
||||
.PHONY: pretty clean ChangeLog.md
|
||||
|
||||
# used programs
|
||||
RE2C = re2c
|
||||
SED = sed
|
||||
|
||||
# main target
|
||||
all:
|
||||
$(MAKE) -C test
|
||||
|
||||
# clean up
|
||||
clean:
|
||||
rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM test/*.dSYM
|
||||
rm -fr benchmarks/files/numbers/*.json
|
||||
$(MAKE) clean -Cdoc
|
||||
$(MAKE) clean -Ctest
|
||||
@echo "ChangeLog.md - generate ChangeLog file"
|
||||
@echo "check - compile and execute test suite"
|
||||
@echo "check-fast - compile and execute test suite (skip long-running tests)"
|
||||
@echo "clean - remove built files"
|
||||
@echo "coverage - create coverage information with lcov"
|
||||
@echo "cppcheck - analyze code with cppcheck"
|
||||
@echo "doctest - compile example files and check their output"
|
||||
@echo "fuzz_testing - prepare fuzz testing of the JSON parser"
|
||||
@echo "fuzz_testing_cbor - prepare fuzz testing of the CBOR parser"
|
||||
@echo "fuzz_testing_msgpack - prepare fuzz testing of the MessagePack parser"
|
||||
@echo "json_unit - create single-file test executable"
|
||||
@echo "pedantic_clang - run Clang with maximal warning flags"
|
||||
@echo "pedantic_gcc - run GCC with maximal warning flags"
|
||||
@echo "pretty - beautify code with Artistic Style"
|
||||
|
||||
|
||||
##########################################################################
|
||||
@ -31,6 +32,28 @@ check:
|
||||
check-fast:
|
||||
$(MAKE) check -C test TEST_PATTERN=""
|
||||
|
||||
# clean up
|
||||
clean:
|
||||
rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM test/*.dSYM
|
||||
rm -fr benchmarks/files/numbers/*.json
|
||||
rm -fr build_coverage
|
||||
$(MAKE) clean -Cdoc
|
||||
$(MAKE) clean -Ctest
|
||||
$(MAKE) clean -Cbenchmarks
|
||||
|
||||
|
||||
##########################################################################
|
||||
# coverage
|
||||
##########################################################################
|
||||
|
||||
coverage:
|
||||
mkdir build_coverage
|
||||
cd build_coverage ; CXX=g++-5 cmake .. -GNinja -DJSON_Coverage=ON
|
||||
cd build_coverage ; ninja
|
||||
cd build_coverage ; ctest
|
||||
cd build_coverage ; ninja lcov_html
|
||||
open build_coverage/test/html/index.html
|
||||
|
||||
|
||||
##########################################################################
|
||||
# documentation tests
|
||||
@ -49,19 +72,88 @@ doctest:
|
||||
# -Wno-documentation-unknown-command: code uses user-defined commands like @complexity
|
||||
# -Wno-exit-time-destructors: warning in Catch code
|
||||
# -Wno-keyword-macro: unit-tests use "#define private public"
|
||||
# -Wno-deprecated-declarations: some functions are deprecated until 3.0.0
|
||||
# -Wno-range-loop-analysis: iterator_wrapper tests tests "for(const auto i...)"
|
||||
pedantic:
|
||||
# -Wno-deprecated-declarations: the library deprecated some functions
|
||||
# -Wno-weak-vtables: exception class is defined inline, but has virtual method
|
||||
# -Wno-range-loop-analysis: iterator_wrapper tests "for(const auto i...)"
|
||||
# -Wno-float-equal: not all comparisons in the tests can be replaced by Approx
|
||||
# -Wno-switch-enum -Wno-covered-switch-default: pedantic/contradicting warnings about switches
|
||||
# -Wno-padded: padding is nothing to warn about
|
||||
pedantic_clang:
|
||||
$(MAKE) json_unit CXXFLAGS="\
|
||||
-std=c++11 \
|
||||
-std=c++11 -Wno-c++98-compat -Wno-c++98-compat-pedantic \
|
||||
-Werror \
|
||||
-Weverything \
|
||||
-Wno-documentation-unknown-command \
|
||||
-Wno-exit-time-destructors \
|
||||
-Wno-keyword-macro \
|
||||
-Wno-deprecated-declarations \
|
||||
-Wno-range-loop-analysis"
|
||||
-Wno-weak-vtables \
|
||||
-Wno-range-loop-analysis \
|
||||
-Wno-float-equal \
|
||||
-Wno-switch-enum -Wno-covered-switch-default \
|
||||
-Wno-padded"
|
||||
|
||||
# calling GCC with most warnings
|
||||
pedantic_gcc:
|
||||
$(MAKE) json_unit CXXFLAGS="\
|
||||
-std=c++11 \
|
||||
-Wno-deprecated-declarations \
|
||||
-Werror \
|
||||
-Wall -Wpedantic -Wextra \
|
||||
-Walloca \
|
||||
-Warray-bounds=2 \
|
||||
-Wcast-qual -Wcast-align \
|
||||
-Wchar-subscripts \
|
||||
-Wconditionally-supported \
|
||||
-Wconversion \
|
||||
-Wdate-time \
|
||||
-Wdeprecated \
|
||||
-Wdisabled-optimization \
|
||||
-Wdouble-promotion \
|
||||
-Wduplicated-branches \
|
||||
-Wduplicated-cond \
|
||||
-Wformat-overflow=2 \
|
||||
-Wformat-signedness \
|
||||
-Wformat-truncation=2 \
|
||||
-Wformat=2 \
|
||||
-Wno-ignored-qualifiers \
|
||||
-Wimplicit-fallthrough=5 \
|
||||
-Wlogical-op \
|
||||
-Wmissing-declarations \
|
||||
-Wmissing-format-attribute \
|
||||
-Wmissing-include-dirs \
|
||||
-Wnoexcept \
|
||||
-Wnonnull \
|
||||
-Wnull-dereference \
|
||||
-Wold-style-cast \
|
||||
-Woverloaded-virtual \
|
||||
-Wparentheses \
|
||||
-Wplacement-new=2 \
|
||||
-Wredundant-decls \
|
||||
-Wreorder \
|
||||
-Wrestrict \
|
||||
-Wshadow=global \
|
||||
-Wshift-overflow=2 \
|
||||
-Wsign-conversion \
|
||||
-Wsign-promo \
|
||||
-Wsized-deallocation \
|
||||
-Wstrict-overflow=5 \
|
||||
-Wsuggest-attribute=const \
|
||||
-Wsuggest-attribute=format \
|
||||
-Wsuggest-attribute=noreturn \
|
||||
-Wsuggest-attribute=pure \
|
||||
-Wsuggest-final-methods \
|
||||
-Wsuggest-final-types \
|
||||
-Wsuggest-override \
|
||||
-Wtrigraphs \
|
||||
-Wundef \
|
||||
-Wuninitialized -Wunknown-pragmas \
|
||||
-Wunused \
|
||||
-Wunused-const-variable=2 \
|
||||
-Wunused-macros \
|
||||
-Wunused-parameter \
|
||||
-Wuseless-cast \
|
||||
-Wvariadic-macros"
|
||||
|
||||
##########################################################################
|
||||
# fuzzing
|
||||
@ -114,19 +206,11 @@ fuzzing-stop:
|
||||
cppcheck:
|
||||
cppcheck --enable=warning --inconclusive --force --std=c++11 src/json.hpp --error-exitcode=1
|
||||
|
||||
# run clang sanitize (we are overrding the CXXFLAGS provided by travis in order to use gcc's libstdc++)
|
||||
clang_sanitize: clean
|
||||
CXX=clang++ CXXFLAGS="-g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer" $(MAKE) check
|
||||
|
||||
|
||||
##########################################################################
|
||||
# maintainer targets
|
||||
##########################################################################
|
||||
|
||||
# create scanner with re2c
|
||||
re2c: src/json.hpp.re2c
|
||||
$(RE2C) -W --utf-8 --encoding-policy fail --bit-vectors --nested-ifs --no-debug-info $< | $(SED) '1d' > src/json.hpp
|
||||
|
||||
# pretty printer
|
||||
pretty:
|
||||
astyle --style=allman --indent=spaces=4 --indent-modifiers \
|
||||
@ -134,19 +218,8 @@ pretty:
|
||||
--indent-col1-comments --pad-oper --pad-header --align-pointer=type \
|
||||
--align-reference=type --add-brackets --convert-tabs --close-templates \
|
||||
--lineend=linux --preserve-date --suffix=none --formatted \
|
||||
src/json.hpp src/json.hpp.re2c test/src/*.cpp \
|
||||
benchmarks/benchmarks.cpp doc/examples/*.cpp
|
||||
|
||||
|
||||
##########################################################################
|
||||
# benchmarks
|
||||
##########################################################################
|
||||
|
||||
# benchmarks
|
||||
json_benchmarks: benchmarks/benchmarks.cpp benchmarks/benchpress.hpp benchmarks/cxxopts.hpp src/json.hpp
|
||||
cd benchmarks/files/numbers ; python generate.py
|
||||
$(CXX) -std=c++11 -pthread $(CXXFLAGS) -DNDEBUG -O3 -flto -I src -I benchmarks $< $(LDFLAGS) -o $@
|
||||
./json_benchmarks
|
||||
src/json.hpp test/src/*.cpp \
|
||||
benchmarks/src/benchmarks.cpp doc/examples/*.cpp
|
||||
|
||||
|
||||
##########################################################################
|
||||
|
174
README.md
174
README.md
@ -5,11 +5,12 @@
|
||||
[![Coverage Status](https://img.shields.io/coveralls/nlohmann/json.svg)](https://coveralls.io/r/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&utm_medium=referral&utm_content=nlohmann/json&utm_campaign=Badge_Grade)
|
||||
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](http://melpon.org/wandbox/permlink/4NEU6ZZMoM9lpIex)
|
||||
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/TZS6TQdqmEUcN8WW)
|
||||
[![Documentation](https://img.shields.io/badge/docs-doxygen-blue.svg)](http://nlohmann.github.io/json)
|
||||
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nlohmann/json/master/LICENSE.MIT)
|
||||
[![Github Releases](https://img.shields.io/github/release/nlohmann/json.svg)](https://github.com/nlohmann/json/releases)
|
||||
[![Github Issues](https://img.shields.io/github/issues/nlohmann/json.svg)](http://github.com/nlohmann/json/issues)
|
||||
[![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")
|
||||
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/289/badge)](https://bestpractices.coreinfrastructure.org/projects/289)
|
||||
|
||||
- [Design goals](#design-goals)
|
||||
@ -25,6 +26,7 @@
|
||||
- [Binary formats (CBOR and MessagePack)](#binary-formats-cbor-and-messagepack)
|
||||
- [Supported compilers](#supported-compilers)
|
||||
- [License](#license)
|
||||
- [Contact](#contact)
|
||||
- [Thanks](#thanks)
|
||||
- [Used third-party tools](#used-third-party-tools)
|
||||
- [Projects using JSON for Modern C++](#projects-using-json-for-modern-c)
|
||||
@ -65,6 +67,16 @@ to the files you want to use JSON objects. That's it. Do not forget to set the n
|
||||
|
||||
: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`.
|
||||
|
||||
If you are using the [Meson Build System](http://mesonbuild.com), then you can wrap this repo as a subproject.
|
||||
|
||||
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 [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 [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.
|
||||
|
||||
:warning: [Version 3.0.0](https://github.com/nlohmann/json/wiki/Road-toward-3.0.0) is currently under development. Branch `develop` is used for the ongoing work and is probably **unstable**. Please use the `master` branch for the last stable version 2.1.1.
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
@ -148,7 +160,7 @@ json empty_object_implicit = json({});
|
||||
json empty_object_explicit = json::object();
|
||||
|
||||
// a way to express an _array_ of key/value pairs [["currency", "USD"], ["value", 42.99]]
|
||||
json array_not_object = { json::array({"currency", "USD"}), json::array({"value", 42.99}) };
|
||||
json array_not_object = json::array({ {"currency", "USD"}, {"value", 42.99} });
|
||||
```
|
||||
|
||||
|
||||
@ -195,6 +207,29 @@ std::cout << j.dump(4) << std::endl;
|
||||
// }
|
||||
```
|
||||
|
||||
Note the difference between serialization and assignment:
|
||||
|
||||
```cpp
|
||||
// store a string in a JSON value
|
||||
json j_string = "this is a string";
|
||||
|
||||
// retrieve the string value (implicit JSON to std::string conversion)
|
||||
std::string cpp_string = j_string;
|
||||
// retrieve the string value (explicit JSON to std::string conversion)
|
||||
auto cpp_string2 = j_string.get<std::string>();
|
||||
|
||||
// retrieve the serialized value (explicit JSON serialization)
|
||||
std::string serialized_string = j_string.dump();
|
||||
|
||||
// output of original string
|
||||
std::cout << cpp_string << " == " << cpp_string2 << " == " << j_string.get<std::string>() << '\n';
|
||||
// output of serialized value
|
||||
std::cout << j_string << " == " << serialized_string << std::endl;
|
||||
```
|
||||
|
||||
`.dump()` always returns the serialized value, and `.get<std::string>()` returns the originally stored string value.
|
||||
|
||||
|
||||
#### To/from streams (e.g. files, string streams)
|
||||
|
||||
You can also use streams to serialize and deserialize:
|
||||
@ -228,17 +263,17 @@ Please note that setting the exception bit for `failbit` is inappropriate for th
|
||||
|
||||
#### Read from iterator range
|
||||
|
||||
You can also read 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<uint8_t>`:
|
||||
You can also read 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>`:
|
||||
|
||||
```cpp
|
||||
std::vector<uint8_t> v = {'t', 'r', 'u', 'e'};
|
||||
std::vector<std::uint8_t> v = {'t', 'r', 'u', 'e'};
|
||||
json j = json::parse(v.begin(), v.end());
|
||||
```
|
||||
|
||||
You may leave the iterators for the range [begin, end):
|
||||
|
||||
```cpp
|
||||
std::vector<uint8_t> v = {'t', 'r', 'u', 'e'};
|
||||
std::vector<std::uint8_t> v = {'t', 'r', 'u', 'e'};
|
||||
json j = json::parse(v);
|
||||
```
|
||||
|
||||
@ -319,7 +354,7 @@ o.erase("foo");
|
||||
|
||||
### Conversion from STL containers
|
||||
|
||||
Any sequence container (`std::array`, `std::vector`, `std::deque`, `std::forward_list`, `std::list`) whose values can be used to construct JSON types (e.g., integers, floating point numbers, Booleans, string types, or again STL containers described in this section) can be used to create a JSON array. The same holds for similar associative containers (`std::set`, `std::multiset`, `std::unordered_set`, `std::unordered_multiset`), but in these cases the order of the elements of the array depends how the elements are ordered in the respective STL container.
|
||||
Any sequence container (`std::array`, `std::vector`, `std::deque`, `std::forward_list`, `std::list`) whose values can be used to construct JSON types (e.g., integers, floating point numbers, Booleans, string types, or again STL containers described in this section) can be used to create a JSON array. The same holds for similar associative containers (`std::set`, `std::multiset`, `std::unordered_set`, `std::unordered_multiset`), but in these cases the order of the elements of the array depends on how the elements are ordered in the respective STL container.
|
||||
|
||||
```cpp
|
||||
std::vector<int> c_vector {1, 2, 3, 4};
|
||||
@ -359,7 +394,7 @@ json j_umset(c_umset); // both entries for "one" are used
|
||||
// maybe ["one", "two", "one", "four"]
|
||||
```
|
||||
|
||||
Likewise, any associative key-value containers (`std::map`, `std::multimap`, `std::unordered_map`, `std::unordered_multimap`) whose keys can construct an `std::string` and whose values can be used to construct JSON types (see examples above) can be used to to create a JSON object. Note that in case of multimaps only one key is used in the JSON object and the value depends on the internal order of the STL container.
|
||||
Likewise, any associative key-value containers (`std::map`, `std::multimap`, `std::unordered_map`, `std::unordered_multimap`) whose keys can construct an `std::string` and whose values can be used to construct JSON types (see examples above) can be used to create a JSON object. Note that in case of multimaps only one key is used in the JSON object and the value depends on the internal order of the STL container.
|
||||
|
||||
```cpp
|
||||
std::map<std::string, int> c_map { {"one", 1}, {"two", 2}, {"three", 3} };
|
||||
@ -515,9 +550,9 @@ namespace ns {
|
||||
}
|
||||
|
||||
void from_json(const json& j, person& p) {
|
||||
p.name = j["name"].get<std::string>();
|
||||
p.address = j["address"].get<std::string>();
|
||||
p.age = j["age"].get<int>();
|
||||
p.name = j.at("name").get<std::string>();
|
||||
p.address = j.at("address").get<std::string>();
|
||||
p.age = j.at("age").get<int>();
|
||||
}
|
||||
} // namespace ns
|
||||
```
|
||||
@ -529,6 +564,11 @@ Some important things:
|
||||
|
||||
* Those methods **MUST** be in your type's namespace (which can be the global namespace), or the library will not be able to locate them (in this example, they are in namespace `ns`, where `person` is defined).
|
||||
* When using `get<your_type>()`, `your_type` **MUST** be [DefaultConstructible](http://en.cppreference.com/w/cpp/concept/DefaultConstructible). (There is a way to bypass this requirement described later.)
|
||||
* In function `from_json`, use function [`at()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a93403e803947b86f4da2d1fb3345cf2c.html#a93403e803947b86f4da2d1fb3345cf2c) to access the object values rather than `operator[]`. In case a key does not exist, `at` throws an exception that you can handle, whereas `operator[]` exhibits undefined behavior.
|
||||
* In case your type contains several `operator=` definitions, code like `your_variable = your_json;` [may not compile](https://github.com/nlohmann/json/issues/667). You need to write `your_variable = your_json.get<decltype your_variable>();` instead.
|
||||
* You do not need to add serializers or deserializers for STL types like `std::vector`: the library already implements these.
|
||||
* Be careful with the definition order of the `from_json`/`to_json` functions: If a type `B` has a member of type `A`, you **MUST** define `to_json(A)` before `to_json(B)`. Look at [issue 561](https://github.com/nlohmann/json/issues/561) for more details.
|
||||
|
||||
|
||||
#### How do I convert third-party types?
|
||||
|
||||
@ -680,7 +720,7 @@ Though JSON is a ubiquitous data format, it is not a very compact format suitabl
|
||||
json j = R"({"compact": true, "schema": 0})"_json;
|
||||
|
||||
// serialize to CBOR
|
||||
std::vector<uint8_t> v_cbor = json::to_cbor(j);
|
||||
std::vector<std::uint8_t> v_cbor = json::to_cbor(j);
|
||||
|
||||
// 0xa2, 0x67, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0xf5, 0x66, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x00
|
||||
|
||||
@ -688,7 +728,7 @@ std::vector<uint8_t> v_cbor = json::to_cbor(j);
|
||||
json j_from_cbor = json::from_cbor(v_cbor);
|
||||
|
||||
// serialize to MessagePack
|
||||
std::vector<uint8_t> v_msgpack = json::to_msgpack(j);
|
||||
std::vector<std::uint8_t> v_msgpack = json::to_msgpack(j);
|
||||
|
||||
// 0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0xc3, 0xa6, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x00
|
||||
|
||||
@ -699,11 +739,13 @@ json j_from_msgpack = json::from_msgpack(v_msgpack);
|
||||
|
||||
## Supported compilers
|
||||
|
||||
Though it's 2016 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work:
|
||||
Though it's 2017 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work:
|
||||
|
||||
- GCC 4.9 - 6.0 (and possibly later)
|
||||
- Clang 3.4 - 3.9 (and possibly later)
|
||||
- GCC 4.9 - 7.2 (and possibly later)
|
||||
- Clang 3.4 - 5.0 (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++ 2017 / Build Tools 15.5.180.51428 (and possibly later)
|
||||
|
||||
I would be happy to learn about other compilers/versions.
|
||||
|
||||
@ -726,23 +768,28 @@ The following compilers are currently used in continuous integration at [Travis]
|
||||
|
||||
| Compiler | Operating System | Version String |
|
||||
|-----------------|------------------------------|----------------|
|
||||
| GCC 4.9.3 | Ubuntu 14.04.4 LTS | g++-4.9 (Ubuntu 4.9.3-8ubuntu2~14.04) 4.9.3 |
|
||||
| GCC 5.3.0 | Ubuntu 14.04.4 LTS | g++-5 (Ubuntu 5.3.0-3ubuntu1~14.04) 5.3.0 20151204 |
|
||||
| GCC 6.1.1 | Ubuntu 14.04.4 LTS | g++-6 (Ubuntu 6.1.1-3ubuntu11~14.04.1) 6.1.1 20160511 |
|
||||
| Clang 3.6.0 | Ubuntu 14.04.4 LTS | clang version 3.6.0 (tags/RELEASE_360/final) |
|
||||
| Clang 3.6.1 | Ubuntu 14.04.4 LTS | clang version 3.6.1 (tags/RELEASE_361/final) |
|
||||
| Clang 3.6.2 | Ubuntu 14.04.4 LTS | clang version 3.6.2 (tags/RELEASE_362/final) |
|
||||
| Clang 3.7.0 | Ubuntu 14.04.4 LTS | clang version 3.7.0 (tags/RELEASE_370/final) |
|
||||
| Clang 3.7.1 | Ubuntu 14.04.4 LTS | clang version 3.7.1 (tags/RELEASE_371/final) |
|
||||
| Clang 3.8.0 | Ubuntu 14.04.4 LTS | clang version 3.8.0 (tags/RELEASE_380/final) |
|
||||
| Clang 3.8.1 | Ubuntu 14.04.4 LTS | clang version 3.8.1 (tags/RELEASE_381/final) |
|
||||
| GCC 4.9.4 | Ubuntu 14.04.5 LTS | g++-4.9 (Ubuntu 4.9.4-2ubuntu1~14.04.1) 4.9.4 |
|
||||
| GCC 5.4.1 | Ubuntu 14.04.5 LTS | g++-5 (Ubuntu 5.4.1-2ubuntu1~14.04) 5.4.1 20160904 |
|
||||
| GCC 6.3.0 | Ubuntu 14.04.5 LTS | g++-6 (Ubuntu/Linaro 6.3.0-18ubuntu2~14.04) 6.3.0 20170519 |
|
||||
| GCC 7.1.0 | Ubuntu 14.04.5 LTS | g++-7 (Ubuntu 7.1.0-5ubuntu2~14.04) 7.1.0
|
||||
| Clang 3.5.0 | Ubuntu 14.04.5 LTS | clang version 3.5.0-4ubuntu2~trusty2 (tags/RELEASE_350/final) |
|
||||
| Clang 3.6.2 | Ubuntu 14.04.5 LTS | clang version 3.6.2-svn240577-1~exp1 (branches/release_36) |
|
||||
| Clang 3.7.1 | Ubuntu 14.04.5 LTS | clang version 3.7.1-svn253571-1~exp1 (branches/release_37) |
|
||||
| Clang 3.8.0 | Ubuntu 14.04.5 LTS | clang version 3.8.0-2ubuntu3~trusty5 (tags/RELEASE_380/final) |
|
||||
| Clang 3.9.1 | Ubuntu 14.04.5 LTS | clang version 3.9.1-4ubuntu3~14.04.2 (tags/RELEASE_391/rc2) |
|
||||
| Clang 4.0.1 | Ubuntu 14.04.5 LTS | clang version 4.0.1-svn305264-1~exp1 (branches/release_40) |
|
||||
| Clang 5.0.0 | Ubuntu 14.04.5 LTS | clang version 5.0.0-svn310902-1~exp1 (branches/release_50) |
|
||||
| Clang Xcode 6.4 | Darwin Kernel Version 14.3.0 (OSX 10.10.3) | Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn) |
|
||||
| Clang Xcode 7.3 | Darwin Kernel Version 15.0.0 (OSX 10.10.5) | Apple LLVM version 7.3.0 (clang-703.0.29) |
|
||||
| Clang Xcode 8.0 | Darwin Kernel Version 15.6.0 | Apple LLVM version 8.0.0 (clang-800.0.38) |
|
||||
| Clang Xcode 8.1 | Darwin Kernel Version 16.1.0 (macOS 10.12.1) | Apple LLVM version 8.0.0 (clang-800.0.42.1) |
|
||||
| Clang Xcode 8.2 | Darwin Kernel Version 16.1.0 (macOS 10.12.1) | Apple LLVM version 8.0.0 (clang-800.0.42.1) |
|
||||
| Visual Studio 14 2015 | Windows Server 2012 R2 (x64) | Microsoft (R) Build Engine version 14.0.25123.0 |
|
||||
|
||||
| Clang Xcode 8.3 | Darwin Kernel Version 16.5.0 (macOS 10.12.4) | Apple LLVM version 8.1.0 (clang-802.0.38) |
|
||||
| Clang Xcode 9.0 | Darwin Kernel Version 16.7.0 (macOS 10.12.6) | Apple LLVM version 9.0.0 (clang-900.0.37) |
|
||||
| Clang Xcode 9.1 | Darwin Kernel Version 16.7.0 (macOS 10.12.6) | Apple LLVM version 9.0.0 (clang-900.0.38) |
|
||||
| Clang Xcode 9.2 | Darwin Kernel Version 16.7.0 (macOS 10.12.6) | Apple LLVM version 8.1.0 (clang-900.0.39.2) |
|
||||
| Visual Studio 14 2015 | Windows Server 2012 R2 (x64) | Microsoft (R) Build Engine version 14.0.25420.1, MSVC 19.0.24215.1 |
|
||||
| Visual Studio 2017 | Windows Server 2016 | Microsoft (R) Build Engine version 15.5.180.51428, MSVC 19.12.25830.2 |
|
||||
|
||||
## License
|
||||
|
||||
@ -758,11 +805,23 @@ The above copyright notice and this permission notice shall be included in all c
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
* * *
|
||||
|
||||
The class contains the UTF-8 Decoder from Bjoern Hoehrmann which is licensed under the [MIT License](http://opensource.org/licenses/MIT) (see above). Copyright © 2008-2009 [Björn Hoehrmann](http://bjoern.hoehrmann.de/) <bjoern@hoehrmann.de>
|
||||
|
||||
## Contact
|
||||
|
||||
If you have questions regarding the library, I would like to invite you to [open an issue at Github](https://github.com/nlohmann/json/issues/new). Please describe your request, problem, or question as detailed as possible, and also mention the version of the library you are using as well as the version of your compiler and operating system. Opening an issue at Github allows other users and contributors to this library to collaborate. For instance, I have little experience with MSVC, and most issues in this regard have been solved by a growing community. If you have a look at the [closed issues](https://github.com/nlohmann/json/issues?q=is%3Aissue+is%3Aclosed), you will see that we react quite timely in most cases.
|
||||
|
||||
Only if your request would contain confidential information, please [send me an email](mailto:mail@nlohmann.me). For encrypted messages, please use [this key](https://keybase.io/nlohmann/pgp_keys.asc).
|
||||
|
||||
|
||||
## Thanks
|
||||
|
||||
I deeply appreciate the help of the following people.
|
||||
|
||||
![Contributors](https://raw.githubusercontent.com/nlohmann/json/develop/doc/avatars.png)
|
||||
|
||||
- [Teemperor](https://github.com/Teemperor) implemented CMake support and lcov integration, realized escape and Unicode handling in the string parser, and fixed the JSON serialization.
|
||||
- [elliotgoodrich](https://github.com/elliotgoodrich) fixed an issue with double deletion in the iterator classes.
|
||||
- [kirkshoop](https://github.com/kirkshoop) made the iterators of the class composable to other libraries.
|
||||
@ -807,7 +866,7 @@ I deeply appreciate the help of the following people.
|
||||
- [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`.
|
||||
- [ChristophJud](https://github.com/ChristophJud) overworked the CMake files to ease project inclusion.
|
||||
- [Vladimir Petrigo](https://github.com/vpetrigo) made a SFINAE hack more readable.
|
||||
- [Vladimir Petrigo](https://github.com/vpetrigo) made a SFINAE hack more readable and added Visual Studio 17 to the build matrix.
|
||||
- [Denis Andrejew](https://github.com/seeekr) fixed a grammar issue in the README file.
|
||||
- [Pierre-Antoine Lacaze](https://github.com/palacaze) found a subtle bug in the `dump()` function.
|
||||
- [TurpentineDistillery](https://github.com/TurpentineDistillery) pointed to [`std::locale::classic()`](http://en.cppreference.com/w/cpp/locale/locale/classic) to avoid too much locale joggling, found some nice performance improvements in the parser, improved the benchmarking code, and realized locale-independent number parsing and printing.
|
||||
@ -823,16 +882,49 @@ I deeply appreciate the help of the following people.
|
||||
- [EnricoBilla](https://github.com/EnricoBilla) noted a typo in an example.
|
||||
- [Martin Hořeňovský](https://github.com/horenmar) found a way for a 2x speedup for the compilation time of the test suite.
|
||||
- [ukhegg](https://github.com/ukhegg) found proposed an improvement for the examples section.
|
||||
- [rswanson-ihi](https://github.com/rswanson-ihi) noted a type in the README.
|
||||
- [rswanson-ihi](https://github.com/rswanson-ihi) noted a typo in the README.
|
||||
- [Mihai Stan](https://github.com/stanmihai4) fixed a bug in the comparison with `nullptr`s.
|
||||
- [Tushar Maheshwari](https://github.com/tusharpm) added [cotire](https://github.com/sakra/cotire) support to speed up the compilation.
|
||||
- [TedLyngmo](https://github.com/TedLyngmo) noted a typo in the README, removed unnecessary bit arithmetic, and fixed some `-Weffc++` warnings.
|
||||
- [Krzysztof Woś](https://github.com/krzysztofwos) made exceptions more visible.
|
||||
- [ftillier](https://github.com/ftillier) fixed a compiler warning.
|
||||
- [tinloaf](https://github.com/tinloaf) made sure all pushed warnings are properly popped.
|
||||
- [Fytch](https://github.com/Fytch) found a bug in the documentation.
|
||||
- [Jay Sistar](https://github.com/Type1J) implemented a Meson build description.
|
||||
- [Henry Lee](https://github.com/HenryRLee) fixed a warning in ICC and improved the iterator implementation.
|
||||
- [Vincent Thiery](https://github.com/vthiery) maintains a package for the Conan package manager.
|
||||
- [Steffen](https://github.com/koemeet) fixed a potential issue with MSVC and `std::min`.
|
||||
- [Mike Tzou](https://github.com/Chocobo1) fixed some typos.
|
||||
- [amrcode](https://github.com/amrcode) noted a missleading documentation about comparison of floats.
|
||||
- [Oleg Endo](https://github.com/olegendo) reduced the memory consumption by replacing `<iostream>` with `<iosfwd>`.
|
||||
- [dan-42](https://github.com/dan-42) cleaned up the CMake files to simplify including/reusing of the library.
|
||||
- [Nikita Ofitserov](https://github.com/himikof) allowed for moving values from initializer lists.
|
||||
- [Greg Hurrell](https://github.com/wincent) fixed a typo.
|
||||
- [Dmitry Kukovinets](https://github.com/DmitryKuk) fixed a typo.
|
||||
- [kbthomp1](https://github.com/kbthomp1) fixed an issue related to the Intel OSX compiler.
|
||||
- [Markus Werle](https://github.com/daixtrose) fixed a typo.
|
||||
- [WebProdPP](https://github.com/WebProdPP) fixed a subtle error in a precondition check.
|
||||
- [Alex](https://github.com/leha-bot) noted an error in a code sample.
|
||||
- [Tom de Geus](https://github.com/tdegeus) reported some warnings with ICC and helped fixing them.
|
||||
- [Perry Kundert](https://github.com/pjkundert) simplified reading from input streams.
|
||||
- [Sonu Lohani](https://github.com/sonulohani) fixed a small compilation error.
|
||||
- [Jamie Seward](https://github.com/jseward) fixed all MSVC warnings.
|
||||
- [Nate Vargas](https://github.com/eld00d) added a Doxygen tag file.
|
||||
- [pvleuven](https://github.com/pvleuven) helped fixing a warning in ICC.
|
||||
- [Pavel](https://github.com/crea7or) helped fixing some warnings in MSVC.
|
||||
- [Jamie Seward](https://github.com/jseward) avoided unneccessary string copies in `find()` and `count()`.
|
||||
- [Mitja](https://github.com/Itja) fixed some typos.
|
||||
- [Jorrit Wronski](https://github.com/jowr) updated the Hunter package links.
|
||||
- [Matthias Möller](https://github.com/TinyTinni) added a `.natvis` for the MSVC debug view.
|
||||
- [bogemic](https://github.com/bogemic) fixed some C++17 deprecation warnings.
|
||||
|
||||
|
||||
Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I forgot someone.
|
||||
|
||||
|
||||
## Used third-party tools
|
||||
|
||||
The library itself contains of a single header file licensed under the MIT license. However, it is built, tested, documented, and whatnot using a lot of thirs-party tools and services. Thanks a lot!
|
||||
The library itself contains 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!
|
||||
|
||||
- [**American fuzzy lop**](http://lcamtuf.coredump.cx/afl/) for fuzz testing
|
||||
- [**AppVeyor**](https://www.appveyor.com) for [continuous integration](https://ci.appveyor.com/project/nlohmann/json) on Windows
|
||||
@ -842,7 +934,6 @@ The library itself contains of a single header file licensed under the MIT licen
|
||||
- [**Clang**](http://clang.llvm.org) for compilation with code sanitizers
|
||||
- [**Cmake**](https://cmake.org) for build automation
|
||||
- [**Codacity**](https://www.codacy.com) for further [code analysis](https://www.codacy.com/app/nlohmann/json)
|
||||
- [**cotire**](https://github.com/sakra/cotire) to speed of compilation
|
||||
- [**Coveralls**](https://coveralls.io) to measure [code coverage](https://coveralls.io/github/nlohmann/json)
|
||||
- [**Coverity Scan**](https://scan.coverity.com) for [static analysis](https://scan.coverity.com/projects/nlohmann-json)
|
||||
- [**cppcheck**](http://cppcheck.sourceforge.net) for static analysis
|
||||
@ -852,11 +943,11 @@ The library itself contains of a single header file licensed under the MIT licen
|
||||
- [**Github Changelog Generator**](https://github.com/skywinder/github-changelog-generator) to generate the [ChangeLog](https://github.com/nlohmann/json/blob/develop/ChangeLog.md)
|
||||
- [**libFuzzer**](http://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
|
||||
- [**re2c**](http://re2c.org) to generate an automaton for the lexical analysis
|
||||
- [**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)
|
||||
- [**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
|
||||
- [**Wandbox**](http://melpon.org/wandbox) for [online examples](http://melpon.org/wandbox/permlink/4NEU6ZZMoM9lpIex)
|
||||
- [**Wandbox**](http://melpon.org/wandbox) for [online examples](https://wandbox.org/permlink/TZS6TQdqmEUcN8WW)
|
||||
|
||||
|
||||
## Projects using JSON for Modern C++
|
||||
@ -870,33 +961,24 @@ The library is currently used in Apple macOS Sierra and iOS 10. I am not sure wh
|
||||
- As the exact type of a number is not defined in the [JSON specification](http://rfc7159.net/rfc7159), this library tries to choose the best fitting C++ number type automatically. As a result, the type `double` may be used to store numbers which may yield [**floating-point exceptions**](https://github.com/nlohmann/json/issues/181) in certain rare situations if floating-point exceptions have been unmasked in the calling code. These exceptions are not caused by the library and need to be fixed in the calling code, such as by re-masking the exceptions prior to calling library functions.
|
||||
- The library supports **Unicode input** as follows:
|
||||
- Only **UTF-8** encoded input is supported which is the default encoding for JSON according to [RFC 7159](http://rfc7159.net/rfc7159#rfc.section.8.1).
|
||||
- Other encodings such as Latin-1, UTF-16, or UTF-32 are not supported and will yield parse errors.
|
||||
- Other encodings such as Latin-1, UTF-16, or UTF-32 are not supported and will yield parse or serialization errors.
|
||||
- [Unicode noncharacters](http://www.unicode.org/faq/private_use.html#nonchar1) will not be replaced by the library.
|
||||
- Invalid surrogates (e.g., incomplete pairs such as `\uDEAD`) will yield parse errors.
|
||||
- The strings stored in the library are UTF-8 encoded. When using the default string type (`std::string`), note that its length/size functions return the number of stored bytes rather than the number of characters or glyphs.
|
||||
- The code can be compiled without C++ **runtime type identification** features; that is, you can use the `-fno-rtti` compiler flag.
|
||||
- **Exceptions** are used widly within the library. They can, however, be switched off with either using the compiler flag `-fno-exceptions` or by defining the symbol `JSON_NOEXCEPTION`. In this case, exceptions are replaced by an `abort()` call.
|
||||
- **Exceptions** are used widely within the library. They can, however, be switched off with either using the compiler flag `-fno-exceptions` or by defining the symbol `JSON_NOEXCEPTION`. In this case, exceptions are replaced by an `abort()` call.
|
||||
- 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/rfc7159.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)).
|
||||
|
||||
|
||||
## Execute unit tests
|
||||
|
||||
To compile and run the tests, you need to execute
|
||||
|
||||
```sh
|
||||
$ make json_unit -Ctest
|
||||
$ ./test/json_unit "*""
|
||||
|
||||
===============================================================================
|
||||
All tests passed (11202597 assertions in 47 test cases)
|
||||
```
|
||||
|
||||
Alternatively, you can use [CMake](https://cmake.org) and run
|
||||
|
||||
```sh
|
||||
$ mkdir build
|
||||
$ cd build
|
||||
$ cmake ..
|
||||
$ make
|
||||
$ cmake --build .
|
||||
$ ctest
|
||||
```
|
||||
|
||||
|
27
appveyor.yml
27
appveyor.yml
@ -1,10 +1,27 @@
|
||||
version: '{build}'
|
||||
os: Visual Studio 2015
|
||||
|
||||
os:
|
||||
- Visual Studio 2015
|
||||
- Visual Studio 2017
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- additional_flags: ""
|
||||
- additional_flags: "/permissive- /std:c++latest /utf-8"
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- additional_flags: "/permissive- /std:c++latest /utf-8"
|
||||
os: Visual Studio 2015
|
||||
|
||||
init: []
|
||||
|
||||
install: []
|
||||
|
||||
build_script:
|
||||
- set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH%
|
||||
- cmake . -G "Visual Studio 14 2015"
|
||||
- cmake --build . --config Release
|
||||
- IF "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2015" ( SET GEN="Visual Studio 14 2015") ELSE (SET GEN="Visual Studio 15 2017")
|
||||
- cmake . -G%GEN% -DCMAKE_CXX_FLAGS="%additional_flags%"
|
||||
- cmake --build . --config Release
|
||||
|
||||
test_script:
|
||||
- ctest -C Release -V
|
||||
- ctest -C Release -V -j
|
||||
|
21
benchmarks/Makefile
Normal file
21
benchmarks/Makefile
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
#
|
||||
# Build/run json.hpp benchmarks, eg. CXX=g++-7 make
|
||||
#
|
||||
# The existing json_benchmarks did not allow optimization under some compilers
|
||||
#
|
||||
all: json_benchmarks json_benchmarks_simple number_jsons
|
||||
bash -c 'time ./json_benchmarks'
|
||||
bash -c 'time ./json_benchmarks_simple'
|
||||
|
||||
json_benchmarks: src/benchmarks.cpp ../src/json.hpp
|
||||
$(CXX) -std=c++11 -pthread $(CXXFLAGS) -DNDEBUG -O3 -flto -I thirdparty/benchpress -I thirdparty/cxxopts -I../src src/benchmarks.cpp $(LDFLAGS) -o $@
|
||||
|
||||
json_benchmarks_simple: src/benchmarks_simple.cpp ../src/json.hpp
|
||||
$(CXX) -std=c++11 $(CXXFLAGS) -DNDEBUG -O3 -flto -I../src $(<) $(LDFLAGS) -o $@
|
||||
|
||||
number_jsons:
|
||||
(test -e files/numbers/floats.json -a -e files/numbers/signed_ints.json -a -e files/numbers/unsigned_ints.json) || (cd files/numbers ; python generate.py)
|
||||
|
||||
clean:
|
||||
rm -f json_benchmarks json_benchmarks_simple files/numbers/*.json
|
3
benchmarks/README.md
Normal file
3
benchmarks/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Bechmarks
|
||||
|
||||
Run `make` to compile and run a small set of benchmarks.
|
@ -34,6 +34,19 @@ static void bench(benchpress::context& ctx,
|
||||
{
|
||||
// using string streams for benchmarking to factor-out cold-cache disk
|
||||
// access.
|
||||
#if defined( FROMFILE )
|
||||
std::ifstream istr;
|
||||
{
|
||||
istr.open( in_path, std::ifstream::in );
|
||||
|
||||
// read the stream once
|
||||
json j;
|
||||
istr >> j;
|
||||
// clear flags and rewind
|
||||
istr.clear();
|
||||
istr.seekg(0);
|
||||
}
|
||||
#else
|
||||
std::stringstream istr;
|
||||
{
|
||||
// read file into string stream
|
||||
@ -43,11 +56,12 @@ static void bench(benchpress::context& ctx,
|
||||
|
||||
// read the stream once
|
||||
json j;
|
||||
j << istr;
|
||||
istr >> j;
|
||||
// clear flags and rewind
|
||||
istr.clear();
|
||||
istr.seekg(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
@ -62,7 +76,7 @@ static void bench(benchpress::context& ctx,
|
||||
istr.clear();
|
||||
istr.seekg(0);
|
||||
json j;
|
||||
j << istr;
|
||||
istr >> j;
|
||||
}
|
||||
|
||||
break;
|
||||
@ -74,7 +88,7 @@ static void bench(benchpress::context& ctx,
|
||||
{
|
||||
// create JSON value from input
|
||||
json j;
|
||||
j << istr;
|
||||
istr >> j;
|
||||
std::stringstream ostr;
|
||||
|
||||
ctx.reset_timer();
|
||||
@ -104,15 +118,15 @@ static void bench(benchpress::context& ctx,
|
||||
bench(*ctx, (in_path), (mode)); \
|
||||
})
|
||||
|
||||
BENCHMARK_I(EMode::input, "parse jeopardy.json", "benchmarks/files/jeopardy/jeopardy.json");
|
||||
BENCHMARK_I(EMode::input, "parse canada.json", "benchmarks/files/nativejson-benchmark/canada.json");
|
||||
BENCHMARK_I(EMode::input, "parse citm_catalog.json", "benchmarks/files/nativejson-benchmark/citm_catalog.json");
|
||||
BENCHMARK_I(EMode::input, "parse twitter.json", "benchmarks/files/nativejson-benchmark/twitter.json");
|
||||
BENCHMARK_I(EMode::input, "parse numbers/floats.json", "benchmarks/files/numbers/floats.json");
|
||||
BENCHMARK_I(EMode::input, "parse numbers/signed_ints.json", "benchmarks/files/numbers/signed_ints.json");
|
||||
BENCHMARK_I(EMode::input, "parse numbers/unsigned_ints.json", "benchmarks/files/numbers/unsigned_ints.json");
|
||||
BENCHMARK_I(EMode::input, "parse jeopardy.json", "files/jeopardy/jeopardy.json");
|
||||
BENCHMARK_I(EMode::input, "parse canada.json", "files/nativejson-benchmark/canada.json");
|
||||
BENCHMARK_I(EMode::input, "parse citm_catalog.json", "files/nativejson-benchmark/citm_catalog.json");
|
||||
BENCHMARK_I(EMode::input, "parse twitter.json", "files/nativejson-benchmark/twitter.json");
|
||||
BENCHMARK_I(EMode::input, "parse numbers/floats.json", "files/numbers/floats.json");
|
||||
BENCHMARK_I(EMode::input, "parse numbers/signed_ints.json", "files/numbers/signed_ints.json");
|
||||
BENCHMARK_I(EMode::input, "parse numbers/unsigned_ints.json", "files/numbers/unsigned_ints.json");
|
||||
|
||||
BENCHMARK_I(EMode::output_no_indent, "dump jeopardy.json", "benchmarks/files/jeopardy/jeopardy.json");
|
||||
BENCHMARK_I(EMode::output_with_indent, "dump jeopardy.json with indent", "benchmarks/files/jeopardy/jeopardy.json");
|
||||
BENCHMARK_I(EMode::output_no_indent, "dump numbers/floats.json", "benchmarks/files/numbers/floats.json");
|
||||
BENCHMARK_I(EMode::output_no_indent, "dump numbers/signed_ints.json", "benchmarks/files/numbers/signed_ints.json");
|
||||
BENCHMARK_I(EMode::output_no_indent, "dump jeopardy.json", "files/jeopardy/jeopardy.json");
|
||||
BENCHMARK_I(EMode::output_with_indent, "dump jeopardy.json with indent", "files/jeopardy/jeopardy.json");
|
||||
BENCHMARK_I(EMode::output_no_indent, "dump numbers/floats.json", "files/numbers/floats.json");
|
||||
BENCHMARK_I(EMode::output_no_indent, "dump numbers/signed_ints.json", "files/numbers/signed_ints.json");
|
158
benchmarks/src/benchmarks_simple.cpp
Normal file
158
benchmarks/src/benchmarks_simple.cpp
Normal file
@ -0,0 +1,158 @@
|
||||
//
|
||||
// benchmarks_simple.cpp -- a less complex version of benchmarks.cpp, that better reflects actual performance
|
||||
//
|
||||
// For some reason, the complexity of benchmarks.cpp doesn't allow
|
||||
// the compiler to optimize code using json.hpp effectively. The
|
||||
// exact same tests, with the use of benchpress and cxxopts produces
|
||||
// much faster code, at least under g++.
|
||||
//
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <list>
|
||||
#include <tuple>
|
||||
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
enum class EMode { input, output, indent };
|
||||
|
||||
static double bench(const EMode mode, size_t iters, const std::string& in_path )
|
||||
{
|
||||
// using string streams for benchmarking to factor-out cold-cache disk
|
||||
// access. Define FROMFILE to use file I/O instead.
|
||||
#if defined( FROMFILE )
|
||||
std::ifstream istr;
|
||||
{
|
||||
istr.open( in_path, std::ifstream::in );
|
||||
|
||||
// read the stream once
|
||||
json j;
|
||||
istr >> j;
|
||||
// clear flags and rewind
|
||||
istr.clear();
|
||||
istr.seekg(0);
|
||||
}
|
||||
#else
|
||||
std::stringstream istr;
|
||||
{
|
||||
// read file into string stream
|
||||
std::ifstream input_file(in_path);
|
||||
istr << input_file.rdbuf();
|
||||
input_file.close();
|
||||
|
||||
// read the stream once
|
||||
json j;
|
||||
istr >> j;
|
||||
// clear flags and rewind
|
||||
istr.clear();
|
||||
istr.seekg(0);
|
||||
}
|
||||
#endif
|
||||
double tps = 0;
|
||||
switch (mode)
|
||||
{
|
||||
// benchmarking input
|
||||
case EMode::input:
|
||||
{
|
||||
auto start = std::chrono::system_clock::now();
|
||||
for (size_t i = 0; i < iters; ++i)
|
||||
{
|
||||
// clear flags and rewind
|
||||
istr.clear();
|
||||
istr.seekg(0);
|
||||
json j;
|
||||
istr >> j;
|
||||
}
|
||||
auto ended = std::chrono::system_clock::now();
|
||||
tps = 1.0 / std::chrono::duration<double>( ended - start ).count();
|
||||
break;
|
||||
}
|
||||
|
||||
// benchmarking output
|
||||
case EMode::output:
|
||||
case EMode::indent:
|
||||
{
|
||||
// create JSON value from input
|
||||
json j;
|
||||
istr >> j;
|
||||
std::stringstream ostr;
|
||||
|
||||
auto start = std::chrono::system_clock::now();
|
||||
for (size_t i = 0; i < iters; ++i)
|
||||
{
|
||||
if (mode == EMode::indent)
|
||||
{
|
||||
ostr << j;
|
||||
}
|
||||
else
|
||||
{
|
||||
ostr << std::setw(4) << j;
|
||||
}
|
||||
|
||||
// reset data
|
||||
ostr.str(std::string());
|
||||
}
|
||||
auto ended = std::chrono::system_clock::now();
|
||||
tps = 1.0 / std::chrono::duration<double>( ended - start ).count();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
return tps;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct average {
|
||||
T _sum { 0 };
|
||||
size_t _count { 0 };
|
||||
T operator+=( const T &val_ ) { _sum += val_; +_count++; return val_; }
|
||||
operator T() { return _sum / _count; }
|
||||
};
|
||||
|
||||
// Execute each test approximately enough times to get near 1
|
||||
// transaction per second, and compute the average; a single aggregate
|
||||
// number that gives a performance metric representing both parsing
|
||||
// and output.
|
||||
|
||||
int main( int, char ** )
|
||||
{
|
||||
std::list<std::tuple<std::string, EMode, size_t, std::string>> tests {
|
||||
{ "parse jeopardy.json", EMode::input, 2, "files/jeopardy/jeopardy.json" },
|
||||
{ "parse canada.json", EMode::input, 30, "files/nativejson-benchmark/canada.json" },
|
||||
{ "parse citm_catalog.json", EMode::input, 120, "files/nativejson-benchmark/citm_catalog.json" },
|
||||
{ "parse twitter.json", EMode::input, 225, "files/nativejson-benchmark/twitter.json" },
|
||||
{ "parse floats.json", EMode::input, 5, "files/numbers/floats.json" },
|
||||
{ "parse signed_ints.json", EMode::input, 6, "files/numbers/signed_ints.json" },
|
||||
{ "parse unsigned_ints.json", EMode::input, 6, "files/numbers/unsigned_ints.json" },
|
||||
{ "dump jeopardy.json", EMode::output, 5, "files/jeopardy/jeopardy.json" },
|
||||
{ "dump jeopardy.json w/ind.", EMode::indent, 5, "files/jeopardy/jeopardy.json" },
|
||||
{ "dump floats.json", EMode::output, 2, "files/numbers/floats.json" },
|
||||
{ "dump signed_ints.json", EMode::output, 20, "files/numbers/signed_ints.json" },
|
||||
};
|
||||
|
||||
average<double> avg;
|
||||
for ( auto t : tests ) {
|
||||
std::string name, path;
|
||||
EMode mode;
|
||||
size_t iters;
|
||||
std::tie(name, mode, iters, path) = t;
|
||||
auto tps = bench( mode, iters, path );
|
||||
avg += tps;
|
||||
std::cout
|
||||
<< std::left
|
||||
<< std::setw( 30 ) << name
|
||||
<< std::right
|
||||
<< " x " << std::setw( 3 ) << iters
|
||||
<< std::left
|
||||
<< " == " << std::setw( 10 ) << tps
|
||||
<< std::right
|
||||
<< " TPS, " << std::setw( 8 ) << std::round( tps * 1e6 / iters )
|
||||
<< " ms/op"
|
||||
<< std::endl;
|
||||
}
|
||||
std::cout << std::setw( 40 ) << "" << std::string( 10, '-' ) << std::endl;
|
||||
std::cout << std::setw( 40 ) << "" << std::setw( 10 ) << std::left << avg << " TPS Average" << std::endl;
|
||||
return 0;
|
||||
}
|
21
benchmarks/thirdparty/benchpress/LICENSE
vendored
Normal file
21
benchmarks/thirdparty/benchpress/LICENSE
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Christopher Gilbert
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
19
benchmarks/thirdparty/cxxopts/LICENSE
vendored
Normal file
19
benchmarks/thirdparty/cxxopts/LICENSE
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2014 Jarryd Beck
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
@ -1,7 +1,3 @@
|
||||
@PACKAGE_INIT@
|
||||
set_and_check(JSON_INCLUDE_DIR "@PACKAGE_JSON_INCLUDE_DESTINATION@")
|
||||
|
||||
cmake_policy(PUSH)
|
||||
cmake_policy(SET CMP0024 OLD)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/@JSON_TARGETS_FILENAME@)
|
||||
cmake_policy(POP)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@NLOHMANN_JSON_TARGETS_EXPORT_NAME@.cmake")
|
||||
check_required_components("@PROJECT_NAME@")
|
||||
|
4008
cmake/cotire.cmake
4008
cmake/cotire.cmake
File diff suppressed because it is too large
Load Diff
30
doc/Doxyfile
30
doc/Doxyfile
@ -1,12 +1,12 @@
|
||||
# Doxyfile 1.8.9.1
|
||||
# Doxyfile 1.8.14
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = "JSON for Modern C++"
|
||||
PROJECT_NUMBER = 2.1.1
|
||||
PROJECT_BRIEF =
|
||||
PROJECT_NUMBER = 3.0.0
|
||||
PROJECT_BRIEF =
|
||||
PROJECT_LOGO =
|
||||
OUTPUT_DIRECTORY = .
|
||||
CREATE_SUBDIRS = NO
|
||||
@ -27,10 +27,11 @@ MULTILINE_CPP_IS_BRIEF = NO
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = YES
|
||||
TAB_SIZE = 4
|
||||
ALIASES = "complexity=@par Complexity\n"
|
||||
ALIASES += liveexample{2}="@par Example\n \1 \n @includelineno \2.cpp \n Output (play with this example @htmlinclude \2.link):\n @verbinclude \2.output \n The example code above can be translated with @verbatim g++ -std=c++11 -Isrc doc/examples/\2.cpp -o \2 @endverbatim"
|
||||
ALIASES += requirement="@par Requirements\n"
|
||||
ALIASES += exceptionsafety="@par Exception safety\n"
|
||||
ALIASES = "complexity=@par Complexity\n" \
|
||||
"liveexample{2}=@par Example\n \1 \n @includelineno \2.cpp \n Output (play with this example @htmlinclude \2.link):\n @verbinclude \2.output \n The <a href= https://github.com/nlohmann/json/blob/develop/doc/examples/\2.cpp>example code</a> above can be translated with @verbatim g++ -std=c++11 -Isrc doc/examples/\2.cpp -o \2 @endverbatim" \
|
||||
"requirement=@par Requirements\n" \
|
||||
"exceptionsafety=@par Exception safety\n" \
|
||||
"iterators=@par Iterator validity\n"
|
||||
TCL_SUBST =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
@ -38,12 +39,14 @@ OPTIMIZE_FOR_FORTRAN = NO
|
||||
OPTIMIZE_OUTPUT_VHDL = NO
|
||||
EXTENSION_MAPPING =
|
||||
MARKDOWN_SUPPORT = YES
|
||||
TOC_INCLUDE_HEADINGS = 0
|
||||
AUTOLINK_SUPPORT = NO
|
||||
BUILTIN_STL_SUPPORT = YES
|
||||
CPP_CLI_SUPPORT = NO
|
||||
SIP_SUPPORT = NO
|
||||
IDL_PROPERTY_SUPPORT = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
GROUP_NESTED_COMPOUNDS = NO
|
||||
SUBGROUPING = YES
|
||||
INLINE_GROUPED_CLASSES = NO
|
||||
INLINE_SIMPLE_STRUCTS = NO
|
||||
@ -97,12 +100,14 @@ WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = YES
|
||||
WARN_AS_ERROR = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = ../src/json.hpp index.md
|
||||
INPUT = ../src/json.hpp \
|
||||
index.md faq.md
|
||||
INPUT_ENCODING = UTF-8
|
||||
FILE_PATTERNS =
|
||||
RECURSIVE = NO
|
||||
@ -131,6 +136,8 @@ REFERENCES_LINK_SOURCE = NO
|
||||
SOURCE_TOOLTIPS = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = NO
|
||||
CLANG_ASSISTED_PARSING = YES
|
||||
CLANG_OPTIONS = -std=c++11
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
@ -152,13 +159,14 @@ HTML_COLORSTYLE_HUE = 220
|
||||
HTML_COLORSTYLE_SAT = 100
|
||||
HTML_COLORSTYLE_GAMMA = 80
|
||||
HTML_TIMESTAMP = YES
|
||||
HTML_DYNAMIC_MENUS = YES
|
||||
HTML_DYNAMIC_SECTIONS = YES
|
||||
HTML_INDEX_NUM_ENTRIES = 100
|
||||
GENERATE_DOCSET = YES
|
||||
DOCSET_FEEDNAME = "Doxygen generated docs"
|
||||
DOCSET_BUNDLE_ID = me.nlohmann.json
|
||||
DOCSET_PUBLISHER_ID = me.nlohmann
|
||||
DOCSET_PUBLISHER_NAME = Niels Lohmann
|
||||
DOCSET_PUBLISHER_NAME = NielsLohmann
|
||||
GENERATE_HTMLHELP = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
@ -215,6 +223,7 @@ LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
LATEX_SOURCE_CODE = NO
|
||||
LATEX_BIB_STYLE = plain
|
||||
LATEX_TIMESTAMP = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
@ -272,7 +281,7 @@ SKIP_FUNCTION_MACROS = YES
|
||||
# Configuration options related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
GENERATE_TAGFILE = html/nlohmann_json.tag
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
EXTERNAL_PAGES = YES
|
||||
@ -308,6 +317,7 @@ DOTFILE_DIRS =
|
||||
MSCFILE_DIRS =
|
||||
DIAFILE_DIRS =
|
||||
PLANTUML_JAR_PATH =
|
||||
PLANTUML_CFG_FILE =
|
||||
PLANTUML_INCLUDE_PATH =
|
||||
DOT_GRAPH_MAX_NODES = 50
|
||||
MAX_DOT_GRAPH_DEPTH = 0
|
||||
|
@ -58,9 +58,12 @@ doxygen: create_output create_links
|
||||
$(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >@@g' html/*.html
|
||||
$(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >@@g' html/*.html
|
||||
$(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType JSONSerializer >@@g' html/*.html
|
||||
$(SED) -i 's@template<template< typename U, typename V, typename... Args > class ObjectType = std::map, template< typename U, typename... Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator, template< typename T, typename SFINAE=void > class JSONSerializer = adl_serializer>@@g' html/*.html
|
||||
$(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >@@g' html/*.html
|
||||
$(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >@@g' html/*.html
|
||||
|
||||
upload: clean doxygen check_output
|
||||
cd html ; ../scripts/git-update-ghpages nlohmann/json
|
||||
scripts/git-update-ghpages nlohmann/json html
|
||||
rm -fr html
|
||||
open http://nlohmann.github.io/json/
|
||||
|
||||
|
BIN
doc/avatars.png
Normal file
BIN
doc/avatars.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 530 KiB |
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@ -29,7 +30,8 @@ int main()
|
||||
j["new"]["key"]["value"] = {"another", "list"};
|
||||
|
||||
// count elements
|
||||
j["size"] = j.size();
|
||||
auto s = j.size();
|
||||
j["size"] = s;
|
||||
|
||||
// pretty print with indent of 4 spaces
|
||||
std::cout << std::setw(4) << j << '\n';
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/4NEU6ZZMoM9lpIex"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/TZS6TQdqmEUcN8WW"><b>online</b></a>
|
@ -23,5 +23,5 @@
|
||||
"value": 42.99
|
||||
},
|
||||
"pi": 3.141,
|
||||
"size": 9
|
||||
"size": 8
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/1fsm4gI55p83DOwU"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/jKwlQd7pFg6UcIN5"><b>online</b></a>
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@ -21,13 +22,27 @@ int main()
|
||||
// output changed array
|
||||
std::cout << object << '\n';
|
||||
|
||||
// try to write at a nonexisting key
|
||||
|
||||
// exception type_error.304
|
||||
try
|
||||
{
|
||||
// use at() on a non-object type
|
||||
json str = "I am a string";
|
||||
str.at("the good") = "Another string";
|
||||
}
|
||||
catch (json::type_error& e)
|
||||
{
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
|
||||
// exception out_of_range.401
|
||||
try
|
||||
{
|
||||
// try to write at a nonexisting key
|
||||
object.at("the fast") = "il rapido";
|
||||
}
|
||||
catch (std::out_of_range& e)
|
||||
catch (json::out_of_range& e)
|
||||
{
|
||||
std::cout << "out of range: " << e.what() << '\n';
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/tb5CaFfsMWpAvi7m"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/FR2yYACZpx0k3Rzp"><b>online</b></a>
|
@ -1,3 +1,4 @@
|
||||
"il brutto"
|
||||
{"the bad":"il cattivo","the good":"il buono","the ugly":"il brutto"}
|
||||
out of range: key 'the fast' not found
|
||||
[json.exception.type_error.304] cannot use at() with string
|
||||
[json.exception.out_of_range.403] key 'the fast' not found
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@ -15,12 +16,26 @@ int main()
|
||||
// output element with key "the ugly"
|
||||
std::cout << object.at("the ugly") << '\n';
|
||||
|
||||
// try to read from a nonexisting key
|
||||
|
||||
// exception type_error.304
|
||||
try
|
||||
{
|
||||
// use at() on a non-object type
|
||||
const json str = "I am a string";
|
||||
std::cout << str.at("the good") << '\n';
|
||||
}
|
||||
catch (json::type_error& e)
|
||||
{
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
|
||||
// exception out_of_range.401
|
||||
try
|
||||
{
|
||||
// try to read from a nonexisting key
|
||||
std::cout << object.at("the fast") << '\n';
|
||||
}
|
||||
catch (std::out_of_range)
|
||||
catch (json::out_of_range)
|
||||
{
|
||||
std::cout << "out of range" << '\n';
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/NFG86H5khRUePc1s"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/aeF8S2D89A8lfVx1"><b>online</b></a>
|
@ -1,2 +1,3 @@
|
||||
"il brutto"
|
||||
[json.exception.type_error.304] cannot use at() with string
|
||||
out of range
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@ -16,13 +17,27 @@ int main()
|
||||
// output changed array
|
||||
std::cout << array << '\n';
|
||||
|
||||
// try to write beyond the array limit
|
||||
|
||||
// exception type_error.304
|
||||
try
|
||||
{
|
||||
// use at() on a non-array type
|
||||
json str = "I am a string";
|
||||
str.at(0) = "Another string";
|
||||
}
|
||||
catch (json::type_error& e)
|
||||
{
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
|
||||
// exception out_of_range.401
|
||||
try
|
||||
{
|
||||
// try to write beyond the array limit
|
||||
array.at(5) = "sixth";
|
||||
}
|
||||
catch (std::out_of_range& e)
|
||||
catch (json::out_of_range& e)
|
||||
{
|
||||
std::cout << "out of range: " << e.what() << '\n';
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/R7z2SB2rMdFQ9XtR"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/GmNdQadc8cWDzYpn"><b>online</b></a>
|
@ -1,3 +1,4 @@
|
||||
"third"
|
||||
["first","second","third","fourth"]
|
||||
out of range: array index 5 is out of range
|
||||
[json.exception.type_error.304] cannot use at() with string
|
||||
[json.exception.out_of_range.401] array index 5 is out of range
|
||||
|
@ -1,22 +1,37 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON array
|
||||
json array = {"first", "2nd", "third", "fourth"};
|
||||
const json array = {"first", "2nd", "third", "fourth"};
|
||||
|
||||
// output element at index 2 (third element)
|
||||
std::cout << array.at(2) << '\n';
|
||||
|
||||
// try to read beyond the array limit
|
||||
|
||||
// exception type_error.304
|
||||
try
|
||||
{
|
||||
// use at() on a non-array type
|
||||
const json str = "I am a string";
|
||||
std::cout << str.at(0) << '\n';
|
||||
}
|
||||
catch (json::type_error& e)
|
||||
{
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
|
||||
// exception out_of_range.401
|
||||
try
|
||||
{
|
||||
// try to read beyond the array limit
|
||||
std::cout << array.at(5) << '\n';
|
||||
}
|
||||
catch (std::out_of_range)
|
||||
catch (json::out_of_range& e)
|
||||
{
|
||||
std::cout << "out of range" << '\n';
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/L1bMeiN6nYm7JrvA"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/zLkp80JFsKEuPd1t"><b>online</b></a>
|
@ -1,2 +1,3 @@
|
||||
"third"
|
||||
out of range
|
||||
[json.exception.type_error.304] cannot use at() with string
|
||||
[json.exception.out_of_range.401] array index 5 is out of range
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@ -32,4 +33,60 @@ int main()
|
||||
j.at("/array/1"_json_pointer) = 21;
|
||||
// output the changed array
|
||||
std::cout << j["array"] << '\n';
|
||||
|
||||
|
||||
// out_of_range.106
|
||||
try
|
||||
{
|
||||
// try to use an array index with leading '0'
|
||||
json::reference ref = j.at("/array/01"_json_pointer);
|
||||
}
|
||||
catch (json::parse_error& e)
|
||||
{
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
|
||||
// out_of_range.109
|
||||
try
|
||||
{
|
||||
// try to use an array index that is not a number
|
||||
json::reference ref = j.at("/array/one"_json_pointer);
|
||||
}
|
||||
catch (json::parse_error& e)
|
||||
{
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
|
||||
// out_of_range.401
|
||||
try
|
||||
{
|
||||
// try to use a an invalid array index
|
||||
json::reference ref = j.at("/array/4"_json_pointer);
|
||||
}
|
||||
catch (json::out_of_range& e)
|
||||
{
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
|
||||
// out_of_range.402
|
||||
try
|
||||
{
|
||||
// try to use the array index '-'
|
||||
json::reference ref = j.at("/array/-"_json_pointer);
|
||||
}
|
||||
catch (json::out_of_range& e)
|
||||
{
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
|
||||
// out_of_range.404
|
||||
try
|
||||
{
|
||||
// try to use a JSON pointer that cannot be resolved
|
||||
json::reference ref = j.at("/number/foo"_json_pointer);
|
||||
}
|
||||
catch (json::out_of_range& e)
|
||||
{
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/NDSjglHZIjIZ0Uxg"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/mlj2WqOtwBidvuJx"><b>online</b></a>
|
@ -4,3 +4,8 @@
|
||||
2
|
||||
"bar"
|
||||
[1,21]
|
||||
[json.exception.parse_error.106] parse error: array index '01' must not begin with '0'
|
||||
[json.exception.parse_error.109] parse error: array index 'one' is not a number
|
||||
[json.exception.out_of_range.401] array index 4 is out of range
|
||||
[json.exception.out_of_range.402] array index '-' (2) is out of range
|
||||
[json.exception.out_of_range.404] unresolved reference token 'foo'
|
||||
|
@ -1,11 +1,12 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a JSON value
|
||||
json j =
|
||||
const json j =
|
||||
{
|
||||
{"number", 1}, {"string", "foo"}, {"array", {1, 2}}
|
||||
};
|
||||
@ -20,4 +21,48 @@ int main()
|
||||
std::cout << j.at("/array"_json_pointer) << '\n';
|
||||
// output element with JSON pointer "/array/1"
|
||||
std::cout << j.at("/array/1"_json_pointer) << '\n';
|
||||
|
||||
// out_of_range.109
|
||||
try
|
||||
{
|
||||
// try to use an array index that is not a number
|
||||
json::const_reference ref = j.at("/array/one"_json_pointer);
|
||||
}
|
||||
catch (json::parse_error& e)
|
||||
{
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
|
||||
// out_of_range.401
|
||||
try
|
||||
{
|
||||
// try to use a an invalid array index
|
||||
json::const_reference ref = j.at("/array/4"_json_pointer);
|
||||
}
|
||||
catch (json::out_of_range& e)
|
||||
{
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
|
||||
// out_of_range.402
|
||||
try
|
||||
{
|
||||
// try to use the array index '-'
|
||||
json::const_reference ref = j.at("/array/-"_json_pointer);
|
||||
}
|
||||
catch (json::out_of_range& e)
|
||||
{
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
|
||||
// out_of_range.404
|
||||
try
|
||||
{
|
||||
// try to use a JSON pointer that cannot be resolved
|
||||
json::const_reference ref = j.at("/number/foo"_json_pointer);
|
||||
}
|
||||
catch (json::out_of_range& e)
|
||||
{
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/OuLYiMJ3pgyOHupb"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/vHKlyYl9DwaUO9UN"><b>online</b></a>
|
@ -2,3 +2,7 @@
|
||||
"foo"
|
||||
[1,2]
|
||||
2
|
||||
[json.exception.parse_error.109] parse error: array index 'one' is not a number
|
||||
[json.exception.out_of_range.401] array index 4 is out of range
|
||||
[json.exception.out_of_range.402] array index '-' (2) is out of range
|
||||
[json.exception.out_of_range.404] unresolved reference token 'foo'
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json j_null;
|
||||
json j_boolean = true;
|
||||
json j_number_integer = 17;
|
||||
json j_number_float = 23.42;
|
||||
@ -16,7 +16,6 @@ int main()
|
||||
json j_string = "Hello, world";
|
||||
|
||||
// call back()
|
||||
//std::cout << j_null.back() << '\n'; // would throw
|
||||
std::cout << j_boolean.back() << '\n';
|
||||
std::cout << j_number_integer.back() << '\n';
|
||||
std::cout << j_number_float.back() << '\n';
|
||||
@ -25,4 +24,15 @@ int main()
|
||||
std::cout << j_array.back() << '\n';
|
||||
//std::cout << j_array_empty.back() << '\n'; // undefined behavior
|
||||
std::cout << j_string.back() << '\n';
|
||||
|
||||
// back() called on a null value
|
||||
try
|
||||
{
|
||||
json j_null;
|
||||
j_null.back();
|
||||
}
|
||||
catch (json::invalid_iterator& e)
|
||||
{
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/nPVnBcHf8nrNpGOJ"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/VXTfLJQl9x7NaHrI"><b>online</b></a>
|
@ -4,3 +4,4 @@ true
|
||||
2
|
||||
16
|
||||
"Hello, world"
|
||||
[json.exception.invalid_iterator.214] cannot get value
|
||||
|
@ -1,10 +1,12 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include <deque>
|
||||
#include <list>
|
||||
#include <forward_list>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <valarray>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@ -66,6 +68,10 @@ int main()
|
||||
std::vector<int> c_vector {1, 2, 3, 4};
|
||||
json j_vec(c_vector);
|
||||
|
||||
// create an array from std::valarray
|
||||
std::valarray<short> c_valarray {10, 9, 8, 7};
|
||||
json j_valarray(c_valarray);
|
||||
|
||||
// create an array from std::deque
|
||||
std::deque<double> c_deque {1.2, 2.3, 3.4, 5.6};
|
||||
json j_deque(c_deque);
|
||||
@ -101,6 +107,7 @@ int main()
|
||||
// serialize the JSON arrays
|
||||
std::cout << j_array_t << '\n';
|
||||
std::cout << j_vec << '\n';
|
||||
std::cout << j_valarray << '\n';
|
||||
std::cout << j_deque << '\n';
|
||||
std::cout << j_list << '\n';
|
||||
std::cout << j_flist << '\n';
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/VM7W2kpE7sIYJ5DW"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/s7Ecy7hDYSmUWHyx"><b>online</b></a>
|
@ -6,6 +6,7 @@
|
||||
|
||||
["one","two",3,4.5,false]
|
||||
[1,2,3,4]
|
||||
[10,9,8,7]
|
||||
[1.2,2.3,3.4,5.6]
|
||||
[true,true,false,true]
|
||||
[12345678909876,23456789098765,34567890987654,45678909876543]
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@ -18,4 +19,14 @@ int main()
|
||||
std::cout << j_array_range << '\n';
|
||||
std::cout << j_number_range << '\n';
|
||||
std::cout << j_object_range << '\n';
|
||||
|
||||
// example for an exception
|
||||
try
|
||||
{
|
||||
json j_invalid(j_number.begin() + 1, j_number.end());
|
||||
}
|
||||
catch (json::invalid_iterator& e)
|
||||
{
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/nKF1QcieoCHm6Lez"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/qpFQRSCnP6iVb3dF"><b>online</b></a>
|
@ -1,3 +1,4 @@
|
||||
["bravo","charly"]
|
||||
42
|
||||
{"one":"eins"}
|
||||
[json.exception.invalid_iterator.204] iterators out of range
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/6Qfn12BDzb3vqO5p"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/hRrKgHP2a0zgdxJ1"><b>online</b></a>
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/iWYvmlA4qQmtvACX"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/4p0zccjr9gUI65H2"><b>online</b></a>
|
@ -1,57 +0,0 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// a JSON text
|
||||
auto text = R"(
|
||||
{
|
||||
"Image": {
|
||||
"Width": 800,
|
||||
"Height": 600,
|
||||
"Title": "View from 15th Floor",
|
||||
"Thumbnail": {
|
||||
"Url": "http://www.example.com/image/481989943",
|
||||
"Height": 125,
|
||||
"Width": 100
|
||||
},
|
||||
"Animated" : false,
|
||||
"IDs": [116, 943, 234, 38793]
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
// fill a stream with JSON text
|
||||
std::stringstream ss;
|
||||
ss << text;
|
||||
|
||||
// create JSON from stream
|
||||
json j_complete(ss); // deprecated!
|
||||
// shall be replaced by: json j_complete = json::parse(ss);
|
||||
std::cout << std::setw(4) << j_complete << "\n\n";
|
||||
|
||||
|
||||
// define parser callback
|
||||
json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
|
||||
{
|
||||
// skip object elements with key "Thumbnail"
|
||||
if (event == json::parse_event_t::key and parsed == json("Thumbnail"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// fill a stream with JSON text
|
||||
ss.clear();
|
||||
ss << text;
|
||||
|
||||
// create JSON from stream (with callback)
|
||||
json j_filtered(ss, cb);
|
||||
// shall be replaced by: json j_filtered = json::parse(ss, cb);
|
||||
std::cout << std::setw(4) << j_filtered << '\n';
|
||||
}
|
@ -1 +0,0 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/R6dzpKXlxrttShf7"><b>online</b></a>
|
@ -1,34 +0,0 @@
|
||||
{
|
||||
"Image": {
|
||||
"Animated": false,
|
||||
"Height": 600,
|
||||
"IDs": [
|
||||
116,
|
||||
943,
|
||||
234,
|
||||
38793
|
||||
],
|
||||
"Thumbnail": {
|
||||
"Height": 125,
|
||||
"Url": "http://www.example.com/image/481989943",
|
||||
"Width": 100
|
||||
},
|
||||
"Title": "View from 15th Floor",
|
||||
"Width": 800
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"Image": {
|
||||
"Animated": false,
|
||||
"Height": 600,
|
||||
"IDs": [
|
||||
116,
|
||||
943,
|
||||
234,
|
||||
38793
|
||||
],
|
||||
"Title": "View from 15th Floor",
|
||||
"Width": 800
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/iZzzxEpB7tbhz0cx"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/XyDVBlGsU1DHpRl9"><b>online</b></a>
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/CaDlatv1uXhQiu7o"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/Z1uToOcza9ALJxNU"><b>online</b></a>
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/9Tvfs2dJBW8m8ihA"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/JQUGGZT8qZyQsHRv"><b>online</b></a>
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/IFZT4VL0oRotJBxl"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/l4fEe7Un5ctCQNuA"><b>online</b></a>
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/qdV5W2Lrljmjv4LG"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/BRt1QpTsOBkiVcRC"><b>online</b></a>
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/K4L4D6nibuGXbjfd"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/zTlubIHYOK6EGxnc"><b>online</b></a>
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/RMpEI2o935KgD2o2"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/NlKuJEkKDx7IhN9Z"><b>online</b></a>
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/0lW1WJ1ZP8g92Jp9"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/fTnaiB7w2ocgAsw8"><b>online</b></a>
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/yarD6DyxYlIf8Ymg"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/I7blCyINJHBX81JG"><b>online</b></a>
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/9oPbpnFNgKtKjB0O"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/LQmVooyLiQWjqnra"><b>online</b></a>
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/wwsjMZP8U6bWhUil"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/bJHYVEctvmaszdBj"><b>online</b></a>
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/yv5TMrq9qREivvHf"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/nAD5pUgjv1DcMhh7"><b>online</b></a>
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/GQz9A5y7HduQHVMw"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/3ylcqXCMzsKBSkxZ"><b>online</b></a>
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/Qom888gs2RM4wR4H"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/viOKm4V0ccy238mU"><b>online</b></a>
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/hicmeOK39tBxaluM"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/QJlGaO7RqgvibCbR"><b>online</b></a>
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@ -7,14 +8,35 @@ int main()
|
||||
// create JSON values
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
json j_array = {1, 2, 4, 8, 16};
|
||||
json j_string = "Hellö 😀!";
|
||||
|
||||
// call dump()
|
||||
std::cout << j_object.dump() << "\n\n";
|
||||
std::cout << j_object.dump(-1) << "\n\n";
|
||||
std::cout << j_object.dump(0) << "\n\n";
|
||||
std::cout << j_object.dump(4) << "\n\n";
|
||||
std::cout << j_array.dump() << "\n\n";
|
||||
std::cout << j_array.dump(-1) << "\n\n";
|
||||
std::cout << j_array.dump(0) << "\n\n";
|
||||
std::cout << j_array.dump(4) << "\n\n";
|
||||
std::cout << "objects:" << '\n'
|
||||
<< j_object.dump() << "\n\n"
|
||||
<< j_object.dump(-1) << "\n\n"
|
||||
<< j_object.dump(0) << "\n\n"
|
||||
<< j_object.dump(4) << "\n\n"
|
||||
<< j_object.dump(1, '\t') << "\n\n";
|
||||
|
||||
std::cout << "arrays:" << '\n'
|
||||
<< j_array.dump() << "\n\n"
|
||||
<< j_array.dump(-1) << "\n\n"
|
||||
<< j_array.dump(0) << "\n\n"
|
||||
<< j_array.dump(4) << "\n\n"
|
||||
<< j_array.dump(1, '\t') << "\n\n";
|
||||
|
||||
std::cout << "strings:" << '\n'
|
||||
<< j_string.dump() << '\n'
|
||||
<< j_string.dump(-1, ' ', true) << '\n';
|
||||
|
||||
// create JSON value with invalid UTF-8 byte sequence
|
||||
json j_invalid = "\xF0\xA4\xAD\xC0";
|
||||
try
|
||||
{
|
||||
std::cout << j_invalid.dump() << std::endl;
|
||||
}
|
||||
catch (json::type_error& e)
|
||||
{
|
||||
std::cout << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/rjYfsEq7v1RCHprk"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/mHH9TibITCYPpLwy"><b>online</b></a>
|
@ -1,3 +1,4 @@
|
||||
objects:
|
||||
{"one":1,"two":2}
|
||||
|
||||
{"one":1,"two":2}
|
||||
@ -12,6 +13,12 @@
|
||||
"two": 2
|
||||
}
|
||||
|
||||
{
|
||||
"one": 1,
|
||||
"two": 2
|
||||
}
|
||||
|
||||
arrays:
|
||||
[1,2,4,8,16]
|
||||
|
||||
[1,2,4,8,16]
|
||||
@ -32,3 +39,15 @@
|
||||
16
|
||||
]
|
||||
|
||||
[
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
8,
|
||||
16
|
||||
]
|
||||
|
||||
strings:
|
||||
"Hellö 😀!"
|
||||
"Hell\u00f6 \ud83d\ude00!"
|
||||
[json.exception.type_error.316] invalid UTF-8 byte at index 3: 0xC0
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/B6ILaoysGMliouEO"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/xc7HomW1EFM5PV6n"><b>online</b></a>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user