Is it possible to emplace a key, value pair into a boost::json::value?

  Kiến thức lập trình

Is it possible to emplace or otherwise add a key/value pair into a boost::json::value, like you can into a boost::json::object?

boost::json::object obj;
 obj.emplace("timestamp", "2023-01-01T00:00:00");

Does there exist some sort of short notation, something like this?

boost::json::value val;
val["key"] = "value";

Or do you need to explicitly create a boost::json::object for such use?

As I understand it, the boost::json::value is a kind of a wrapper for various types of json data, does it work similarly to std::variant?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT