https://kotlinlang.org logo
#server
Title
# server
f

Fred Bowker

03/06/2024, 1:39 PM
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
not kotlin but kotlin colored 1
v

Vampire

03/06/2024, 1:51 PM
Please don't cross-post to multiple channels, that wastes the time of anyone reading the message multiple times and splits discussions. Pick one appropriate channel according to name and subject and at most post a link in other channels if you really feel you need more attention. @spand how is a question about Kotlin serialization not-kotlin? Besides that this is not the right channel.
s

spand

03/06/2024, 1:52 PM
He is asking how to perform dependency injection no ?
🤷‍♂️ 1
f

Fred Bowker

03/06/2024, 1:53 PM
thanks for your reply, I hadn’t realized there was a serialization channel initially, will ensure to not cross-post in the future, cheers
👌 2