Hi everyone, I got a surprise that Kotlin serializ...
# serialization
f
Hi everyone, I got a surprise that Kotlin serialization doesn’t serialize, defaults values, by default I think it should serialize these values, as it’s kind of unexpected behaviour. Anyone know how I would change
Copy code
@Singleton
class PostServiceWeb
@Inject
constructor(
    properties: AppProperties,
    networkJson: Json,
) : ServiceWeb(
to use a Json that has
Copy code
Json { encodeDefaults = true }
Basically I want to create a default JSON that has this set then it would be injected across the application, or do people change this at the retrofit level, any help would be appreciated
j
Since you are injecting the
Json
instance, find wherever you provide that instance into the dependency graph and replace it with the one you desire.
f
Cool, thanks Jake, I’ve got it sorted now
Copy code
@Provides
@Singleton
fun providesNetworkJson(): Json = Json {
    encodeDefaults = true
}