1

I have a couple of data classes like below

data class Base (
  val prop1: String,
  val prop2: String
)

data class Derived (
  val base: Base,
  val prop3: String
)

The serialized form of Derived type looks like this

{
  "prop1": "value1",
  "prop2": "value2",
  "prop3": "value3"
}

I can write custom serializers using kotlinx for the derived class, but I'll be having many classes like Derived class which will have a field of Base type. I don't want to write custom serializer and de-serializer for every one of the type.

What options do I have? I'm just looking for more convenient ways to add new types, without writing custom serializers for each of them.

Any other libraries solve this problem? jackson?

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.