获取json响应的数据

时间:2018-03-30 11:36:13

标签: c# json

https://rbx.rocks/apis/user_items?u=Zinthetic

响应是json,我正试图获得\“stats \”:{\“RAP \”:\“270,924 \”

我试图让RAP值达到270,924 你们能帮助我吗?感谢

1 个答案:

答案 0 :(得分:0)

这对我有用。试试这个

var data = JsonConvert.DeserializeObject<RootObject>(json);
foreach (var item in data.inventory)
{
   Console.WriteLine(item.RAP);
}

课程将是:

public class Inventory
{
    public string Name { get; set; }
    public string RAP { get; set; }
    public string Value { get; set; }
    public List<int> UserAssetIDs { get; set; }
    public List<object> Serials { get; set; }
    public object SerialNumTotal { get; set; }
    public int Copies { get; set; }
    public int AssetID { get; set; }
    public string ImageLink { get; set; }
    public string ItemLink { get; set; }
    public string Img { get; set; }
    public int Demand { get; set; }
    public string ItemID { get; set; }
}

public class Stats
{
    public string RAP { get; set; }
    public string Value { get; set; }
    public string Count { get; set; }
    public int ID { get; set; }
    public string Username { get; set; }
    public bool verified { get; set; }
    public bool is_scammer { get; set; }
    public int percentagechange { get; set; }
    public int ecostatus { get; set; }
    public List<List<object>> rappoints { get; set; }
    public List<List<object>> valuepoints { get; set; }
    public int history_points { get; set; }
    public string Rank { get; set; }
}

public class RootObject
{
    public bool success { get; set; }
    public string reason { get; set; }
    public List<Inventory> inventory { get; set; }
    public Stats stats { get; set; }
}