Add to_json for bool, nullptr, string
This commit is contained in:
parent
e4da68ffe7
commit
b0c6b33f20
24
json.cpp.rl
24
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<node>
|
||||
io<bool>::serialise (const bool &b) {
|
||||
return std::unique_ptr<node> (new boolean (b));
|
||||
}
|
||||
|
||||
template <>
|
||||
std::unique_ptr<node>
|
||||
io<nullptr_t>::serialise (const nullptr_t &) {
|
||||
return std::unique_ptr<node> (new null ());
|
||||
}
|
||||
|
||||
template <>
|
||||
std::unique_ptr<node>
|
||||
io<std::string>::serialise (const std::string &s) {
|
||||
return std::unique_ptr<node> (new string (s));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user