This is a small compiler plug-in that generates a serializer for a given class with a single val argument in the primary constructor which will serialize the class inline. This is typically something that you may want with data classes of this kind:
data class TimeSec(val value : Double)
An instance of this class would be serialized to JSON as something like
{ "value": 4.5 }
Marking the class with @InlineSerializable will cause this compiler plug-in to generate a serializer that will serialize the same object as
4.5
The serializer is also associated with the class.
Note that, while data classes of this kind are obvious candidates for being inline classes, currently Kotlin does not support serialization of inline classes. In my case, this means that I have a plethora of data classes waiting to be converted to inline classes as soon as that limitation is removed.
Feel free to include this example in your repository, if you find any value in it.
This is my first pull request. I'm at your disposal, in case you need any changes.
This is a small compiler plug-in that generates a serializer for a given class with a single
val
argument in the primary constructor which will serialize the class inline. This is typically something that you may want withdata class
es of this kind:data class TimeSec(val value : Double)
An instance of this class would be serialized to JSON as something like
{ "value": 4.5 }
Marking the class with
@InlineSerializable
will cause this compiler plug-in to generate a serializer that will serialize the same object as4.5
The serializer is also associated with the class.
Note that, while
data class
es of this kind are obvious candidates for beinginline class
es, currently Kotlin does not support serialization ofinline class
es. In my case, this means that I have a plethora ofdata class
es waiting to be converted toinline class
es as soon as that limitation is removed.Feel free to include this example in your repository, if you find any value in it.
This is my first pull request. I'm at your disposal, in case you need any changes.