From 6dc80508b1c0f431007f8a8c947c152ec00c3d15 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期一, 08 九月 2025 09:24:05 +0800
Subject: [PATCH] Merge branch 'clh' into liuyang
---
SourceCode/Bond/Servo/GlassJson.h | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/SourceCode/Bond/Servo/GlassJson.h b/SourceCode/Bond/Servo/GlassJson.h
new file mode 100644
index 0000000..f056313
--- /dev/null
+++ b/SourceCode/Bond/Servo/GlassJson.h
@@ -0,0 +1,28 @@
+#pragma once
+#include <string>
+#include <json/json.h>
+
+namespace SERVO { class CGlass; }
+
+/**
+ * @brief CGlass <-> JSON 的最小工具类(基于 JsonCpp)
+ *
+ * - 不修改任何现有类头文件
+ * - 兼容老版 JsonCpp(无 Json::Int64/UInt64/asInt64)
+ * - 写库:ToString / ToPrettyString
+ * - 读库:FromString(返回 true/false)
+ */
+class GlassJson {
+public:
+ // 核心:对象 <-> Json::Value
+ static Json::Value ToJson(const SERVO::CGlass& g);
+ static void FromJson(const Json::Value& j, SERVO::CGlass& g);
+
+ // 便捷:对象 <-> 紧凑字符串
+ static std::string ToString(const SERVO::CGlass& g); // 紧凑
+ static bool FromString(const std::string& text, SERVO::CGlass& g,
+ std::string* err = nullptr); // 解析失败返回 false
+
+// 便捷:对象 <-> 美化字符串
+ static std::string ToPrettyString(const SERVO::CGlass& g); // 美化
+};
--
Gitblit v1.9.3