How does nlohmann::json implement the nice deserialization syntax?

279 views Asked by At

How nlohmann::json implement the nice deserialization syntax?

// 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;

Grammally it seems wrong. But it indeed works. Any tricks here?

0

There are 0 answers