【发布时间】:2022-01-11 12:08:22
【问题描述】:
如何在不执行模型绑定的情况下更改 json 属性名称的大小写? JsonElement 序列化忽略 PropertyNaming JsonSerializer 选项,这里也确认:https://github.com/dotnet/runtime/issues/61843 建议使用 JsonNode/JsonObject 会导致相同的行为。
任何提示我可以如何做到这一点?
例如,我想改变这个:
{
"MyPoperty" : 5,
"MyComplexProperty" : {
"MyOtherProperty": "value",
"MyThirdProperty": true
}
}
到这里:
{
"myPoperty" : 5,
"myComplexProperty" : {
"myOtherProperty": "value",
"myThirdProperty": true
}
}
干杯。
【问题讨论】:
-
好像你的问题在这里已经有了答案:stackoverflow.com/questions/58570189/…
-
否 - 该解决方案需要模型绑定。序列化 JsonElements 时,序列化不考虑命名策略或自定义转换器。
标签: json .net system.text.json .net-6.0 camelcasing