mirror of
https://github.com/nlohmann/json
synced 2024-11-10 14:30:08 +00:00
Merge remote-tracking branch 'upstream/develop' into develop
This commit is contained in:
commit
c4923e3d05
@ -19,6 +19,9 @@ jobs:
|
||||
- run:
|
||||
name: Create build files
|
||||
command: 'mkdir build ; cd build ; cmake ..'
|
||||
- run:
|
||||
name: Versions
|
||||
command: 'g++ --version ; uname -a'
|
||||
- run:
|
||||
name: Compile
|
||||
command: 'cmake --build build'
|
||||
|
@ -155,11 +155,14 @@ matrix:
|
||||
- os: osx
|
||||
osx_image: xcode10.1
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode10.2
|
||||
|
||||
# Linux / GCC
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: compiler=g++-4.8
|
||||
env: COMPILER=g++-4.8
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
@ -167,7 +170,7 @@ matrix:
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: compiler=g++-4.9
|
||||
env: COMPILER=g++-4.9
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
|
4
Makefile
4
Makefile
@ -134,7 +134,7 @@ pedantic_clang:
|
||||
|
||||
# calling GCC with most warnings
|
||||
pedantic_gcc:
|
||||
$(MAKE) json_unit CXX=/usr/local/bin/g++-9 CXXFLAGS=" \
|
||||
$(MAKE) json_unit CXX=g++-9 CXXFLAGS=" \
|
||||
-std=c++11 \
|
||||
-Waddress \
|
||||
-Waddress-of-packed-member \
|
||||
@ -594,7 +594,7 @@ ChangeLog.md:
|
||||
release:
|
||||
rm -fr release_files
|
||||
mkdir release_files
|
||||
zip -9 --recurse-paths -X include.zip $(SRCS)
|
||||
zip -9 --recurse-paths -X include.zip $(SRCS) $(AMALGAMATED_FILE) meson.build
|
||||
gpg --armor --detach-sig include.zip
|
||||
mv include.zip include.zip.asc release_files
|
||||
gpg --armor --detach-sig $(AMALGAMATED_FILE)
|
||||
|
26
README.md
26
README.md
@ -153,7 +153,9 @@ endif()
|
||||
|
||||
: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 get a wrap file by downloading it from [Meson WrapDB](https://wrapdb.mesonbuild.com/nlohmann_json), or simply use `meson wrap install nlohmann_json`.
|
||||
If you are using the [Meson Build System](http://mesonbuild.com), add this source tree as a [meson subproject](https://mesonbuild.com/Subprojects.html#using-a-subproject). You may also use the `include.zip` published in this project's [Releases](https://github.com/nlohmann/json/releases) to reduce the size of the vendored source tree. Alternatively, you can get a wrap file by downloading it from [Meson WrapDB](https://wrapdb.mesonbuild.com/nlohmann_json), or simply use `meson wrap install nlohmann_json`. Please see the meson project for any issues regarding the packaging.
|
||||
|
||||
The provided meson.build can also be used as an alternative to cmake for installing `nlohmann_json` system-wide in which case a pkg-config file is installed. To use it, simply have your build system require the `nlohmann_json` pkg-config dependency. In Meson, it is preferred to use the [`dependency()`](https://mesonbuild.com/Reference-manual.html#dependency) object with a subproject fallback, rather than using the subproject directly.
|
||||
|
||||
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.
|
||||
|
||||
@ -1000,11 +1002,12 @@ json j_from_ubjson = json::from_ubjson(v_ubjson);
|
||||
|
||||
Though it's 2019 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work:
|
||||
|
||||
- GCC 4.8 - 9.0 (and possibly later)
|
||||
- Clang 3.4 - 8.0 (and possibly later)
|
||||
- GCC 4.8 - 9.2 (and possibly later)
|
||||
- Clang 3.4 - 9.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)
|
||||
- Microsoft Visual C++ 2019 / Build Tools 16.3.1+1def00d3d (and possibly later)
|
||||
|
||||
I would be happy to learn about other compilers/versions.
|
||||
|
||||
@ -1025,7 +1028,7 @@ Please note:
|
||||
|
||||
- Unsupported versions of GCC and Clang are rejected by `#error` directives. This can be switched off by defining `JSON_SKIP_UNSUPPORTED_COMPILER_CHECK`. Note that you can expect no support in this case.
|
||||
|
||||
The following compilers are currently used in continuous integration at [Travis](https://travis-ci.org/nlohmann/json), [AppVeyor](https://ci.appveyor.com/project/nlohmann/json), and [Doozer](https://doozer.io):
|
||||
The following compilers are currently used in continuous integration at [Travis](https://travis-ci.org/nlohmann/json), [AppVeyor](https://ci.appveyor.com/project/nlohmann/json), [CircleCI](https://circleci.com/gh/nlohmann/json), and [Doozer](https://doozer.io):
|
||||
|
||||
| Compiler | Operating System | Version String |
|
||||
|-----------------------|------------------------------|----------------|
|
||||
@ -1035,11 +1038,13 @@ The following compilers are currently used in continuous integration at [Travis]
|
||||
| GCC 4.9.4 | Ubuntu 14.04.1 LTS | g++-4.9 (Ubuntu 4.9.4-2ubuntu1~14.04.1) 4.9.4 |
|
||||
| GCC 5.3.1 (armv7l) | Ubuntu 16.04 LTS | g++ (Ubuntu/Linaro 5.3.1-14ubuntu2) 5.3.1 20160413 |
|
||||
| GCC 5.5.0 | Ubuntu 14.04.1 LTS | g++-5 (Ubuntu 5.5.0-12ubuntu1~14.04) 5.5.0 20171010 |
|
||||
| GCC 6.3.0 | Debian 9 (stretch) | g++ (Debian 6.3.0-18+deb9u1) 6.3.0 20170516 |
|
||||
| GCC 6.3.1 | Fedora release 24 (Twenty Four) | g++ (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1) |
|
||||
| GCC 6.4.0 | Ubuntu 14.04.1 LTS | g++-6 (Ubuntu 6.4.0-17ubuntu1~14.04) 6.4.0 20180424 |
|
||||
| GCC 7.3.0 | Ubuntu 14.04.1 LTS | g++-7 (Ubuntu 7.3.0-21ubuntu1~14.04) 7.3.0 |
|
||||
| GCC 7.3.0 | Windows Server 2012 R2 (x64) | g++ (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 7.3.0 |
|
||||
| GCC 8.1.0 | Ubuntu 14.04.1 LTS | g++-8 (Ubuntu 8.1.0-5ubuntu1~14.04) 8.1.0 |
|
||||
| GCC 9.2.1 | Ubuntu 14.05.1 LTS | g++-9 (Ubuntu 9.2.1-16ubuntu1~14.04.1) 9.2.1 20191030 |
|
||||
| Clang 3.5.0 | Ubuntu 14.04.1 LTS | clang version 3.5.0-4ubuntu2~trusty2 (tags/RELEASE_350/final) (based on LLVM 3.5.0) |
|
||||
| Clang 3.6.2 | Ubuntu 14.04.1 LTS | clang version 3.6.2-svn240577-1~exp1 (branches/release_36) (based on LLVM 3.6.2) |
|
||||
| Clang 3.7.1 | Ubuntu 14.04.1 LTS | clang version 3.7.1-svn253571-1~exp1 (branches/release_37) (based on LLVM 3.7.1) |
|
||||
@ -1056,8 +1061,10 @@ The following compilers are currently used in continuous integration at [Travis]
|
||||
| Clang Xcode 9.3 | OSX 10.13.3 | Apple LLVM version 9.1.0 (clang-902.0.39.2) |
|
||||
| Clang Xcode 10.0 | OSX 10.13.3 | Apple LLVM version 10.0.0 (clang-1000.11.45.2) |
|
||||
| Clang Xcode 10.1 | OSX 10.13.3 | Apple LLVM version 10.0.0 (clang-1000.11.45.5) |
|
||||
| Clang Xcode 10.2 | OSX 10.14.4 | Apple LLVM version 10.0.1 (clang-1001.0.46.4) |
|
||||
| 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.7.180.61344, MSVC 19.14.26433.0 |
|
||||
| Visual Studio 15 2017 | Windows Server 2012 R2 (x64) | Microsoft (R) Build Engine version 15.9.21+g9802d43bc3, MSVC 19.16.27032.1 |
|
||||
| Visual Studio 16 2019 | Windows Server 2012 R2 (x64) | Microsoft (R) Build Engine version 16.3.1+1def00d3d, MSVC 19.23.28106.4 |
|
||||
|
||||
## License
|
||||
|
||||
@ -1270,6 +1277,15 @@ I deeply appreciate the help of the following people.
|
||||
- [Gabe Ron](https://github.com/Macr0Nerd) implemented the `to_string` method.
|
||||
- [Watal M. Iwasaki](https://github.com/heavywatal) fixed a Clang warning.
|
||||
- [Viktor Kirilov](https://github.com/onqtam) switched the unit tests from [Catch](https://github.com/philsquared/Catch) to [doctest](https://github.com/onqtam/doctest)
|
||||
- [Juncheng E](https://github.com/ejcjason) fixed a typo.
|
||||
- [tete17](https://github.com/tete17) fixed a bug in the `contains` function.
|
||||
- [Xav83](https://github.com/Xav83) fixed some cppcheck warnings.
|
||||
- [0xflotus](https://github.com/0xflotus) fixed some typos.
|
||||
- [Christian Deneke](https://github.com/chris0x44) added a const version of `json_pointer::back`.
|
||||
- [Julien Hamaide](https://github.com/crazyjul) made the `items()` function work with custom string types.
|
||||
- [Evan Nemerson](https://github.com/nemequ) updated fixed a bug in Hedley and updated this library accordingly.
|
||||
- [Florian Pigorsch](https://github.com/flopp) fixed a lot of typos.
|
||||
- [Camille Bégué](https://github.com/cbegue) fixed an issue in the conversion from `std::pair` to `json`.
|
||||
|
||||
Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I forgot someone.
|
||||
|
||||
|
59
appveyor.yml
59
appveyor.yml
@ -16,6 +16,20 @@ environment:
|
||||
LINKER_FLAGS: ""
|
||||
GENERATOR: Visual Studio 15 2017
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
configuration: Debug
|
||||
platform: x86
|
||||
CXX_FLAGS: ""
|
||||
LINKER_FLAGS: ""
|
||||
GENERATOR: Visual Studio 16 2019
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
configuration: Debug
|
||||
platform: x64
|
||||
CXX_FLAGS: ""
|
||||
LINKER_FLAGS: ""
|
||||
GENERATOR: Visual Studio 16 2019
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
configuration: Debug
|
||||
COMPILER: mingw
|
||||
@ -47,13 +61,6 @@ environment:
|
||||
LINKER_FLAGS: ""
|
||||
GENERATOR: Visual Studio 14 2015
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
configuration: Release
|
||||
platform: x86
|
||||
CXX_FLAGS: ""
|
||||
LINKER_FLAGS: ""
|
||||
GENERATOR: Visual Studio 15 2017
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
configuration: Release
|
||||
platform: x86
|
||||
@ -61,43 +68,51 @@ environment:
|
||||
LINKER_FLAGS: ""
|
||||
GENERATOR: Visual Studio 15 2017
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
configuration: Release
|
||||
platform: x86
|
||||
CXX_FLAGS: ""
|
||||
LINKER_FLAGS: ""
|
||||
GENERATOR: Visual Studio 16 2019
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
configuration: Release
|
||||
platform: x64
|
||||
CXX_FLAGS: ""
|
||||
LINKER_FLAGS: ""
|
||||
GENERATOR: Visual Studio 14 2015 Win64
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
configuration: Release
|
||||
platform: x64
|
||||
CXX_FLAGS: ""
|
||||
LINKER_FLAGS: ""
|
||||
GENERATOR: Visual Studio 15 2017 Win64
|
||||
GENERATOR: Visual Studio 14 2015
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
configuration: Release
|
||||
platform: x64
|
||||
CXX_FLAGS: "/permissive- /std:c++latest /utf-8 /F4000000"
|
||||
LINKER_FLAGS: "/STACK:4000000"
|
||||
GENERATOR: Visual Studio 15 2017 Win64
|
||||
GENERATOR: Visual Studio 15 2017
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
configuration: Release
|
||||
platform: x64
|
||||
CXX_FLAGS: ""
|
||||
LINKER_FLAGS: ""
|
||||
GENERATOR: Visual Studio 16 2019
|
||||
|
||||
init:
|
||||
- cmake --version
|
||||
- msbuild /version
|
||||
|
||||
install:
|
||||
- if "%COMPILER%"=="mingw" appveyor DownloadFile https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-win.zip -FileName ninja.zip
|
||||
- if "%COMPILER%"=="mingw" 7z x ninja.zip -oC:\projects\deps\ninja > nul
|
||||
- if "%COMPILER%"=="mingw" set PATH=C:\projects\deps\ninja;%PATH%
|
||||
- if "%COMPILER%"=="mingw" set PATH=C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin;%PATH%
|
||||
- if "%COMPILER%"=="mingw" g++ --version
|
||||
- if "%COMPILER%"=="mingw" appveyor DownloadFile https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-win.zip -FileName ninja.zip
|
||||
- if "%COMPILER%"=="mingw" 7z x ninja.zip -oC:\projects\deps\ninja > nul
|
||||
- if "%COMPILER%"=="mingw" set PATH=C:\projects\deps\ninja;%PATH%
|
||||
- if "%COMPILER%"=="mingw" set PATH=C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin;%PATH%
|
||||
- if "%COMPILER%"=="mingw" g++ --version
|
||||
- if "%platform%"=="x86" set GENERATOR_PLATFORM=Win32
|
||||
|
||||
before_build:
|
||||
# for with_win_header build, inject the inclusion of Windows.h to the single-header library
|
||||
- ps: if ($env:name -Eq "with_win_header") { $header_path = "single_include\nlohmann\json.hpp" }
|
||||
- ps: if ($env:name -Eq "with_win_header") { "#include <Windows.h>`n" + (Get-Content $header_path | Out-String) | Set-Content $header_path }
|
||||
- cmake . -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%configuration%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin"
|
||||
- if "%GENERATOR%"=="Ninja" (cmake . -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%configuration%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin") else (cmake . -G "%GENERATOR%" -A "%GENERATOR_PLATFORM%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin")
|
||||
|
||||
build_script:
|
||||
- cmake --build . --config "%configuration%"
|
||||
|
BIN
doc/avatars.png
BIN
doc/avatars.png
Binary file not shown.
Before Width: | Height: | Size: 997 KiB After Width: | Height: | Size: 1.0 MiB |
@ -1 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/9GFummh9iBAkOFiL"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/B8QFt317rARJWiGI"><b>online</b></a>
|
@ -1 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/mxBfUH9gOY9AiOOk"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/SEuKMiM0vuzQDU8U"><b>online</b></a>
|
@ -2,7 +2,7 @@
|
||||
"compiler": {
|
||||
"c++": "201103",
|
||||
"family": "clang",
|
||||
"version": "10.0.1 (clang-1001.0.46.4)"
|
||||
"version": "11.0.0 (clang-1100.0.33.8)"
|
||||
},
|
||||
"copyright": "(C) 2013-2017 Niels Lohmann",
|
||||
"name": "JSON for Modern C++",
|
||||
|
@ -302,8 +302,8 @@ void to_json(BasicJsonType& j, const T(&arr)[N])
|
||||
external_constructor<value_t::array>::construct(j, arr);
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename... Args>
|
||||
void to_json(BasicJsonType& j, const std::pair<Args...>& p)
|
||||
template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value, int > = 0 >
|
||||
void to_json(BasicJsonType& j, const std::pair<T1, T2>& p)
|
||||
{
|
||||
j = { p.first, p.second };
|
||||
}
|
||||
|
@ -3733,8 +3733,8 @@ void to_json(BasicJsonType& j, const T(&arr)[N])
|
||||
external_constructor<value_t::array>::construct(j, arr);
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename... Args>
|
||||
void to_json(BasicJsonType& j, const std::pair<Args...>& p)
|
||||
template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value, int > = 0 >
|
||||
void to_json(BasicJsonType& j, const std::pair<T1, T2>& p)
|
||||
{
|
||||
j = { p.first, p.second };
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
add_test(NAME cmake_import_configure
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-G "${CMAKE_GENERATOR}"
|
||||
-A "${CMAKE_GENERATOR_PLATFORM}"
|
||||
-Dnlohmann_json_DIR=${PROJECT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/project
|
||||
)
|
||||
|
@ -1,6 +1,7 @@
|
||||
add_test(NAME cmake_import_minver_configure
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-G "${CMAKE_GENERATOR}"
|
||||
-A "${CMAKE_GENERATOR_PLATFORM}"
|
||||
-Dnlohmann_json_DIR=${PROJECT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/project
|
||||
)
|
||||
|
@ -584,10 +584,9 @@ TEST_CASE("BSON input/output_adapters")
|
||||
{
|
||||
SECTION("std::ostringstream")
|
||||
{
|
||||
std::ostringstream ss;
|
||||
std::basic_ostringstream<std::uint8_t> ss;
|
||||
json::to_bson(json_representation, ss);
|
||||
std::istringstream iss(ss.str());
|
||||
json j3 = json::from_bson(iss);
|
||||
json j3 = json::from_bson(ss.str());
|
||||
CHECK(json_representation == j3);
|
||||
}
|
||||
|
||||
|
@ -1580,7 +1580,7 @@ TEST_CASE("single CBOR roundtrip")
|
||||
{
|
||||
SECTION("std::ostringstream")
|
||||
{
|
||||
std::ostringstream ss;
|
||||
std::basic_ostringstream<std::uint8_t> ss;
|
||||
json::to_cbor(j1, ss);
|
||||
json j3 = json::from_cbor(ss.str());
|
||||
CHECK(j1 == j3);
|
||||
|
@ -1334,7 +1334,7 @@ TEST_CASE("single MessagePack roundtrip")
|
||||
{
|
||||
SECTION("std::ostringstream")
|
||||
{
|
||||
std::ostringstream ss;
|
||||
std::basic_ostringstream<std::uint8_t> ss;
|
||||
json::to_msgpack(j1, ss);
|
||||
json j3 = json::from_msgpack(ss.str());
|
||||
CHECK(j1 == j3);
|
||||
|
@ -192,6 +192,17 @@ struct adl_serializer<NonDefaultFromJsonStruct>
|
||||
};
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// for #1805
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct NotSerializableData
|
||||
{
|
||||
int mydata;
|
||||
float myfloat;
|
||||
};
|
||||
|
||||
|
||||
TEST_CASE("regression tests")
|
||||
{
|
||||
SECTION("issue #60 - Double quotation mark is not parsed correctly")
|
||||
@ -1771,31 +1782,37 @@ TEST_CASE("regression tests")
|
||||
{
|
||||
SECTION("a bunch of -1, ensure_ascii=true")
|
||||
{
|
||||
const auto length = 300;
|
||||
|
||||
json dump_test;
|
||||
std::vector<char> data(300, -1);
|
||||
std::vector<std::string> vec_string(300, "\\ufffd");
|
||||
std::string s{data.data(), data.size()};
|
||||
dump_test["1"] = s;
|
||||
std::ostringstream os;
|
||||
os << "{\"1\":\"";
|
||||
std::copy( vec_string.begin(), vec_string.end(), std::ostream_iterator<std::string>(os));
|
||||
os << "\"}";
|
||||
s = dump_test.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace);
|
||||
CHECK(s == os.str());
|
||||
dump_test["1"] = std::string(length, -1);
|
||||
|
||||
std::string expected = "{\"1\":\"";
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
expected += "\\ufffd";
|
||||
}
|
||||
expected += "\"}";
|
||||
|
||||
auto s = dump_test.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace);
|
||||
CHECK(s == expected);
|
||||
}
|
||||
SECTION("a bunch of -2, ensure_ascii=false")
|
||||
{
|
||||
const auto length = 500;
|
||||
|
||||
json dump_test;
|
||||
std::vector<char> data(500, -2);
|
||||
std::vector<std::string> vec_string(500, "\xEF\xBF\xBD");
|
||||
std::string s{data.data(), data.size()};
|
||||
dump_test["1"] = s;
|
||||
std::ostringstream os;
|
||||
os << "{\"1\":\"";
|
||||
std::copy( vec_string.begin(), vec_string.end(), std::ostream_iterator<std::string>(os));
|
||||
os << "\"}";
|
||||
s = dump_test.dump(-1, ' ', false, nlohmann::json::error_handler_t::replace);
|
||||
CHECK(s == os.str());
|
||||
dump_test["1"] = std::string(length, -2);
|
||||
|
||||
std::string expected = "{\"1\":\"";
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
expected += "\xEF\xBF\xBD";
|
||||
}
|
||||
expected += "\"}";
|
||||
|
||||
auto s = dump_test.dump(-1, ' ', false, nlohmann::json::error_handler_t::replace);
|
||||
CHECK(s == expected);
|
||||
}
|
||||
SECTION("test case in issue #1445")
|
||||
{
|
||||
@ -1858,6 +1875,13 @@ TEST_CASE("regression tests")
|
||||
auto val = nlohmann::json("one").get<for_1647>();
|
||||
CHECK(val == for_1647::one);
|
||||
}
|
||||
|
||||
SECTION("issue #1805 - A pair<T1, T2> is json constructible only if T1 and T2 are json constructible")
|
||||
{
|
||||
static_assert(!std::is_constructible<json, std::pair<std::string, NotSerializableData>>::value, "");
|
||||
static_assert(!std::is_constructible<json, std::pair<NotSerializableData, std::string>>::value, "");
|
||||
static_assert(std::is_constructible<json, std::pair<int, std::string>>::value, "");
|
||||
}
|
||||
}
|
||||
|
||||
#if not defined(JSON_NOEXCEPTION)
|
||||
|
Loading…
Reference in New Issue
Block a user