JSON for Modern C++ Version 2.0.3
- Release date: 2016-08-31
- SHA-256: 535b73efe5546fde9e763c14aeadfc7b58183c0b3cd43c29741025aba6cf6bd3
Summary
This release combines a lot of small fixes and improvements. The release is backwards compatible.
Changes
- The parser/deserialization functions have been generalized to process any contiguous sequence of 1-byte elements (e.g.,
char
,unsigned char
,uint8_t
). This includes all kind of string representations (string literals, char arrays,std::string
,const char*
), contiguous containers (C-style arrays,std::vector
,std::array
,std::valarray
,std::initializer_list
). User-defined containers providing random-access iterator access viastd::begin
andstd::end
can be used as well. See the documentation (1, 2, 3, 4) for more information. Note that contiguous storage cannot be checked at compile time; if any of the parse functions are called with a noncompliant container, the behavior is undefined and will most likely yield segmentation violation. The preconditions are enforced by an assertion unless the library is compiled with preprocessor symbolNDEBUG
. - As a general remark on assertions: The library uses assertions to preclude undefined behavior. A prominent example for this is the
operator[]
for const JSON objects. The behavior of this const version of the operator is undefined if the given key does not exist in the JSON object, because unlike the non-const version, it cannot add anull
value at the given key. Assertions can be switched of by defining the preprocessor symbolNDEBUG
. See the documentation ofassert
for more information. - In the course of cleaning up the parser/deserialization functions, the constructor
basic_json(std::istream&, const parser_callback_t)
has been deprecated and will be deleted with the next major release 3.0.0 to unify the interface of the library. Deserialization will be done by stream operators or by calling one of theparse
functions. That is, calls likejson j(i);
for an input streami
need to be replaced byjson j = json::parse(i);
. Compilers will produce a deprecation warning if client code uses this function. - Minor improvements:
- Improved the performance of the serialization by avoiding the re-creation of a locale object.
- Fixed two MSVC warnings. Compiling the test suite with
/Wall
now only warns about non-inlined functions (C4710) and the deprecation of the constructor from input-stream (C4996).
- Some project internals:
- The project has qualified for the Core Infrastructure Initiative Best Practices Badge. While most requirements where already satisfied, some led to a more explicit documentation of quality-ensuring procedures. For instance, static analysis is now executed with every commit on the build server. Furthermore, the contribution guidelines document how to communicate security issues privately.
- The test suite has been overworked and split into several files to allow for faster compilation and analysis. The execute the test suite, simply execute
make check
. - The continuous integration with Travis was extended with Clang versions 3.6.0 to 3.8.1 and now includes 18 different compiler/OS combinations.
- An 11-day run of American fuzzy lop checked 962 million inputs on the parser and found no issue.