diff --git a/src/serial_AT.cpp b/src/serial_AT.cpp index 5eb8f12..ced5653 100644 --- a/src/serial_AT.cpp +++ b/src/serial_AT.cpp @@ -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(