Preconfigured symfony/serializer for Nette Framework.
- Serialize and deserialize PHP objects to/from JSON
- Handles nested objects and arrays (via PHPDoc annotations)
- Enums support
- Discriminators
- Syntax sugar for Guzzle: Ability to directly deserialize MessageInterface/StreamInterface
- PHP 8.4 or higher
composer require vitek-dev/nette-json-serializer
extensions:
vd.serializer: VitekDev\Serializer\DI\JsonSerializerExtension
Deserialization of class with no properties will end up with NotNormalizableValueException
class Garage {
/**
* @param Car[] $cars
*/
public function __construct(
public array $cars,
) {}
}
class Car {
// No properties
}