MongoDB,json类和字典成员序列化



假设我有这样一个类:

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> 

字典的键/值对不会被序列化。。。

提前谢谢!

我自己得到了它-自定义序列化。

最新更新