upload
This commit is contained in:
36
libs/vslam_web/src/json_writer.h
Normal file
36
libs/vslam_web/src/json_writer.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef VSLAM_JSON_WRITER_H_
|
||||
#define VSLAM_JSON_WRITER_H_
|
||||
|
||||
// Sinh JSON bang cach noi chuoi. Header NOI BO, khong phat hanh.
|
||||
//
|
||||
// Vi sao khong dung nlohmann/json: no khong co san tren may nao trong hai may
|
||||
// (dev focal lan Jetson jammy), va schema o day co dinh va nho -- mot
|
||||
// serializer ~150 dong khong phai danh doi gi dang ke.
|
||||
//
|
||||
// Chi ho tro chieu GHI. Doc JSON (body cua POST /api/*) lam bang json_parse.h,
|
||||
// cung mot ly do.
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "vslam/web_snapshot.h"
|
||||
|
||||
namespace vslam {
|
||||
|
||||
// Escape theo RFC 8259: ", \, va cac ky tu dieu khien < 0x20.
|
||||
void JsonEscape(const std::string& in, std::string* out);
|
||||
|
||||
// Ghi so thuc voi so chu so co dinh. Tra "null" neu NaN hoac inf -- JSON
|
||||
// khong co hai gia tri do, va de nguyen thi JSON.parse() cua browser nem loi
|
||||
// lam mat CA khung, khong chi mot truong.
|
||||
void JsonNumber(double v, int decimals, std::string* out);
|
||||
|
||||
// Toan bo khung trang thai, khop schema mo ta trong ke hoach.
|
||||
void WriteStateJson(const WebSnapshot& snap, std::string* out);
|
||||
|
||||
// Tra loi cho POST /api/*.
|
||||
void WriteStatusJson(const StatusResponse& st, std::string* out);
|
||||
|
||||
} // namespace vslam
|
||||
|
||||
#endif // VSLAM_JSON_WRITER_H_
|
||||
Reference in New Issue
Block a user