mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 04:22:04 -04:00
Removed Newtonsoft
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace KfChatDotNetBot.Extensions;
|
||||
|
||||
@@ -138,30 +137,4 @@ public static class Extensions
|
||||
{
|
||||
return $"@{user.KfUsername}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserialize a JSON string to the specified type using Newtonsoft.Json
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type to deserialize to</typeparam>
|
||||
/// <param name="jsonString">JSON string to deserialize</param>
|
||||
/// <returns>Deserialized object or null if string is null/empty</returns>
|
||||
public static T? JsonDeserialize<T>(this string? jsonString) where T : class
|
||||
{
|
||||
if (string.IsNullOrEmpty(jsonString))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return JsonConvert.DeserializeObject<T>(jsonString);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serialize an object to JSON string using Newtonsoft.Json
|
||||
/// </summary>
|
||||
/// <param name="obj">Object to serialize</param>
|
||||
/// <returns>JSON string representation</returns>
|
||||
public static string JsonSerialize(this object obj)
|
||||
{
|
||||
return JsonConvert.SerializeObject(obj, Formatting.Indented);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user