MediaWiki master
|
Inherits MediaWiki\Json\JsonDeserializer, and MediaWiki\Json\JsonSerializer.
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. | |
detectNonSerializableData ( $value, bool $expectDeserialize=false) | |
Checks if the $value is JSON-serializable (contains only scalar values) and returns a JSON-path to the first non-serializable property encountered. | |
serialize ( $value) | |
Encode $value as JSON with an intent to use JsonDeserializer::unserialize to decode it back. | |
unserialize ( $json, ?string $expectedClass=null) | |
unserializeArray (array $array) | |
Public Member Functions inherited from MediaWiki\Json\JsonDeserializer | |
unserialize ( $json, string $expectedClass=null) | |
Backwards-compatibility alias for deserialize() | |
Definition at line 37 of file JsonCodec.php.
MediaWiki\Json\JsonCodec::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.
@phpcs:ignore MediaWiki.Commenting.FunctionComment.ObjectTypeHintParam
array | string | object | $json | |
string | null | $expectedClass | What class to expect in deserialization. If null, no expectation. Must be a descendant of JsonDeserializable. |
InvalidArgumentException | if the passed $json can't be deserialized. |
Implements MediaWiki\Json\JsonDeserializer.
Definition at line 44 of file JsonCodec.php.
References MediaWiki\Json\JsonCodec\deserializeArray(), MediaWiki\Json\FormatJson\FORCE_ASSOC, MediaWiki\Json\FormatJson\parse(), and MediaWiki\Json\JsonConstants\TYPE_ANNOTATION.
Referenced by BenchmarkJsonCodec\execute(), and MediaWiki\Json\JsonCodec\unserialize().
MediaWiki\Json\JsonCodec::deserializeArray | ( | array | $array | ) |
Helper to deserialize an array of JsonDeserializable instances or simple types.
array | $array |
Implements MediaWiki\Json\JsonDeserializer.
Definition at line 102 of file JsonCodec.php.
References MediaWiki\Json\JsonConstants\COMPLEX_ANNOTATION.
Referenced by MediaWiki\Json\JsonCodec\deserialize().
MediaWiki\Json\JsonCodec::detectNonSerializableData | ( | $value, | |
bool | $expectDeserialize = false ) |
Checks if the $value is JSON-serializable (contains only scalar values) and returns a JSON-path to the first non-serializable property encountered.
mixed | $value | |
bool | $expectDeserialize | whether to expect the $value to be deserializable with JsonDeserializer. |
Definition at line 305 of file JsonCodec.php.
Referenced by BenchmarkJsonCodec\execute().
MediaWiki\Json\JsonCodec::serialize | ( | $value | ) |
Encode $value as JSON with an intent to use JsonDeserializer::unserialize to decode it back.
mixed | JsonDeserializable | $value | A value to encode. Can be any scalar, array, stdClass, JsonDeserializable or any combination of them. |
InvalidArgumentException | if the value can not be serialized. |
Implements MediaWiki\Json\JsonSerializer.
Definition at line 161 of file JsonCodec.php.
Referenced by BenchmarkJsonCodec\execute().
MediaWiki\Json\JsonCodec::unserialize | ( | $json, | |
?string | $expectedClass = null ) |
Definition at line 40 of file JsonCodec.php.
References MediaWiki\Json\JsonCodec\deserialize().
MediaWiki\Json\JsonCodec::unserializeArray | ( | array | $array | ) |
Implements MediaWiki\Json\JsonDeserializer.
Definition at line 98 of file JsonCodec.php.