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