Unverified Commit fa3e42f8 authored by Niels Lohmann's avatar Niels Lohmann

Merge branch 'develop' into feature/wstring

parents cf91b4f2 b5d1755d
...@@ -155,6 +155,9 @@ matrix: ...@@ -155,6 +155,9 @@ matrix:
- os: osx - os: osx
osx_image: xcode9.2 osx_image: xcode9.2
- os: osx
osx_image: xcode9.3
# Linux / GCC # Linux / GCC
- os: linux - os: linux
......
...@@ -22,13 +22,15 @@ option(JSON_MultipleHeaders "Use non-amalgamated version of the library." OFF) ...@@ -22,13 +22,15 @@ option(JSON_MultipleHeaders "Use non-amalgamated version of the library." OFF)
## CONFIGURATION ## CONFIGURATION
## ##
set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME}) set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME})
set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "lib/cmake/${PROJECT_NAME}") set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "lib/cmake/${PROJECT_NAME}"
CACHE INTERNAL "")
set(NLOHMANN_JSON_INCLUDE_INSTALL_DIR "include") set(NLOHMANN_JSON_INCLUDE_INSTALL_DIR "include")
set(NLOHMANN_JSON_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets") set(NLOHMANN_JSON_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
set(NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE "cmake/config.cmake.in") 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_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}")
set(NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}ConfigVersion.cmake") set(NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
set(NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Config.cmake") set(NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Config.cmake")
set(NLOHMANN_JSON_CMAKE_PROJECT_TARGETS_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Targets.cmake")
if (JSON_MultipleHeaders) if (JSON_MultipleHeaders)
set(NLOHMANN_JSON_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/include/") set(NLOHMANN_JSON_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/include/")
...@@ -43,7 +45,7 @@ endif() ...@@ -43,7 +45,7 @@ endif()
## create target and add include path ## create target and add include path
## ##
add_library(${NLOHMANN_JSON_TARGET_NAME} INTERFACE) add_library(${NLOHMANN_JSON_TARGET_NAME} INTERFACE)
add_library(${PROJECT_NAME}::${NLOHMANN_JSON_TARGET_NAME} ALIAS ${NLOHMANN_JSON_TARGET_NAME})
target_compile_features(${NLOHMANN_JSON_TARGET_NAME} INTERFACE cxx_std_11) target_compile_features(${NLOHMANN_JSON_TARGET_NAME} INTERFACE cxx_std_11)
target_include_directories( target_include_directories(
...@@ -53,7 +55,7 @@ target_include_directories( ...@@ -53,7 +55,7 @@ target_include_directories(
$<INSTALL_INTERFACE:include> $<INSTALL_INTERFACE:include>
) )
## add debug view defintion file for msvc (natvis) ## add debug view definition file for msvc (natvis)
if (MSVC) if (MSVC)
set(NLOHMANN_ADD_NATVIS TRUE) set(NLOHMANN_ADD_NATVIS TRUE)
set(NLOHMANN_NATVIS_FILE "nlohmann_json.natvis") set(NLOHMANN_NATVIS_FILE "nlohmann_json.natvis")
...@@ -104,6 +106,11 @@ if (NLOHMANN_ADD_NATVIS) ...@@ -104,6 +106,11 @@ if (NLOHMANN_ADD_NATVIS)
DESTINATION . DESTINATION .
) )
endif() endif()
export(
TARGETS ${NLOHMANN_JSON_TARGET_NAME}
NAMESPACE ${PROJECT_NAME}::
FILE ${NLOHMANN_JSON_CMAKE_PROJECT_TARGETS_FILE}
)
install( install(
TARGETS ${NLOHMANN_JSON_TARGET_NAME} TARGETS ${NLOHMANN_JSON_TARGET_NAME}
EXPORT ${NLOHMANN_JSON_TARGETS_EXPORT_NAME} EXPORT ${NLOHMANN_JSON_TARGETS_EXPORT_NAME}
...@@ -111,5 +118,6 @@ install( ...@@ -111,5 +118,6 @@ install(
) )
install( install(
EXPORT ${NLOHMANN_JSON_TARGETS_EXPORT_NAME} EXPORT ${NLOHMANN_JSON_TARGETS_EXPORT_NAME}
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${NLOHMANN_JSON_CONFIG_INSTALL_DIR} DESTINATION ${NLOHMANN_JSON_CONFIG_INSTALL_DIR}
) )
...@@ -834,7 +834,8 @@ The following compilers are currently used in continuous integration at [Travis] ...@@ -834,7 +834,8 @@ The following compilers are currently used in continuous integration at [Travis]
| 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 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.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.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) | | Clang Xcode 9.2 | Darwin Kernel Version 16.7.0 (macOS 10.12.6) | Apple LLVM version 9.0.0 (clang-900.0.39.2) |
| Clang Xcode 9.3 | Darwin Kernel Version 17.4.0 (macOS 10.13.0) | Apple LLVM version 9.1.0 (clang-902.0.39.1)
| 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 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 | | Visual Studio 2017 | Windows Server 2016 | Microsoft (R) Build Engine version 15.5.180.51428, MSVC 19.12.25830.2 |
...@@ -977,7 +978,12 @@ I deeply appreciate the help of the following people. ...@@ -977,7 +978,12 @@ I deeply appreciate the help of the following people.
- [Paul Fultz II](https://github.com/pfultz2) added a note on the cget package manager. - [Paul Fultz II](https://github.com/pfultz2) added a note on the cget package manager.
- [Wilson Lin](https://github.com/wla80) made the integration section of the README more concise. - [Wilson Lin](https://github.com/wla80) made the integration section of the README more concise.
- [RalfBielig](https://github.com/ralfbielig) detected and fixed a memory leak in the parser callback. - [RalfBielig](https://github.com/ralfbielig) detected and fixed a memory leak in the parser callback.
- [agrianius](https://github.com/agrianius) allowed to dump JSON to an alternative string type - [agrianius](https://github.com/agrianius) allowed to dump JSON to an alternative string type.
- [Kevin Tonon](https://github.com/ktonon) overworked the C++11 compiler checks in CMake.
- [Axel Huebl](https://github.com/ax3l) simplified a CMake check and added support for the [Spack package manager](https://spack.io).
- [Carlos O'Ryan](https://github.com/coryan) fixed a typo.
- [James Upjohn](https://github.com/jammehcow) fixed a version number in the compilers section.
- [Chuck Atkins](https://github.com/chuckatkins) adjusted the CMake files to the CMake packaging guidelines
Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I forgot someone. Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I forgot someone.
......
@PACKAGE_INIT@ @PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/@NLOHMANN_JSON_TARGETS_EXPORT_NAME@.cmake") if(NOT TARGET @PROJECT_NAME@::@NLOHMANN_JSON_TARGET_NAME@)
include("${CMAKE_CURRENT_LIST_DIR}/@NLOHMANN_JSON_TARGETS_EXPORT_NAME@.cmake")
endif()
check_required_components("@PROJECT_NAME@") check_required_components("@PROJECT_NAME@")
doc/avatars.png

568 KB | W: | H:

doc/avatars.png

635 KB | W: | H:

doc/avatars.png
doc/avatars.png
doc/avatars.png
doc/avatars.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -3405,7 +3405,7 @@ class basic_json ...@@ -3405,7 +3405,7 @@ class basic_json
@return copy of the element at key @a key or @a default_value if @a key @return copy of the element at key @a key or @a default_value if @a key
is not found is not found
@throw type_error.306 if the JSON value is not an objec; in that case, @throw type_error.306 if the JSON value is not an object; in that case,
using `value()` with a key makes no sense. using `value()` with a key makes no sense.
@complexity Logarithmic in the size of the container. @complexity Logarithmic in the size of the container.
......
...@@ -13225,7 +13225,7 @@ class basic_json ...@@ -13225,7 +13225,7 @@ class basic_json
@return copy of the element at key @a key or @a default_value if @a key @return copy of the element at key @a key or @a default_value if @a key
is not found is not found
@throw type_error.306 if the JSON value is not an objec; in that case, @throw type_error.306 if the JSON value is not an object; in that case,
using `value()` with a key makes no sense. using `value()` with a key makes no sense.
@complexity Logarithmic in the size of the container. @complexity Logarithmic in the size of the container.
......
...@@ -175,29 +175,6 @@ TEST_CASE("controlled bad_alloc") ...@@ -175,29 +175,6 @@ TEST_CASE("controlled bad_alloc")
CHECK_THROWS_AS(my_json::json_value(v), std::bad_alloc&); CHECK_THROWS_AS(my_json::json_value(v), std::bad_alloc&);
next_construct_fails = false; next_construct_fails = false;
} }
/*
SECTION("json_value(const object_t&)")
{
next_construct_fails = false;
my_json::object_t v {{"foo", "bar"}};
CHECK_NOTHROW(my_json::json_value j(v));
next_construct_fails = true;
CHECK_THROWS_AS(my_json::json_value j(v), std::bad_alloc&);
next_construct_fails = false;
}
*/
/*
SECTION("json_value(const array_t&)")
{
next_construct_fails = false;
my_json::array_t v = {"foo", "bar", "baz"};
CHECK_NOTHROW(my_json::json_value j(v));
next_construct_fails = true;
CHECK_THROWS_AS(my_json::json_value j(v), std::bad_alloc&);
next_construct_fails = false;
}
*/
} }
SECTION("class basic_json") SECTION("class basic_json")
......
...@@ -491,7 +491,6 @@ TEST_CASE("CBOR") ...@@ -491,7 +491,6 @@ TEST_CASE("CBOR")
} }
} }
/*
SECTION("-32768..-129 (int 16)") SECTION("-32768..-129 (int 16)")
{ {
for (int16_t i = -32768; i <= -129; ++i) for (int16_t i = -32768; i <= -129; ++i)
...@@ -517,14 +516,13 @@ TEST_CASE("CBOR") ...@@ -517,14 +516,13 @@ TEST_CASE("CBOR")
// check individual bytes // check individual bytes
CHECK(result[0] == 0xd1); CHECK(result[0] == 0xd1);
int16_t restored = (result[1] << 8) + result[2]; int16_t restored = static_cast<int16_t>((result[1] << 8) + result[2]);
CHECK(restored == i); CHECK(restored == i);
// roundtrip // roundtrip
CHECK(json::from_msgpack(result) == j); CHECK(json::from_msgpack(result) == j);
} }
} }
*/
} }
SECTION("unsigned") SECTION("unsigned")
...@@ -1044,28 +1042,6 @@ TEST_CASE("CBOR") ...@@ -1044,28 +1042,6 @@ TEST_CASE("CBOR")
// roundtrip // roundtrip
CHECK(json::from_cbor(result) == j); CHECK(json::from_cbor(result) == j);
} }
/*
SECTION("array with uint64_t elements")
{
json j(4294967296, nullptr);
std::vector<uint8_t> expected(j.size() + 9, 0xf6); // all null
expected[0] = 0x9b; // array 64 bit
expected[1] = 0x00; // size (0x0000000100000000), byte 0
expected[2] = 0x00; // size (0x0000000100000000), byte 1
expected[3] = 0x00; // size (0x0000000100000000), byte 2
expected[4] = 0x01; // size (0x0000000100000000), byte 3
expected[5] = 0x00; // size (0x0000000100000000), byte 4
expected[6] = 0x00; // size (0x0000000100000000), byte 5
expected[7] = 0x00; // size (0x0000000100000000), byte 6
expected[8] = 0x00; // size (0x0000000100000000), byte 7
const auto result = json::to_cbor(j);
CHECK(result == expected);
// roundtrip
CHECK(json::from_cbor(result) == j);
}
*/
} }
SECTION("object") SECTION("object")
......
...@@ -173,15 +173,4 @@ TEST_CASE("lexer class") ...@@ -173,15 +173,4 @@ TEST_CASE("lexer class")
s += "\""; s += "\"";
CHECK((scan_string(s.c_str()) == json::lexer::token_type::value_string)); CHECK((scan_string(s.c_str()) == json::lexer::token_type::value_string));
} }
/* NOTE: to_unicode function has been removed
SECTION("to_unicode")
{
// lexer to call to_unicode on
json::lexer dummy_lexer("", 0);
CHECK(dummy_lexer.to_unicode(0x1F4A9) == "💩");
CHECK_THROWS_AS(dummy_lexer.to_unicode(0x200000), json::parse_error);
CHECK_THROWS_WITH(dummy_lexer.to_unicode(0x200000), "[json.exception.parse_error.103] parse error: code points above 0x10FFFF are invalid");
}
*/
} }
...@@ -136,19 +136,19 @@ TEST_CASE("regression tests") ...@@ -136,19 +136,19 @@ TEST_CASE("regression tests")
SECTION("issue #70 - Handle infinity and NaN cases") SECTION("issue #70 - Handle infinity and NaN cases")
{ {
/* // previously, NAN/INFINITY created a null value; now, the values are
// properly stored, but are dumped as "null"
SECTION("NAN value") SECTION("NAN value")
{ {
CHECK(json(NAN) == json()); CHECK(json(NAN).dump() == "null");
CHECK(json(json::number_float_t(NAN)) == json()); CHECK(json(json::number_float_t(NAN)).dump() == "null");
} }
SECTION("infinity") SECTION("infinity")
{ {
CHECK(json(INFINITY) == json()); CHECK(json(INFINITY).dump() == "null");
CHECK(json(json::number_float_t(INFINITY)) == json()); CHECK(json(json::number_float_t(INFINITY)).dump() == "null");
} }
*/
// With 3.0.0, the semantics of this changed: NAN and infinity are // With 3.0.0, the semantics of this changed: NAN and infinity are
// stored properly inside the JSON value (no exception or conversion // stored properly inside the JSON value (no exception or conversion
...@@ -1213,41 +1213,6 @@ TEST_CASE("regression tests") ...@@ -1213,41 +1213,6 @@ TEST_CASE("regression tests")
CHECK(j["bool_vector"].dump() == "[false,true,false,false]"); CHECK(j["bool_vector"].dump() == "[false,true,false,false]");
} }
/* NOTE: m_line_buffer is not used any more
SECTION("issue #495 - fill_line_buffer incorrectly tests m_stream for eof but not fail or bad bits")
{
SECTION("setting failbit")
{
std::stringstream ss;
ss << "[1,2,3\n,4,5]";
json::lexer l(ss);
CHECK(l.m_line_buffer == "[1,2,3\n");
l.m_stream->setstate(std::ios_base::failbit);
CHECK_THROWS_AS(l.fill_line_buffer(), json::parse_error&);
CHECK_THROWS_WITH(l.fill_line_buffer(), "[json.exception.parse_error.111] parse error: bad input stream");
}
SECTION("setting badbit")
{
std::stringstream ss;
ss << "[1,2,3\n,4,5]";
json::lexer l(ss);
CHECK(l.m_line_buffer == "[1,2,3\n");
l.m_stream->setstate(std::ios_base::badbit);
CHECK_THROWS_AS(l.fill_line_buffer(), json::parse_error&);
CHECK_THROWS_WITH(l.fill_line_buffer(), "[json.exception.parse_error.111] parse error: bad input stream");
}
}
*/
SECTION("issue #504 - assertion error (OSS-Fuzz 856)") SECTION("issue #504 - assertion error (OSS-Fuzz 856)")
{ {
std::vector<uint8_t> vec1 = {0xf9, 0xff, 0xff, 0x4a, 0x3a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x37, 0x02, 0x38}; std::vector<uint8_t> vec1 = {0xf9, 0xff, 0xff, 0x4a, 0x3a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x37, 0x02, 0x38};
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment