MyGit

v3.0.0

nlohmann/json

版本发布时间: 2017-12-17 18:08:12

nlohmann/json最新发布版本:v3.11.3(2023-11-29 05:38:09)

Release date: 2017-12-17 SHA-256: 076d4a0cb890a3c3d389c68421a11c3d77c64bd788e85d50f1b77ed252f2a462

Summary

After almost a year, here is finally a new release of JSON for Modern C++, and it is a major one! As we adhere to semantic versioning, this means the release includes some breaking changes, so please read the next section carefully before you update. But don't worry, we also added a few new features and put a lot of effort into fixing a lot of bugs and straighten out a few inconsistencies.

:boom: Breaking changes

This section describes changes that change the public API of the library and may require changes in code using a previous version of the library. In section "Moving from 2.x.x to 3.0.0" at the end of the release notes, we describe in detail how existing code needs to be changed.

:fire: Deprecated functions

To unify the interfaces and to improve similarity with the STL, the following functions are now deprecated and will be removed in the next major version (i.e., 4.0.0):

Please use friend std::istream& operator>>(std::istream&, basic_json&) and friend operator<<(std::ostream&, const basic_json&) instead.

:sparkles: New features

With all this breaking and deprecation out of the way, let's talk about features!

:hammer: Further changes

Furthermore, there have been a lot of changes under the hood:

Moving from 2.x.x to 3.0.0

User-defined Exceptions

There are five different exceptions inheriting from json::exception:

To support these exception, the try/catch blocks of your code need to be adjusted:

new exception previous exception
parse_error.101 invalid_argument
parse_error.102 invalid_argument
parse_error.103 invalid_argument
parse_error.104 invalid_argument
parse_error.105 invalid_argument
parse_error.106 domain_error
parse_error.107 domain_error
parse_error.108 domain_error
parse_error.109 invalid_argument
parse_error.110 out_of_range
parse_error.111 invalid_argument
parse_error.112 invalid_argument
invalid_iterator.201 domain_error
invalid_iterator.202 domain_error
invalid_iterator.203 domain_error
invalid_iterator.204 out_of_range
invalid_iterator.205 out_of_range
invalid_iterator.206 domain_error
invalid_iterator.207 domain_error
invalid_iterator.208 domain_error
invalid_iterator.209 domain_error
invalid_iterator.210 domain_error
invalid_iterator.211 domain_error
invalid_iterator.212 domain_error
invalid_iterator.213 domain_error
invalid_iterator.214 out_of_range
type_error.301 domain_error
type_error.302 domain_error
type_error.303 domain_error
type_error.304 domain_error
type_error.305 domain_error
type_error.306 domain_error
type_error.307 domain_error
type_error.308 domain_error
type_error.309 domain_error
type_error.310 domain_error
type_error.311 domain_error
type_error.313 domain_error
type_error.314 domain_error
type_error.315 domain_error
out_of_range.401 out_of_range
out_of_range.402 out_of_range
out_of_range.403 out_of_range
out_of_range.404 out_of_range
out_of_range.405 domain_error
other_error.501 domain_error

Handling of NaN and INF

Removal of deprecated functions

Function explicit basic_json(std::istream& i, const parser_callback_t cb = nullptr) should be replaced by the parse function: Let ss be a stream and cb be a parse callback function.

Old code:

json j(ss, cb);

New code:

json j = json::parse(ss, cb);

If no callback function is used, also the following code works:

json j;
j << ss;

or

json j;
ss >> j;

相关地址:原始地址 下载(tar) 下载(zip)

1、 json.hpp 500.88KB

2、 json.hpp.asc 833B

查看:2017-12-17发行的版本