mennovanhout / laravel-jms
Adds jms serializer to Laravel
Installs: 1 023
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- doctrine/cache: ^2.2.0
- jms/serializer: ^3.18.2
This package is auto-updated.
Last update: 2024-10-20 17:07:57 UTC
README
More info coming soon
Installation
composer require mennovanhout/laravel-jms
Usage
$serializer = app(Serializer::class);
Example
JSON
{ "title": "Hello World!" }
DTO
use JMS\Serializer\Annotation as Serializer; class PaymentDTO { /** * @Serializer\SerializedName("title") * @Serializer\Type("string") * * @var string */ private $title; /** * @return string */ public function getTitle(): string { return $this->title; } }
Deserialize
$serializer = app(Serializer::class); /** @var PaymentDTO */ $paymentDTO = $serializer->deserialize($json, PaymentDTO::class, 'json');
Serialize
$serializer = app(Serializer::class); $json = $serializer->serialize($paymentDTO, 'json');
More info
Annotations: https://jmsyst.com/libs/serializer/master/reference/annotations