-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Way to ignore properties from delegate #459
Comments
Interesting idea, I think that we'd be able to do that with some changes in |
I would recommend caution wrt adding such logic in It does sound something that would not necessarily Kotlin-specific (if I understand this correctly), so it could possibly be in databind. One other thing to consider for now is that |
The limitations on If the following is implemented in |
In response to comment from @sandwwraith, I have reviewed this issue again. As for the requested feature, unfortunately I don't think it is important enough to introduce it into First of all, we have had a long time so far, and there does not seem to be a lot of support for this feature request. import com.fasterxml.jackson.annotation.JsonIgnore
import org.junit.jupiter.api.Test
interface I {
val i: Int
}
data class Delegated(val p: I) : I by p
abstract class MixIn : I {
@get:JsonIgnore
abstract override val i: Int
}
class Temp {
@Test
fun test() {
val dto = Delegated(object : I { override val i: Int = 1 })
val mapper = jacksonObjectMapper().addMixIn(Delegated::class.java, MixIn::class.java)
println(mapper.writeValueAsString(dto)) // -> {"p":{"i":1}}
}
} |
I agree that the feature would need to be implemented in |
I'm also looking for a solution to deserialize a data class which is using inheritance by delegation. |
Hi, consider following code:
When using
objectMapper.writeValueAsString(specific)
, result JSON looks like this:Is there a way to ignore all delegated properties from delegate
Base
without specifying every one of them using@JsonIgnoreProperties
? Something like@JsonIgnoreDelegates("baseProps")
would be great. The result should look like this:The text was updated successfully, but these errors were encountered: