You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dear team, could you please add, or maybe there is already such functionality for ignoring an exception during a calling some property to get its value to serialize. Here is my case my POJO is actually a hibernate proxy and when ObjectMapper reads some of its property there is an SQL Exception, that actually I'd like to ignore and serialize as null rather than get an exception.
I was even trying to add some custom module but it is not working eventually:
.registerModule(SimpleModule().setSerializerModifier(object : BeanSerializerModifier() {
override fun changeProperties(config: SerializationConfig, beanDesc: BeanDescription, properties: List<BeanPropertyWriter>) = properties.map {
object : BeanPropertyWriter(it) {
override fun serializeAsField(bean: Any, gen: JsonGenerator, prov: SerializerProvider) = try {
super.serializeAsField(bean, gen, prov)
} catch (exception: Exception) {
println("ignoring $exception for field $name of $bean instance")
}
}
}
}))
Please give a piece of advice how to handle such case
The text was updated successfully, but these errors were encountered:
Dear team, could you please add, or maybe there is already such functionality for ignoring an exception during a calling some property to get its value to serialize. Here is my case my POJO is actually a hibernate proxy and when ObjectMapper reads some of its property there is an SQL Exception, that actually I'd like to ignore and serialize as null rather than get an exception.
I was even trying to add some custom module but it is not working eventually:
Please give a piece of advice how to handle such case
The text was updated successfully, but these errors were encountered: