c# - Why JsonConvert.DeserializeObject not working? -


i have result web service, string results :

{"status":"success","data":{"address":"aa@aa.aa","unconfirmed":[{"tx":"cb2f252078d933f63d9cef52bee8857427d70c1142f41f10567cfad7ef1d2dcb","time_utc":"2015-03-31t19:05:09z","amount":0.1,"n":0},{"tx":"a34fc5b8b3c29c7046ca8acaedd39280f81597a853f30825856e2f46e498c478","time_utc":"2015-03-31t19:05:01z","amount":0.1,"n":0}]},"code":200,"message":""} 

i'm calling jsonconvert.deserializeobject:

utbyaddressessresponse data = serializer.deserialize(result);

public static t deserialize<t>(string json)         {             return jsonconvert.deserializeobject<t>(json);         }     public class utbyaddressessresponse     {         public string status { get; set; }         public unconfirmedaddressinfo[] data { get; set; }          public string code { get; set; }         public string message { get; set; }     }   public class unconfirmedaddressinfo     {         public string address { get; set; }         public list<ut> unconfirmed { get; set; }     }    public class ut     {         public string tx { get; set; }         public datetime time_utc { get; set; }         public float amount { get; set; }         public long n { get; set; }     } 

but keep getting error :

cannot deserialize current json object (e.g. {"name":"value"}) type 'dice.common.objects.unconfirmedaddressinfo[]' because type requires json array (e.g. [1,2,3]) deserialize correctly.

why ?

the problem

public class utbyaddressessresponse     {         public string status { get; set; }         public unconfirmedaddressinfo[] data { get; set; }          public string code { get; set; }         public string message { get; set; }     } 

should

public class utbyaddressessresponse     {         public string status { get; set; }         public unconfirmedaddressinfo data { get; set; } // not array          public string code { get; set; }         public string message { get; set; }     } 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -