diff --git a/README.md b/README.md
index 8052f6bf..d160d38e 100644
--- a/README.md
+++ b/README.md
@@ -70,7 +70,9 @@ If you are using the [Meson Build System](http://mesonbuild.com), then you can w
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 [nlohman_json package](https://github.com/ruslo/hunter/wiki/pkg.nlohmann_json). Please see the hunter project for any issues regarding the packaging.
+If you are using [hunter](https://github.com/ruslo/hunter/) on your project for external dependencies, then you can use the [nlohmann_json package](https://github.com/ruslo/hunter/wiki/pkg.nlohmann_json). 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.
diff --git a/appveyor.yml b/appveyor.yml
index 50331a1f..4f423e2f 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -2,7 +2,7 @@ version: '{build}'
os:
- Visual Studio 2015
- - Previous Visual Studio 2017
+ - Visual Studio 2017
environment:
matrix:
diff --git a/doc/examples/operator_deserialize.cpp b/doc/examples/operator_deserialize.cpp
index 06656b65..b553cf67 100644
--- a/doc/examples/operator_deserialize.cpp
+++ b/doc/examples/operator_deserialize.cpp
@@ -18,7 +18,7 @@ int main()
// create JSON value and read the serialization from the stream
json j;
- j << ss;
+ ss >> j;
// serialize JSON
std::cout << std::setw(2) << j << '\n';
diff --git a/doc/examples/operator_deserialize.link b/doc/examples/operator_deserialize.link
index 4544a65b..407b40e1 100644
--- a/doc/examples/operator_deserialize.link
+++ b/doc/examples/operator_deserialize.link
@@ -1 +1 @@
-online
\ No newline at end of file
+online
\ No newline at end of file
diff --git a/src/json.hpp b/src/json.hpp
index a6285446..6c30e8a1 100644
--- a/src/json.hpp
+++ b/src/json.hpp
@@ -62,7 +62,7 @@ SOFTWARE.
#if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
#error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
#endif
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40900
#error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
#endif
@@ -3576,7 +3576,7 @@ class primitive_iterator_t
static constexpr difference_type end_value = begin_value + 1;
/// iterator as signed integer type
- difference_type m_it = std::numeric_limits::min();
+ difference_type m_it = (std::numeric_limits::min)();
};
/*!
@@ -6316,7 +6316,7 @@ class serializer
*/
static constexpr std::size_t bytes_following(const uint8_t u)
{
- return ((0 <= u and u <= 127) ? 0
+ return ((u <= 127) ? 0
: ((192 <= u and u <= 223) ? 1
: ((224 <= u and u <= 239) ? 2
: ((240 <= u and u <= 247) ? 3 : std::string::npos))));
@@ -9755,7 +9755,7 @@ class basic_json
, "incompatible pointer type");
// delegate the call to get_impl_ptr<>() const
- return get_impl_ptr(static_cast(nullptr));
+ return get_impl_ptr(static_cast(nullptr));
}
/*!
@@ -12814,6 +12814,7 @@ class basic_json
future version of the library. Please use
@ref operator<<(std::ostream&, const basic_json&)
instead; that is, replace calls like `j >> o;` with `o << j;`.
+ @since version 1.0.0; deprecated since version 3.0.0
*/
JSON_DEPRECATED
friend std::ostream& operator>>(const basic_json& j, std::ostream& o)
@@ -12997,6 +12998,7 @@ class basic_json
future version of the library. Please use
@ref operator>>(std::istream&, basic_json&)
instead; that is, replace calls like `j << i;` with `i >> j;`.
+ @since version 1.0.0; deprecated since version 3.0.0
*/
JSON_DEPRECATED
friend std::istream& operator<<(basic_json& j, std::istream& i)
diff --git a/test/src/unit-cbor.cpp b/test/src/unit-cbor.cpp
index 4ec03f23..02f3d482 100644
--- a/test/src/unit-cbor.cpp
+++ b/test/src/unit-cbor.cpp
@@ -739,13 +739,13 @@ TEST_CASE("CBOR")
{
SECTION("no byte follows")
{
- CHECK_THROWS_AS(json::from_cbor(std::vector({0xf9})), json::parse_error);
+ CHECK_THROWS_AS(json::from_cbor(std::vector({0xf9})), json::parse_error&);
CHECK_THROWS_WITH(json::from_cbor(std::vector({0xf9})),
"[json.exception.parse_error.110] parse error at 2: unexpected end of input");
}
SECTION("only one byte follows")
{
- CHECK_THROWS_AS(json::from_cbor(std::vector({0xf9, 0x7c})), json::parse_error);
+ CHECK_THROWS_AS(json::from_cbor(std::vector({0xf9, 0x7c})), json::parse_error&);
CHECK_THROWS_WITH(json::from_cbor(std::vector({0xf9, 0x7c})),
"[json.exception.parse_error.110] parse error at 3: unexpected end of input");
}
diff --git a/test/src/unit-deserialization.cpp b/test/src/unit-deserialization.cpp
index 9f574807..2798f102 100644
--- a/test/src/unit-deserialization.cpp
+++ b/test/src/unit-deserialization.cpp
@@ -451,11 +451,11 @@ TEST_CASE("deserialization")
SECTION("BOM only")
{
- CHECK_THROWS_AS(json::parse(bom), json::parse_error);
+ CHECK_THROWS_AS(json::parse(bom), json::parse_error&);
CHECK_THROWS_WITH(json::parse(bom),
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal");
- CHECK_THROWS_AS(json::parse(std::istringstream(bom)), json::parse_error);
+ CHECK_THROWS_AS(json::parse(std::istringstream(bom)), json::parse_error&);
CHECK_THROWS_WITH(json::parse(std::istringstream(bom)),
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal");
}
@@ -468,22 +468,22 @@ TEST_CASE("deserialization")
SECTION("2 byte of BOM")
{
- CHECK_THROWS_AS(json::parse(bom.substr(0, 2)), json::parse_error);
+ CHECK_THROWS_AS(json::parse(bom.substr(0, 2)), json::parse_error&);
CHECK_THROWS_WITH(json::parse(bom),
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal");
- CHECK_THROWS_AS(json::parse(std::istringstream(bom.substr(0, 2))), json::parse_error);
+ CHECK_THROWS_AS(json::parse(std::istringstream(bom.substr(0, 2))), json::parse_error&);
CHECK_THROWS_WITH(json::parse(std::istringstream(bom)),
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal");
}
SECTION("1 byte of BOM")
{
- CHECK_THROWS_AS(json::parse(bom.substr(0, 1)), json::parse_error);
+ CHECK_THROWS_AS(json::parse(bom.substr(0, 1)), json::parse_error&);
CHECK_THROWS_WITH(json::parse(bom),
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal");
- CHECK_THROWS_AS(json::parse(std::istringstream(bom.substr(0, 1))), json::parse_error);
+ CHECK_THROWS_AS(json::parse(std::istringstream(bom.substr(0, 1))), json::parse_error&);
CHECK_THROWS_WITH(json::parse(std::istringstream(bom)),
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal");
}
@@ -504,9 +504,9 @@ TEST_CASE("deserialization")
CAPTURE(i2);
std::string s = "";
- s.push_back(bom[0] + i0);
- s.push_back(bom[1] + i1);
- s.push_back(bom[2] + i2);
+ s.push_back(static_cast(bom[0] + i0));
+ s.push_back(static_cast(bom[1] + i1));
+ s.push_back(static_cast(bom[2] + i2));
if (i0 == 0 and i1 == 0 and i2 == 0)
{
@@ -517,8 +517,8 @@ TEST_CASE("deserialization")
else
{
// any variation is an error
- CHECK_THROWS_AS(json::parse(s + "null"), json::parse_error);
- CHECK_THROWS_AS(json::parse(std::istringstream(s + "null")), json::parse_error);
+ CHECK_THROWS_AS(json::parse(s + "null"), json::parse_error&);
+ CHECK_THROWS_AS(json::parse(std::istringstream(s + "null")), json::parse_error&);
}
}
}
diff --git a/test/src/unit-json_pointer.cpp b/test/src/unit-json_pointer.cpp
index a9fbc613..ee55dc58 100644
--- a/test/src/unit-json_pointer.cpp
+++ b/test/src/unit-json_pointer.cpp
@@ -430,4 +430,23 @@ TEST_CASE("JSON pointers")
CHECK(json::json_pointer(ptr).to_string() == ptr);
}
}
+
+ SECTION("conversion")
+ {
+ SECTION("array")
+ {
+ json j;
+ // all numbers -> array
+ j["/12"_json_pointer] = 0;
+ CHECK(j.is_array());
+ }
+
+ SECTION("object")
+ {
+ json j;
+ // contains a number, but is not a number -> object
+ j["/a12"_json_pointer] = 0;
+ CHECK(j.is_object());
+ }
+ }
}