我有一堂课:
[Serializable]
public class KVPair<TKey, TValue>
{
public TKey Key { get; set; }
public TValue Value { get; set; }
public KVPair(TKey k, TValue v)
{
Key = k;
Value = v;
}
}
我创建的:
List<KVPair<string,string>> kvPairs;
使用 JSON.Net 库,我可以序列化列表并产生:
"[{\"Key\":\"Two\",\"Value\":\"2\"},{\"Key\":\"One\",\"Value\":\"1\"}]"
当我将此字符串反序列化回 List> 时,我得到了正确的对象计数,但它们为空。任何建议都会有很大帮助。