runtime: KeyValuePair is not properly serialized with JsonNamingPolicy.CamelCase - System.Text.Json
When serializing a collection of KeyValuePair with CamelCase enabled the properties are serialized in PascalCase:
MVC Configuration is:
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase;
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
}
The result is:
{ Key: "Test", Value: "Test1" }
Expected result:
{ key: "Test", value: "Test1" }
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 15
- Comments: 15 (13 by maintainers)
{ Key: "Test", Value: "Test1" }Key and Value are just properties on the struct.
PropertyNamingPolicyshould apply to them.