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
I have run into a situation where I need to serialize a data class, but one of the properties is nullable, and I need to NOT include that property if the value is null.
@Serializable
data class Operation(
val op: OperationType, // enumeration
val pathString: String,
@Optional val value: String? = null
) {}
When serialized, this gives a json object with three properties.
Ideally, there would be an annotation similar to @Transient like @TransientIfNull.
If there is a way to do this with a CustomSerializer, that would be great, too. Thank you.
The text was updated successfully, but these errors were encountered:
I have run into a situation where I need to serialize a data class, but one of the properties is nullable, and I need to NOT include that property if the value is null.
When serialized, this gives a json object with three properties.
Ideally, there would be an annotation similar to
@Transient
like@TransientIfNull
.If there is a way to do this with a CustomSerializer, that would be great, too. Thank you.
The text was updated successfully, but these errors were encountered: