所以我下载的单个字符串将具有以下格式:
"MatchId": "83570b03-2963-4b44-834c-bf77c74f2d0a",
"MatchType": 3,
"GameMode": 3,
"SeasonId": null,
"PlaylistId": "282fc197-7bf1-4865-81ec-a312d07567b6",
"Teams": {
"1": {
"TeamSize": 2
},
"2": {
"TeamSize": 2
}
},
"MapId": "skirmish\\design\\MP_Veteran\\MP_Veteran",
"MatchStartDate": {
"ISO8601Date": "2017-02-24T21:20:42.024Z"
},
"PlayerMatchDuration": "PT35M39.4550853S",
"PlayerIndex": 3,
"TeamId": 1,
"TeamPlayerIndex": 1,
"LeaderId": 3,
"PlayerCompletedMatch": true,
"PlayerMatchOutcome": 2,
"XPProgress": {
"PreviousTotalXP": 23300,
"GameplayXP": 600,
"ChallengesXP": 0,
"UpdatedTotalXP": 23900,
"CompletedSpartanRanks": []
我想知道的是,如果我有一个单独的类,其中包含'MatchId','MatchType','GameMode'等变量。如何输入此字符串并自动将所有值存储到正确的变量中?
谢谢:))
答案 0 :(得分:1)
这看起来像JSON,是否有周围的{
和}
?如果是这样,你需要将它解析为JSON,如果你使用像Icepickle建议的东西(NewtonSoft.JSON)那么它应该很简单