Table of Contents

Class JsonResult

Namespace
MADE.Web.Mvc.Responses
Assembly
MADE.Web.Mvc.dll

Defines a model for a result of a request that is serialized as JSON.

public class JsonResult : ActionResult, IStatusCodeActionResult, IActionResult
Inheritance
JsonResult
Implements
Inherited Members
Extension Methods

Constructors

JsonResult(object, HttpStatusCode, JsonSerializerOptions?)

Initializes a new instance of the JsonResult class with the object to serialize.

public JsonResult(object value, HttpStatusCode statusCode = HttpStatusCode.OK, JsonSerializerOptions? serializerOptions = null)

Parameters

value object

The value object to serialize.

statusCode HttpStatusCode

The expected result HTTP status code.

serializerOptions JsonSerializerOptions

The JSON serializer options for serializing the result.

Properties

SerializerOptions

Gets the JSON serializer options for serializing the result.

public JsonSerializerOptions? SerializerOptions { get; }

Property Value

JsonSerializerOptions

StatusCode

Gets the expected result HTTP status code.

public int? StatusCode { get; }

Property Value

int?

Value

Gets the value object to serialize.

public object Value { get; }

Property Value

object

Methods

ExecuteResultAsync(ActionContext)

Executes the result operation of the action method asynchronously writing the Value to the response.

public override Task ExecuteResultAsync(ActionContext context)

Parameters

context ActionContext

The context in which the result is executed.

Returns

Task

An asynchronous operation.

Exceptions

ArgumentNullException

Thrown if context is null.