JSON解析C#(数组?)



我真的什么都没有。浏览了与C#和JSON相关的各种问题。我试过干预,我只能A:获得所有的JSON输出,或者什么都不能,我似乎不知道如何获得我想要的。

所以我从这里提取JSON:https://yts.ag/api/v2/list_movies.json?limit=1&quality=720p为了方便起见,我只将其限制为1,你可以增加它,看看代码是否可以缩放。

现在,我要做的是,从URL中键入key/Value对和该键的Value。

您可能可以使用这个类获取完整的数据并对其进行解密

public class Rootobject
{
    public string status { get; set; }
    public string status_message { get; set; }
    public Data data { get; set; }
    public Meta meta { get; set; }
}
public class Data
{
    public int movie_count { get; set; }
    public int limit { get; set; }
    public int page_number { get; set; }
    public Movie[] movies { get; set; }
}
public class Movie
{
    public int id { get; set; }
    public string url { get; set; }
    public string imdb_code { get; set; }
    public string title { get; set; }
    public string title_english { get; set; }
    public string title_long { get; set; }
    public string slug { get; set; }
    public int year { get; set; }
    public float rating { get; set; }
    public int runtime { get; set; }
    public string[] genres { get; set; }
    public string summary { get; set; }
    public string description_full { get; set; }
    public string synopsis { get; set; }
    public string yt_trailer_code { get; set; }
    public string language { get; set; }
    public string mpa_rating { get; set; }
    public string background_image { get; set; }
    public string background_image_original { get; set; }
    public string small_cover_image { get; set; }
    public string medium_cover_image { get; set; }
    public string large_cover_image { get; set; }
    public string state { get; set; }
    public Torrent[] torrents { get; set; }
    public string date_uploaded { get; set; }
    public int date_uploaded_unix { get; set; }
}
public class Torrent
{
    public string url { get; set; }
    public string hash { get; set; }
    public string quality { get; set; }
    public int seeds { get; set; }
    public int peers { get; set; }
    public string size { get; set; }
    public int size_bytes { get; set; }
    public string date_uploaded { get; set; }
    public int date_uploaded_unix { get; set; }
}
public class Meta
{
    public int server_time { get; set; }
    public string server_timezone { get; set; }
    public int api_version { get; set; }
    public string execution_time { get; set; }
}

像这样反序列化JSON

Rootobject JsonObj = JsonConvert.DeserializeObject<Rootobject>(json);

然后你可以提取你想要的任何数据。

string movieURL = JsonObj.data.movies[0].url;

相关内容

  • 没有找到相关文章

最新更新