System.Text.Json serialized JSON use camel case for all attribute names

asp.net core3.x new serial number interfaces System.Text.Json

When serialized, if you want to use camel case for all attribute names JSON

The JsonSerializerOptions.PropertyNamingPolicy set JsonNamingPolicy.CamelCase即可

 Example:

1 var serializeOptions = new JsonSerializerOptions
2 {
3     PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
4     WriteIndented = true
5 };
6 jsonString = JsonSerializer.Serialize(weatherForecast, serializeOptions);
View Code

 

Guess you like

Origin www.cnblogs.com/jie566/p/12571614.html