From 49741a951153efee7927e52d8785e8662fe1bc8e Mon Sep 17 00:00:00 2001 From: James Thompson Date: Wed, 22 May 2024 08:24:52 +1000 Subject: [PATCH] #205 Move to System.Text.Json from Newtonsoft --- jsnlog/Infrastructure/LogMessageHelpers.cs | 8 ++++---- jsnlog/JSNLog.ClassLibrary.nuspec | 14 +++++++------- jsnlog/JSNLog.nuspec | 12 ++++++------ jsnlog/jsnlog.csproj | 7 ++----- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/jsnlog/Infrastructure/LogMessageHelpers.cs b/jsnlog/Infrastructure/LogMessageHelpers.cs index 60e8127a..5993a695 100644 --- a/jsnlog/Infrastructure/LogMessageHelpers.cs +++ b/jsnlog/Infrastructure/LogMessageHelpers.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using Newtonsoft.Json; +using System.Text.Json; namespace JSNLog.Infrastructure { @@ -8,14 +8,14 @@ internal class LogMessageHelpers { public static T DeserializeJson(string json) { - T result = JsonConvert.DeserializeObject(json); + T result = JsonSerializer.Deserialize(json); return result; } public static bool IsPotentialJson(string msg) { string trimmedMsg = msg.Trim(); - return (trimmedMsg.StartsWith("{") && trimmedMsg.EndsWith("}")); + return (trimmedMsg.StartsWith("{") && trimmedMsg.EndsWith("}")); } /// @@ -71,7 +71,7 @@ public static bool IsJsonString(string msg) /// /// Takes a log message and finds out if it contains a valid JSON string. /// If so, returns it unchanged. - /// + /// /// Otherwise, surrounds the string with quotes (") and escapes the string for JavaScript. /// /// diff --git a/jsnlog/JSNLog.ClassLibrary.nuspec b/jsnlog/JSNLog.ClassLibrary.nuspec index 88f7c22c..f0b4d960 100644 --- a/jsnlog/JSNLog.ClassLibrary.nuspec +++ b/jsnlog/JSNLog.ClassLibrary.nuspec @@ -1,7 +1,7 @@ - JSNLog.ClassLibrary + JSNLog.ClassLibrary 0.0.0 JSNLog.ClassLibrary - Class library for JSNLog Matt Perdeck @@ -19,7 +19,7 @@ * JSNLog * CommonLogging - a copy of JSNLog, except for the id. * JSNLog.ClassLibrary.nuspec - does not copy contents files or the readme.txt file, and does not depend on WebActivatorEx. For use in class libraries. - + The CommonLogging NuGet package and the JSNLog package have the same dependencies and files. This because CommonLogging is purely a convenience package - JSNLog already builds on Common.Logging, so it is not really needed. Only reason it is there @@ -30,9 +30,9 @@ in the other as well. --> - - + - + diff --git a/jsnlog/JSNLog.nuspec b/jsnlog/JSNLog.nuspec index c4d86373..d1fe2490 100644 --- a/jsnlog/JSNLog.nuspec +++ b/jsnlog/JSNLog.nuspec @@ -1,7 +1,7 @@ - JSNLog + JSNLog 0.0.0 JSNLog - JavaScript Logging Package Matt Perdeck @@ -31,9 +31,9 @@ - - + - + diff --git a/jsnlog/jsnlog.csproj b/jsnlog/jsnlog.csproj index ed0e2854..a7dc640d 100644 --- a/jsnlog/jsnlog.csproj +++ b/jsnlog/jsnlog.csproj @@ -39,22 +39,19 @@ + - - - - true readme.txt - +