diff --git a/RGB.NET.Devices.SteelSeries/API/Model/CoreProps.cs b/RGB.NET.Devices.SteelSeries/API/Model/CoreProps.cs index a3f1f85..2fde5f8 100644 --- a/RGB.NET.Devices.SteelSeries/API/Model/CoreProps.cs +++ b/RGB.NET.Devices.SteelSeries/API/Model/CoreProps.cs @@ -1,10 +1,10 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace RGB.NET.Devices.SteelSeries.API.Model { internal class CoreProps { - [JsonProperty(PropertyName = "address")] + [JsonPropertyName("address")] public string Address { get; set; } } } diff --git a/RGB.NET.Devices.SteelSeries/API/Model/Event.cs b/RGB.NET.Devices.SteelSeries/API/Model/Event.cs index ba3eb60..2e5f043 100644 --- a/RGB.NET.Devices.SteelSeries/API/Model/Event.cs +++ b/RGB.NET.Devices.SteelSeries/API/Model/Event.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace RGB.NET.Devices.SteelSeries.API.Model { @@ -7,13 +7,13 @@ namespace RGB.NET.Devices.SteelSeries.API.Model { #region Properties & Fields - [JsonProperty("game")] + [JsonPropertyName("game")] public string Game { get; set; } - [JsonProperty("event")] + [JsonPropertyName("event")] public string Name { get; set; } - [JsonProperty("data")] + [JsonPropertyName("data")] public Dictionary Data { get; } = new Dictionary(); #endregion diff --git a/RGB.NET.Devices.SteelSeries/API/Model/Game.cs b/RGB.NET.Devices.SteelSeries/API/Model/Game.cs index d93c7e4..33c62b1 100644 --- a/RGB.NET.Devices.SteelSeries/API/Model/Game.cs +++ b/RGB.NET.Devices.SteelSeries/API/Model/Game.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace RGB.NET.Devices.SteelSeries.API.Model { @@ -6,10 +6,10 @@ namespace RGB.NET.Devices.SteelSeries.API.Model { #region Properties & Fields - [JsonProperty("game")] + [JsonPropertyName("game")] public string Name { get; set; } - [JsonProperty("game_display_name")] + [JsonPropertyName("game_display_name")] public string DisplayName { get; set; } #endregion diff --git a/RGB.NET.Devices.SteelSeries/API/Model/GoLispHandler.cs b/RGB.NET.Devices.SteelSeries/API/Model/GoLispHandler.cs index 27d5315..f84b4b5 100644 --- a/RGB.NET.Devices.SteelSeries/API/Model/GoLispHandler.cs +++ b/RGB.NET.Devices.SteelSeries/API/Model/GoLispHandler.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace RGB.NET.Devices.SteelSeries.API.Model { @@ -6,10 +6,10 @@ namespace RGB.NET.Devices.SteelSeries.API.Model { #region Properties & Fields - [JsonProperty("game")] + [JsonPropertyName("game")] public string Game { get; set; } - [JsonProperty("golisp")] + [JsonPropertyName("golisp")] public string Handler { get; set; } #endregion diff --git a/RGB.NET.Devices.SteelSeries/API/SteelSeriesSDK.cs b/RGB.NET.Devices.SteelSeries/API/SteelSeriesSDK.cs index bf82309..012d749 100644 --- a/RGB.NET.Devices.SteelSeries/API/SteelSeriesSDK.cs +++ b/RGB.NET.Devices.SteelSeries/API/SteelSeriesSDK.cs @@ -5,7 +5,8 @@ using System.Linq; using System.Net.Http; using System.Runtime.InteropServices; using System.Text; -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using RGB.NET.Devices.SteelSeries.API.Model; namespace RGB.NET.Devices.SteelSeries.API @@ -73,13 +74,16 @@ namespace RGB.NET.Devices.SteelSeries.API string corePropsPath = GetCorePropsPath(); if (!string.IsNullOrWhiteSpace(corePropsPath) && File.Exists(corePropsPath)) { - CoreProps coreProps = JsonConvert.DeserializeObject(File.ReadAllText(corePropsPath)); - _baseUrl = coreProps.Address; - if (!_baseUrl.StartsWith("http://", StringComparison.Ordinal)) - _baseUrl = "http://" + _baseUrl; + CoreProps coreProps = JsonSerializer.Deserialize(File.ReadAllText(corePropsPath)); + _baseUrl = coreProps?.Address; + if (_baseUrl != null) + { + if (!_baseUrl.StartsWith("http://", StringComparison.Ordinal)) + _baseUrl = "http://" + _baseUrl; - RegisterGame(_game); - RegisterGoLispHandler(new GoLispHandler(_game, HANDLER)); + RegisterGame(_game); + RegisterGoLispHandler(new GoLispHandler(_game, HANDLER)); + } } } catch @@ -122,7 +126,7 @@ namespace RGB.NET.Devices.SteelSeries.API private static string PostJson(string urlSuffix, object o) { - string payload = JsonConvert.SerializeObject(o); + string payload = JsonSerializer.Serialize(o); return _client.PostAsync(_baseUrl + urlSuffix, new StringContent(payload, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result; } diff --git a/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj b/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj index 46e564e..d1971bc 100644 --- a/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj +++ b/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj @@ -51,7 +51,6 @@ - \ No newline at end of file