我在搞乱 Steam Web API。我正在尝试创建一个函数来查找一段文本,然后提取另一段文本,这将根据我使用函数查找的用户而改变。
我尝试过使用 IndexOf,但由于我要提取的文本长度可能不同,所以很难。
我想从中提取字符串的 Json 响应看起来像这样,但会因我查找的每个用户而异。
{
"response": {
"game_count": 54,
"games": [
{
"appid": 240,
"playtime_forever": 51842
},
{
"appid": 260,
"playtime_forever": 43
},
{
"appid": 300,
"playtime_forever": 191
},
{
"appid": 320,
"playtime_forever": 130
},
{
"appid": 340,
"playtime_forever": 4
},
{
"appid": 520
},
{
"appid": 4000,
"playtime_2weeks": 798,
"playtime_forever": 61803
},
{
"appid": 440,
"playtime_forever": 19466
},
{
"appid": 105600,
"playtime_forever": 2084
},
{
"appid": 72850,
"playtime_forever": 2010
},
{
"appid": 380,
"playtime_forever": 91
},
{
"appid": 400,
"playtime_forever": 76
},
{
"appid": 420
},
{
"appid": 220,
"playtime_forever": 827
},
{
"appid": 550,
"playtime_forever": 906
},
{
"appid": 33910,
"playtime_forever": 77
},
{
"appid": 33930,
"playtime_2weeks": 1714,
"playtime_forever": 31904
},
{
"appid": 219540,
"playtime_forever": 0
},
{
"appid": 570
},
{
"appid": 205790
},
{
"appid": 22380,
"playtime_forever": 1119
},
{
"appid": 105400,
"playtime_forever": 134
},
{
"appid": 204030
},
{
"appid": 12120
},
{
"appid": 12250
},
{
"appid": 24010
},
{
"appid": 8190,
"playtime_forever": 723
},
{
"appid": 620,
"playtime_forever": 101
},
{
"appid": 644
},
{
"appid": 730,
"playtime_forever": 431
},
{
"appid": 10,
"playtime_forever": 396
},
{
"appid": 80
},
{
"appid": 100
},
{
"appid": 42680,
"playtime_forever": 65
},
{
"appid": 42690,
"playtime_forever": 1435
},
{
"appid": 22200
},
{
"appid": 113200,
"playtime_forever": 270
},
{
"appid": 20540
},
{
"appid": 55110
},
{
"appid": 43110
},
{
"appid": 9340
},
{
"appid": 50620
},
{
"appid": 4560
},
{
"appid": 55230,
"playtime_forever": 1354
},
{
"appid": 4540
},
{
"appid": 4570
},
{
"appid": 22370,
"playtime_forever": 305
},
{
"appid": 70,
"playtime_forever": 479
},
{
"appid": 70300,
"playtime_forever": 138
},
{
"appid": 220240,
"playtime_2weeks": 72,
"playtime_forever": 453
},
{
"appid": 107410,
"playtime_2weeks": 80,
"playtime_forever": 403
},
{
"appid": 40800,
"playtime_2weeks": 124,
"playtime_forever": 124
},
{
"appid": 12210,
"playtime_2weeks": 663,
"playtime_forever": 663
},
{
"appid": 12220,
"playtime_2weeks": 658,
"playtime_forever": 658
}
]
}
}
我想要做的是搜索即“\”appid\“:440”,然后能够得到后面的playtime_forever int。我不知道该怎么做。如果字符串具有设定的长度,我只能从 Split 函数中获得帮助,因为这样我就可以返回我想要的数组索引。
如果这不清楚,我非常抱歉,我尽力解释我想要实现的目标。
提前致谢,
伊萨克