Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMS Serializer: how to use camel case for properties

I'm using FOS Rest bundle and JMS Serializer to create a REST Api. The problem is I would like to keep the property names in the JSON response camel cased instead of using _.

For example, I have a property called employeeIdentifier, by default that gets converted to employee_identifier.

I saw that there's an option in the config to disable the lowercase and get rid of the _, but then it becomes EmployeeIdentifier.

Is there any way that JMS Serializer keeps the original name of the property? Thanks in advance

like image 395
petekaner Avatar asked Apr 20 '17 20:04

petekaner


Video Answer


1 Answers

Worked for me (Symfony 4.4 and JMS ^3.8) with this config in config/packages/jms_serializer.yaml :

jms_serializer:
    property_naming:
        id: jms_serializer.identical_property_naming_strategy

and removing the cache manually

https://github.com/schmittjoh/serializer/issues/1037

like image 79
Kvn91 Avatar answered Sep 17 '22 09:09

Kvn91