Skip to content

KeyValuePair is not properly serialized with JsonNamingPolicy.CamelCase - System.Text.Json #1197

@untaught

Description

@untaught

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" }

Metadata

Metadata

Assignees

Labels

area-System.Text.Jsonbreaking-changeIssue or PR that represents a breaking API or functional change over a previous release.bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions