| | | 1 | | using System.Text.Json; |
| | | 2 | | using ArturRios.Data.Export.Configuration; |
| | | 3 | | |
| | | 4 | | namespace ArturRios.Data.Export.Exporters; |
| | | 5 | | |
| | | 6 | | /// <summary>Serializes the collection as a JSON array via System.Text.Json.</summary> |
| | | 7 | | /// <typeparam name="T">The record type.</typeparam> |
| | | 8 | | /// <param name="options">JSON options.</param> |
| | 5 | 9 | | public class JsonExporter<T>(JsonOptions options) : ExporterBase<T> where T : class |
| | | 10 | | { |
| | | 11 | | /// <inheritdoc /> |
| | | 12 | | protected override Task WriteCoreAsync(IEnumerable<T> data, Stream destination, CancellationToken ct) |
| | 3 | 13 | | { |
| | 3 | 14 | | var serializerOptions = options.SerializerOptions ?? new JsonSerializerOptions { WriteIndented = options.WriteIn |
| | 3 | 15 | | return JsonSerializer.SerializeAsync(destination, data, serializerOptions, ct); |
| | 3 | 16 | | } |
| | | 17 | | } |