24 lines
711 B
C++
24 lines
711 B
C++
#include "include/json_serializer.h"
|
|
|
|
// Deserialize JSON -> class
|
|
void from_json(const json& j, ticket_t& t) {
|
|
t.id = j.at("id").get<int>();
|
|
t.title = j.at("title").get<std::string>();
|
|
t.description = j.at("description").get<std::string>();
|
|
t.status = j.at("status").get<std::string>();
|
|
t.created_at = j.at("created_at").get<std::string>();
|
|
t.updated_at = j.at("updated_at").get<std::string>();
|
|
}
|
|
|
|
// Serialize class -> JSON
|
|
void to_json(json& j, const ticket_t& t) {
|
|
j = json{
|
|
{"id", t.id},
|
|
{"title", t.title},
|
|
{"description", t.description},
|
|
{"status", t.status},
|
|
{"created_at", t.created_at},
|
|
{"updated_at", t.updated_at}
|
|
};
|
|
}
|