JsonCodec
Interfaces to serialize and deserialize PHP objects to/from JSON
|
This is a simple class codec used for stdClass
objects.
More...
Public Member Functions | |
toJsonArray ( $obj) | |
Returns a JSON array representing the contents of the given object, that can be deserialized with the corresponding newFromJsonArray() method, using a ::toJsonArray() method on the object itself. | |
newFromJsonArray (string $className, array $json) | |
Creates a new instance of the given class and initializes it from the $json array, using a static method on $className. | |
jsonClassHintFor (string $className, string $keyName) | |
Returns null, to indicate no type hint for any properties in the stdClass value being encoded. | |
Static Public Member Functions | |
static | getInstance () |
Return a singleton instance of this stdClass codec. | |
This is a simple class codec used for stdClass
objects.
|
static |
Return a singleton instance of this stdClass codec.
Wikimedia\JsonCodec\JsonStdClassCodec::jsonClassHintFor | ( | string | $className, |
string | $keyName ) |
Returns null, to indicate no type hint for any properties in the stdClass
value being encoded.
class-string<T> | $className | |
string | $keyName |
Implements Wikimedia\JsonCodec\JsonClassCodec.
Wikimedia\JsonCodec\JsonStdClassCodec::newFromJsonArray | ( | string | $className, |
array | $json ) |
Creates a new instance of the given class and initializes it from the $json array, using a static method on $className.
class-string<T> | $className | |
array | $json |
Implements Wikimedia\JsonCodec\JsonClassCodec.
Wikimedia\JsonCodec\JsonStdClassCodec::toJsonArray | ( | $obj | ) |
Returns a JSON array representing the contents of the given object, that can be deserialized with the corresponding newFromJsonArray() method, using a ::toJsonArray() method on the object itself.
object | $obj | An object of the type handled by this JsonClassCodec |
Implements Wikimedia\JsonCodec\JsonClassCodec.