using System.Text.Json;

namespace RpgRoller.Contracts;

public static class RpgRollerJson
{
    public static JsonSerializerOptions CreateSerializerOptions()
    {
        var options = new JsonSerializerOptions(JsonSerializerDefaults.Web);
        Configure(options);
        return options;
    }

    public static void Configure(JsonSerializerOptions options)
    {
        if (!options.TypeInfoResolverChain.Contains(RpgRollerJsonSerializerContext.Default))
            options.TypeInfoResolverChain.Insert(0, RpgRollerJsonSerializerContext.Default);
    }
}