Commit e29d6b5f by Niels

Merge branch 'release/2.0.1'

parents 25ccf7f9 026fe804
...@@ -3,7 +3,14 @@ All notable changes to this project will be documented in this file. This projec ...@@ -3,7 +3,14 @@ All notable changes to this project will be documented in this file. This projec
## [Unreleased](https://github.com/nlohmann/json/tree/HEAD) ## [Unreleased](https://github.com/nlohmann/json/tree/HEAD)
[Full Changelog](https://github.com/nlohmann/json/compare/v1.1.0...HEAD) [Full Changelog](https://github.com/nlohmann/json/compare/v2.0.0...HEAD)
- dump\(\) performance degradation in v2 [\#272](https://github.com/nlohmann/json/issues/272)
- fixed a tiny typo [\#271](https://github.com/nlohmann/json/pull/271) ([thelostt](https://github.com/thelostt))
## [v2.0.0](https://github.com/nlohmann/json/releases/tag/v2.0.0) (2016-06-23)
[Full Changelog](https://github.com/nlohmann/json/compare/v1.1.0...v2.0.0)
- concatenate objects [\#252](https://github.com/nlohmann/json/issues/252) - concatenate objects [\#252](https://github.com/nlohmann/json/issues/252)
- Unit test fails when doing a CMake out-of-tree build [\#241](https://github.com/nlohmann/json/issues/241) - Unit test fails when doing a CMake out-of-tree build [\#241](https://github.com/nlohmann/json/issues/241)
......
![JSON for Modern C++](https://raw.githubusercontent.com/nlohmann/json/master/doc/json.gif) [![JSON for Modern C++](https://raw.githubusercontent.com/nlohmann/json/master/doc/json.gif)](https://github.com/nlohmann/json/releases)
[![Build Status](https://travis-ci.org/nlohmann/json.svg?branch=master)](https://travis-ci.org/nlohmann/json) [![Build Status](https://travis-ci.org/nlohmann/json.svg?branch=master)](https://travis-ci.org/nlohmann/json)
[![Build Status](https://ci.appveyor.com/api/projects/status/1acb366xfyg3qybk?svg=true)](https://ci.appveyor.com/project/nlohmann/json) [![Build Status](https://ci.appveyor.com/api/projects/status/1acb366xfyg3qybk?svg=true)](https://ci.appveyor.com/project/nlohmann/json)
...@@ -291,7 +291,7 @@ json j_umset(c_umset); // both entries for "one" are used ...@@ -291,7 +291,7 @@ json j_umset(c_umset); // both entries for "one" are used
// maybe ["one", "two", "one", "four"] // maybe ["one", "two", "one", "four"]
``` ```
Likewise, any associative key-value containers (`std::map`, `std::multimap`, `std::unordered_map`, `std::unordered_multimap`) whose keys are 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 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 ```cpp
std::map<std::string, int> c_map { {"one", 1}, {"two", 2}, {"three", 3} }; std::map<std::string, int> c_map { {"one", 1}, {"two", 2}, {"three", 3} };
...@@ -323,7 +323,7 @@ json j_original = R"({ ...@@ -323,7 +323,7 @@ json j_original = R"({
})"_json; })"_json;
// access members with a JSON pointer (RFC 6901) // access members with a JSON pointer (RFC 6901)
j_original["/baz/2"_json_pointer]; j_original["/baz/1"_json_pointer];
// "two" // "two"
// a JSON patch (RFC 6902) // a JSON patch (RFC 6902)
...@@ -390,7 +390,7 @@ Though it's 2016 already, the support for C++11 is still a bit sparse. Currently ...@@ -390,7 +390,7 @@ Though it's 2016 already, the support for C++11 is still a bit sparse. Currently
- GCC 4.9 - 6.0 (and possibly later) - GCC 4.9 - 6.0 (and possibly later)
- Clang 3.4 - 3.9 (and possibly later) - Clang 3.4 - 3.9 (and possibly later)
- Microsoft Visual C++ 2015 / 14.0 (and possibly later) - Microsoft Visual C++ 2015 / Build Tools 14.0.25123.0 (and possibly later)
I would be happy to learn about other compilers/versions. I would be happy to learn about other compilers/versions.
...@@ -483,6 +483,8 @@ I deeply appreciate the help of the following people. ...@@ -483,6 +483,8 @@ I deeply appreciate the help of the following people.
- [Róbert Márki](https://github.com/robertmrk) added a fix to use move iterators and improved the integration via CMake. - [Róbert Márki](https://github.com/robertmrk) added a fix to use move iterators and improved the integration via CMake.
- [Chris Kitching](https://github.com/ChrisKitching) cleaned up the CMake files. - [Chris Kitching](https://github.com/ChrisKitching) cleaned up the CMake files.
- [Tom Needham](https://github.com/06needhamt) fixed a subtle bug with MSVC 2015 which was also proposed by [Michael K.](https://github.com/Epidal). - [Tom Needham](https://github.com/06needhamt) fixed a subtle bug with MSVC 2015 which was also proposed by [Michael K.](https://github.com/Epidal).
- [Mário Feroldi](https://github.com/thelostt) fixed a small typo.
- [duncanwerner](https://github.com/duncanwerner) found a really embarrassing performance regression in the 2.0.0 release.
Thanks a lot for helping out! Thanks a lot for helping out!
...@@ -502,7 +504,7 @@ $ make ...@@ -502,7 +504,7 @@ $ make
$ ./json_unit "*" $ ./json_unit "*"
=============================================================================== ===============================================================================
All tests passed (5568715 assertions in 32 test cases) All tests passed (5568718 assertions in 32 test cases)
``` ```
For more information, have a look at the file [.travis.yml](https://github.com/nlohmann/json/blob/master/.travis.yml). For more information, have a look at the file [.travis.yml](https://github.com/nlohmann/json/blob/master/.travis.yml).
...@@ -2097,6 +2097,8 @@ class basic_json ...@@ -2097,6 +2097,8 @@ class basic_json
string_t dump(const int indent = -1) const string_t dump(const int indent = -1) const
{ {
std::stringstream ss; std::stringstream ss;
// fix locale problems
ss.imbue(std::locale(std::locale(), new DecimalSeparator));
if (indent >= 0) if (indent >= 0)
{ {
...@@ -5655,9 +5657,14 @@ class basic_json ...@@ -5655,9 +5657,14 @@ class basic_json
// reset width to 0 for subsequent calls to this stream // reset width to 0 for subsequent calls to this stream
o.width(0); o.width(0);
// fix locale problems
auto old_locale = o.imbue(std::locale(std::locale(), new DecimalSeparator));
// do the actual serialization // do the actual serialization
j.dump(o, pretty_print, static_cast<unsigned int>(indentation)); j.dump(o, pretty_print, static_cast<unsigned int>(indentation));
// reset locale
o.imbue(old_locale);
return o; return o;
} }
...@@ -6128,11 +6135,8 @@ class basic_json ...@@ -6128,11 +6135,8 @@ class basic_json
// string->double->string or string->long // string->double->string or string->long
// double->string; to be safe, we read this value from // double->string; to be safe, we read this value from
// std::numeric_limits<number_float_t>::digits10 // std::numeric_limits<number_float_t>::digits10
std::stringstream ss; o << std::setprecision(std::numeric_limits<double>::digits10)
ss.imbue(std::locale(std::locale(), new DecimalSeparator)); // fix locale problems << m_value.number_float;
ss << std::setprecision(std::numeric_limits<double>::digits10)
<< m_value.number_float;
o << ss.str();
} }
return; return;
} }
......
...@@ -2097,6 +2097,8 @@ class basic_json ...@@ -2097,6 +2097,8 @@ class basic_json
string_t dump(const int indent = -1) const string_t dump(const int indent = -1) const
{ {
std::stringstream ss; std::stringstream ss;
// fix locale problems
ss.imbue(std::locale(std::locale(), new DecimalSeparator));
if (indent >= 0) if (indent >= 0)
{ {
...@@ -5655,9 +5657,14 @@ class basic_json ...@@ -5655,9 +5657,14 @@ class basic_json
// reset width to 0 for subsequent calls to this stream // reset width to 0 for subsequent calls to this stream
o.width(0); o.width(0);
// fix locale problems
auto old_locale = o.imbue(std::locale(std::locale(), new DecimalSeparator));
// do the actual serialization // do the actual serialization
j.dump(o, pretty_print, static_cast<unsigned int>(indentation)); j.dump(o, pretty_print, static_cast<unsigned int>(indentation));
// reset locale
o.imbue(old_locale);
return o; return o;
} }
...@@ -6128,11 +6135,8 @@ class basic_json ...@@ -6128,11 +6135,8 @@ class basic_json
// string->double->string or string->long // string->double->string or string->long
// double->string; to be safe, we read this value from // double->string; to be safe, we read this value from
// std::numeric_limits<number_float_t>::digits10 // std::numeric_limits<number_float_t>::digits10
std::stringstream ss; o << std::setprecision(std::numeric_limits<double>::digits10)
ss.imbue(std::locale(std::locale(), new DecimalSeparator)); // fix locale problems << m_value.number_float;
ss << std::setprecision(std::numeric_limits<double>::digits10)
<< m_value.number_float;
o << ss.str();
} }
return; return;
} }
......
...@@ -10531,7 +10531,7 @@ TEST_CASE("README", "[hide]") ...@@ -10531,7 +10531,7 @@ TEST_CASE("README", "[hide]")
})"_json; })"_json;
// access members with a JSON pointer (RFC 6901) // access members with a JSON pointer (RFC 6901)
j_original["/baz/2"_json_pointer]; j_original["/baz/1"_json_pointer];
// "two" // "two"
// a JSON patch (RFC 6902) // a JSON patch (RFC 6902)
...@@ -14079,6 +14079,16 @@ TEST_CASE("regression tests") ...@@ -14079,6 +14079,16 @@ TEST_CASE("regression tests")
CHECK(j1a.dump() == "23.42"); CHECK(j1a.dump() == "23.42");
CHECK(j1b.dump() == "23.42"); CHECK(j1b.dump() == "23.42");
// check if locale is properly reset
std::stringstream ss;
ss.imbue(std::locale(std::locale(), new CommaDecimalSeparator));
ss << 47.11;
CHECK(ss.str() == "47,11");
ss << j1a;
CHECK(ss.str() == "47,1123.42");
ss << 47.11;
CHECK(ss.str() == "47,1123.4247,11");
CHECK(j2a.dump() == "23.42"); CHECK(j2a.dump() == "23.42");
//issue #230 //issue #230
//CHECK(j2b.dump() == "23.42"); //CHECK(j2b.dump() == "23.42");
......
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