JsonIgnoreProperties depth on a field #184
Replies: 1 comment 2 replies
-
|
You might want to ask over at Kotlin module repo |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am struggling to achieve a piece of behaviour with Jackson in Kotlin.
A minimal example is:
{ "class": "Parent", "parentValue": 1, "childValue": 1, "action": { "class": "Action", "actionValue": 1 } }The fact that
Childmust be a separatedata classtoParent, rather than including its properties directly in the constructor ofParent, is a requirement of the data structure.In this example, I must ignore the value of
classon the@JsonUnwrappedChildinstance, since otherwise there would be a clash when serialising betweenParent.classandParent.base.class. However, using@field:JsonIgnoreProperties("class")also ignores theclassproperty on theaction, meaning that the data serialises to:{ "class": "Parent", "parentValue": 1, "childValue": 1, "action": { "actionValue": 1 } }Is there any way of specifying a property to be ignored using the
@JsonIgnorePropertiesannotation only to a certain depth, or alternatively, by the class type in which it appears? (e.g@field:JsonIgnoreProperties("Child::class"))Beta Was this translation helpful? Give feedback.
All reactions