SmartPipe.Extensions.Http.Json 2.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SmartPipe.Extensions.Http.Json --version 2.2.0
                    
NuGet\Install-Package SmartPipe.Extensions.Http.Json -Version 2.2.0
                    
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="SmartPipe.Extensions.Http.Json" Version="2.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SmartPipe.Extensions.Http.Json" Version="2.2.0" />
                    
Directory.Packages.props
<PackageReference Include="SmartPipe.Extensions.Http.Json" />
                    
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 SmartPipe.Extensions.Http.Json --version 2.2.0
                    
#r "nuget: SmartPipe.Extensions.Http.Json, 2.2.0"
                    
#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 SmartPipe.Extensions.Http.Json@2.2.0
                    
#: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=SmartPipe.Extensions.Http.Json&version=2.2.0
                    
Install as a Cake Addin
#tool nuget:?package=SmartPipe.Extensions.Http.Json&version=2.2.0
                    
Install as a Cake Tool

SmartPipe.Extensions.Http.Json

Bounded, source-generated JSON codecs for SmartPipe.Extensions.Http: streaming root-array and NDJSON response readers, and JSON request content for sinks.

Installation

dotnet package add SmartPipe.Extensions.Http.Json

Package graph

SmartPipe.Extensions.Http.Json depends on SmartPipe.Extensions.Http and SmartPipe.Extensions.Json. It adds no transport of its own, has no Polly or bundle dependency, and has no reflection serialization fallback.

What this package owns

  • HttpJsonResponseReaders.JsonArray<T>(JsonTypeInfo<T>, HttpJsonArrayOptions?) streams the items of a root JSON array.
  • HttpJsonResponseReaders.Ndjson<T>(JsonTypeInfo<T>, HttpNdjsonOptions?) streams newline-delimited JSON records.
  • HttpJsonRequestContent.Post<T>(Uri, JsonTypeInfo<T>) returns an HttpRequestFactory<T> that creates a fresh POST request with a JSON body for every write.
  • HttpJsonPipelineDefinitionBuilderExtensions provides FromHttpJsonArray, FromHttpNdjson, and ToHttpJson for direct and factory clients and for initial and typed builders. They only delegate to FromHttp/ToHttp, with the same return types and key rules.

Metadata snapshot

At composition, each factory copies the caller's JsonSerializerOptions and keeps its source-generated resolver and converters. It then applies the configured MaxDepth, freezes the copy, and captures a private JsonTypeInfo<T>. Runs use that snapshot directly. Your metadata is never changed, and later changes to your options do not affect a composed reader.

A composed reader rejects a null HttpResponseMessage when it is invoked, before enumeration starts. An empty body fails array JSON validation during enumeration; an empty NDJSON body produces an empty sequence. Leading array comments follow the frozen metadata's ReadCommentHandling option.

Limits and policies

Option Default Contract
MaxDepth 64 JSON nesting limit applied to the frozen metadata.
MaxUnframedBytes 256 MiB Total raw body bytes from the stream position at invocation. Counted while reading. Each read asks for at most the remaining budget plus one sentinel byte.
MaxRecordSizeBytes (NDJSON) 16 MiB Maximum encoded size of one line, and so of the memory buffered for it. Must fit a managed byte array.
NullItemPolicy Throw Skip drops a JSON null item at a complete item boundary.
OversizeRecordPolicy (NDJSON) Throw Throw stops once nonblank oversize content is known; Skip drains the oversized line in bounded memory and continues at the next line. The total-body limit still applies.

Exceeding MaxUnframedBytes raises a JsonException. So does invalid array or record JSON, which ends the stream. A root array has only the total-body bound, not a per-element limit, so a single element can use up to that bound. The array reader never builds an unbounded list.

NDJSON framing uses the internal bounded UTF-8 line reader shared with SmartPipe.Extensions.Json (src/Shared/JsonFraming). It handles LF, CRLF, blank lines, a final record with no newline, UTF-8 characters split across reads, and one-byte streams. It never uses StreamReader.ReadLineAsync. Raw records and payloads never appear in exceptions or logs. The readers take no logger, so Skip has no logging side effect.

Trimming and NativeAOT

The full-json-type-info contract covers the source-generated JsonTypeInfo<T> path. The http-json-trim and http-json-nativeaot consumers publish and run an NDJSON source, a JSON POST sink, and a bounded array reader with JsonSerializerIsReflectionEnabledByDefault=false. Reflection serialization is not an advertised path.

Usage

[JsonSerializable(typeof(Order))]
internal sealed partial class OrderJsonContext : JsonSerializerContext;

var definition = HttpJsonPipelineDefinitionBuilderExtensions
    .FromHttpNdjson(
        new PipelineKey("orders"),
        httpClient,
        static (_, _) => ValueTask.FromResult(
            new HttpRequestMessage(HttpMethod.Get, "https://example.test/orders.ndjson")),
        OrderJsonContext.Default.Order,
        new HttpNdjsonOptions { OversizeRecordPolicy = HttpJsonOversizeRecordPolicy.Skip })
    .ToHttpJson(
        clientFactory,
        "orders-sink",
        new Uri("https://example.test/archive"),
        OrderJsonContext.Default.Order,
        idempotencyKeySelector: static envelope => $"order-{envelope.Payload.Id}");

For how the transport handles ownership, timeouts, error previews, and retries, see the SmartPipe.Extensions.Http README.

Product Compatible and additional computed target framework versions.
.NET 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 (1)

Showing the top 1 NuGet packages that depend on SmartPipe.Extensions.Http.Json:

Package Downloads
SmartPipe.Extensions

Compatibility facade and convenience bundle for SmartPipe.Core and its runtime integration packages. New applications should reference specific SmartPipe.Extensions.* packages. Retained 2.1.2 APIs use type forwarding or the frozen legacy DI/Hosting/Health cluster; removed HTTP/Polly APIs require migration and recompilation.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.2.1 149 10/13/2026
2.2.0 958 10/7/2026

First standalone release in 2.2.0. Adds source-generated JSON codecs for streaming HTTP pipelines. Use explicit JsonTypeInfo metadata for trimming and NativeAOT; optional HTTP JSON integration is separate from Core and Json.