Deserializing List<KeyValuePair<string, string>>

Mar 6, 2010 at 10:29 PM

JsonConvert.DeserializeObject<T>(string) isn't deserializing a List<KeyValuePair<string, string>> correclty. By running the code below, the result object will contain two elements, but the values in Key and Value is null :/

 

List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
list.Add(new KeyValuePair<string, string>("key1", "value1"));
list.Add(new KeyValuePair<string, string>("key2", "value2"));

string json = JsonConvert.SerializeObject(list);

List<KeyValuePair<string, string>> result = JsonConvert.DeserializeObject<List<KeyValuePair<string, string>>>(json);

Coordinator
Mar 17, 2010 at 7:59 AM

This is now fixed in the latest version of the source code.

http://json.codeplex.com/SourceControl/list/changesets