【问题标题】:Get the data of a json response获取json响应的数据
【发布时间】:2018-03-30 11:36:13
【问题描述】:

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

响应是 json,我正在尝试获取 \"stats\":{\"RAP\":\"270,924\"

我正在尝试获取 RAP 值,所以 270,924 你们能帮帮我吗?谢谢

【问题讨论】:

标签: c# json


【解决方案1】:

这对我有用。试试这个

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; }
}

【讨论】:

    猜你喜欢
    • 2015-07-02
    • 1970-01-01
    • 1970-01-01
    • 2022-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-18
    • 1970-01-01
    相关资源
    最近更新 更多