MediaWiki master
MediaWiki\Json\JsonDeserializer Interface Reference

Deserializes things from JSON. More...

Inherited by MediaWiki\Json\JsonCodec.

Public Member Functions

 deserialize ( $json, ?string $expectedClass=null)
 Restore an instance of simple type or JsonDeserializable subclass from the JSON serialization.
 deserializeArray (array $array)
 Helper to deserialize an array of JsonDeserializable instances or simple types.
 unserialize ( $json, ?string $expectedClass=null)
 Backwards-compatibility alias for deserialize().
 unserializeArray (array $array)
 Backwards-compatibility alias for deserializeArray().

Detailed Description

Deserializes things from JSON.

Since
1.36
Deprecated
since 1.45; use JsonCodecInterface

Definition at line 19 of file JsonDeserializer.php.

Member Function Documentation

◆ deserialize()

MediaWiki\Json\JsonDeserializer::deserialize ( $json,
?string $expectedClass = null )

Restore an instance of simple type or JsonDeserializable subclass from the JSON serialization.

It supports passing array/object to allow manual decoding of the JSON string if needed.

Note
JSON objects are unconditionally deserialized as PHP associative arrays, and not as instances of \stdClass.
Parameters
array | string | object$json
string | null$expectedClassWhat class to expect in deserialization. If null, no expectation. Must be a descendant of JsonDeserializable.
Exceptions
JsonExceptionif the passed $json can't be deserialized.
Returns
mixed

Implemented in MediaWiki\Json\JsonCodec.

◆ deserializeArray()

MediaWiki\Json\JsonDeserializer::deserializeArray ( array $array)

Helper to deserialize an array of JsonDeserializable instances or simple types.

Parameters
array$array
Returns
array

Implemented in MediaWiki\Json\JsonCodec.

◆ unserialize()

MediaWiki\Json\JsonDeserializer::unserialize ( $json,
?string $expectedClass = null )

Backwards-compatibility alias for deserialize().

Deprecated
since 1.43

Implemented in MediaWiki\Json\JsonCodec.

◆ unserializeArray()

MediaWiki\Json\JsonDeserializer::unserializeArray ( array $array)

Backwards-compatibility alias for deserializeArray().

Deprecated
since 1.43

Implemented in MediaWiki\Json\JsonCodec.


The documentation for this interface was generated from the following file: