我有一个模特:
[Serializable]
public class User
{
public string UserID { get; set; }
public string UserName { get; set; }
public string Password { get; set;}
public bool isLoggedIn { get; set; }
public CookieCollection Cookies { get; set; }
[NonSerialized]
public string Response = "";
}
只是尝试序列化和反序列化:
string str = Newtonsoft.Json.JsonConvert.SerializeObject(u, typeof(User), settings);
User us = Newtonsoft.Json.JsonConvert.DeserializeObject<User>(str);
我收到错误:
Cannot create and populate list type System.Net.CookieCollection. Path 'Cookies', line 1, position 92.
Json string:
{"UserID":null,"UserName":"nazarkin659","Password":"Hakers659","isLoggedIn":true,"Cookies":[]}
我知道我错过了一些东西,但我真的能理解......