serialize
Return a string representing a serialized element.
Synopsis
Defined in header <boost/json/serialize.hpp>.
std::string
serialize(
value const& t,
serialize_options const& opts = {}); (1)
std::string
serialize(
array const& t,
serialize_options const& opts = {}); (2)
std::string
serialize(
object const& t,
serialize_options const& opts = {}); (3)
std::string
serialize(
string const& t,
serialize_options const& opts = {}); (4)
template<
class T>
std::string
serialize(
T const& t,
serialize_options const& opts = {}); (5)
std::string
serialize(
string_view t,
serialize_options const& opts = {}); (6)
Description
This function serializes t
as JSON and returns it as a std::string
.
Complexity
Linear in the size of t
.
Exception Safety
Strong guarantee. Calls to allocate may throw.
Return Value
The serialized string.
Parameters
Name | Description |
---|---|
|
The value to serialize |
|
The options for the serializer. If this parameter is omitted, the serializer will output only standard JSON. |
Convenience header <boost/json.hpp>