using System.Text.Json.Serialization;
using System.Text.Json;

namespace e_suite.Modules.UserManager.Utils;
public static class ObjectExtensions
{
    /// <summary>
    /// Serialize the current object to Json
    /// </summary>
    /// <param name="value"></param>
    /// <returns></returns>
    public static string ToJson(this object value, bool writeIndented = true)
    {
        var options = new JsonSerializerOptions
        {
            WriteIndented = writeIndented,
            DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
        };
        return JsonSerializer.Serialize(value, options);
    }
}