JMS Serializer: how to use camel case for properties

后端 未结 4 1646
广开言路
广开言路 2021-01-12 00:20

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

4条回答
  •  礼貌的吻别
    2021-01-12 00:47

    Having upgraded jms/serilizer-bundle from 1.1 to 2.2 the parameter hack described above did not work. You can override the service definition as follows:

    #app/config/services.yml
    services:
        ....
        jms_serializer.serialized_name_annotation_strategy:
            class: JMS\Serializer\Naming\SerializedNameAnnotationStrategy
            arguments:
                - '@jms_serializer.identical_property_naming_strategy'
    

提交回复
热议问题