如果子元素的名称不是静态的,如何为json创建一个类?在示例中,它被命名为" 2785989080"或" 866191093_188530139"。
UPD:嗯,简单地提出一个问题:如何为这个json响应创建一个C#类?
这是一个例子json:
{
"success": true,
"rgInventory": {
"1853236180": {
"id": "1853236180",
"classid": "866191093",
"instanceid": "188530139",
"amount": "1",
"pos": 6
},
"2785011973": {
"id": "2785011973",
"classid": "1104575269",
"instanceid": "480085569",
"amount": "1",
"pos": 2
}
},
"rgCurrency": [],
"rgDescriptions": {
"866191093_188530139": {
"appid": "730",
"classid": "866191093",
"instanceid": "188530139",
"icon_url": "-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXH5ApeO4YmlhxYQknCRvCo04DEVlxkKgposbupIgthwczbYQJP6c--q5OHluT8Nqjunm5Q_tw_ieyVod322w3l_hdvNjugctOUegU7NAmBqwToku3ogcXu6ciam3UwuT5iuyio602etQ",
"icon_url_large": "-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXH5ApeO4YmlhxYQknCRvCo04DEVlxkKgposbupIgthwczbYQJP6c--q5OHluT8Nqjunm5Q_txOhujT8om7i1Hg_0I_YGDyIdKWJ1RtNw3R8lK7lL--1MPq757OzSEx73Vxt3iOnAv3309KxEWqOg",
"icon_drag_url": "",
"name": "Souvenir Galil AR | Hunting Blind",
"market_hash_name": "Souvenir Galil AR | Hunting Blind (Battle-Scarred)",
"market_name": "Souvenir Galil AR | Hunting Blind (Battle-Scarred)",
"name_color": "FFD700",
"background_color": "",
"type": "Souvenir Consumer Grade Rifle",
"tradable": 1,
"marketable": 1,
"commodity": 0,
"market_tradable_restriction": "7",
"descriptions": [
{
"type": "html",
"value": "Exterior: Battle-Scarred"
},
{
"type": "html",
"value": " "
},
{
"type": "html",
"value": "This item commemorates ESL One Katowice 2015 CS:GO Championship.",
"color": "ffd700"
},
{
"type": "html",
"value": " "
},
{
"type": "html",
"value": "It was dropped during the Semifinal match between Fnatic and Virtus.Pro.",
"color": "ffd700"
},
{
"type": "html",
"value": " "
},
{
"type": "html",
"value": "A less expensive option among the terrorist-exclusive assault rifles, the Galil AR is a serviceable weapon in medium to long-range combat. It has been spray-painted freehand using mesh fabric as a stencil."
},
{
"type": "html",
"value": " "
},
{
"type": "html",
"value": "The Mirage Collection",
"color": "9da1a9",
"app_data": {
"def_index": "65535",
"is_itemset_name": 1
}
},
{
"type": "html",
"value": " "
},
{
"type": "html",
"value": "<br><div id=\"sticker_info\" name=\"sticker_info\" title=\"Sticker Details\" style=\"border: 2px solid rgb(102, 102, 102); border-radius: 6px; width=100; margin:4px; padding:8px;\"><center><img width=64 height=48 src=\"https://steamcdn-a.akamaihd.net/apps/730/icons/econ/stickers/eslkatowice2015/esl_a_gold.511130e5cd35082f8a58fe9510013e8b094b6f5f.png\"><img width=64 height=48 src=\"https://steamcdn-a.akamaihd.net/apps/730/icons/econ/stickers/eslkatowice2015/fnatic_gold.c9e28989883f9def16bebaf62ab506ab473915fe.png\"><img width=64 height=48 src=\"https://steamcdn-a.akamaihd.net/apps/730/icons/econ/stickers/eslkatowice2015/virtuspro_gold.f4d7fb45cc724daaa48b8fb5dc139bebc03aefbe.png\"><br>Sticker: ESL One (Gold) | Katowice 2015, Fnatic (Gold) | Katowice 2015, Virtus.pro (Gold) | Katowice 2015</center></div>",
"app_data": {
"def_index": "65535"
}
}
],
"owner_descriptions": "",
"actions": [
{
"name": "Inspect in Game...",
"link": "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S%owner_steamid%A%assetid%D4774453798104612769"
}
],
"market_actions": [
{
"name": "Inspect in Game...",
"link": "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D4774453798104612769"
}
],
"tags": [
{
"internal_name": "CSGO_Type_Rifle",
"name": "Rifle",
"category": "Type",
"category_name": "Type"
},
{
"internal_name": "weapon_galilar",
"name": "Galil AR",
"category": "Weapon",
"category_name": "Weapon"
},
{
"internal_name": "set_mirage",
"name": "The Mirage Collection",
"category": "ItemSet",
"category_name": "Collection"
},
{
"internal_name": "tournament",
"name": "Souvenir",
"category": "Quality",
"color": "FFD700",
"category_name": "Category"
},
{
"internal_name": "Rarity_Common_Weapon",
"name": "Consumer Grade",
"category": "Rarity",
"color": "b0c3d9",
"category_name": "Quality"
},
{
"internal_name": "WearCategory4",
"name": "Battle-Scarred",
"category": "Exterior",
"category_name": "Exterior"
},
{
"internal_name": "Tournament6",
"name": "2015 ESL One Katowice",
"category": "Tournament",
"category_name": "Tournament"
},
{
"internal_name": "Team6",
"name": "Fnatic",
"category": "TournamentTeam",
"category_name": "Team"
},
{
"internal_name": "Team31",
"name": "Virtus.Pro",
"category": "TournamentTeam",
"category_name": "Team"
}
]
}
},
"more": false,
"more_start": false
}