diff --git a/json.cpp.rl b/json.cpp.rl index 3f5f2bd5..b2881e04 100644 --- a/json.cpp.rl +++ b/json.cpp.rl @@ -557,3 +557,27 @@ json::null::write (std::ostream &os) const { ostream& json::operator <<(ostream &os, const json::node &n) { return n.write (os); } + + +//----------------------------------------------------------------------------- +// to_json + +namespace json { + template <> + std::unique_ptr + io::serialise (const bool &b) { + return std::unique_ptr (new boolean (b)); + } + + template <> + std::unique_ptr + io::serialise (const nullptr_t &) { + return std::unique_ptr (new null ()); + } + + template <> + std::unique_ptr + io::serialise (const std::string &s) { + return std::unique_ptr (new string (s)); + } +} diff --git a/json.hpp b/json.hpp index b86476e9..56385619 100644 --- a/json.hpp +++ b/json.hpp @@ -286,7 +286,7 @@ namespace json { template -json::node&& to_json (const T &t, Args&&... args) { +std::unique_ptr to_json (const T &t, Args&&... args) { return json::io::serialise (t, std::forward(args)...); }