Skip to content

Instantly share code, notes, and snippets.

@AnthonyGiretti
Created January 7, 2026 19:47
Show Gist options
  • Select an option

  • Save AnthonyGiretti/6e64c1817f181e3ac53e0fd78c8d9af2 to your computer and use it in GitHub Desktop.

Select an option

Save AnthonyGiretti/6e64c1817f181e3ac53e0fd78c8d9af2 to your computer and use it in GitHub Desktop.
.NET 10 System.Text.Json and PipeReader support
using System.IO.Pipelines;
using System.Text.Json;
// Produce JSON into a pipeline
var pipe = new Pipe();
_ = Task.Run(async () =>
{
await JsonSerializer.SerializeAsync(pipe.Writer, new Person("Alice"));
await pipe.Writer.CompleteAsync();
});
await pipe.Writer.CompleteAsync();
// Consume JSON directly from PipeReader
Person? person = await JsonSerializer.DeserializeAsync<Person>(pipe.Reader);
Console.WriteLine(person?.Name); // "Alice"
public record Person(string Name);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment