【发布时间】:2023-03-17 21:11:01
【问题描述】:
假设我有这样一门课:
class A
{
Dictionary<string, string> Dict1 { get; set }
}
我希望它像这样被序列化为 Json:
"A" : {"strKey1" : "strVal1", "strKey2" : "strVal2"}
代替:
"A" : { "Dict1" : {"strKey1" : "strVal1", "strKey2" : "strVal2"}}
可以这么说,我想跳过生成“Dict1”键。
有可能吗?
另外,如何强制序列化“自定义”字典成员? 当我这样写我的课时:
class A : Dictionary<string, string>
他们字典的键/值对没有被序列化...
提前谢谢你!
【问题讨论】:
标签: json mongodb dictionary mongodb-.net-driver bson