I'm using Symfony serializer. It works well.
use Symfony\Component\Serializer\Annotation\Groups;
/**
*
* @Groups({"default", "notification"})
*/
public function getUser()
{
...
}
Is it possible serialise property as another name? So I want to use getUser
in framework, but property should named as profile
in serialised json.
How I can do that?
Edit 19-11-2018, this feature is now available since Symfony 4.2:
/**
* @SerializedName("some_name")
*/
private $lastName;
More information in the doc.
Thanks to Sodj for the reminder.
You can use a custom name converter for that purpose. Every information to achieve this are in this part of the doc.
There is also an issue opened to override property name of the serialized object directly with annotations https://github.com/symfony/symfony/issues/15171
Did you tried, like for JMSserializer, this annotation : @SerializedName("changed_name") - https://jmsyst.com/libs/serializer/master/reference/annotations#serializedname ?