JMSSerializerBundle
JMSSerializerBundle copied to clipboard
New Feature: support multiple configurations
Currently I need to use the serializer differently at one point in my application, would be excellent if we can declare a default serializer and others with different configurations
Example currently my configuration is
jms_serializer:
enable_short_alias: true
handlers:
datetime:
default_format: 'Y-m-d\TH:i:sO'
default_timezone: America/Bogota
cdata: true
maybe can be
jms_serializer:
default:
enable_short_alias: true
handlers:
datetime:
default_format: 'Y-m-d\TH:i:sO'
default_timezone: America/Bogota
cdata: true
simple:
handlers:
datetime:
default_format: 'Y-m-d'
default_timezone: America/Bogota
cdata: true
in the code
$container->get('serializer'); // return default handler alias to 'serializer_default'
$container->get('serializer_simple') ; // return simple handler
Should the timezone be stored in the context instead? this will make it even more flexible
I have a similar scenario. I some parts of my project I want to use one peculiar visitors configuration:
jms_serializer:
unescaped:
visitors:
json:
options: JSON_UNESCAPED_SLASHES
In order to have some serializations with unescaped strings and other with escaped ones (needed for backward compatibility).
Is it possible to achieve this without multiple configurations?
currently is not possible
My application interact with two 3rd party services. First service have snake_cased fields, second have camelCased fields. It would be great to have multiple serializer configurations.
see https://github.com/schmittjoh/JMSSerializerBundle/pull/831