无法反序列化json对象

本文关键字:对象 json 反序列化 | 更新日期: 2023-09-27 17:53:19

我正在使用JavaScriptSerializer,当我试图反序列化JSON对象

Json.Deserialize<List<HeyWatchVideo>>(Request("video")); 

我得到以下异常:

MissingMethodException:没有为'System.String'类型定义的无参数构造函数。

我试着匹配我的。net类,和他们的属性类型就像接近我的json对象,但仍然得到上面的异常

My JSON object:

[{
    "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; }
}

我在这里做错了什么?

无法反序列化json对象

我的问题解决了。我的。net类不完全匹配Json对象。(两者都在问题中)

当它们匹配时,此错误消失