3

I found this thread proposing a neat way of overriding globally the default naming strategy in config.yml

but this is for symfony 3 and I am on symfony 4 so I added the line to my config > packages > jms_serializer.yaml but this has no effect at all.

jms_serializer:
  visitors:
    xml_serialization:
        format_output: '%kernel.debug%'
  property_naming:
    id: 'jms_serializer.identical_property_naming_strategy'

Does anyone understand why ?

I do dependency injection of SerializerInterface $serializer to use the serializer as it is not possible to call the service from AbstractController in SF4. Controller is deprecated in SF4.

Sam
  • 1,557
  • 3
  • 26
  • 51

2 Answers2

6

Try removing var/cache manually. When I cleared cache with cache:clear command it didn't work, but after I cleaned it manually it did!

I hope this solution will help you too.

Dawid Góra
  • 165
  • 2
  • 14
-1

Add jms_serializer.camel_case_naming_strategy.class: JMS\Serializer\Naming\IdenticalPropertyNamingStrategy to your parameters configuration.

Bart McLeod
  • 151
  • 2
  • 6