Possible Duplicate:
Deserializing JSON into an object with Json.NET
Any ideas of how to deserialize the following response into anonymous type using Json.Net?
{"d":[{"day":"Wednesday","firstSet":{"start":"17:00","close":"23:00","hours":6,"isValid":true},"secondSet":{"start":"00:00","close":"00:00","hours":0,"isValid":false},"personMinimum":2,"personMaximum":25}]}
Attempts so far result in the following error
Could not cast or convert from System.String to <>f__AnonymousType35[System.String,<>f__AnonymousType2
4[System.String,System.String,System.Int32,System.Boolean],<>f__AnonymousType2`4[System.String,System.String,System.Int32,System.Boolean],System.Int32,System.Int32].
Code is supplied below
var json_complex = new
{
d = new
{
day = "",
firstSet = new
{
start = "",
close = "",
hours = 0,
isValid = false
},
secondSet = new
{
start = "",
close = "",
hours = 0,
isValid = false
},
personMinimum = 2,
personMaximum = 25
}
};
var json = JsonConvert.DeserializeAnonymousType(jsonResponse, json_complex);
Any ideas?