JsonEncode
in package
implements
EncoderInterface
Encodes JSON data.
Tags
Table of Contents
Interfaces
Constants
- OPTIONS = 'json_encode_options'
Properties
- $defaultContext : mixed
Methods
- __construct() : mixed
- encode() : string
- Encodes data into the given format.
- supportsEncoding() : bool
- Checks whether the serializer can encode to given format.
Constants
OPTIONS
public
mixed
OPTIONS
= 'json_encode_options'
Properties
$defaultContext
private
mixed
$defaultContext
= [self::OPTIONS => 0]
Methods
__construct()
public
__construct([array<string|int, mixed> $defaultContext = [] ]) : mixed
Parameters
- $defaultContext : array<string|int, mixed> = []
encode()
Encodes data into the given format.
public
encode(mixed $data, string $format[, array<string|int, mixed> $context = [] ]) : string
Parameters
- $data : mixed
-
Data to encode
- $format : string
-
Format name
- $context : array<string|int, mixed> = []
-
Options that normalizers/encoders have access to
Return values
stringsupportsEncoding()
Checks whether the serializer can encode to given format.
public
supportsEncoding(string $format) : bool
Parameters
- $format : string
-
Format name