diff --git a/OpenUtau.Core/DiffSinger/DiffSingerScript.cs b/OpenUtau.Core/DiffSinger/DiffSingerScript.cs index 9cd1fa67b..3824b26e2 100644 --- a/OpenUtau.Core/DiffSinger/DiffSingerScript.cs +++ b/OpenUtau.Core/DiffSinger/DiffSingerScript.cs @@ -4,7 +4,6 @@ using System.IO; using System.Linq; using System.Text; -using Newtonsoft.Json; using OpenUtau.Core.Render; using OpenUtau.Core.Ustx; @@ -199,7 +198,7 @@ static public void SavePart(UProject project, UVoicePart part, string filePath, .Select(x => new DiffSingerScript(x, options).toRaw()) .ToArray(); File.WriteAllText(filePath, - JsonConvert.SerializeObject(ScriptArray, Formatting.Indented), + Json.Serialize(ScriptArray), new UTF8Encoding(false)); } } diff --git a/OpenUtau.Core/DiffSinger/DiffSingerUtils.cs b/OpenUtau.Core/DiffSinger/DiffSingerUtils.cs index c9f05309c..48a7084dc 100644 --- a/OpenUtau.Core/DiffSinger/DiffSingerUtils.cs +++ b/OpenUtau.Core/DiffSinger/DiffSingerUtils.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Text; using Microsoft.ML.OnnxRuntime.Tensors; -using Newtonsoft.Json; using OpenUtau.Core.Render; namespace OpenUtau.Core.DiffSinger { @@ -319,7 +318,7 @@ public static Dictionary LoadPhonemes(string filePath){ static Dictionary LoadPhonemesFromJson(string filePath){ var json = File.ReadAllText(filePath, Encoding.UTF8); - return JsonConvert.DeserializeObject>(json); + return Json.Deserialize>(json); } static Dictionary LoadPhonemesFromTxt(string filePath){ @@ -333,7 +332,7 @@ static Dictionary LoadPhonemesFromTxt(string filePath){ public static Dictionary LoadLanguageIds(string filePath){ var json = File.ReadAllText(filePath, Encoding.UTF8); - return JsonConvert.DeserializeObject>(json); + return Json.Deserialize>(json); } public static string PhonemeLanguage(string phoneme){ diff --git a/OpenUtau.Core/Enunu/EnunuClient.cs b/OpenUtau.Core/Enunu/EnunuClient.cs index e939e0e3a..0cb145dbf 100644 --- a/OpenUtau.Core/Enunu/EnunuClient.cs +++ b/OpenUtau.Core/Enunu/EnunuClient.cs @@ -1,7 +1,6 @@ using System; using NetMQ; using NetMQ.Sockets; -using Newtonsoft.Json; using Serilog; namespace OpenUtau.Core.Enunu { @@ -12,7 +11,7 @@ internal T SendRequest(string[] args) { internal T SendRequest(string[] args, string port,int second = 300 ) { using (var client = new RequestSocket()) { client.Connect($"tcp://localhost:{port}"); - string request = JsonConvert.SerializeObject(args); + string request = Json.Serialize(args); Log.Information($"EnunuProcess sending {request}"); client.SendFrame(request); client.TryReceiveFrameString(TimeSpan.FromSeconds(second), out string? message); @@ -20,7 +19,7 @@ internal T SendRequest(string[] args, string port,int second = 300 ) { if (string.IsNullOrEmpty(message)) { return (T)Activator.CreateInstance(typeof(T))!; } - return JsonConvert.DeserializeObject(message ?? string.Empty)!; + return Json.Deserialize(message ?? string.Empty)!; } } } diff --git a/OpenUtau.Core/Format/Commonnote.cs b/OpenUtau.Core/Format/Commonnote.cs index 3411562c8..2a2ead933 100644 --- a/OpenUtau.Core/Format/Commonnote.cs +++ b/OpenUtau.Core/Format/Commonnote.cs @@ -1,13 +1,8 @@ -using Melanchall.DryWetMidi.Core; -using Melanchall.DryWetMidi.Interaction; -using Newtonsoft.Json; -using OpenUtau.Core.Ustx; +using OpenUtau.Core.Ustx; using OpenUtau.Core.Util; using System; using System.Collections.Generic; -using System.ComponentModel.Design; using System.Linq; -using System.Reflection.Emit; using TextCopy; using Serilog; @@ -62,11 +57,11 @@ public static string Dumps(List uNotes, UProject project) { }, notes = uNotes.Select(DumpNote).ToList(), }; - return JsonConvert.SerializeObject(data); + return Json.Serialize(data); } public static List Loads(string text, UProject project) { - var data = JsonConvert.DeserializeObject(text); + var data = Json.Deserialize(text); if (data.identifier != "commonnote") { Log.Error($"Clipboard is missing commonnote header"); return null; diff --git a/OpenUtau.Core/Format/Ufdata.cs b/OpenUtau.Core/Format/Ufdata.cs index e31c23c3b..6593863f0 100644 --- a/OpenUtau.Core/Format/Ufdata.cs +++ b/OpenUtau.Core/Format/Ufdata.cs @@ -1,8 +1,6 @@ using System.IO; using System.Linq; using System.Text; -using Newtonsoft.Json; - using OpenUtau.Core.Ustx; //reference: https://github.com/sdercolin/utaformatix-data/blob/main/lib/csharp/UtaFormatix.Data @@ -118,7 +116,7 @@ public static UProject Load(string file){ Ustx.AddDefaultExpressions(project); project.FilePath = file; - var ufProject = JsonConvert.DeserializeObject(File.ReadAllText(file,Encoding.UTF8)).project; + var ufProject = Json.Deserialize(File.ReadAllText(file,Encoding.UTF8)).project; //parse tempo project.tempos=ufProject.tempos diff --git a/OpenUtau.Core/OpenUtau.Core.csproj b/OpenUtau.Core/OpenUtau.Core.csproj index de3d0761f..517530d20 100644 --- a/OpenUtau.Core/OpenUtau.Core.csproj +++ b/OpenUtau.Core/OpenUtau.Core.csproj @@ -18,7 +18,6 @@ - diff --git a/OpenUtau.Core/PackageManager.cs b/OpenUtau.Core/PackageManager.cs index c49074be3..6765fec7d 100644 --- a/OpenUtau.Core/PackageManager.cs +++ b/OpenUtau.Core/PackageManager.cs @@ -5,9 +5,9 @@ using System.Net.Http; using System.Security.Cryptography; using System.Text; +using System.Text.Json; +using System.Text.Json.Nodes; using System.Threading.Tasks; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using Serilog; using SharpCompress.Archives; using OpenUtau.Core.Util; @@ -63,10 +63,10 @@ public async Task> FetchRegistryAsync() { List list = new List(); try { - var token = JToken.Parse(body); - var items = token["items"]; - if (items != null && items.Type == JTokenType.Array) { - list = items.ToObject>() ?? new List(); + var token = JsonObject.Parse(body); + var items = token?["items"]; + if (items?.GetValueKind() == JsonValueKind.Array) { + list = Json.Deserialize>(items) ?? new List(); } } catch (Exception e) { Log.Warning(e, "Failed to parse registry JSON"); diff --git a/OpenUtau.Core/Util/Json.cs b/OpenUtau.Core/Util/Json.cs new file mode 100644 index 000000000..cbf7d4b39 --- /dev/null +++ b/OpenUtau.Core/Util/Json.cs @@ -0,0 +1,32 @@ +using System.IO; +using System.Text.Encodings.Web; +using System.Text.Json; +using System.Text.Json.Nodes; + +namespace OpenUtau.Core { + public class Json { + + public static readonly JsonSerializerOptions DefaultJsonOptions = new() { + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, + IncludeFields = true, + WriteIndented = true + }; + + public static string Serialize(object? graph, JsonSerializerOptions? options = null) { + return JsonSerializer.Serialize(graph, options ?? DefaultJsonOptions); + } + + public static T? Deserialize(string input, JsonSerializerOptions? options = null) { + return JsonSerializer.Deserialize(input, options ?? DefaultJsonOptions); + } + + public static T? Deserialize(Stream input, JsonSerializerOptions? options = null) { + return JsonSerializer.Deserialize(input, options ?? DefaultJsonOptions); + } + + public static T? Deserialize(JsonNode? input, JsonSerializerOptions? options = null) { + return input.Deserialize(options ?? DefaultJsonOptions); + } + + } +} \ No newline at end of file diff --git a/OpenUtau.Core/Util/NotePresets.cs b/OpenUtau.Core/Util/NotePresets.cs index ddf3c73b8..6125c12f0 100644 --- a/OpenUtau.Core/Util/NotePresets.cs +++ b/OpenUtau.Core/Util/NotePresets.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Text; -using Newtonsoft.Json; using OpenUtau.Core.Ustx; using Serilog; @@ -17,7 +16,7 @@ static NotePresets() { public static void Save() { try { File.WriteAllText(PathManager.Inst.NotePresetsFilePath, - JsonConvert.SerializeObject(Default, Formatting.Indented), + Json.Serialize(Default), Encoding.UTF8); } catch (Exception e) { Log.Error(e, "Failed to save note presets."); @@ -27,7 +26,7 @@ public static void Save() { private static void Load() { try { if (File.Exists(PathManager.Inst.NotePresetsFilePath)) { - Default = JsonConvert.DeserializeObject( + Default = Json.Deserialize( File.ReadAllText(PathManager.Inst.NotePresetsFilePath, Encoding.UTF8)); } else { Reset(); diff --git a/OpenUtau.Core/Util/Preferences.cs b/OpenUtau.Core/Util/Preferences.cs index 132412639..d5f20b326 100644 --- a/OpenUtau.Core/Util/Preferences.cs +++ b/OpenUtau.Core/Util/Preferences.cs @@ -4,14 +4,14 @@ using System.Globalization; using System.IO; using System.Text; -using Newtonsoft.Json; +using System.Text.Json.Serialization; using OpenUtau.Core.Render; using Serilog; namespace OpenUtau.Core.Util { public static class Preferences { - public static SerializablePreferences Default; + public static SerializablePreferences Default { get; private set; } static Preferences() { Load(); @@ -20,7 +20,7 @@ static Preferences() { public static void Save() { try { File.WriteAllText(PathManager.Inst.PrefsFilePath, - JsonConvert.SerializeObject(Default, Formatting.Indented), + Json.Serialize(Default), Encoding.UTF8); } catch (Exception e) { Log.Error(e, "Failed to save prefs."); @@ -34,7 +34,7 @@ public static void Reset() { string exePath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); string shippedPrefsPath = Path.Combine(exePath, "prefs-default.json"); if (File.Exists(shippedPrefsPath)) { - var shippedPrefs = JsonConvert.DeserializeObject( + var shippedPrefs = Json.Deserialize( File.ReadAllText(shippedPrefsPath, Encoding.UTF8)); if (shippedPrefs != null) { Default = shippedPrefs; @@ -102,7 +102,7 @@ private static void AddRecentFile(string filePath) { private static void Load() { try { if (File.Exists(PathManager.Inst.PrefsFilePath)) { - Default = JsonConvert.DeserializeObject( + Default = Json.Deserialize( File.ReadAllText(PathManager.Inst.PrefsFilePath, Encoding.UTF8)); if(Default == null) { Reset(); @@ -217,43 +217,44 @@ public class SerializablePreferences { public bool LockUnselectedNotesVibrato = true; public bool LockUnselectedNotesExpressions = true; public bool VoicebankPublishUseIgnore = true; - public string VoicebankPublishIgnores = @"#Adobe Audition -*.pkf + public string VoicebankPublishIgnores = """ + #Adobe Audition + *.pkf -#UTAU Engines -*.ctspec -*.d4c -*.dio -*.frc -*.frt -#*.frq -*.harvest -*.lessaudio -*.llsm -*.mrq -*.pitchtier -*.pkf -*.platinum -*.pmk -*.sc.npz -*.star -*.uspec -*.vs4ufrq + #UTAU Engines + *.ctspec + *.d4c + *.dio + *.frc + *.frt + #*.frq + *.harvest + *.lessaudio + *.llsm + *.mrq + *.pitchtier + *.pkf + *.platinum + *.pmk + *.sc.npz + *.star + *.uspec + *.vs4ufrq -#UTAU related tools -\$read -*.setParam-Scache -*.lbp -*.lbp.caches/* + #UTAU related tools + \$read + *.setParam-Scache + *.lbp + *.lbp.caches/* -#OpenUtau -errors.txt -"; + #OpenUtau + errors.txt + """; public string RecoveryPath = string.Empty; public bool DetachPianoRoll = false; // Legacy - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public int? Theme; } } diff --git a/OpenUtau.Core/Vogen/VogenSingerLoader.cs b/OpenUtau.Core/Vogen/VogenSingerLoader.cs index 252325603..9c6f2b73c 100644 --- a/OpenUtau.Core/Vogen/VogenSingerLoader.cs +++ b/OpenUtau.Core/Vogen/VogenSingerLoader.cs @@ -2,8 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; -using Newtonsoft.Json; using OpenUtau.Core.Ustx; using OpenUtau.Core.Util; using Serilog; @@ -76,9 +74,7 @@ public USinger LoadSinger(string filePath) { throw new ArgumentException("missing meta.json"); } using (var stream = metaEntry.OpenEntryStream()) { - using var reader = new StreamReader(stream, Encoding.UTF8); - JsonSerializer serializer = new JsonSerializer(); - meta = (VogenMeta)serializer.Deserialize(reader, typeof(VogenMeta)); + meta = Json.Deserialize(stream); } model = Zip.ExtractBytes(archive, "model.onnx"); if (model == null) { diff --git a/OpenUtau.Core/Voicevox/VoicevoxConfig.cs b/OpenUtau.Core/Voicevox/VoicevoxConfig.cs index 7791b2820..285826ca8 100644 --- a/OpenUtau.Core/Voicevox/VoicevoxConfig.cs +++ b/OpenUtau.Core/Voicevox/VoicevoxConfig.cs @@ -3,7 +3,7 @@ using System.IO; using System.Linq; using System.Text; -using Newtonsoft.Json.Linq; +using System.Text.Json.Nodes; using OpenUtau.Classic; using OpenUtau.Core.Ustx; using OpenUtau.Core.Util; @@ -34,13 +34,13 @@ public class VoicevoxConfig { public static VoicevoxConfig Load(USinger singer) { try { var response = VoicevoxClient.Inst.SendRequest(new VoicevoxURL() { method = "GET", path = "/engine_manifest" }); - var jObj = JObject.Parse(response.Item1); - if (jObj.ContainsKey("detail")) { + var jObj = JsonObject.Parse(response.Item1); + if (jObj?.AsObject().ContainsKey("detail") == true) { var errorMessage = $"Response was incorrect. : {jObj}"; Log.Error(errorMessage); throw new VoicevoxException(errorMessage); } - var manifest = jObj.ToObject(); + var manifest = Json.Deserialize(jObj); manifest.SaveLicenses(singer.Location); } catch (Exception e) { var errorMessage = $"Could not load Licenses.:{e}"; @@ -50,13 +50,13 @@ public static VoicevoxConfig Load(USinger singer) { try { var response = VoicevoxClient.Inst.SendRequest(new VoicevoxURL() { method = "GET", path = "/singers" }); - var jObj = JObject.Parse(response.Item1); - if (jObj.ContainsKey("detail")) { + var jObj = JsonObject.Parse(response.Item1); + if (jObj?.AsObject().ContainsKey("detail") == true) { var errorMessage = $"Response was incorrect. : {jObj}"; Log.Error(errorMessage); throw new VoicevoxException(errorMessage); } - var configs = jObj["json"].ToObject>(); + var configs = Json.Deserialize>(jObj?["json"]); var parentDirectory = Directory.GetParent(singer.Location).ToString(); List vvList = new List(); foreach (RawVoicevoxConfig rowVoicevoxConfig in configs) { @@ -95,11 +95,11 @@ public void LoadInfo(VoicevoxConfig voicevoxConfig, string location) { if (voicevoxConfig.style_infos == null) { var queryurl = new VoicevoxURL() { method = "GET", path = "/singer_info", query = new Dictionary { { "speaker_uuid", voicevoxConfig.speaker_uuid } } }; var response = VoicevoxClient.Inst.SendRequest(queryurl); - var jObj = JObject.Parse(response.Item1); - if (jObj.ContainsKey("detail")) { + var jObj = JsonObject.Parse(response.Item1); + if (jObj?.AsObject().ContainsKey("detail") == true) { Log.Error($"Response was incorrect. : {jObj}"); } else { - var rawSinger_Info = jObj.ToObject(); + var rawSinger_Info = Json.Deserialize(jObj); if (rawSinger_Info != null) { rawSinger_Info.SetInfo(voicevoxConfig, location); } diff --git a/OpenUtau.Core/Voicevox/VoicevoxRenderer.cs b/OpenUtau.Core/Voicevox/VoicevoxRenderer.cs index 3f78878f7..3ea86560e 100644 --- a/OpenUtau.Core/Voicevox/VoicevoxRenderer.cs +++ b/OpenUtau.Core/Voicevox/VoicevoxRenderer.cs @@ -2,11 +2,10 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text.Json.Nodes; using System.Threading; using System.Threading.Tasks; using NAudio.Wave; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using OpenUtau.Core.Format; using OpenUtau.Core.Render; using OpenUtau.Core.Ustx; @@ -117,14 +116,14 @@ public Task Render(RenderPhrase phrase, Progress progress, int tra speaker = style.id; } }); - var queryurl = new VoicevoxURL() { method = "POST", path = "/frame_synthesis", query = new Dictionary { { "speaker", speaker.ToString() } }, body = JsonConvert.SerializeObject(vsParams), accept = "audio/wav" }; + var queryurl = new VoicevoxURL() { method = "POST", path = "/frame_synthesis", query = new Dictionary { { "speaker", speaker.ToString() } }, body = Json.Serialize(vsParams), accept = "audio/wav" }; var response = VoicevoxClient.Inst.SendRequest(queryurl); byte[] bytes = null; if (!response.Item2.Equals(null)) { bytes = response.Item2; } else if (!string.IsNullOrEmpty(response.Item1)) { - var jObj = JObject.Parse(response.Item1); - if (jObj.ContainsKey("detail")) { + var jObj = JsonObject.Parse(response.Item1); + if (jObj?.AsObject().ContainsKey("detail") == true) { Log.Error($"Voice synthesis failed with the VOICEVOX engine. : {jObj}"); } } diff --git a/OpenUtau.Core/Voicevox/VoicevoxUtils.cs b/OpenUtau.Core/Voicevox/VoicevoxUtils.cs index bcd57443e..16bbf63bb 100644 --- a/OpenUtau.Core/Voicevox/VoicevoxUtils.cs +++ b/OpenUtau.Core/Voicevox/VoicevoxUtils.cs @@ -2,8 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; +using System.Text.Json.Nodes; using OpenUtau.Core.Render; using Serilog; @@ -181,15 +180,13 @@ public static class VoicevoxUtils { public static Phoneme_list phoneme_List = new Phoneme_list(); public static VoicevoxSynthParams VoicevoxVoiceBase(VoicevoxQueryMain qNotes, string id) { - var queryurl = new VoicevoxURL() { method = "POST", path = "/sing_frame_audio_query", query = new Dictionary { { "speaker", id } }, body = JsonConvert.SerializeObject(qNotes) }; + var queryurl = new VoicevoxURL() { method = "POST", path = "/sing_frame_audio_query", query = new Dictionary { { "speaker", id } }, body = Json.Serialize(qNotes) }; var response = VoicevoxClient.Inst.SendRequest(queryurl); - VoicevoxSynthParams vvNotes; - var jObj = JObject.Parse(response.Item1); - if (jObj.ContainsKey("detail")) { - Log.Error($"Response was incorrect. : {jObj}"); + var jObj = JsonObject.Parse(response.Item1); + if (jObj?.AsObject().ContainsKey("detail") == true) { + Log.Error($"Response was incorrect. : {jObj["detail"]}"); } else { - vvNotes = jObj.ToObject(); - return vvNotes; + return Json.Deserialize(jObj); } return new VoicevoxSynthParams(); } @@ -254,28 +251,28 @@ public static VoicevoxQueryMain NoteGroupsToVQuery(VoicevoxNote[] vNotes, TimeAx public static List QueryToF0(VoicevoxQueryMain vqMain, VoicevoxSynthParams vsParams, string id) { VoicevoxQueryParams vqParams = new VoicevoxQueryParams() { score = vqMain, frame_audio_query = vsParams }; - var queryurl = new VoicevoxURL() { method = "POST", path = "/sing_frame_f0", query = new Dictionary { { "speaker", id } }, body = JsonConvert.SerializeObject(vqParams) }; + var queryurl = new VoicevoxURL() { method = "POST", path = "/sing_frame_f0", query = new Dictionary { { "speaker", id } }, body = Json.Serialize(vqParams) }; var response = VoicevoxClient.Inst.SendRequest(queryurl); List f0s = new List(); - var jObj = JObject.Parse(response.Item1); - if (jObj.ContainsKey("detail")) { - Log.Error($"Response was incorrect. : {jObj}"); + var jObj = JsonObject.Parse(response.Item1); + if (jObj?.AsObject().ContainsKey("detail") == true) { + Log.Error($"Response was incorrect. : {jObj["detail"]}"); } else { - f0s = jObj["json"].ToObject>(); + f0s = Json.Deserialize>(jObj?["json"]); } return f0s; } public static List QueryToVolume(VoicevoxQueryMain vqMain, VoicevoxSynthParams vsParams, string id) { VoicevoxQueryParams vqParams = new VoicevoxQueryParams() { score = vqMain, frame_audio_query = vsParams }; - var queryurl = new VoicevoxURL() { method = "POST", path = "/sing_frame_volume", query = new Dictionary { { "speaker", id } }, body = JsonConvert.SerializeObject(vqParams) }; + var queryurl = new VoicevoxURL() { method = "POST", path = "/sing_frame_volume", query = new Dictionary { { "speaker", id } }, body = Json.Serialize(vqParams) }; var response = VoicevoxClient.Inst.SendRequest(queryurl); List volumes = new List(); - var jObj = JObject.Parse(response.Item1); - if (jObj.ContainsKey("detail")) { - Log.Error($"Response was incorrect. : {jObj}"); + var jObj = JsonObject.Parse(response.Item1); + if (jObj?.AsObject().ContainsKey("detail") == true) { + Log.Error($"Response was incorrect. : {jObj["detail"]}"); } else { - volumes = jObj["json"].ToObject>(); + volumes = Json.Deserialize>(jObj?["json"]); } return volumes; } diff --git a/OpenUtau.Plugin.Builtin/EnunuOnnx/Scaler.cs b/OpenUtau.Plugin.Builtin/EnunuOnnx/Scaler.cs index 6201fcfe5..a9dcbc5e4 100644 --- a/OpenUtau.Plugin.Builtin/EnunuOnnx/Scaler.cs +++ b/OpenUtau.Plugin.Builtin/EnunuOnnx/Scaler.cs @@ -2,7 +2,7 @@ using System.IO; using System.Linq; using System.Text; -using Newtonsoft.Json; +using OpenUtau.Core; namespace OpenUtau.Plugin.Builtin.EnunuOnnx { public class ScalerLine { @@ -24,7 +24,7 @@ public static Scaler load(string path,Encoding encoding = null) { if (encoding == null) { encoding = Encoding.UTF8; } - return JsonConvert.DeserializeObject( + return Json.Deserialize( File.ReadAllText(path, encoding)); } diff --git a/OpenUtau.Test/OpenUtau.Test.csproj b/OpenUtau.Test/OpenUtau.Test.csproj index d57c9d991..b0a83cafd 100644 --- a/OpenUtau.Test/OpenUtau.Test.csproj +++ b/OpenUtau.Test/OpenUtau.Test.csproj @@ -13,7 +13,6 @@ - diff --git a/OpenUtau/Integrations/VLabelerClient.cs b/OpenUtau/Integrations/VLabelerClient.cs index 2a4525ff4..b105412f2 100644 --- a/OpenUtau/Integrations/VLabelerClient.cs +++ b/OpenUtau/Integrations/VLabelerClient.cs @@ -8,7 +8,6 @@ using K4os.Hash.xxHash; using NetMQ; using NetMQ.Sockets; -using Newtonsoft.Json; using OpenUtau.Core; using Serilog; @@ -86,7 +85,7 @@ private static string HashHex(string s) { private bool Heartbeat() { using (var client = new RequestSocket()) { client.Connect("tcp://localhost:32342"); - string reqStr = JsonConvert.SerializeObject(new HeartbeatRequest()); + string reqStr = Json.Serialize(new HeartbeatRequest()); client.SendFrame(reqStr); if (client.TryReceiveFrameString(TimeSpan.FromMilliseconds(1000), out string? respStr)) { return true; @@ -116,7 +115,7 @@ private void OpenOrCreate(Core.Ustx.USinger singer, Core.Ustx.UOto? oto) { } using (var client = new RequestSocket()) { client.Connect("tcp://localhost:32342"); - string reqStr = JsonConvert.SerializeObject(request); + string reqStr = Json.Serialize(request); client.SendFrame(reqStr); if (!client.TryReceiveFrameString(TimeSpan.FromMilliseconds(1000), out string? respStr)) { Log.Warning($"Failed to OpenOrCreate with vLabeler"); diff --git a/OpenUtau/ViewModels/UpdaterViewModel.cs b/OpenUtau/ViewModels/UpdaterViewModel.cs index ff24dedd2..3549a6037 100644 --- a/OpenUtau/ViewModels/UpdaterViewModel.cs +++ b/OpenUtau/ViewModels/UpdaterViewModel.cs @@ -10,7 +10,6 @@ using NetSparkleUpdater.Enums; using NetSparkleUpdater.Interfaces; using NetSparkleUpdater.SignatureVerifiers; -using Newtonsoft.Json; using OpenUtau.Core; using OpenUtau.Core.Util; using ReactiveUI.Fody.Helpers; @@ -87,7 +86,7 @@ public UpdaterViewModel() { using var resposne = await client.GetAsync("https://api.github.com/repos/stakira/OpenUtau/releases"); resposne.EnsureSuccessStatusCode(); string respBody = await resposne.Content.ReadAsStringAsync(); - List? releases = JsonConvert.DeserializeObject>(respBody); + var releases = Json.Deserialize>(respBody); if (releases == null) { return null; }