I'm passing a Java object to a Web service that accepts json, using HttpURLConnection
.
Employing com.fasterxml.jackson
to convert the object to json string and then writing it to the output stream, the service works fine for simple dummy POJOs, but the application breaks when I use a complex object that I'm originally intend to send,
with the console filled with exceptions like StackOverflow and endless clutter of
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:690) at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:155)
Common solutions are like annotating the class with json annotation. Is there any other way to get around it, like using different accept:content-type for web service (other than json or xml as they require annotated objects) or like that?