PHP Class Xpressengine\Support\Json

Author: XE Developers ([email protected])
Show file Open project: xpressengine/xpressengine Class Usage Examples

Public Methods

Method Description
decode ( string $string, boolean $assoc = false, integer $depth = 512, integer $options ) : mixed call json_decode function
encode ( mixed $value, integer $options, integer $depth = 512 ) : string call json_encode function
format ( string $json, boolean $unescapeUnicode, boolean $unescapeSlashes ) : string 주어진 json string을 보기 편하게 정리한다.

Protected Methods

Method Description
exception ( integer $error ) : void message make for version lower then 5.5.0
lastError ( ) : void catch last error and throw exception

Method Details

decode() public static method

call json_decode function
public static decode ( string $string, boolean $assoc = false, integer $depth = 512, integer $options ) : mixed
$string string target for decoding
$assoc boolean when true, object be converted to array
$depth integer recursion depth
$options integer decode option, just support 'JSON_BIGINT_AS_STRING'
return mixed

encode() public static method

call json_encode function
public static encode ( mixed $value, integer $options, integer $depth = 512 ) : string
$value mixed target for encoding
$options integer json behavior constant
$depth integer maximum depth
return string

exception() protected static method

message make for version lower then 5.5.0
protected static exception ( integer $error ) : void
$error integer constant of error type
return void

format() public static method

This code is based on the Composer\Json\JsonFormatter::format(): https://github.com/composer/composer/blob/master/src/Composer/Json/JsonFormatter.php Originally licensed under MIT by Dave Perrett
public static format ( string $json, boolean $unescapeUnicode, boolean $unescapeSlashes ) : string
$json string json string
$unescapeUnicode boolean Un escape unicode
$unescapeSlashes boolean Un escape slashes
return string

lastError() protected static method

catch last error and throw exception
protected static lastError ( ) : void
return void