2 // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // Official repository: https://github.com/boostorg/json
10 #ifndef BOOST_JSON_SERIALIZE_HPP
11 #define BOOST_JSON_SERIALIZE_HPP
13 #include <boost/json/detail/config.hpp>
14 #include <boost/json/value.hpp>
20 /** Return a string representing a serialized element.
22 This function serializes `t` as JSON and returns
23 it as a `std::string`.
26 Constant or linear in the size of `t`.
30 Calls to allocate may throw.
32 @return The serialized string
34 @param t The value to serialize
39 serialize(value const& t);
43 serialize(array const& t);
47 serialize(object const& t);
51 serialize(string const& t);
55 serialize(string_view t);
58 /** Serialize an element to an output stream.
60 This function serializes the specified element
61 as JSON into the output stream.
66 Constant or linear in the size of `t`.
70 Calls to `memory_resource::allocate` may throw.
72 @param os The output stream to serialize to.
74 @param t The value to serialize