Older/Database/Task.cpp
luocai 85b93fbbe3
All checks were successful
Deploy / Build (push) Successful in 5m4s
move dir.
2024-11-26 19:31:09 +08:00

34 lines
871 B
C++

#include "Task.h"
#include <boost/json/array.hpp>
#include <boost/json/object.hpp>
#include <boost/json/serialize.hpp>
namespace boost {
namespace json {
static boost::json::object serialize(const Task &task) {
boost::json::object ret;
ret["id"] = task.id;
ret["parentId"] = task.parentId;
ret["finished"] = task.finished;
ret["createTime"] = task.createTime;
ret["content"] = task.content;
ret["comment"] = task.comment;
boost::json::array children;
for (auto &child : task.children) {
children.push_back(serialize(child));
}
ret["children"] = std::move(children);
return ret;
}
std::string serialize(const Tasks &tasks) {
boost::json::array ret;
for (auto &task : tasks) {
ret.push_back(serialize(task));
}
return boost::json::serialize(ret);
}
} // namespace json
} // namespace boost