Here is my code:
public class TestModel{
public string AAA{get;set;}
public string BBB{get;set;}
}
[Route("Test")]
public async Task<string> Test()
{
TestModel _TestModel=new TestModel(){AAA="123",BBB="привет123"};
string JSON = JsonSerializer.Serialize(_TestModel, typeof(TestModel));
return JSON;
}
When I ran the program
, the JSON
convert successfully.
However, the character which is not English or number can not convert correctly but only displays some strange string such as "\u65B0"
.
I think maybe it is the problem of encoding. However, it seems I can't set the encoding in the JsonSerializer.Serialize
.
How can I solve this problem? Thank you.