diff --git a/Content.Server/GameTicking/GameTicker.StatusShell.cs b/Content.Server/GameTicking/GameTicker.StatusShell.cs index 0ea712d4e8..48fffcbcc0 100644 --- a/Content.Server/GameTicking/GameTicker.StatusShell.cs +++ b/Content.Server/GameTicking/GameTicker.StatusShell.cs @@ -1,5 +1,5 @@ using System; -using Newtonsoft.Json.Linq; +using System.Text.Json.Nodes; using Robust.Server.ServerStatus; using Robust.Shared.IoC; using Robust.Shared.ViewVariables; @@ -24,7 +24,7 @@ namespace Content.Server.GameTicking IoCManager.Resolve().OnStatusRequest += GetStatusResponse; } - private void GetStatusResponse(JObject jObject) + private void GetStatusResponse(JsonNode jObject) { // This method is raised from another thread, so this better be thread safe! lock (_statusShellLock) diff --git a/Content.Server/MoMMI/MoMMILink.cs b/Content.Server/MoMMI/MoMMILink.cs index 1228c95dc6..a32841912e 100644 --- a/Content.Server/MoMMI/MoMMILink.cs +++ b/Content.Server/MoMMI/MoMMILink.cs @@ -1,12 +1,12 @@ using System; using System.Net; using System.Net.Http; -using System.Text; +using System.Net.Http.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using System.Threading.Tasks; using Content.Server.Chat.Managers; -using Content.Shared; using Content.Shared.CCVar; -using Newtonsoft.Json; using Robust.Server.ServerStatus; using Robust.Shared.Asynchronous; using Robust.Shared.Configuration; @@ -62,9 +62,7 @@ namespace Content.Server.MoMMI Contents = messageObject }; - var jsonMessage = JsonConvert.SerializeObject(sentMessage); - var request = - await _httpClient.PostAsync(url, new StringContent(jsonMessage, Encoding.UTF8, "application/json")); + var request = await _httpClient.PostAsJsonAsync(url, sentMessage); if (!request.IsSuccessStatusCode) { @@ -92,7 +90,7 @@ namespace Content.Server.MoMMI { message = context.RequestBodyJson(); } - catch (JsonSerializationException) + catch (JsonException) { // message null so enters block down below. } @@ -116,34 +114,39 @@ namespace Content.Server.MoMMI return true; } - [JsonObject(MemberSerialization.Fields)] - private class MoMMIMessageBase + private sealed class MoMMIMessageBase { - [JsonProperty("password")] public string Password = null!; + [JsonInclude] [JsonPropertyName("password")] + public string Password = null!; - [JsonProperty("type")] public string Type = null!; + [JsonInclude] [JsonPropertyName("type")] + public string Type = null!; - [JsonProperty("contents")] public object Contents = null!; + [JsonInclude] [JsonPropertyName("contents")] + public object Contents = null!; } - [JsonObject(MemberSerialization.Fields)] private class MoMMIMessageOOC { - [JsonProperty("sender")] public string Sender = null!; + [JsonInclude] [JsonPropertyName("sender")] + public string Sender = null!; - [JsonProperty("contents")] public string Contents = null!; + [JsonInclude] [JsonPropertyName("contents")] + public string Contents = null!; } - [JsonObject(MemberSerialization.Fields, ItemRequired = Required.Always)] private class OOCPostMessage { - #pragma warning disable CS0649 - [JsonProperty("password")] public string Password = null!; +#pragma warning disable CS0649 + [JsonInclude] [JsonPropertyName("password")] + public string Password = null!; - [JsonProperty("sender")] public string Sender = null!; + [JsonInclude] [JsonPropertyName("sender")] + public string Sender = null!; - [JsonProperty("contents")] public string Contents = null!; - #pragma warning restore CS0649 + [JsonInclude] [JsonPropertyName("contents")] + public string Contents = null!; +#pragma warning restore CS0649 } } } diff --git a/RobustToolbox b/RobustToolbox index 79f87f03ce..a85b2dd43c 160000 --- a/RobustToolbox +++ b/RobustToolbox @@ -1 +1 @@ -Subproject commit 79f87f03ceb844bb9df2c8f91c197cf86a5b4aba +Subproject commit a85b2dd43c358b5264760f5c91c62ee3bc4ad7a8