2012-03-01 41 views
0

比方說,我有這樣一個類:的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> 
字典的

它們的鍵/值對沒有得到連載...

預先感謝您!

回答

0

我明白了 - 自定義序列化。

+0

小心分享解決方案? – mmmdreg 2013-10-24 09:43:21