serialize.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // Copyright (c) 2019 Vinnie Falco ([email protected])
  3. //
  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)
  6. //
  7. // Official repository: https://github.com/boostorg/json
  8. //
  9. #ifndef BOOST_JSON_SERIALIZE_HPP
  10. #define BOOST_JSON_SERIALIZE_HPP
  11. #include <boost/json/detail/config.hpp>
  12. #include <boost/json/serialize_options.hpp>
  13. #include <boost/json/value.hpp>
  14. #include <iosfwd>
  15. #include <string>
  16. namespace boost {
  17. namespace json {
  18. /** Return a string representing a serialized element.
  19. This function serializes `t` as JSON and returns
  20. it as a `std::string`.
  21. @par Complexity
  22. Constant or linear in the size of `t`.
  23. @par Exception Safety
  24. Strong guarantee.
  25. Calls to allocate may throw.
  26. @return The serialized string
  27. @param t The value to serialize
  28. @param opts The options for the serializer. If this parameter
  29. is omitted, the serializer will output only standard JSON.
  30. */
  31. /** @{ */
  32. BOOST_JSON_DECL
  33. std::string
  34. serialize(value const& t, serialize_options const& opts = {});
  35. BOOST_JSON_DECL
  36. std::string
  37. serialize(array const& t, serialize_options const& opts = {});
  38. BOOST_JSON_DECL
  39. std::string
  40. serialize(object const& t, serialize_options const& opts = {});
  41. BOOST_JSON_DECL
  42. std::string
  43. serialize(string const& t, serialize_options const& opts = {});
  44. BOOST_JSON_DECL
  45. std::string
  46. serialize(string_view t, serialize_options const& opts = {});
  47. /** @} */
  48. } // namespace json
  49. } // namespace boost
  50. #endif