using System.Text.Json;

namespace GenshinAssistant.InputHelper;

internal static class NativeScannerFiles
{
    private static readonly JsonSerializerOptions PrettyJson = new(JsonSerializerDefaults.Web)
    {
        WriteIndented = true,
    };

    private static readonly JsonSerializerOptions LineJson = new(JsonSerializerDefaults.Web);

    public static void WriteJson(string path, object payload)
    {
        File.WriteAllText(path, JsonSerializer.Serialize(payload, PrettyJson));
    }

    public static void AppendJsonLine(StreamWriter writer, object payload)
    {
        writer.WriteLine(JsonSerializer.Serialize(payload, LineJson));
        writer.Flush();
    }
}
