如何将这个JSON对象解析为可在代码中使用的对象

时间:2019-05-28 22:24:38

标签: c# json

这是我的JSON输入:

{
   "assets":[
      {
         "appid":730,
         "contextid":"2",
         "assetid":"16106538532",
         "classid":"3292478154",
         "instanceid":"0",
         "amount":"1"
      },
      {
         "appid":730,
         "contextid":"2",
         "assetid":"16102298435",
         "classid":"3291242689",
         "instanceid":"0",
         "amount":"1"
      }, // ...

   ],
   "descriptions":[
      {
         "appid":730,
         "classid":"3292478154",
         "instanceid":"0",
         "currency":0,
         "background_color":"",
         "icon_url":"//url",
         "descriptions":[...],
         "tradable":0,
         "name":"Spectrum Case",
         "name_color":"D2D2D2",
         "type":"Base Grade Container",
         "market_name":"Spectrum Case",
         "market_hash_name":"Spectrum Case",
         "commodity":1,
         "market_tradable_restriction":7,
         "marketable":1,
         "tags":[//...]
      }, // ...     
      {
         "appid":730,
         "classid":"3291242689",
         "instanceid":"0",
         "currency":0,
         "background_color":"",
         "icon_url":"//url",
         "descriptions":[...],
         "tradable":0,
         "name":"Horizon Case",
         "name_color":"D2D2D2",
         "type":"Base Grade Container",
         "market_name":"Horizon Case",
         "market_hash_name":"Horizon Case",
         "commodity":1,
         "market_tradable_restriction":7,
         "marketable":1,
         "tags":[//...]
      }, // ...
   ],
   "total_inventory_count":45,
   "success":1,
   "rwgrsn":-2
}

我只有AssetID,这是商品的唯一ID

但是要获取商品的信息,首先我必须获取它的ClassID,该ID还存储商品的信息

例如,我有var assetID = "16106538532";,但我也想要ClassID的信息。 "market_hash_name""icon_url",...

如何在C#中获得此代码? 从理论上讲,我知道如何获取JSON数据以及如何将其保存到var json中,但是我不知道如何处理其余数据。 谢谢你的帮助

0 个答案:

没有答案