Customize Jackson ObjectMapper

30 views
Skip to first unread message

kevin.s...@dooapp.com

unread,
May 3, 2016, 9:55:18 AM5/3/16
to wisdom-discuss
Hi,

Is there a way to customize the jackson object mapper used by wisdom?

I need to set the serializer factory on this object.

Thank you in advance for your help

Kevin

Nicolas Delsaux

unread,
May 4, 2016, 11:32:36 AM5/4/16
to wisdom-...@googlegroups.com


Le 03/05/2016 15:55, kevin.s...@dooapp.com a écrit :
> Hi,
>
> Is there a way to customize the jackson object mapper used by wisdom?
>
> I need to set the serializer factory on this object.

hi Kevin

I did a little dig in Wisdom code to find how i worked ...
When you return a Result, and you want that result as json (using the
json method), it is processed by the JSONSerializer object whih do so by
calling the "Json" OSGi service.
This service, in turn, currently has for sole implementation the
JacksonSingleton (which name indicates quite well it is a singleton, I
guess).

Unfortunatly, the Jackson objectMapper class which is used in that Json
service is initialized during the validate method, which make it
absolutely unconfigurable by code as of today. Or is it so ?
Well, in fact, it appear the Json interface has a json#mapper() method,
which provides access to the ObjectMapper itself.

So, how can customization be done if it is not possible in Json class ?
Well, you can use direct annotations
(http://wiki.fasterxml.com/JacksonAnnotations), or even the
mix-annotations
(http://www.cowtowncoder.com/blog/archives/2009/08/entry_305.html). I'm
not sure if they'll work, since they rely upon the serialization config.

kevin.s...@dooapp.com

unread,
May 9, 2016, 4:57:24 AM5/9/16
to wisdom-discuss, nicolas...@gmx.fr
Hi Nicolas,

Thank you for your answer! It was the right way to do it.

Kévin
Reply all
Reply to author
Forward
0 new messages