我有一个JSON响应,长这样:
{
"success": true,
"more": false,
"results_html": "a lot of html in here",
"listinginfo": {
"637640274112277168": {
"listingid": "637640274112277168",
"price": 50,
"fee": 7,
"publisher_fee_app": 730,
"publisher_fee_percent": "0.10000000149011612",
"currencyid": "2005",
"steam_fee": 2,
"publisher_fee": 5,
"converted_price": 1,
"converted_fee": 2,
"converted_currencyid": "2003",
"converted_steam_fee": 1,
"converted_publisher_fee": 1,
"converted_price_per_unit": 1,
"converted_fee_per_unit": 2,
"converted_steam_fee_per_unit": 1,
"converted_publisher_fee_per_unit": 1,
"asset": {
"currency": 0,
"appid": 730,
"contextid": "2",
"id": "6542776191",
"amount": "1"
}
},
"194035710805671301": {
"listingid": "194035710805671301",
"price": 0,
"fee": 0,
"publisher_fee_app": 730,
"publisher_fee_percent": "0.10000000149011612",
"currencyid": "2001",
"asset": {
"currency": 0,
"appid": 730,
"contextid": "2",
"id": "6825071309",
"amount": "0"
}
},
}//end listinginfo
//more fields here..
}
我需要从"listinginfo"节点中获取信息并将它们添加到一个dictionary<string, NewListedItem>
中,其中字符串可以是例如:"637640274112277168",列表的类型为"NewListedItem",包含来自该子节点的所有信息。我的类看起来像这样:
class listinginfo
{
public Dictionary<string, NewListedItem> Items;
}
class Asset
{
public string currency { get; set; }
public string appid { get; set; }
public string contextid { get; set; }
public string id { get; set; }
public string amount { get; set; }
}
class NewListedItem
{
public string listingid { get; set; }
public string price { get; set; }
public string fee { get; set; }
public string publisher_fee_app { get; set; }
public string publisher_fee_percent { get; set; }
public string steam_fee { get; set; }
public string publisher_fee { get; set; }
public string converted_price { get; set; }
public string converted_fee { get; set; }
public string converted_currencyid { get; set; }
public string converted_steam_fee { get; set; }
public string converted_publisher_fee { get; set; }
public string converted_fee_per_unit { get; set; }
public string converted_steam_fee_per_unit { get; set; }
public string converted_publisher_fee_per_unit { get; set; }
public Asset asset { get; set; }
}
我该如何实现这一目标?