using System.Text.Json;

namespace Common.Extensions
{
    public static class JsonExtensions
    {
        private static JsonSerializerOptions _jso = new() { PropertyNameCaseInsensitive = true, PropertyNamingPolicy = JsonNamingPolicy.CamelCase };
        public static string ToJson<T>(this T source) => JsonSerializer.Serialize(source, _jso);
        public static T FromJson<T>(this string source) => JsonSerializer.Deserialize<T>(source, _jso) ?? default!;
    }
}
