使用JsonSerializer.Serialize(obj)
将生成一个转义字符串,但我想要未转义的版本.例如:
using System;
using System.Text.Json;
public class Program
{
public static void Main()
{
var a = new A{Name = "你好"};
var s = JsonSerializer.Serialize(a);
Console.WriteLine(s);
}
}
class A {
public string Name {get; set;}
}
will produce a string {"Name":"\u4F60\u597D"}
but I want {"Name":"你好"}
I created a code snippet at https://dotnetfiddle.net/w73vnO
Please help me.