我正在使用JavaScriptSerializer,当我尝试将JSON对象反序列化为
时Json.Deserialize<List<HeyWatchVideo>>(Request("video"));
我得到以下例外:
MissingMethodException:没有为'System.String'类型定义无参数构造函数。
我尝试匹配我的.NET类,它们的属性类型就像我的json对象一样,但仍然超出异常
我的JSON对象:
[{
"url": "http://media.heywatch.com.s3.amazonaws.com/14/14/a0f356a48381092e6e2a34021ce86b19/11002247",
"specs": {
"size": 3808,
"video": {
"fps": 11.63,
"height": 360,
"length": 61,
"width": 640,
"aspect": 1.78,
"codec": "mpeg4",
"container": "mov",
"rotation": 0,
"bitrate": 507,
"pix_format": "yuv420p",
"stream": 0.1
},
"thumb": "http://media.heywatch.com.s3.amazonaws.com/14/14/ad59fa501d1b9e826552dfc010cf1c98/11002247.jpg",
"audio": {
"sample_rate": 11025,
"channels": 1,
"codec": "aac",
"bitrate": 38,
"synched": true,
"stream": 0
},
"mime_type": "video/mp4"
},
"title": "elves.mp4",
"filename": "11002247",
"link": "http://heywatch.com/video/21091957.bin",
"updated_at": "2013-01-14T15:44:53+01:00",
"created_at": "2013-01-14T15:44:53+01:00",
"id": 21091957
}]
我的课程
public class HeyWatchVideo
{
public DateTime Created_At { get; set; }
public string Title { get; set; }
public Dictionary<string, string> Specs { get; set; }
public DateTime Updated_At { get; set; }
public int Id { get; set; }
public string Filename { get; set; }
public string Link { get; set; }
public string Url { get; set; }
}
public class HeyWatchVideoSpecs
{
public HeyWatchVideoSpecsAudio Audio { get; set; }
public HeyWatchVideoSpecsVideo Video { get; set; }
public string Thumb { get; set; }
public string Mime_type { get; set; }
public int Size { get; set; }
}
public class HeyWatchVideoSpecsVideo
{
public int Rotation { get; set; }
public double Aspect { get; set; }
public string Container { get; set; }
public string Codec { get; set; }
public int Length { get; set; }
public int Width { get; set; }
public int Bitrate { get; set; }
public string Pix_format { get; set; }
public double Fps { get; set; }
public double Stream { get; set; }
public int Height { get; set; }
}
public class HeyWatchVideoSpecsAudio
{
public int Channels { get; set; }
public int Sample_rate { get; set; }
public string Codec { get; set; }
public bool Synched { get; set; }
public int Bitrate { get; set; }
public int Stream { get; set; }
}
我在这里做错了什么?
答案 0 :(得分:1)
我的问题解决了。我的.Net类与Json对象完全不匹配。 (两者都在问题中)
当匹配时,此错误消失