fix: orm 序列化

This commit is contained in:
2248356998 qq.com
2025-10-10 12:26:35 +08:00
parent aad0f0e8c3
commit a8a9774932
2 changed files with 12 additions and 3 deletions

View File

@@ -8,6 +8,8 @@ using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using System.Text.Json.Serialization.Metadata; using System.Text.Json.Serialization.Metadata;
using ThingsGateway.NewLife.Json.Extension;
using JsonProperty = Newtonsoft.Json.Serialization.JsonProperty; using JsonProperty = Newtonsoft.Json.Serialization.JsonProperty;
namespace ThingsGateway.SqlSugar namespace ThingsGateway.SqlSugar
@@ -23,8 +25,10 @@ namespace ThingsGateway.SqlSugar
private static readonly JsonSerializerOptions _systemTextJsonSettings = new() private static readonly JsonSerializerOptions _systemTextJsonSettings = new()
{ {
Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase, PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals,
}; };
private static readonly ConcurrentDictionary<Type, SugarColumn> _typeInfoCache = new(); private static readonly ConcurrentDictionary<Type, SugarColumn> _typeInfoCache = new();
@@ -52,6 +56,11 @@ namespace ThingsGateway.SqlSugar
} }
}); });
_systemTextJsonSettings.Converters.Add(new JTokenSystemTextJsonConverter());
_systemTextJsonSettings.Converters.Add(new JValueSystemTextJsonConverter());
_systemTextJsonSettings.Converters.Add(new JObjectSystemTextJsonConverter());
_systemTextJsonSettings.Converters.Add(new JArraySystemTextJsonConverter());
_systemTextJsonSettings.TypeInfoResolver = resolver; _systemTextJsonSettings.TypeInfoResolver = resolver;
} }
public static bool UseNewtonsoftJson = false; public static bool UseNewtonsoftJson = false;

View File

@@ -1,9 +1,9 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<PluginVersion>10.11.90</PluginVersion> <PluginVersion>10.11.92</PluginVersion>
<ProPluginVersion>10.11.90</ProPluginVersion> <ProPluginVersion>10.11.92</ProPluginVersion>
<DefaultVersion>10.11.90</DefaultVersion> <DefaultVersion>10.11.92</DefaultVersion>
<AuthenticationVersion>10.11.6</AuthenticationVersion> <AuthenticationVersion>10.11.6</AuthenticationVersion>
<SourceGeneratorVersion>10.11.6</SourceGeneratorVersion> <SourceGeneratorVersion>10.11.6</SourceGeneratorVersion>
<NET8Version>8.0.20</NET8Version> <NET8Version>8.0.20</NET8Version>