Skip to content

JsonSerializer always encodes dictionary keys and property names #30728

@chenyj796

Description

@chenyj796

I have some code as below:

var dict = new Dictionary<string, Dictionary<string, string>>();
dict.Add("用户组01", new Dictionary<string, string>
{
    { "用户ABC","123"},
    { "用户DEF","456"}
});
var json = JsonSerializer.Serialize(dict);

and got the json as below:

{"\u7528\u6237\u7EC401":{"\u7528\u6237ABC":"123","\u7528\u6237DEF":"456"}}

when I actually want:

{"用户组01":{"用户ABC":"123","用户DEF":"456"}}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions