23 lines
569 B
C#
23 lines
569 B
C#
using System.Text.Json;
|
|
|
|
namespace ServerLib.RDB.Handlers;
|
|
|
|
public static class HandlerHelper
|
|
{
|
|
public static string Success<T>(T data)
|
|
{
|
|
return JsonSerializer.Serialize(new Response<T> { Success = true, Data = data });
|
|
}
|
|
|
|
public static string Error(string message)
|
|
{
|
|
return JsonSerializer.Serialize(new Response<object> { Success = false, Error = message });
|
|
}
|
|
|
|
public static T? Deserialize<T>(string payload)
|
|
{
|
|
try { return JsonSerializer.Deserialize<T>(payload); }
|
|
catch { return default; }
|
|
}
|
|
}
|