1

nlohmann::json 如何实现漂亮的反序列化语法?

// You can create an object (deserialization) by appending _json to a string literal.

//create object from string literal
json j = "{ \"happy\": true, \"pi\": 3.141 }"_json;

// or even nicer with a raw string literal
auto j2 = R"(
{
    "happy": true,
    "pi": 3.141
}
)"_json;

从语法上讲,它似乎是错误的。但它确实有效。这里有什么技巧吗?

4

0 回答 0