#include "items.h" namespace hm { std::string User::getJsonStr() { /* 13: timestamp: 2023-1-1_0:0:0=>1672502400000, 2100-1-1_0:0:0=>4102416000000 * 47: {"uid":"","name":"","password":"","timestamp":} * */ size_t size = uid.size() + name.size() + password.size() + 60; std::string res(size, 0); sprintf( res.data(), R"({"uid":"%s","name":"%s","password":"%s","timestamp":%ld})", uid.c_str(), name.c_str(), password.c_str(), timestamp ); return res; } std::string Plate::getJsonStr() { /* 13: timestamp: 2023-1-1_0:0:0=>1672502400000, 2100-1-1_0:0:0=>4102416000000 * 42: {"cid":,"name":"","plate":"","timestamp":} * */ size_t size = cid_s.size() + name.size() + plate.size() + 55; std::string res(size, 0); sprintf( res.data(), R"({"cid":%d,"name":"%s","plate":"%s","timestamp":%ld})", cid, name.c_str(), plate.c_str(), timestamp ); return res; } }