Class ProductJsonSerializer
This class will serialize and deserialize a Product entity. It can be used into many places where PHP interacts with external requests such as AJAX or API communication.
category |
System |
---|---|
package |
Extensions |
subpackage |
Serializers |
__construct()
If you override this constructor do not forget to call it from the child class.
decodeJson(mixed $string) : array
mixed
The (potential) JSON string
array
The decoded JSON array
deserialize( $string, $baseObject = null)
jsonEncode(array $data) : string
This function provides PHP v5.3 compatibility and it should be used when serialized objects need to be encoded directly from the serializer instance.
array
Contains the data to be JSON encoded.
string
Returns the encoded JSON string that represents the data.
serialize( $object, $encode = true)
serializeProductArray(array $storedProducts, boolean $encode = true) : array|string
array
The array of ProductInterfaces
boolean
Indicates if the result should be returned JSON encoded.
array|string
Either a JSON string or the serialized array (depends on the $encode parameter)