using System.Text.Json; namespace MicroForge.CLI.Extensions; public static class ObjectStreamExtensions { public static async Task SerializeAsync( this object @object, JsonSerializerOptions? jsonSerializerOptions = null ) { using var stream = new MemoryStream(); using var reader = new StreamReader(stream); var options = jsonSerializerOptions ?? Shared.DefaultJsonSerializerOptions.Default; await JsonSerializer.SerializeAsync(stream, @object, options); stream.Position = 0; return await reader.ReadToEndAsync(); } }