JsonEncoder
in package
implements
EncoderInterface, DecoderInterface
Encodes JSON data.
Tags
Interfaces, Classes, Traits and Enums
Table of Contents
- FORMAT = 'json'
- $decodingImpl : mixed
- $encodingImpl : mixed
- __construct() : mixed
- decode() : mixed
- Decodes a string into PHP data.
- encode() : string
- Encodes data into the given format.
- supportsDecoding() : bool
- Checks whether the deserializer can decode from given format.
- supportsEncoding() : bool
- Checks whether the serializer can encode to given format.
Constants
FORMAT
public
mixed
FORMAT
= 'json'
Properties
$decodingImpl
protected
mixed
$decodingImpl
$encodingImpl
protected
mixed
$encodingImpl
Methods
__construct()
public
__construct([JsonEncode $encodingImpl = null ][, JsonDecode $decodingImpl = null ]) : mixed
Parameters
- $encodingImpl : JsonEncode = null
- $decodingImpl : JsonDecode = null
Return values
mixed —decode()
Decodes a string into PHP data.
public
decode(mixed $data, mixed $format[, array<string|int, mixed> $context = [] ]) : mixed
Parameters
- $data : mixed
-
Data to decode
- $format : mixed
-
Format name
- $context : array<string|int, mixed> = []
-
Options that decoders have access to
The format parameter specifies which format the data is in; valid values depend on the specific implementation. Authors implementing this interface are encouraged to document which formats they support in a non-inherited phpdoc comment.
Return values
mixed —encode()
Encodes data into the given format.
public
encode(mixed $data, mixed $format[, array<string|int, mixed> $context = [] ]) : string
Parameters
- $data : mixed
-
Data to encode
- $format : mixed
-
Format name
- $context : array<string|int, mixed> = []
-
Options that normalizers/encoders have access to
Return values
string —supportsDecoding()
Checks whether the deserializer can decode from given format.
public
supportsDecoding(mixed $format) : bool
Parameters
- $format : mixed
-
Format name
Return values
bool —supportsEncoding()
Checks whether the serializer can encode to given format.
public
supportsEncoding(mixed $format) : bool
Parameters
- $format : mixed
-
Format name