#nullable enable using System.Text.Json; using System.Text.Json.Serialization; namespace PLCSharp.Core.Tools { /// /// 全局共享的 System.Text.Json 序列化选项。 /// public static class JsonOptions { /// /// 默认选项:属性名大小写不敏感(用于 EF Core 列序列化 / 反序列化); /// 允许 NaN / Infinity 等命名浮点字面量,避免局部变量表中的非法值导致序列化崩溃。 /// public static JsonSerializerOptions Default { get; } = new() { PropertyNameCaseInsensitive = true, NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals, }; /// /// 缩进输出选项(用于配置文件读写)。 /// public static JsonSerializerOptions Indented { get; } = new() { PropertyNameCaseInsensitive = true, WriteIndented = true, NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals, }; } }