PHP Class Ouzo\Utilities\Json

Datei anzeigen Open project: letsdrink/ouzo Class Usage Examples

Public Methods

Method Description
decode ( string $string, boolean $asArray = false ) : mixed Decodes a JSON string, or throws JsonDecodeException on failure
encode ( array | JsonSerializable $value ) : string Returns the JSON representation of the $value
lastError ( ) : integer Returns a JSON error code for the last operation.
safeDecode ( string $string, boolean $asArray = false ) : mixed Decodes a JSON string

Private Methods

Method Description
lastErrorMessage ( )

Method Details

decode() public static method

Decodes a JSON string, or throws JsonDecodeException on failure
public static decode ( string $string, boolean $asArray = false ) : mixed
$string string
$asArray boolean
return mixed

encode() public static method

Returns the JSON representation of the $value
public static encode ( array | JsonSerializable $value ) : string
$value array | JsonSerializable
return string

lastError() public static method

Returns a JSON error code for the last operation.
public static lastError ( ) : integer
return integer

safeDecode() public static method

Decodes a JSON string
public static safeDecode ( string $string, boolean $asArray = false ) : mixed
$string string
$asArray boolean
return mixed