using System.Text.Json;

namespace BrassAndSigil.Server.Services;

/// <summary>
/// Project-wide JSON serializer options. Always case-insensitive on read so that
/// hand-edited config files / API responses don't silently fail to bind a property
/// because of a casing mismatch (e.g. "Command" vs "command", "JavaPath" vs "javaPath").
/// Use this everywhere we call JsonSerializer.Deserialize.
/// </summary>
public static class JsonOpts
{
    public static readonly JsonSerializerOptions CaseInsensitive = new()
    {
        PropertyNameCaseInsensitive = true,
        ReadCommentHandling = JsonCommentHandling.Skip,
        AllowTrailingCommas = true,
    };

    public static readonly JsonSerializerOptions Pretty = new()
    {
        WriteIndented = true,
    };
}
