From 67807404e92287576f608d75f34b39907d054b1d Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Fri, 23 Jul 2021 18:59:19 +0800 Subject: [PATCH] Minimize character escaping in AbpSystemTextJsonSerializer --- .../SystemTextJson/AbpSystemTextJsonSerializerOptionsSetup.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/AbpSystemTextJsonSerializerOptionsSetup.cs b/framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/AbpSystemTextJsonSerializerOptionsSetup.cs index 9fd156439b..4de6e96bcc 100644 --- a/framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/AbpSystemTextJsonSerializerOptionsSetup.cs +++ b/framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/AbpSystemTextJsonSerializerOptionsSetup.cs @@ -1,4 +1,5 @@ using System; +using System.Text.Encodings.Web; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Volo.Abp.Json.SystemTextJson.JsonConverters; @@ -24,6 +25,9 @@ namespace Volo.Abp.Json.SystemTextJson options.JsonSerializerOptions.Converters.Add(new ObjectToInferredTypesConverter()); options.JsonSerializerOptions.Converters.Add(new AbpHasExtraPropertiesJsonConverterFactory()); + + // If the user hasn't explicitly configured the encoder, use the less strict encoder that does not encode all non-ASCII characters. + options.JsonSerializerOptions.Encoder ??= JavaScriptEncoder.UnsafeRelaxedJsonEscaping; } } }