Juner.Http.Sequence
1.0.0
dotnet add package Juner.Http.Sequence --version 1.0.0
NuGet\Install-Package Juner.Http.Sequence -Version 1.0.0
<PackageReference Include="Juner.Http.Sequence" Version="1.0.0" />
<PackageVersion Include="Juner.Http.Sequence" Version="1.0.0" />
<PackageReference Include="Juner.Http.Sequence" />
paket add Juner.Http.Sequence --version 1.0.0
#r "nuget: Juner.Http.Sequence, 1.0.0"
#:package Juner.Http.Sequence@1.0.0
#addin nuget:?package=Juner.Http.Sequence&version=1.0.0
#tool nuget:?package=Juner.Http.Sequence&version=1.0.0
Juner.Http.Sequence
HTTP streaming for record-oriented JSON formats in .NET.
It enables end-to-end streaming from HTTP transport to application code, without buffering the entire payload.
This allows true streaming pipelines over HTTP with minimal allocations.
Juner.Http.Sequence integrates Juner.Sequence with HttpContent and HttpRequestMessage,
providing end‑to‑end streaming support for formats such as:
- NDJSON (
application/x-ndjson) - JSON Lines (
application/jsonl) - JSON Text Sequences (RFC 7464,
application/json-seq)
These formats represent a sequence of independent JSON values, allowing incremental processing without loading the entire payload.
Installation
dotnet add package Juner.Http.Sequence
Quick Start
JsonSerializerContext (AOT‑safe)
[JsonSerializable(typeof(MyType))]
public partial class MyJsonContext : JsonSerializerContext { }
Reading (streaming)
Assuming you obtained an HttpContent from HttpResponseMessage:
Core API (AOT‑safe)
await foreach (var item in content.ReadSequenceEnumerable(
MyJsonContext.Default.MyType,
SequenceSerializerOptions.JsonLines,
cancellationToken))
{
Console.WriteLine(item);
}
Format‑specific shortcuts
await foreach (var item in content.ReadJsonLinesAsyncEnumerable(
MyJsonContext.Default.MyType))
{
...
}
await foreach (var item in content.ReadJsonSequenceAsyncEnumerable(
MyJsonContext.Default.MyType))
{
...
}
Notes
- Uses
PipeReader.Create(stream)internally - Throws
ArgumentExceptionifoptions.IsInvalid - Fully streaming: no buffering of the entire HTTP payload
- Backpressure is naturally handled via
IAsyncEnumerable
Writing (streaming)
Core API (AOT‑safe)
var request = new HttpRequestMessage(HttpMethod.Post, url)
.WithSequenceContent(
source,
MyJsonContext.Default.MyType,
SequenceSerializerOptions.JsonLines,
"application/jsonl");
The content type should match the selected sequence format.
Format‑specific shortcuts
request.WithJsonLinesContent(source, MyJsonContext.Default.MyType);
request.WithJsonSequenceContent(source, MyJsonContext.Default.MyType);
request.WithNdJsonContent(source, MyJsonContext.Default.MyType);
Notes
- Uses
PipeWriter.Create(stream)internally - Does not compute content length (
TryComputeLengthreturns false) - Streaming is performed record‑by‑record
- Suitable for chunked transfer encoding
AOT‑Friendly Design
All AOT‑safe APIs require:
JsonTypeInfo<T>
This avoids runtime reflection and ensures compatibility with Native AOT.
Optional Extensions
JsonSerializerOptions Support — not guaranteed AOT‑safe
Reading
await foreach (var item in content.ReadSequenceEnumerable(
jsonSerializerOptions,
SequenceSerializerOptions.JsonLines))
{
...
}
Writing
request.WithSequenceContent(
source,
jsonSerializerOptions,
SequenceSerializerOptions.JsonLines,
"application/jsonl");
Notes
- Uses
JsonSerializerOptions.TypeInfoResolver - Throws if metadata for
Tis not found - Not AOT‑safe
- On .NET 7 or earlier,
DefaultJsonTypeInfoResolveris assigned automatically if missing
JsonSerializerOptions.Default Support — explicitly not AOT‑safe
Reading
await foreach (var item in content.ReadJsonLinesAsyncEnumerable())
{
...
}
Writing
request.WithJsonLinesContent(source);
These APIs:
- Use
JsonSerializerOptions.Default - Are annotated with:
RequiresUnreferencedCodeRequiresDynamicCode
- Are convenience wrappers around the JsonSerializerOptions APIs
- Not AOT‑safe
non‑generic JsonTypeInfo Support — advanced use only
Reading
await foreach (var item in content.ReadSequenceEnumerable(
(JsonTypeInfo)jsonTypeInfo,
SequenceSerializerOptions.JsonLines))
{
...
}
Writing
request.WithSequenceContent(
source,
(JsonTypeInfo)jsonTypeInfo,
SequenceSerializerOptions.JsonLines,
"application/jsonl");
Notes
- Throws if the provided
JsonTypeInfodoes not matchT - Not AOT‑safe
- Provided only for advanced scenarios
Supported Formats
The following formats are supported:
| Format | Content-Type | Notes |
|---|---|---|
| NDJSON | application/x-ndjson | newline‑delimited |
| JSON Lines | application/jsonl | equivalent to NDJSON |
| JSON Sequence | application/json-seq | RFC 7464 (RS‑delimited) |
About JSON Array (application/json)
JSON arrays are already well supported by standard JSON APIs.
Juner.Http.Sequence focuses on record-oriented streaming formats, and does not provide support for JSON arrays.
If you need to read or write JSON arrays, use:
HttpContent.ReadFromJsonAsync<T[]>()
or the standard JsonSerializer.
Architecture
The library is built as a thin HTTP layer on top of Juner.Sequence:
graph TD;
A[Juner.Sequence<br/>Core]
B[Juner.Http.Sequence]
A --> B
B --> C[HttpContent Extensions]
B --> D[HttpRequestMessage Extensions]
B --> E[JsonSerializerOptions Extensions<br/>(not AOT‑safe)]
B --> F[JsonSerializerOptions.Default Extensions<br/>(explicitly not AOT‑safe)]
B --> G[JsonTypeInfo (non‑generic)<br/>Advanced]
When to Use
- Consuming large streaming JSON responses
- Real‑time event streams over HTTP
- High‑performance pipelines
- Native AOT applications
- Avoiding buffering entire HTTP payloads
When NOT to Use
- Small payloads →
HttpContent.ReadFromJsonAsyncis simpler - JSON arrays → use standard JSON APIs
- Native AOT scenarios → avoid
JsonSerializerOptions.Default(not AOT‑safe)
License
MIT
| Product | Versions 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. |
-
net10.0
- Juner.Sequence (>= 1.0.0)
-
net7.0
- Juner.Sequence (>= 1.0.0)
-
net8.0
- Juner.Sequence (>= 1.0.0)
-
net9.0
- Juner.Sequence (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 79 | 3/30/2026 |
| 1.0.0-preview-2 | 77 | 3/26/2026 |