add jsonElement extension

This commit is contained in:
CWX
2025-01-23 13:36:58 +00:00
parent 37e45f5b99
commit 70e00e6f8c
+7
View File
@@ -1,4 +1,5 @@
using System.Reflection;
using System.Text.Json;
namespace SptCommon.Extensions
{
@@ -77,5 +78,11 @@ namespace SptCommon.Extensions
return result;
}
public static T ToObject<T>(this JsonElement element)
{
var json = element.GetRawText();
return JsonSerializer.Deserialize<T>(json);
}
}
}