我有一些代碼負責將一些數據發佈到web api。我正在嘗試發佈詞典。但是當請求被髮布時,key屬性不能被序列化。PostAsJsonAsync無法序列化字典中的對象
有我的代碼:
response = await base.HttpClientInstance.PostAsJsonAsync<Dictionary<ItemDto, string>>(url, dummyItems);
有小提琴手會議紀要:
Content-Type: application/json; charset=utf-8
Host: debug.foo.foo.com
Content-Length: 78
Expect: 100-continue
Connection: Keep-Alive
{"Foo.Contract.Items.ItemDto":"87a0a711-6ecb-4ef5-9aed-04f7573344e1"}
問題出在哪裏,什麼想法?
[Serialize Class contains Dictionary member]可能的重複(http://stackoverflow.com/questions/495647/serialize-class-containing-dictionary-member) – VMAtm 2015-02-10 10:40:49
你不能輕易地序列化實現IDictionary的類 – VMAtm 2015-02-10 10:41:09