JSONResponse
extends Response
in package
A renderer for JSON calls
Tags
Table of Contents
Properties
- $data : T
- response data
Methods
- __construct() : mixed
- constructor of JSONResponse
- getData() : T
- render() : string
- Returns the rendered json
- setData() : JSONResponse
- Sets values in the data json array
Properties
$data
response data
protected
T
$data
Methods
__construct()
constructor of JSONResponse
public
__construct([T $data = [] ][, S $statusCode = Http::STATUS_OK ][, H $headers = [] ]) : mixed
Parameters
- $data : T = []
-
the object or array that should be transformed
- $statusCode : S = Http::STATUS_OK
-
the Http status code, defaults to 200
- $headers : H = []
Tags
getData()
public
getData() : T
Tags
Return values
T —the data
render()
Returns the rendered json
public
render() : string
Tags
Return values
string —the rendered json
setData()
Sets values in the data json array
public
setData(T $data) : JSONResponse
Parameters
- $data : T
-
an array or object which will be transformed to JSON
Tags
Return values
JSONResponse —Reference to this object