How to customize serialization behavior without annotations in Salat?

女生的网名这么多〃 提交于 2019-12-13 00:55:26

问题


I'm using Salat library to serialize objects to be stored in MongoDb via Casbah. Sometimes I need to tune little bit how fields will be serialized, and Salat's Annotations is a pretty convenient way to do it.

BUT, Is there any way to describe serialization parameters(Key, Ignore etc) not directly in case-classes(models) via Annotations, but in some external point, to keep my models clear from Salat dependency(aka POJO/POCO)?


回答1:


Yes, you can add custom serialization logic to your Salat context.

Example from Salat unit tests:

WibbleTransformer

Custom context with custom transformers added



来源:https://stackoverflow.com/questions/26545841/how-to-customize-serialization-behavior-without-annotations-in-salat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!