PHP 클래스 yii\helpers\BaseJson

Do not use BaseJson. Use [[Json]] instead.
부터: 2.0
저자: Qiang Xue ([email protected])
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$jsonErrorMessages array List of JSON Error messages assigned to constant names for better handling of version differences

공개 메소드들

메소드 설명
decode ( string $json, boolean $asArray = true ) : mixed Decodes the given JSON string into a PHP data structure.
encode ( mixed $value, integer $options = 320 ) : string Encodes the given value into a JSON string.
htmlEncode ( mixed $value ) : string Encodes the given value into a JSON string HTML-escaping entities so it is safe to be embedded in HTML code.

보호된 메소드들

메소드 설명
handleJsonError ( integer $lastError ) Handles BaseJson::encode and BaseJson::decode errors by throwing exceptions with the respective error message.
processData ( mixed $data, array &$expressions, string $expPrefix ) : mixed Pre-processes the data before sending it to json_encode().

메소드 상세

decode() 공개 정적인 메소드

Decodes the given JSON string into a PHP data structure.
public static decode ( string $json, boolean $asArray = true ) : mixed
$json string the JSON string to be decoded
$asArray boolean whether to return objects in terms of associative arrays.
리턴 mixed the PHP data

encode() 공개 정적인 메소드

The method enhances json_encode() by supporting JavaScript expressions. In particular, the method will not encode a JavaScript expression that is represented in terms of a [[JsExpression]] object.
public static encode ( mixed $value, integer $options = 320 ) : string
$value mixed the data to be encoded.
$options integer the encoding options. For more details please refer to . Default is `JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE`.
리턴 string the encoding result.

handleJsonError() 보호된 정적인 메소드

Handles BaseJson::encode and BaseJson::decode errors by throwing exceptions with the respective error message.
부터: 2.0.6
protected static handleJsonError ( integer $lastError )
$lastError integer error code from [json_last_error()](http://php.net/manual/en/function.json-last-error.php).

htmlEncode() 공개 정적인 메소드

The method enhances json_encode() by supporting JavaScript expressions. In particular, the method will not encode a JavaScript expression that is represented in terms of a [[JsExpression]] object.
부터: 2.0.4
public static htmlEncode ( mixed $value ) : string
$value mixed the data to be encoded
리턴 string the encoding result

processData() 보호된 정적인 메소드

Pre-processes the data before sending it to json_encode().
protected static processData ( mixed $data, array &$expressions, string $expPrefix ) : mixed
$data mixed the data to be processed
$expressions array collection of JavaScript expressions
$expPrefix string a prefix internally used to handle JS expressions
리턴 mixed the processed data

프로퍼티 상세

$jsonErrorMessages 공개적으로 정적으로 프로퍼티

List of JSON Error messages assigned to constant names for better handling of version differences
부터: 2.0.7
public static array $jsonErrorMessages
리턴 array