PHP Класс Webmozart\Json\JsonDecoder

С версии: 1.0
Автор: Bernhard Schussek ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__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}