Udostępnij za pośrednictwem


ApiController.Json Method

 

Namespace:   System.Web.Http
Assembly:  System.Web.Http (in System.Web.Http.dll)

Overload List

Name Description
System_CAPS_protmethod Json<T>(T)

Creates a JsonResult<T> (200 OK) with the specified value.

System_CAPS_protmethod Json<T>(T, JsonSerializerSettings)

Creates a JsonResult<T> (200 OK) with the specified values.

System_CAPS_protmethod Json<T>(T, JsonSerializerSettings, Encoding)

Creates a JsonResult<T> (200 OK) with the specified values.

See Also

ApiController Class
System.Web.Http Namespace

Return to top

ApiController.Json<T> Method (T)

Creates a JsonResult<T> (200 OK) with the specified value.

Syntax

protected internal JsonResult<T> Json<T>(
    T content
)
public protected:
generic<typename T>
JsonResult<T>^ Json(
    T content
)
member Json<'T> : 
        content:'T -> JsonResult<'T>
Protected Friend Function Json(Of T) (
    content As T
) As JsonResult(Of T)

Parameters

  • content
    Type: T

    The content value to serialize in the entity body.

Return Value

Type: System.Web.Http.Results.JsonResult<T>

A JsonResult<T> with the specified value.

Type Parameters

  • T
    The type of content in the entity body.

Return to top

ApiController.Json<T> Method (T, JsonSerializerSettings)

Creates a JsonResult<T> (200 OK) with the specified values.

Syntax

protected internal JsonResult<T> Json<T>(
    T content,
    JsonSerializerSettings serializerSettings
)
public protected:
generic<typename T>
JsonResult<T>^ Json(
    T content,
    JsonSerializerSettings^ serializerSettings
)
member Json<'T> : 
        content:'T *
        serializerSettings:JsonSerializerSettings -> JsonResult<'T>
Protected Friend Function Json(Of T) (
    content As T,
    serializerSettings As JsonSerializerSettings
) As JsonResult(Of T)

Parameters

  • content
    Type: T

    The content value to serialize in the entity body.

  • serializerSettings
    Type: Newtonsoft.Json.JsonSerializerSettings

    The serializer settings.

Return Value

Type: System.Web.Http.Results.JsonResult<T>

A JsonResult<T> with the specified values.

Type Parameters

  • T
    The type of content in the entity body.

Return to top

ApiController.Json<T> Method (T, JsonSerializerSettings, Encoding)

Creates a JsonResult<T> (200 OK) with the specified values.

Syntax

protected internal virtual JsonResult<T> Json<T>(
    T content,
    JsonSerializerSettings serializerSettings,
    Encoding encoding
)
public protected:
generic<typename T>
virtual JsonResult<T>^ Json(
    T content,
    JsonSerializerSettings^ serializerSettings,
    Encoding^ encoding
)
abstract Json<'T> : 
        content:'T *
        serializerSettings:JsonSerializerSettings *
        encoding:Encoding -> JsonResult<'T>
override Json<'T> : 
        content:'T *
        serializerSettings:JsonSerializerSettings *
        encoding:Encoding -> JsonResult<'T>
Protected Friend Overridable Function Json(Of T) (
    content As T,
    serializerSettings As JsonSerializerSettings,
    encoding As Encoding
) As JsonResult(Of T)

Parameters

  • content
    Type: T

    The content value to serialize in the entity body.

  • serializerSettings
    Type: Newtonsoft.Json.JsonSerializerSettings

    The serializer settings.

Return Value

Type: System.Web.Http.Results.JsonResult<T>

A JsonResult<T> with the specified values.

Type Parameters

  • T
    The type of content in the entity body.

Return to top