Libraries
    Preparing search index...

    Class JsonResult<TStatus, TBody>

    Serializes a value and writes it as JSON with content-type: application/json, bypassing content negotiation entirely.

    Created by ActionResult.json(). ActionResult.ok() and ActionResult.created() produce a JsonResult that goes through content negotiation instead.

    Type Parameters

    • TStatus extends number = number
    • TBody = unknown

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    body: TBody
    headers: Record<string, string>
    status: TStatus

    Methods

    • Parameters

      • _req: IncomingMessage
      • res: ServerResponse
      • _contentNegotiator: ContentNegotiator

      Returns Promise<void>

    • Send a file buffer as a download attachment.

      Parameters

      • content: Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike>
      • fileName: string
      • contentType: string = 'application/octet-stream'

      Returns FileResult

    • Explicit JSON response with a specific status code. Use the named factories (ok, notFound, etc.) for common codes. This overload is an escape hatch for uncommon status codes.

      Type Parameters

      • T

      Parameters

      • body: T

      Returns JsonResult<200, T>

    • Explicit JSON response with a specific status code. Use the named factories (ok, notFound, etc.) for common codes. This overload is an escape hatch for uncommon status codes.

      Type Parameters

      • S extends number
      • T

      Parameters

      • body: T
      • status: S
      • Optionalheaders: Record<string, string>

      Returns JsonResult<S, T>