Use the following code to json serialization
Class Program
{
The static void Main (string [] args)
{
Var json=JsonSerializer. ToString (new {title="code to change the world"});
Console. WriteLine (json);
}
}
The output is encoded in Chinese
{" title ":" \ u4ee3 \ u7801 \ u6539 \ u53d8 \ u4e16 \ u754c "}
How do I let not encoded in Chinese?
CodePudding user response:
https://github.com/dotnet/corefx/blob/master/src/System.Text.Json/docs/SerializerProgrammingModel.md
The JsonIgnore attribute specifies that The property is not serialized or deserialized.
[JsonIgnore] public DateTime? BirthDay {get; The set; }
This attribute
CodePudding user response:
JsonConvert. SerializeObject
CodePudding user response:
Var options=new JsonSerializerOptions ();
The options. The Encoder=System. Text. Encodings. Web. JavaScriptEncoder. Create (UnicodeRanges. All);
Var json=JsonSerializer. Serialize (new title="code" to change the world, attach the options).
Console. WriteLine (json);
CodePudding user response:
The