diff --git a/Tailspin.SpaceGame.Web/LeaderboardFunctionClient/LeaderboardFunctionClient.cs b/Tailspin.SpaceGame.Web/LeaderboardFunctionClient/LeaderboardFunctionClient.cs index e0277887..0ae9ac9b 100644 --- a/Tailspin.SpaceGame.Web/LeaderboardFunctionClient/LeaderboardFunctionClient.cs +++ b/Tailspin.SpaceGame.Web/LeaderboardFunctionClient/LeaderboardFunctionClient.cs @@ -21,7 +21,8 @@ async public Task GetLeaderboard(int page, int pageSize, st using (WebClient webClient = new WebClient()) { string json = await webClient.DownloadStringTaskAsync($"{this._functionUrl}?page={page}&pageSize={pageSize}&mode={mode}®ion={region}"); - return JsonSerializer.Deserialize(json); + var leaderboardResponse = JsonSerializer.Deserialize(json, new JsonSerializerOptions { IncludeFields = true }); + return leaderboardResponse; } } } diff --git a/Tailspin.SpaceGame.Web/LeaderboardFunctionClient/LeaderboardResponse.cs b/Tailspin.SpaceGame.Web/LeaderboardFunctionClient/LeaderboardResponse.cs index 7e74f189..dac61ac3 100644 --- a/Tailspin.SpaceGame.Web/LeaderboardFunctionClient/LeaderboardResponse.cs +++ b/Tailspin.SpaceGame.Web/LeaderboardFunctionClient/LeaderboardResponse.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Text.Json.Serialization; using TailSpin.SpaceGame.Web.Models; namespace TailSpin.SpaceGame.Web @@ -6,17 +7,24 @@ namespace TailSpin.SpaceGame.Web public class LeaderboardResponse { // The game mode selected in the view. + [JsonPropertyName("selectedMode")] public string SelectedMode { get; set; } + // The game region (map) selected in the view. + [JsonPropertyName("selectedRegion")] public string SelectedRegion { get; set; } // The current page to be shown in the view. + [JsonPropertyName("page")] public int Page { get; set; } // The number of items to show per page in the view. + [JsonPropertyName("pageSize")] public int PageSize { get; set; } // The scores to display in the view. + [JsonPropertyName("scores")] public IEnumerable Scores { get; set; } // The total number of results for the selected game mode and region in the view. + [JsonPropertyName("totalResults")] public int TotalResults { get; set; } } } \ No newline at end of file diff --git a/Tailspin.SpaceGame.Web/Models/LeaderboardViewModel.cs b/Tailspin.SpaceGame.Web/Models/LeaderboardViewModel.cs index 479bdec9..59f469ec 100644 --- a/Tailspin.SpaceGame.Web/Models/LeaderboardViewModel.cs +++ b/Tailspin.SpaceGame.Web/Models/LeaderboardViewModel.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Text.Json.Serialization; namespace TailSpin.SpaceGame.Web.Models { @@ -44,8 +45,10 @@ public LeaderboardViewModel() public struct ScoreProfile { // The player's score. + [JsonPropertyName("score")] public Score Score; // The player's profile. + [JsonPropertyName("profile")] public Profile Profile; } } \ No newline at end of file