Results.Json Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates a IResult that serializes the specified data object to JSON.
public static Microsoft.AspNetCore.Http.IResult Json (object? data, System.Text.Json.JsonSerializerOptions? options = default, string? contentType = default, int? statusCode = default);
static member Json : obj * System.Text.Json.JsonSerializerOptions * string * Nullable<int> -> Microsoft.AspNetCore.Http.IResult
Public Shared Function Json (data As Object, Optional options As JsonSerializerOptions = Nothing, Optional contentType As String = Nothing, Optional statusCode As Nullable(Of Integer) = Nothing) As IResult
Parameters
- data
- Object
The object to write as JSON.
- options
- JsonSerializerOptions
The serializer options to use when serializing the value.
- contentType
- String
The content-type to set on the response.
Returns
The created JsonHttpResult<TValue> that serializes the specified data
as JSON format for the response.
Remarks
Callers should cache an instance of serializer settings to avoid recreating cached data with each call.