问题
I have a model:
[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 = "";
}
Just trying to serialize and deserialize:
string str = Newtonsoft.Json.JsonConvert.SerializeObject(u, typeof(User), settings);
User us = Newtonsoft.Json.JsonConvert.DeserializeObject<User>(str);
I am getting an error:
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":[]}
I know that I am missing something, but I can' really understand what...
来源:https://stackoverflow.com/questions/27449717/newtonsoft-json-cannot-create-and-populate-list-type