References JsonEncoder
Reference
C
Class

ApiPlatform\Serializer\JsonEncoder

A JSON encoder with appropriate default options to embed the generated document into HTML.

class ApiPlatform\Serializer\JsonEncoder implements Symfony\Component\Serializer\Encoder\EncoderInterface, Symfony\Component\Serializer\Encoder\DecoderInterface
{
    public __construct(string $format, null|Symfony\Component\Serializer\Encoder\JsonEncoder $jsonEncoder)
    public supportsEncoding($format, array $context): bool
    public encode($data, $format, array $context): string
    public supportsDecoding($format, array $context): bool
    public decode($data, $format, array $context)
}

Methods

__construct

public __construct(string $format, null|Symfony\Component\Serializer\Encoder\JsonEncoder $jsonEncoder)

Parameters

formatstring
jsonEncoderSymfony\Component\Serializer\Encoder\JsonEncoder

supportsEncoding

Checks whether the serializer can encode to given format.

public supportsEncoding($format, array $context): bool

Parameters

format
contextarray

Returns

bool

encode

Encodes data into the given format.

public encode($data, $format, array $context): string

Parameters

data
format
contextarray

Returns

string

supportsDecoding

Checks whether the deserializer can decode from given format.

public supportsDecoding($format, array $context): bool

Parameters

format
contextarray

Returns

bool

decode

Decodes a string into PHP data.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.

public decode($data, $format, array $context)

Parameters

data
format
contextarray

Returns

Made with love by

Les-Tilleuls.coop can help you design and develop your APIs and web projects, and train your teams in API Platform, Symfony, Next.js, Kubernetes and a wide range of other technologies.

Learn more

Copyright © 2023 Kévin Dunglas

Sponsored by Les-Tilleuls.coop