diff --git a/Api/Utility/General.cs b/Api/Utility/General.cs
index 0de6b12..0646f38 100644
--- a/Api/Utility/General.cs
+++ b/Api/Utility/General.cs
@@ -1,6 +1,7 @@
using System.Collections;
using System.Net.NetworkInformation;
using System.Security.Cryptography;
+using System.Text.Json;
using System.Text.RegularExpressions;
using Milimoe.FunGame.Core.Library.Common.Architecture;
using Milimoe.FunGame.Core.Library.Constant;
@@ -128,6 +129,18 @@ namespace Milimoe.FunGame.Core.Api.Utility
return Service.JsonManager.GetString(obj);
}
+ ///
+ /// 返回目标对象的Json字符串 可指定反序列化选项
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static string JsonSerialize(T obj, JsonSerializerOptions options)
+ {
+ return Service.JsonManager.GetString(obj, options);
+ }
+
///
/// 反序列化Json对象
///
@@ -139,6 +152,18 @@ namespace Milimoe.FunGame.Core.Api.Utility
return Service.JsonManager.GetObject(json);
}
+ ///
+ /// 反序列化Json对象 可指定反序列化选项
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static T? JsonDeserialize(string json, JsonSerializerOptions options)
+ {
+ return Service.JsonManager.GetObject(json, options);
+ }
+
///
/// 反序列化Hashtable中的Json对象
///
@@ -148,7 +173,20 @@ namespace Milimoe.FunGame.Core.Api.Utility
///
public static T? JsonDeserializeFromHashtable(Hashtable hashtable, string key)
{
- return Transmittal.DataRequest.GetHashtableJsonObject(hashtable, key);
+ return Service.JsonManager.GetObject(hashtable, key);
+ }
+
+ ///
+ /// 反序列化Hashtable中的Json对象 可指定反序列化选项
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static T? JsonDeserializeFromHashtable(Hashtable hashtable, string key, JsonSerializerOptions options)
+ {
+ return Service.JsonManager.GetObject(hashtable, key, options);
}
}
diff --git a/Service/JsonManager.cs b/Service/JsonManager.cs
index 83237d6..712621b 100644
--- a/Service/JsonManager.cs
+++ b/Service/JsonManager.cs
@@ -38,6 +38,18 @@ namespace Milimoe.FunGame.Core.Service
return JsonSerializer.Serialize(obj, GeneralOptions);
}
+ ///
+ /// 获取Json字符串
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal static string GetString(T obj, JsonSerializerOptions options)
+ {
+ return JsonSerializer.Serialize(obj, options);
+ }
+
///
/// 反序列化Json对象
///
@@ -48,6 +60,18 @@ namespace Milimoe.FunGame.Core.Service
{
return JsonSerializer.Deserialize(json, GeneralOptions);
}
+
+ ///
+ /// 反序列化Json对象
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal static T? GetObject(string json, JsonSerializerOptions options)
+ {
+ return JsonSerializer.Deserialize(json, options);
+ }
///
/// 反序列化Json对象,此方法可能无法返回正确的类型,请注意辨别
@@ -59,6 +83,18 @@ namespace Milimoe.FunGame.Core.Service
return JsonSerializer.Deserialize