james henderson
asked on
json.net won't deserialize string
here is my class:
public class FeedStatusResultMain
{
public long feedstatusid { get; set; }
public long feedid { get; set; }
public long clientid { get; set; }
public string clientname { get; set; }
public string feedname { get; set; }
public string feeddescription { get; set; }
public string direction { get; set; }
public string status { get; set; }
public string starttime { get; set; }
public string endtime { get; set; }
public string nextrundate { get; set; }
public int summaryprocessed { get; set; }
public int summaryloaded { get; set; }
public int summaryrejected { get; set; }
public string environment { get; set; }
}
Here is the json response returned from my web service:
"[{
"feedstatusid":92738,
"feedid":143,
"clientid":2,
"clientname":"client1",
"feedname":"report1",
"feeddescription":"report1 ",
"direction":"O",
"status":"P",
"starttime":"2014-10-23 10:40:32",
"endtime":"2014-10-23 10:40:37",
"nextrundate":"2014-10-23 10:50:32",
"summaryprocessed":3,
"summaryloaded":0,
"summaryrejected":0,
"environment":""
},
{
"feedstatusid":92737,
"feedid":148,
"clientid":2,
"clientname":"client2",
"feedname":"report2",
"feeddescription":"report2 ",
"direction":"O",
"status":"P",
"starttime":"2014-10-23 10:40:00",
"endtime":"2014-10-23 10:40:07",
"nextrundate":"2014-10-23 10:50:00",
"summaryprocessed":2,
"summaryloaded":3,
"summaryrejected":0,
"environment":""
}]"
I try to deserialize into a list<FeedStatusResponseMai n> like this:
List<FeedStatusResultMain> frx = JsonConvert.DeserializeObj ect<List<F eedStatusR esultMain> >(rx);
it throws the following error:
System.ArgumentException: Could not cast or convert from System.String to System.Collections.Generic .List`1[TM SWebServic eClient.Fe edStatusRe sultMain].
I am going nuts trying to find out why this error is happening. I've tried the JArray.parse() and JObject.parse() methods, but nothing works, just errors. I don't see anything wrong with the json and the code is right out of their documentation!
public class FeedStatusResultMain
{
public long feedstatusid { get; set; }
public long feedid { get; set; }
public long clientid { get; set; }
public string clientname { get; set; }
public string feedname { get; set; }
public string feeddescription { get; set; }
public string direction { get; set; }
public string status { get; set; }
public string starttime { get; set; }
public string endtime { get; set; }
public string nextrundate { get; set; }
public int summaryprocessed { get; set; }
public int summaryloaded { get; set; }
public int summaryrejected { get; set; }
public string environment { get; set; }
}
Here is the json response returned from my web service:
"[{
"feedstatusid":92738,
"feedid":143,
"clientid":2,
"clientname":"client1",
"feedname":"report1",
"feeddescription":"report1
"direction":"O",
"status":"P",
"starttime":"2014-10-23 10:40:32",
"endtime":"2014-10-23 10:40:37",
"nextrundate":"2014-10-23 10:50:32",
"summaryprocessed":3,
"summaryloaded":0,
"summaryrejected":0,
"environment":""
},
{
"feedstatusid":92737,
"feedid":148,
"clientid":2,
"clientname":"client2",
"feedname":"report2",
"feeddescription":"report2
"direction":"O",
"status":"P",
"starttime":"2014-10-23 10:40:00",
"endtime":"2014-10-23 10:40:07",
"nextrundate":"2014-10-23 10:50:00",
"summaryprocessed":2,
"summaryloaded":3,
"summaryrejected":0,
"environment":""
}]"
I try to deserialize into a list<FeedStatusResponseMai
List<FeedStatusResultMain>
it throws the following error:
System.ArgumentException: Could not cast or convert from System.String to System.Collections.Generic
I am going nuts trying to find out why this error is happening. I've tried the JArray.parse() and JObject.parse() methods, but nothing works, just errors. I don't see anything wrong with the json and the code is right out of their documentation!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There shouldn't be a need to do this. I would use Fiddler to control what is really sent to you. Those quotes may be from the VS debugger.
ASKER