|
MediaWiki 1.44.0
|
Inherits Wikimedia\JsonCodec\JsonCodec, MediaWiki\Json\JsonDeserializer, and MediaWiki\Json\JsonSerializer.

Public Member Functions | |
| __construct (?ContainerInterface $services=null) | |
| Create a new JsonCodec, with optional access to the provided services. | |
| 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) | |
Protected Member Functions | |
| codecFor (string $className) | |
| Support the JsonCodecable interface by maintaining a mapping of class names to codecs. | |
| isArrayMarked (array $value) | |
| markArray (array &$value, string $className, ?string $classHint) | |
| unmarkArray (array &$value, ?string $classHint) | |
Definition at line 42 of file JsonCodec.php.
| MediaWiki\Json\JsonCodec::__construct | ( | ?ContainerInterface | $services = null | ) |
Create a new JsonCodec, with optional access to the provided services.
Definition at line 57 of file JsonCodec.php.
|
protected |
Support the JsonCodecable interface by maintaining a mapping of class names to codecs.
| class-string | $className |
Definition at line 67 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 145 of file JsonCodec.php.
Referenced by BenchmarkJsonCodec\execute().
| 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 196 of file JsonCodec.php.
| 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 327 of file JsonCodec.php.
Referenced by BenchmarkJsonCodec\execute().
|
protected |
Definition at line 108 of file JsonCodec.php.
|
protected |
Definition at line 96 of file JsonCodec.php.
References MediaWiki\Json\JsonConstants\COMPLEX_ANNOTATION, and MediaWiki\Json\JsonConstants\TYPE_ANNOTATION.
| 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 206 of file JsonCodec.php.
Referenced by BenchmarkJsonCodec\execute().
|
protected |
Definition at line 121 of file JsonCodec.php.
| MediaWiki\Json\JsonCodec::unserialize | ( | $json, | |
| ?string | $expectedClass = null ) |
Implements MediaWiki\Json\JsonDeserializer.
Definition at line 141 of file JsonCodec.php.
| MediaWiki\Json\JsonCodec::unserializeArray | ( | array | $array | ) |
Implements MediaWiki\Json\JsonDeserializer.
Definition at line 192 of file JsonCodec.php.