using System.Text.Json; using System.Text.Json.Serialization; namespace SVSim.Bootstrap.Importers; /// /// Reads a JSON seed file under SVSim.Bootstrap/Data/seeds/. Replaces ImporterBase.LoadCapture. /// Files are produced by extractors in data_dumps/extract/; the bootstrap project does not /// transform wire formats. Missing files are non-fatal (returns empty/null) — caller decides. /// public static class SeedLoader { private static readonly JsonSerializerOptions Options = new() { PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower, NumberHandling = JsonNumberHandling.AllowReadingFromString, ReadCommentHandling = JsonCommentHandling.Skip, AllowTrailingCommas = true, }; public static List LoadList(string path) { if (!File.Exists(path)) { Console.Error.WriteLine($"[SeedLoader] Missing seed file: {path}"); return new List(); } using var fs = File.OpenRead(path); return JsonSerializer.Deserialize>(fs, Options) ?? new List(); } public static T? LoadObject(string path) where T : class { if (!File.Exists(path)) { Console.Error.WriteLine($"[SeedLoader] Missing seed file: {path}"); return null; } using var fs = File.OpenRead(path); return JsonSerializer.Deserialize(fs, Options); } }