修正json消息体

This commit is contained in:
cxh 2026-01-05 10:31:54 +08:00
parent b8301d704f
commit 8252a9e004

View File

@ -9,6 +9,7 @@
#include "httplib.h"
#include "logger.hpp"
#include "nlohmann/json.hpp"
#include "serial_port.h"
// ================== 全局 IMEI ==================
@ -67,18 +68,11 @@ void start_http_server(int port)
std::string imei = get_imei();
std::ostringstream oss;
oss << R"({
"ok": true,
"server": {
"device_type": "tbox",
"imei": ")"
<< imei << R"(",
"fw": "b-v2.1.0"
}
})";
nlohmann::json j;
j["ok"] = true;
j["server"] = {{"device_type", "tbox"}, {"imei", imei}, {"fw", "b-v2.1.0"}};
res.set_content(oss.str(), "application/json");
res.set_content(j.dump(2), "application/json");
});
http_thread = std::thread(