FasterXML / FasterXML/jackson-module-kotlin

Way to ignore properties from delegate

Aperta
#459 6 commenti 1 reazione 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Kotlin
Stelle
1.2k
Fork
187
Merge medio
9h 48m
PR unite (30g)
16

Descrizione

Hi, consider following code:

```kotlin
data class Base(
@JsonProperty("prop1") val prop1: String,
@JsonProperty("prop2") val prop2: String
)

data class Specific(
@JsonProperty("baseProps") val baseProps: Base,
@JsonProperty("prop3") val prop3: String
) : Base by baseProps
```

When using `objectMapper.writeValueAsString(specific)`, result JSON looks like this:

```json
{
"@type": "Specific",
"baseProps": {
"@type": "Base",
"prop1": "value1",
"prop2": "value2"
},
"prop1": "value1",
"prop2": "value2",
"prop3": "value3"
}
```

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:

```json
{
"@type": "Specific",
"baseProps": {
"@type": "Base",
"prop1": "value1",
"prop2": "value2"
},
"prop3": "value3"
}
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.