Skip to content

Instantly share code, notes, and snippets.

@AnthonyGiretti
Last active January 7, 2026 20:02
Show Gist options
  • Select an option

  • Save AnthonyGiretti/83f0e311820cdc32286efb0e38ec1fdd to your computer and use it in GitHub Desktop.

Select an option

Save AnthonyGiretti/83f0e311820cdc32286efb0e38ec1fdd to your computer and use it in GitHub Desktop.
Before .NET 10 System.Text.Json and deserilization from Stream
using System.IO.Pipelines;
var pipe = new Pipe();
_ = Task.Run(async () =>
{
try
{
await JsonSerializer.SerializeAsync(pipe.Writer, new Person("Alice"));
await pipe.Writer.FlushAsync();
}
finally
{
await pipe.Writer.CompleteAsync();
}
});
var stream = pipe.Reader.AsStream();
var person = await JsonSerializer.DeserializeAsync<Person>(stream);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment