Skip to content

Releases: nlohmann/json

JSON for Modern C++ Version 2.0.0

23 Jun 22:51
Compare
Choose a tag to compare
  • Release date: 2016-06-24
  • SHA-256: ac9e1fb25c2ac9ca5fc501fcd2fe3281fe04f07018a1b48820e7b1b11491bb6c

Summary

This release adds several features such as JSON Pointers, JSON Patch, or support for 64 bit unsigned integers. Furthermore, several (subtle) bugs have been fixed.

As noexcept and constexpr specifier have been added to several functions, the public API has effectively been changed in a (potential) non-backwards compatible manner. As we adhere to Semantic Versioning, this calls for a new major version, so say hello to 2️⃣.0️⃣.0️⃣.

Changes

  • 🔟 A JSON value now uses uint64_t (default value for template parameter NumberUnsignedType) as data type for unsigned integer values. This type is used automatically when an unsigned number is parsed. Furthermore, constructors, conversion operators and an is_number_unsigned() test have been added.
  • 👉 JSON Pointer (RFC 6901) support: A JSON Pointer is a string (similar to an XPath expression) to address a value inside a structured JSON value. JSON Pointers can be used in at() and operator[] functions. Furthermore, JSON values can be “flattened” to key/value pairs using flatten() where each key is a JSON Pointer. The original value can be restored by “unflattening” the flattened value using unflatten().
  • 🏥 JSON Patch (RFC 6902) support. A JSON Patch is a JSON value that describes the required edit operations (add, change, remove, …) to transform a JSON value into another one. A JSON Patch can be created with function diff(const basic_json&) and applied with patch(const basic_json&). Note the created patches use a rather primitive algorithm so far and leave room for improvement.
  • 🇪🇺 The code is now locale-independent: Floating-point numbers are always serialized with a period (.) as decimal separator and ignores different settings from the locale.
  • 🍺 Homebrew support: Install the library with brew tap nlohmann/json && brew install nlohmann_json.
  • Added constructor to create a JSON value by parsing a std::istream (e.g., std::stringstream or std::ifstream).
  • Added noexcept specifier to basic_json(boolean_t), basic_json(const number_integer_t), basic_json(const int), basic_json(const number_float_t), iterator functions (begin(), end(), etc.)
  • When parsing numbers, the sign of 0.0 (vs. -0.0) is preserved.
  • Improved MSVC 2015, Android, and MinGW support. See README for more information.
  • Improved test coverage (added 2,225,386 tests).
  • Removed some misuses of std::move.
  • Fixed several compiler warnings.
  • Improved error messages from JSON parser.
  • Updated to re2c to version 0.16 to use a minimal DFAs for the lexer.
  • Updated test suite to use Catch version 1.5.6.
  • Made type getters (is_number, etc.) and const value access constexpr.
  • Functions push_back and operator+= now work with key/value pairs passed as initializer list, e.g. j_object += {"key", 1}.
  • Overworked CMakeLists.txt to make it easier to integrate the library into other projects.

Notes

  • Parser error messages are still very vague and contain no information on the error location.
  • The implemented diff function is rather primitive and does not create minimal diffs.
  • The name of function iteration_wrapper may change in the future and the function will be deprecated in the next release.
  • Roundtripping (i.e., parsing a JSON value from a string, serializing it, and comparing the strings) of floating-point numbers is not 100% accurate. Note that RFC 7159 defines no format to internally represent numbers and states not requirement for roundtripping. Nevertheless, benchmarks like Native JSON Benchmark treat roundtripping deviations as conformance errors.

JSON for Modern C++ Version 1.1.0

24 Jan 21:53
Compare
Choose a tag to compare
  • Release date: 2016-01-24
  • SHA-256: c0cf0e3017798ca6bb18e757ebc570d21a3bdac877845e2b9e9573d183ed2f05

Summary

This release fixes several small bugs and adds functionality in a backwards-compatible manner. Compared to the last version (1.0.0), the following changes have been made:

