c# - Getting error Type 'System.String' is not supported for deserialization of an array -


i'm having issues deserializing nested array of json objects in c# using javascriptdeserializer

here code

  using (stream s = request.getresponse().getresponsestream())                 {                     using (streamreader sr = new streamreader(s))                     {                         string jsondata = sr.readtoend();                          var workout = ser.deserialize<clserviceoutput1>(jsondata);                     }                 } 

here jsondata

{"data":"50951","filedata":[37,80,68,70,45,49,46,51,13,37,226,227,207,211,13,10],"mailitem":null,"status":"success","turnaroundtime":null} 

here class

public class clserviceoutput1     {         public string data { get; set; }         public string filedata { get; set; }         public string mailitem { get; set; }         public string status { get; set; }         public string turnaroundtime { get; set; }      } 

filedata collection of numeric values in json string.

"filedata":[37,80,68,70,45,49,46,51,13,37,226,227,207,211,13,10] 

you need

list<int> filedata //or int[] 

as side note, use http://json2csharp.com/ copy json , c# template class back. pasting json in above site results in:

public class rootobject {     public string data { get; set; }     public list<int> filedata { get; set; }     public object mailitem { get; set; }     public string status { get; set; }     public object turnaroundtime { get; set; } } 

based on comment @xanatos

by name of field, seems binary "stream" of file, not must expanded. byte[] could type of field


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -