Guides
Tutorials
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)
}
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)
}
public __construct(string $format, null|Symfony\Component\Serializer\Encoder\JsonEncoder $jsonEncoder)
public __construct(string $format, null|Symfony\Component\Serializer\Encoder\JsonEncoder $jsonEncoder)
format | string | |
jsonEncoder | Symfony\Component\Serializer\Encoder\JsonEncoder |
Checks whether the serializer can encode to given format.
public supportsEncoding($format, array $context): bool
public supportsEncoding($format, array $context): bool
format | ||
context | array |
bool
Encodes data into the given format.
public encode($data, $format, array $context): string
public encode($data, $format, array $context): string
data | ||
format | ||
context | array |
string
Checks whether the deserializer can decode from given format.
public supportsDecoding($format, array $context): bool
public supportsDecoding($format, array $context): bool
format | ||
context | array |
bool
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)
public decode($data, $format, array $context)
data | ||
format | ||
context | array |