[英]How can I get parameters out of a string and store them in variables? (C#)
So I have a single string downloaded that will have this format: 因此,我下载了一个具有以下格式的字符串:
"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": []
What I want to know is if I have a separate class with variables such as 'MatchId', 'MatchType', 'GameMode' etc. How can I input this string and automatically store all of the values into the correct variable? 我想知道的是,如果我有一个带有变量的单独类,例如'MatchId','MatchType','GameMode'等。如何输入此字符串并将所有值自动存储到正确的变量中?
Thanks :) 谢谢 :)
This looks like JSON, does this have a surrounding {
and }
? 看起来像JSON,它周围有
{
和}
吗? If so you need to parse it as JSON which should be pretty easy if you use something like what Icepickle suggested (NewtonSoft.JSON) 如果是这样,则需要将其解析为JSON,如果您使用类似Icepickle建议的内容(NewtonSoft.JSON),这应该非常容易
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.