PHP 클래스 Webmozart\Json\JsonDecoder

부터: 1.0
저자: Bernhard Schussek ([email protected])
파일 보기 프로젝트 열기: webmozart/json 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( JsonValidator $validator = null ) Creates a new decoder.
decode ( string $json, string | object $schema = null ) : mixed Decodes and validates a JSON string.
decodeFile ( string $path, string | object $schema = null ) : mixed Decodes and validates a JSON file.
getBigIntDecoding ( ) : integer Returns the decoding of big integers.
getMaxDepth ( ) : integer Returns the maximum recursion depth.
getObjectDecoding ( ) : integer Returns the decoding of JSON objects.
setBigIntDecoding ( integer $decoding ) Sets the decoding of big integers.
setMaxDepth ( integer $maxDepth ) Sets the maximum recursion depth.
setObjectDecoding ( integer $decoding ) Sets the decoding of JSON objects.

비공개 메소드들

메소드 설명
decodeJson ( $json )

메소드 상세

__construct() 공개 메소드

Creates a new decoder.
public __construct ( JsonValidator $validator = null )
$validator JsonValidator

decode() 공개 메소드

If a schema is passed, the decoded object is validated against that schema. The schema may be passed as file path or as object returned from JsonDecoder::decodeFile($schemaFile). You can adjust the decoding with {@link setObjectDecoding()}, {@link setBigIntDecoding()} and {@link setMaxDepth()}. Schema validation is not supported when objects are decoded as associative arrays.
public decode ( string $json, string | object $schema = null ) : mixed
$json string The JSON string
$schema string | object The schema file or object
리턴 mixed The decoded value

decodeFile() 공개 메소드

Decodes and validates a JSON file.
또한 보기: decode
public decodeFile ( string $path, string | object $schema = null ) : mixed
$path string The path to the JSON file
$schema string | object The schema file or object
리턴 mixed The decoded file

getBigIntDecoding() 공개 메소드

Returns the decoding of big integers.
public getBigIntDecoding ( ) : integer
리턴 integer One of the constants {@link FLOAT} and {@link JSON_STRING}

getMaxDepth() 공개 메소드

A depth of zero means that objects are not allowed. A depth of one means only one level of objects or arrays is allowed.
public getMaxDepth ( ) : integer
리턴 integer The maximum recursion depth

getObjectDecoding() 공개 메소드

Returns the decoding of JSON objects.
public getObjectDecoding ( ) : integer
리턴 integer One of the constants {@link JSON_OBJECT} and {@link ASSOC_ARRAY}

setBigIntDecoding() 공개 메소드

By default, big integers are decoded as floats.
public setBigIntDecoding ( integer $decoding )
$decoding integer One of the constants {@link FLOAT} and {@link JSON_STRING}

setMaxDepth() 공개 메소드

If the depth is exceeded during decoding, an {@link DecodingnFailedException} will be thrown. A depth of zero means that objects are not allowed. A depth of one means only one level of objects or arrays is allowed.
public setMaxDepth ( integer $maxDepth )
$maxDepth integer The maximum recursion depth

setObjectDecoding() 공개 메소드

By default, JSON objects are decoded as instances of {@link \stdClass}.
public setObjectDecoding ( integer $decoding )
$decoding integer One of the constants {@link JSON_OBJECT} and {@link ASSOC_ARRAY}