JSON for Modern C ++ releases version 3.1
JSON for Modern C ++ 3.1 adds support for the Universal Binary JSON (UBJSON) specification and JSON Merge Patch (Merge Patch.
UBJSON is one of several formats supported by Modern C ++. It can reduce the size of the encoding value and speed up decoding. In addition to UBJSON, CBOR and MessagePack also support Modern C ++. Each format has different advantages. The format you choose depends on the Data Type you need. Among the three formats, UBJSON is the only complete binary format. This means that all JSON values can be converted to UBJSON and all UBJSON values can be converted to JSON.
JSON merge patch format is used to declare the differences between two JSON documents. This format is used with http patch. It can partially update resources, while http put is used to completely replace resources. JSON merge patch allows you to define only a part of JSON and merge it into the server. This is more convenient than using the basic JSON patch format. The basic JSON patch format relies on a set of Operation Specifications to patch the original JSON document. For example:
// a JSON valuejson j_document = R"({ "a": "b", "c": { "d": "e", "f": "g" }})"_json;// a JSON patch (RFC 6902)json j_patch_1 = R"([ { "op": "replace", "path": "/a", "value": "z" }, { "op": "remove", "path": "/f"}])"_json;// a JSON Merge patch (RFC 7386)json j_patch_2 = R"({ "a":"z", "c": { "f": null }})"_json;
The JSON for Modern C ++ library is designed to provide an intuitive syntax for processing JSON data, just as the JSON data is of the first-class type. For example, you can use the following statement to initialize an object:
json j2 = { {"pi", 3.141}, {"happy", true}, {"name", "Niels"}, {"nothing", nullptr}, {"answer", { {"everything", 42} }}, {"list", {1, 0, 2}}, {"object", { {"currency", "USD"}, {"value", 42.99} }}}
Similarly, you can__jsonAppend the json code to decode the JSON code:
auto j2 = R"( { "happy": true, "pi": 3.141 })"_json;
JSON for Modern C ++ is easy to integrate, thanks to its ability to be encapsulated in a separate header filejson.hppWithout any external libraries or dependencies. In addition, it also claims to be able to overwrite unit tests with 100% of the Code, and there is no memory leakage.
JSON for Modern C ++ Reaches Version 3.1
This article permanently updates link: https://www.bkjia.com/Linux/2018-02/150999.htm