Reputation: 95
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?
Upvotes: 0
Views: 54
Reputation: 10662
This looks like JSON, does this have a surrounding {
and }
? If so you need to parse it as JSON which should be pretty easy if you use something like what Icepickle suggested (NewtonSoft.JSON)
Upvotes: 1