Jackson 3rd Party Class without a default constructor

I am trying to use Jackson to read / write my POJOs to / from Json. At the moment, I have configured and worked for my classes, with the exception of the third class. When I try to read in Json, I get an error:

org.codehaus.jackson.map.JsonMappingException: No suitable constructor found for type 

After some quick google searches, it seems like my class needs either a default constructor or override the default constructor with annotations . Unfortunately, the class in which this occurs belongs to a third-party library, and this class does not have a default constructor, and I obviously cannot rewrite the code.

So my question is: is there anything I can do about this or am I just out of luck?

Thank.

+26
java json jackson
Aug 07 2018-12-12T00:
source share
1 answer

You can use the Jackson Mix-Ins function , in combination with the Creator function . The Mix-Ins function eliminates the need to annotate the original third-party code, and the Creator function provides a mechanism for creating custom instances.

For even greater customization, it is not too important to write a custom deserializer .

+22
Aug 07 '12 at 2:30
source share



All Articles