class JsonSerializer implements SerializerInterface (View source)

Encodes and decodes data to and from JSON. Decodes to associative arrays by default.

Throws a JsonDecodeException if decoding or encoding fails.

Methods

__construct(JsonEncode $encoder = null, JsonDecode $decoder = null)

No description

mixed
decode(mixed $value)

Deserialize the value.

mixed
encode(mixed $value)

Serialize the value.

static JsonSerializer
make(JsonEncode $encoder = null, JsonDecode $decoder = null)

No description

Details

__construct(JsonEncode $encoder = null, JsonDecode $decoder = null)

No description

Parameters

JsonEncode $encoder

The encoder to use (optional, defaults to a new JsonEncode instance).

JsonDecode $decoder

The decoder to use (optional, defaults to a new JsonDecode instance).

mixed decode(mixed $value)

Deserialize the value.

Parameters

mixed $value

The value to decode.

Return Value

mixed

mixed encode(mixed $value)

Serialize the value.

Parameters

mixed $value

The value to encode.

Return Value

mixed

static JsonSerializer make(JsonEncode $encoder = null, JsonDecode $decoder = null)

No description

Parameters

JsonEncode $encoder

The encoder to use (optional, defaults to a new JsonEncode instance).

JsonDecode $decoder

The decoder to use (optional, defaults to a new JsonDecode instance).

Return Value

JsonSerializer