使用 json.net 反序列化对象列表

2024-04-18

我有这门课

public class Image
{
    public string url { get; set; }
    public string url_40px { get; set; }
    public string url_50px { get; set; }
}

public class Category
{
    public List<int> ancestor_ids { get; set; }
    public int parent_id { get; set; }
    public List<object> children_ids { get; set; }
    public string nodename { get; set; }
    public int num_parts { get; set; }
    public List<Image> images { get; set; }
    public string __class__ { get; set; }
    public int id { get; set; }
}

我像这样反序列化它

retObject = JsonConvert.DeserializeObject(Of Category)(jsonResp)

但对于返回的类别列表,我如何转换为List<Category>? thanks


类型参数为DeserializeObject必须List<Category>代替Category.

在 C# 中它会是JsonConvert.DeserializeObject<List<Category>>(json)

在 VB.Net 中,它是JsonConvert.DeserializeObject(Of List(Of Category))(json)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 json.net 反序列化对象列表 的相关文章

随机推荐