MediaWiki master
MediaWiki\Json\JsonDeserializer Interface Reference

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

Definition at line 33 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.

@phpcs:ignore MediaWiki.Commenting.FunctionComment.ObjectTypeHintParam

Parameters
array | string | object$json
string | null$expectedClassWhat class to expect in deserialization. If null, no expectation. Must be a descendant of JsonDeserializable.
Exceptions
InvalidArgumentExceptionif 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

◆ 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: