This commit is contained in:
Niels 2015-12-20 15:30:07 +01:00
parent 1adb9d62dd
commit 457bfc2401
4 changed files with 24 additions and 3 deletions

View file

@ -398,7 +398,7 @@ $ make
$ ./json_unit "*"
===============================================================================
All tests passed (3341846 assertions in 28 test cases)
All tests passed (3341848 assertions in 28 test cases)
```
For more information, have a look at the file [.travis.yml](https://github.com/nlohmann/json/blob/master/.travis.yml).

View file

@ -2550,7 +2550,9 @@ class basic_json
@tparam ValueType non-pointer type compatible to the JSON value, for
instance `int` for JSON integer numbers, `bool` for JSON booleans, or
`std::vector` types for JSON arrays
`std::vector` types for JSON arrays. The character type of @ref string_t
as well as an initializer list of this type is excluded to avoid
ambiguities as these types implicitly convert to `std::string`.
@return copy of the JSON value, converted to type @a ValueType
@ -2571,6 +2573,8 @@ class basic_json
template<typename ValueType, typename
std::enable_if<
not std::is_pointer<ValueType>::value
and not std::is_same<ValueType, typename string_t::value_type>::value
and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
, int>::type = 0>
operator ValueType() const
{

View file

@ -2550,7 +2550,9 @@ class basic_json
@tparam ValueType non-pointer type compatible to the JSON value, for
instance `int` for JSON integer numbers, `bool` for JSON booleans, or
`std::vector` types for JSON arrays
`std::vector` types for JSON arrays. The character type of @ref string_t
as well as an initializer list of this type is excluded to avoid
ambiguities as these types implicitly convert to `std::string`.
@return copy of the JSON value, converted to type @a ValueType
@ -2571,6 +2573,8 @@ class basic_json
template<typename ValueType, typename
std::enable_if<
not std::is_pointer<ValueType>::value
and not std::is_same<ValueType, typename string_t::value_type>::value
and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
, int>::type = 0>
operator ValueType() const
{

View file

@ -10323,6 +10323,19 @@ TEST_CASE("regression tests")
CHECK(j["string"] == "\u0007\u0007");
}
SECTION("issue #144 - implicit assignment to std::string fails")
{
json o = {{"name", "value"}};
std::string s1 = o["name"];
CHECK(s1 == "value");
std::string s2;
s2 = o["name"];
CHECK(s2 == "value");
}
SECTION("character following a surrogate pair is skipped")
{
CHECK(json::parse("\"\\ud80c\\udc60abc\"").get<json::string_t>() == u8"\U00013060abc");