Juner.Sequence 1.0.0-preview-2

This is a prerelease version of Juner.Sequence.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Juner.Sequence --version 1.0.0-preview-2
                    
NuGet\Install-Package Juner.Sequence -Version 1.0.0-preview-2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Juner.Sequence" Version="1.0.0-preview-2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Juner.Sequence" Version="1.0.0-preview-2" />
                    
Directory.Packages.props
<PackageReference Include="Juner.Sequence" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Juner.Sequence --version 1.0.0-preview-2
                    
#r "nuget: Juner.Sequence, 1.0.0-preview-2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Juner.Sequence@1.0.0-preview-2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Juner.Sequence&version=1.0.0-preview-2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Juner.Sequence&version=1.0.0-preview-2&prerelease
                    
Install as a Cake Tool

Juner.Sequence

A high-performance, AOT-friendly JSON sequence serializer for .NET.

Juner.Sequence provides streaming serialization and deserialization for sequence-based JSON formats such as:

  • JSON Lines (.jsonl)
  • JSON Text Sequences (RFC 7464, RS-delimited)

It is designed with System.IO.Pipelines and System.Text.Json in mind, focusing on:

  • ๐Ÿš€ High performance (minimal allocations)
  • ๐Ÿ”’ AOT compatibility (no reflection by default)
  • ๐Ÿ”„ True streaming via IAsyncEnumerable<T>

โœจ Features

  • Fully streaming (no full buffering required)
  • JsonTypeInfo<T>-based (AOT safe)
  • Supports JSON Lines and JSON Sequence formats
  • Works directly with PipeReader / PipeWriter
  • Optional extensions for:
    • Encoding support
    • JsonSerializerOptions compatibility

๐Ÿ“ฆ Installation

dotnet add package Juner.Sequence

๐Ÿš€ Quick Start

Serialize

await SequenceSerializer.SerializeAsync(
    writer,
    asyncEnumerable,
    jsonTypeInfo,
    SequenceSerializerOptions.JsonLines,
    cancellationToken);

Deserialize

await foreach (var item in SequenceSerializer.DeserializeAsyncEnumerable(
    reader,
    jsonTypeInfo,
    SequenceSerializerOptions.JsonLines,
    cancellationToken))
{
    Console.WriteLine(item);
}

๐Ÿ”‘ AOT-Friendly Design

This library is built around:

JsonTypeInfo<T>

instead of JsonSerializerOptions.

Why?

  • No runtime reflection
  • Works with Native AOT
  • Better performance and predictability

โš ๏ธ Optional: JsonSerializerOptions Support

You can opt-in to JsonSerializerOptions support:

using Juner.Sequence.Extensions.Json;

Example:

await SequenceSerializer.SerializeAsync(
    writer,
    asyncEnumerable,
    jsonSerializerOptions,
    SequenceSerializerOptions.JsonLines);

โš ๏ธ These APIs are not AOT-safe and may use reflection.


๐ŸŒ Encoding Support

By default, the library operates in UTF-8.

To use other encodings:

using Juner.Sequence.Extensions;

await SequenceSerializer.SerializeAsync(
    writer,
    asyncEnumerable,
    jsonTypeInfo,
    SequenceSerializerOptions.JsonLines,
    Encoding.UTF8);

Internally, this uses a transcoding stream.


๐Ÿ“š Supported Formats

JSON Lines

{"id":1}
{"id":2}

JSON Text Sequence (RFC 7464)

RS {"id":1}
RS {"id":2}

๐Ÿงฑ Architecture

Juner.Sequence
 โ”œ Core (AOT-safe)
 โ”‚   โ”” JsonTypeInfo<T> APIs
 โ”‚
 โ”œ Extensions
 โ”‚   โ”” Encoding support
 โ”‚
 โ”” Extensions.Json
     โ”” JsonSerializerOptions support (โš  not AOT-safe)

๐Ÿงช Example with PipeReader

var reader = PipeReader.Create(stream);

await foreach (var item in SequenceSerializer.DeserializeAsyncEnumerable(
    reader,
    jsonTypeInfo,
    SequenceSerializerOptions.JsonLines))
{
    // process item
}

๐Ÿ“Œ When to Use

Use this library when:

  • Processing large JSON streams
  • Building high-performance APIs
  • Targeting Native AOT
  • Working with pipelines or streaming systems

โš ๏ธ When NOT to Use

  • Small payloads โ†’ use JsonSerializer
  • Reflection-heavy scenarios โ†’ use JsonSerializerOptions directly

๐Ÿ“„ License

MIT License


๐Ÿ™Œ Contributing

Contributions are welcome!
Feel free to open issues or pull requests.


๐Ÿ’ก Notes

  • Prefer JsonTypeInfo<T> for best performance and AOT safety
  • Use extensions only when necessary
  • Keep streaming โ€” avoid buffering
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Juner.Sequence:

Package Downloads
Juner.AspNetCore.Sequence

Streaming JSON support for ASP.NET Core (NDJSON, JSON Lines, JSON Sequence). Also supports JSON arrays as non-streaming input/output for convenience. Provides Minimal API and MVC integration with content negotiation and OpenAPI support.

Juner.Http.Sequence

Streaming JSON sequence support for HttpClient and HttpContent. Send and receive NDJSON, JSON Lines, and JSON Sequence using IAsyncEnumerable<T>. Built on System.Text.Json and the Juner.Sequence core serializer.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 154 3/30/2026
1.0.0-preview-2 136 3/26/2026