Jackson ObjectMapper set JsonFormat.Shape.ARRAY without annotation

Viewed 2686

I need to use two jackson 2 object mappers. Both mappers work with the same set of classes. In the first I need to use standard serialization. In the second i want to use ARRAY shape type for all classes (see https://fasterxml.github.io/jackson-annotations/javadoc/2.2.0/com/fasterxml/jackson/annotation/JsonFormat.Shape.html#ARRAY).

But i want to global set this feature for my second ObjectMapper. Something like mapper.setShape(...)

How to do it?

UPD:

I found a way to override the config for the class:

mapper.configOverride(MyClass.class)
   .setFormat(JsonFormat.Value.forShape(JsonFormat.Shape.ARRAY));

So I can change for all my classes using Reflection API.

It is embarrassing that I override the global setting, but I can not directly set it.

1 Answers
Related