I am using JMS Serializer Bundle and Symfony2. I am using VirtualProperties. I am currently setting the property name using the SerializedName annotation.
/** * @JMS\VirtualProperty() * @JMS\SerializedName("SOME_NAME") */ public function getSomething() { return $this->something }
Is it possible to dynamically set a serialized name inside a function? Or can you dynamically influence a name using Post / Pre serialization events?
Thank!
, , - , , . , null JMS.
, , :
$this->serializer = SerializerBuilder::create()->setPropertyNamingStrategy(new IdenticalPropertyNamingStrategy())->build(); $json = $this->serializer->serialize($object, 'json'); dump($json);