Added API to DiscordBotCore

This commit is contained in:
2024-11-02 15:43:35 +02:00
parent bd3f79430b
commit f2a9982d41
13 changed files with 343 additions and 17 deletions

View File

@@ -8,6 +8,20 @@ namespace DiscordBotCore.Others;
public static class JsonManager
{
public static async Task<string> ConvertToJsonString<T>(T Data)
{
var str = new MemoryStream();
await JsonSerializer.SerializeAsync(str, Data, typeof(T), new JsonSerializerOptions
{
WriteIndented = false,
});
var result = Encoding.ASCII.GetString(str.ToArray());
await str.FlushAsync();
str.Close();
return result;
}
/// <summary>
/// Save to JSON file
/// </summary>