AbstractJsonSerializer

Implements \SerializerInterface

Abstract Json Serializer

Serializers that extend this class should parse and encode entities so that they can be used in the shop's APIs.

Serialization must follow the "null" approach in order to enhance response clarity. That means that serializers must provide a null value than an empty string or an omitted node.

category

System

package

Extensions

subpackage

Serializers

Methods

AbstractJsonSerializer Constructor

__construct() 

If you override this constructor do not forget to call it from the child class.

Deserialize Addon Values

_deserializeAddonValues( $json) : array

Common method for deserializing addon values in various resource serializer classes.

Arguments

$json

Response

array

Deserialize Language Specific Property

_deserializeLanguageSpecificProperty(mixed $object, \stdobject $json, string $property,  $type = 'StringType') 

This method will deserialize the value of a JSON property and set the value to the object by using the corresponding setter method.

Throws
\RuntimeException

If the setter method does not exist.

Arguments

$object

mixed

The object being deserialized.

$json

\stdobject

The JSON object containing the property value.

$property

string

The property name to be deserialized.

$type

Serialize Addon Values

_serializeAddonValues(\KeyValueCollection $addonValues) : array

Common method for serializing addon values in various resource serializer classes.

Arguments

$addonValues

\KeyValueCollection

Response

array

Serialize Language Specific Property

_serializeLanguageSpecificProperty(mixed $object, string $property) : array

In order for this method to work there has to be a proper getter method in the object instance. Otherwise a RuntimeException will be thrown.

Throws
\RuntimeException

If there is no getter for the provided property.

Arguments

$object

mixed

The object instance containing the property.

$property

string

The property name to be serialized.

Response

array

deserialize

deserialize( $string,  $baseObject = null) 
abstract

Arguments

$string

$baseObject

JSON Encode Wrapper

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.

Arguments

$data

array

Contains the data to be JSON encoded.

Response

string

Returns the encoded JSON string that represents the data.

serialize

serialize( $object,  $encode = true) 
abstract

Arguments

$object

$encode

Properties

Used for the resources that require multiple languages.

languageProvider : \LanguageProviderInterface