JMSSerializerBundle icon indicating copy to clipboard operation
JMSSerializerBundle copied to clipboard

Ability to use multiple visitors for same format

Open AlexeyKosov opened this issue 8 years ago • 1 comments

I need to have the serializer to treat null values as an empty string for some models (but not globally) and an obvious solution is to write a custom visitor implementing visitNull. But the only way I see to use the custom visitor is to redefine the visitor service class parameter, which affects the whole project rather than selected entities. I cannot use a custom handler for that because the GraphNavigator resets the data type and type arguments if the value is null.

So, is there any option to use a custom visitor only for selected entities or maybe there's another way to customize null-serialization behavior?

AlexeyKosov avatar Jun 27 '17 15:06 AlexeyKosov

an obvious solution is to write a custom visitor implementing visitNull.

Why not just implement a custom exclusion strategy?

This (https://github.com/schmittjoh/serializer/pull/790) has been merged recently.. can it be helpful?

goetas avatar Jul 09 '17 22:07 goetas