Hi, I’m trying to implement functionality that exc...
# serialization
m
Hi, I’m trying to implement functionality that excludes the whole object from the serialization if all inner objects are excluded. For example when I want to serialize this data class to json
Copy code
data class Car(val engine: Engine? = null, val size: Size?  = null)
data class Engine(val type: String?  = null, val horsePower: Int?  = null)
data class Size(val size: Int? = null)

Car(engine = Engine(horsePower = null), size = Size(size = 1000))
then I should get the following output (engine is excluded even if it is set)
Copy code
car {
    size {
        size = 1000
    }
}
Does anyone have any tip on how to achieve this?