force jackson mapper to always add class type on writeValue without annotations
jackson, json
Solution
You can do that with enableDefaultTyping() of the ObjectMapper
e.g.
mapper.enableDefaultTyping(DefaultTyping.OBJECT_AND_NON_CONCRETE);
See ObjectMapper API
Problem
Is it possible to configure jackson to always add the type of the serialized object to the generated json output. For example: ``` package org.acme; class ClassA { String a; String b; } ``` and I want the generated json to be: ["org.acme.ClassA",{"a":"str1","b":"str2"}]