From e85af628bfe45bc63d3911440ffe09807a260770 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 6 Aug 2025 18:07:46 +0800 Subject: [PATCH] :bug: Fixes embedding json loop --- DysonNetwork.Shared/Proto/GrpcTypeHelper.cs | 7 +++++++ DysonNetwork.Sphere/WebReader/EmbeddableBase.cs | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/DysonNetwork.Shared/Proto/GrpcTypeHelper.cs b/DysonNetwork.Shared/Proto/GrpcTypeHelper.cs index 03f2d53..e30761e 100644 --- a/DysonNetwork.Shared/Proto/GrpcTypeHelper.cs +++ b/DysonNetwork.Shared/Proto/GrpcTypeHelper.cs @@ -14,6 +14,13 @@ namespace DysonNetwork.Shared.Proto; public abstract class GrpcTypeHelper { + public static readonly JsonSerializerOptions? SerializerOptionsWithIgnore = new JsonSerializerOptions() + { + PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower, + DefaultIgnoreCondition = JsonIgnoreCondition.Never, + PropertyNameCaseInsensitive = true, + }.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb); + public static readonly JsonSerializerOptions? SerializerOptions = new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower, diff --git a/DysonNetwork.Sphere/WebReader/EmbeddableBase.cs b/DysonNetwork.Sphere/WebReader/EmbeddableBase.cs index 28d9ee3..50aceca 100644 --- a/DysonNetwork.Sphere/WebReader/EmbeddableBase.cs +++ b/DysonNetwork.Sphere/WebReader/EmbeddableBase.cs @@ -31,7 +31,13 @@ public abstract class EmbeddableBase public static Dictionary ToDictionary(dynamic input) { - var jsonRaw = JsonSerializer.Serialize(input, GrpcTypeHelper.SerializerOptions); - return JsonSerializer.Deserialize>(jsonRaw, GrpcTypeHelper.SerializerOptions); + var jsonRaw = JsonSerializer.Serialize( + input, + GrpcTypeHelper.SerializerOptionsWithIgnore + ); + return JsonSerializer.Deserialize>( + jsonRaw, + GrpcTypeHelper.SerializerOptionsWithIgnore + ); } } \ No newline at end of file