From efda62dbeef5f10ca8c2a5e3951b968bb0afcb87 Mon Sep 17 00:00:00 2001
From: PhyxionNL <7643972+PhyxionNL@users.noreply.github.com>
Date: Wed, 17 Sep 2025 16:18:42 +0200
Subject: [PATCH] Drop Newtonsoft.Json
---
.../LibreHardwareMonitor.csproj | 2 +-
LibreHardwareMonitor/Utilities/HttpServer.cs | 36 +++++++------------
2 files changed, 14 insertions(+), 24 deletions(-)
diff --git a/LibreHardwareMonitor/LibreHardwareMonitor.csproj b/LibreHardwareMonitor/LibreHardwareMonitor.csproj
index bc3a6ef..2976d9d 100644
--- a/LibreHardwareMonitor/LibreHardwareMonitor.csproj
+++ b/LibreHardwareMonitor/LibreHardwareMonitor.csproj
@@ -25,7 +25,7 @@
none
-
+
diff --git a/LibreHardwareMonitor/Utilities/HttpServer.cs b/LibreHardwareMonitor/Utilities/HttpServer.cs
index 8788c64..c8f5d04 100644
--- a/LibreHardwareMonitor/Utilities/HttpServer.cs
+++ b/LibreHardwareMonitor/Utilities/HttpServer.cs
@@ -21,7 +21,6 @@ using System.Threading;
using System.Web;
using LibreHardwareMonitor.Hardware;
using LibreHardwareMonitor.UI;
-using Newtonsoft.Json.Linq;
namespace LibreHardwareMonitor.Utilities;
@@ -228,7 +227,7 @@ public class HttpServer
//{"result":"fail","message":"Some error message"}
//or:
//{"result":"ok"}
- private void HandleSensorRequest(HttpListenerRequest request, JObject result)
+ private void HandleSensorRequest(HttpListenerRequest request, Dictionary result)
{
IDictionary dict = ToDictionary(HttpUtility.ParseQueryString(request.Url.Query));
@@ -283,7 +282,7 @@ public class HttpServer
//Currently the only supported base URL is http://localhost:8085/Sensor.
private string HandlePostRequest(HttpListenerRequest request)
{
- JObject result = new() { ["result"] = "ok" };
+ var result = new Dictionary { ["result"] = "ok" };
try
{
@@ -306,11 +305,7 @@ public class HttpServer
result["result"] = "fail";
result["message"] = e.ToString();
}
-#if DEBUG
- return result.ToString(Newtonsoft.Json.Formatting.Indented);
-#else
- return result.ToString(Newtonsoft.Json.Formatting.None);
-#endif
+ return System.Text.Json.JsonSerializer.Serialize(result);
}
private void ListenerCallback(IAsyncResult result)
@@ -391,7 +386,7 @@ public class HttpServer
if (requestedFile.Contains("Sensor"))
{
- JObject sensorResult = new();
+ var sensorResult = new Dictionary();
HandleSensorRequest(request, sensorResult);
SendJsonSensor(context.Response, sensorResult);
return;
@@ -537,7 +532,7 @@ public class HttpServer
private void SendJson(HttpListenerResponse response, HttpListenerRequest request = null)
{
- JObject json = new();
+ Dictionary json = new();
int nodeIndex = 0;
@@ -548,14 +543,9 @@ public class HttpServer
json["Max"] = "Max";
json["ImageURL"] = string.Empty;
- json["Children"] = new JArray { GenerateJsonForNode(_root, ref nodeIndex) };
+ json["Children"] = new List