PHP 클래스 yii\web\JsonResponseFormatter

It is used by Response to format response data. To configure properties like [[encodeOptions]] or [[prettyPrint]], you can configure the response application component like the following: php 'response' => [ ... 'formatters' => [ \yii\web\Response::FORMAT_JSON => [ 'class' => 'yii\web\JsonResponseFormatter', 'prettyPrint' => YII_DEBUG, // use "pretty" output in debug mode ... ], ], ],
부터: 2.0
저자: Qiang Xue ([email protected])
상속: extends yii\base\Component, implements yii\web\ResponseFormatterInterface
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$encodeOptions the encoding options passed to [[Json::encode()]]. For more details please refer to . Default is JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE. This property has no effect, when [[useJsonp]] is true.
$prettyPrint whether to format the output in a readable "pretty" format. This can be useful for debugging purpose. If this is true, JSON_PRETTY_PRINT will be added to [[encodeOptions]]. Defaults to false. This property has no effect, when [[useJsonp]] is true.
$useJsonp whether to use JSONP response format. When this is true, the [[Response::data|response data]] must be an array consisting of data and callback members. The latter should be a JavaScript function name while the former will be passed to this function as a parameter.

공개 메소드들

메소드 설명
format ( Response $response ) Formats the specified response.

보호된 메소드들

메소드 설명
formatJson ( Response $response ) Formats response data in JSON format.
formatJsonp ( Response $response ) Formats response data in JSONP format.

메소드 상세

format() 공개 메소드

Formats the specified response.
public format ( Response $response )
$response Response the response to be formatted.

formatJson() 보호된 메소드

Formats response data in JSON format.
protected formatJson ( Response $response )
$response Response

formatJsonp() 보호된 메소드

Formats response data in JSONP format.
protected formatJsonp ( Response $response )
$response Response

프로퍼티 상세

$encodeOptions 공개적으로 프로퍼티

the encoding options passed to [[Json::encode()]]. For more details please refer to . Default is JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE. This property has no effect, when [[useJsonp]] is true.
부터: 2.0.7
public $encodeOptions

$prettyPrint 공개적으로 프로퍼티

whether to format the output in a readable "pretty" format. This can be useful for debugging purpose. If this is true, JSON_PRETTY_PRINT will be added to [[encodeOptions]]. Defaults to false. This property has no effect, when [[useJsonp]] is true.
부터: 2.0.7
public $prettyPrint

$useJsonp 공개적으로 프로퍼티

whether to use JSONP response format. When this is true, the [[Response::data|response data]] must be an array consisting of data and callback members. The latter should be a JavaScript function name while the former will be passed to this function as a parameter.
public $useJsonp