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.
Overloads
Json(Object, JsonSerializerOptions, String, Nullable<Int32>) |
Creates a IResult that serializes the specified |
Json(Object, JsonTypeInfo, String, Nullable<Int32>) |
Creates a IResult that serializes the specified |
Json(Object, Type, JsonSerializerContext, String, Nullable<Int32>) |
Creates a IResult that serializes the specified |
Json<TValue>(TValue, JsonSerializerOptions, String, Nullable<Int32>) |
Creates a IResult that serializes the specified |
Json<TValue>(TValue, JsonSerializerContext, String, Nullable<Int32>) |
Creates a IResult that serializes the specified |
Json<TValue>(TValue, JsonTypeInfo<TValue>, String, Nullable<Int32>) |
Creates a IResult that serializes the specified |
Json(Object, JsonSerializerOptions, String, Nullable<Int32>)
- Source:
- Results.cs
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.
Applies to
Json(Object, JsonTypeInfo, String, Nullable<Int32>)
- Source:
- Results.cs
Creates a IResult that serializes the specified data
object to JSON.
public static Microsoft.AspNetCore.Http.IResult Json (object? data, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo, string? contentType = default, int? statusCode = default);
static member Json : obj * System.Text.Json.Serialization.Metadata.JsonTypeInfo * string * Nullable<int> -> Microsoft.AspNetCore.Http.IResult
Public Shared Function Json (data As Object, jsonTypeInfo As JsonTypeInfo, Optional contentType As String = Nothing, Optional statusCode As Nullable(Of Integer) = Nothing) As IResult
Parameters
- data
- Object
The object to write as JSON.
- jsonTypeInfo
- JsonTypeInfo
Metadata about the type to convert.
- 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.
Applies to
Json(Object, Type, JsonSerializerContext, String, Nullable<Int32>)
- Source:
- Results.cs
Creates a IResult that serializes the specified data
object to JSON.
public static Microsoft.AspNetCore.Http.IResult Json (object? data, Type type, System.Text.Json.Serialization.JsonSerializerContext context, string? contentType = default, int? statusCode = default);
static member Json : obj * Type * System.Text.Json.Serialization.JsonSerializerContext * string * Nullable<int> -> Microsoft.AspNetCore.Http.IResult
Public Shared Function Json (data As Object, type As Type, context As JsonSerializerContext, Optional contentType As String = Nothing, Optional statusCode As Nullable(Of Integer) = Nothing) As IResult
Parameters
- data
- Object
The object to write as JSON.
- type
- Type
The type of object to write.
- context
- JsonSerializerContext
A metadata provider for serializable types.
- 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.
Applies to
Json<TValue>(TValue, JsonSerializerOptions, String, Nullable<Int32>)
- Source:
- Results.cs
Creates a IResult that serializes the specified data
object to JSON.
public static Microsoft.AspNetCore.Http.IResult Json<TValue> (TValue? data, System.Text.Json.JsonSerializerOptions? options = default, string? contentType = default, int? statusCode = default);
static member Json : 'Value * System.Text.Json.JsonSerializerOptions * string * Nullable<int> -> Microsoft.AspNetCore.Http.IResult
Public Shared Function Json(Of TValue) (data As TValue, Optional options As JsonSerializerOptions = Nothing, Optional contentType As String = Nothing, Optional statusCode As Nullable(Of Integer) = Nothing) As IResult
Type Parameters
- TValue
Parameters
- data
- TValue
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.
Applies to
Json<TValue>(TValue, JsonSerializerContext, String, Nullable<Int32>)
- Source:
- Results.cs
Creates a IResult that serializes the specified data
object to JSON.
public static Microsoft.AspNetCore.Http.IResult Json<TValue> (TValue? data, System.Text.Json.Serialization.JsonSerializerContext context, string? contentType = default, int? statusCode = default);
static member Json : 'Value * System.Text.Json.Serialization.JsonSerializerContext * string * Nullable<int> -> Microsoft.AspNetCore.Http.IResult
Public Shared Function Json(Of TValue) (data As TValue, context As JsonSerializerContext, Optional contentType As String = Nothing, Optional statusCode As Nullable(Of Integer) = Nothing) As IResult
Type Parameters
- TValue
Parameters
- data
- TValue
The object to write as JSON.
- context
- JsonSerializerContext
A metadata provider for serializable types.
- 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.
Applies to
Json<TValue>(TValue, JsonTypeInfo<TValue>, String, Nullable<Int32>)
- Source:
- Results.cs
Creates a IResult that serializes the specified data
object to JSON.
public static Microsoft.AspNetCore.Http.IResult Json<TValue> (TValue? data, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo, string? contentType = default, int? statusCode = default);
static member Json : 'Value * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> * string * Nullable<int> -> Microsoft.AspNetCore.Http.IResult
Public Shared Function Json(Of TValue) (data As TValue, jsonTypeInfo As JsonTypeInfo(Of TValue), Optional contentType As String = Nothing, Optional statusCode As Nullable(Of Integer) = Nothing) As IResult
Type Parameters
- TValue
Parameters
- data
- TValue
The object to write as JSON.
- jsonTypeInfo
- JsonTypeInfo<TValue>
Metadata about the type to convert.
- 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.