ToJson方法防止中文编码
This commit is contained in:
parent
7aaaacb309
commit
7350a60bb2
|
@ -5,7 +5,9 @@ using System.Diagnostics;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Text.Encodings.Web;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using System.Text.Unicode;
|
||||||
|
|
||||||
namespace Falcon.SugarApi
|
namespace Falcon.SugarApi
|
||||||
{
|
{
|
||||||
|
@ -142,6 +144,7 @@ namespace Falcon.SugarApi
|
||||||
/// <returns>转换后字符串</returns>
|
/// <returns>转换后字符串</returns>
|
||||||
public static string ToJson<T>(this T obj,Action<JsonSerializerOptions>? OptionBuilder = null) {
|
public static string ToJson<T>(this T obj,Action<JsonSerializerOptions>? OptionBuilder = null) {
|
||||||
var option = new JsonSerializerOptions();
|
var option = new JsonSerializerOptions();
|
||||||
|
option.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
|
||||||
OptionBuilder?.Invoke(option);
|
OptionBuilder?.Invoke(option);
|
||||||
var ser = new JsonSerialize.JsonSerializeFactory().CreateJsonSerialize(option);
|
var ser = new JsonSerialize.JsonSerializeFactory().CreateJsonSerialize(option);
|
||||||
return ser.Serialize(obj);
|
return ser.Serialize(obj);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user