22 lines
597 B
C++
22 lines
597 B
C++
|
#include "Task.h"
|
||
|
#include <boost/json/array.hpp>
|
||
|
#include <boost/json/object.hpp>
|
||
|
#include <boost/json/serialize.hpp>
|
||
|
|
||
|
namespace boost {
|
||
|
namespace json {
|
||
|
std::string serialize(const Tasks &tasks) {
|
||
|
boost::json::array ret;
|
||
|
for (auto &task : tasks) {
|
||
|
boost::json::object t;
|
||
|
t["id"] = task.id;
|
||
|
t["finished"] = task.finished;
|
||
|
t["createTime"] = task.createTime;
|
||
|
t["content"] = task.content;
|
||
|
t["comment"] = task.comment;
|
||
|
ret.push_back(std::move(t));
|
||
|
}
|
||
|
return boost::json::serialize(ret);
|
||
|
}
|
||
|
} // namespace json
|
||
|
} // namespace boost
|