有关如何使用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}]}
到目前为止尝试导致以下错误
无法从System.String转换或转换为&lt;&gt; f__AnonymousType3 5[System.String,<>f__AnonymousType2
4 [System.String,System.String,System.Int32,System.Boolean],&lt;&gt; f__AnonymousType2`4 [ System.String,System.String,System.Int32,System.Boolean],System.Int32,System.Int32]。
代码在
下面提供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);
有什么想法吗?
答案 0 :(得分:-10)