Development · Native API migration preview · Coverage validation in progress Published release →

API Browser

Module

System.Web.Http.Json

module System.Web.Http.Json

JSON over HTTP

JsonContent and HttpClientJsonExtensions connect HTTP content and client operations to System.Data.Json. Client helpers return HttpError | JsonError, exposing the original alternatives without an aggregation wrapper. GET rejects unsuccessful status as HttpError.UnsuccessfulStatus before JSON decoding. Match the typed alternatives after extracting Error. Nominal error contracts remain useful where their cases add domain meaning.

See Web and JSON. These helpers retain the underlying HTTP and JSON bounds and supported mapping shapes; they do not add a separate transport or unrestricted object serializer.

Content reads are available directly through HttpContentJsonExtensions: ReadFromJson<T>, ReadFromJson(TypeInfo) and ReadJsonNode, each with a cancellation overload. They return tasks containing Result values, preserve JsonError and do not consume buffered content. Pre-cancellation skips conversion. Conversion remains synchronous, strict UTF-8 and bounded by the serializer; streams are unsupported.

HttpContextJsonExtensions.RespondJson configures status 200 or an explicit status with JSON content. Serialization failure leaves the response unchanged. It does not send; Complete retains responsibility for status/body validation and sending.

Native model conversion requires retained reflection metadata, as with JsonSerializer itself. Missing retention can raise a runtime fault before a JsonError is available; the HTTP helpers do not add metadata or catch that fault. DOM conversions avoid model-member reflection.

Types

2 items
HttpJsonError Legacy nominal HTTP/JSON wrapper retained for explicitly declared contracts. Current JSON client helpers return HttpError \| JsonError directly.
JsonContent Shared synchronous JSON conversion for buffered request and response content.

Type extensions

3 items
HttpClientJsonExtensions for HttpClient Buffered JSON client conveniences using the configured HTTP handler.
HttpContentJsonExtensions for HttpContent Asynchronous JSON reads for buffered or streaming request and response content.
HttpContextJsonExtensions for HttpContext JSON response configuration for an accepted server exchange.