Changes

  • Fixed: Floating-point numbers are now serialized and deserialized properly such that rountripping works in more cases. [#185, #186, #190, #191, #194]
  • Added: The code now contains assertions to detect undefined behavior during development. As the standard function assert is used, the assertions can be switched off by defining the preprocessor symbol NDEBUG during compilation. [#168]
  • Added: It is now possible to get a reference to the stored values via the newly added function get_ref(). [#128, #184]
  • Fixed: Access to object values via keys (operator[]) now works with all kind of string representations. [#171, #189]
  • Fixed: The code now compiles again with Microsoft Visual Studio 2015. [#144, #167, #188]
  • Fixed: All required headers are now included.
  • Fixed: Typos and other small issues. [#162, #166, #175, #177, #179, #180]

Notes

There are still known open issues (#178, #187) which will be fixed in version 2.0.0. However, these fixes will require a small API change and will not be entirely backwards-compatible.

JSON for Modern C++ Version 1.0.0

28 Dec 13:58
Compare
Choose a tag to compare
  • Release date: 2015-12-28
  • SHA-256: 767dc2fab1819d7b9e19b6e456d61e38d21ef7182606ecf01516e3f5230446de

Summary

This is the first official release. Compared to the prerelease version 1.0.0-rc1, only a few minor improvements have been made:

Changes

  • Changed: A UTF-8 byte order mark is silently ignored.
  • Changed: sprintf is no longer used.
  • Changed: iterator_wrapper also works for const objects; note: the name may change!
  • Changed: Error messages during deserialization have been improved.
  • Added: The parse function now also works with type std::istream&&.
  • Added: Function value(key, default_value) returns either a copy of an object's element at the specified key or a given default value if no element with the key exists.
  • Added: Public functions are tagged with the version they were introduced. This shall allow for better versioning in the future.
  • Added: All public functions and types are documented (see http://nlohmann.github.io/json/) including executable examples.
  • Added: Allocation of all types (in particular arrays, strings, and objects) is now exception-safe.
  • Added: They descriptions of thrown exceptions have been overworked and are part of the tests suite and documentation.

JSON for Modern C++ Version 1.0.0-rc1

26 Jul 18:49
Compare
Choose a tag to compare
Pre-release
  • Release date: 2015-07-26
  • SHA-256: b87b2565b9786abb938c1f0ac5793fa99220509084220edc45f59aab2dec57e2

Summary

The 1.0.0 release should be the first "official" release after the initial announcement of the class in January 2015 via reddit ("0.1.0") and a heavily overworked second version ("0.2.0") in February.

Changes

  • Changed: In the generic class basic_json, all JSON value types (array, object, string, bool, integer number, and floating-point) are now templated. That is, you can choose whether you like a std::list for your arrays or an std::unordered_map for your objects. The specialization json sets some reasonable defaults.
  • Changed: The library now consists of a single header, called json.hpp. Consequently, build systems such as Automake or CMake are not any longer required.
  • Changed: The deserialization is now supported by a lexer generated with re2c from file src/json.hpp.re2c. As a result, we strictly follow the JSON specification. Note neither the tool re2c nor its input are required to use the class.
  • Added: The library now satisfies the ReversibleContainer requirement. It hence provides four different iterators (iterator, const_iterator, reverse_iterator, and const_reverse_iterator), comparison functions, swap(), size(), max_size(), and empty() member functions.
  • Added: The class uses user-defined allocators which default to std::allocator, but can be templated via parameter Allocator.
  • Added: To simplify pretty-printing, the std::setw stream manipulator has been overloaded to set the desired indentation. Pretty-printing a JSON object j is as simple as std::cout << std::setw(4) << j << '\n'.
  • Changed: The type json::value_t::number is now called json::value_t::number_integer to be more symmetric compared to json::value_t::number_float.
  • Added: The documentation is generated with Doxygen and hosted at nlohmann.github.io/json. Every public member function is thoroughly described including an example which also can be tried online.
  • Added: The class is heavily unit-tested (3341774 assertions) and has a line coverage of 100%. With every commit, the code is compiled with g++ 4.9, g++ 5.0, Clang 3.6 (thanks to Travis CI), and Microsoft Visual Studio 14 2015 (thanks to AppVeyor).