gwt-jackson icon indicating copy to clipboard operation
gwt-jackson copied to clipboard

More (de)serialization customization (JsonFilter or equivalent)

Open gkresic opened this issue 5 years ago • 0 comments

Imagine a class whose getters in some cases throw specific exception. JSON serialization should respond to these exceptions by not serializing given field.

On server, I solved this using com.fasterxml.jackson.databind.ser.PropertyFilter, but I can't find a way to do anything similar in gwt-jackson.

I'm aware that @JsonFilter is not supported, so I tried other approaches but without success.

Exception's stacktrace is: BeanPropertySerializer:93 BeanPropertySerializer:103 AbstractObjectMapper:126

So I tried to find a way to subclass those two classes during generator's run, but I couldn't find a way to inject them instead of BeanPropertySerializer/AbstractObjectMapper:

  • BeanPropertySerializer as default implementation seems to be hardcoded at BeanJsonSerializerCreator:182
  • AbstractObjectMapper as default superclass seems to be hardcoded at AbstractBeanJsonCreator:159

Anything else I could try? Any guidance for creating a patch?

gkresic avatar Jan 17 '20 11:01 gkresic