This repository was archived by the owner on Mar 18, 2024. It is now read-only.
Added inline-serialization example#23
Open
mel4tonin4 wants to merge 4 commits into
Open
Conversation
Member
|
Thank you so much @mel4tonin4 🎉 Sorry for the delayed response. Please, could you update it with Kotlin 1.4.10? Thanks!! |
rachelcarmena
suggested changes
Apr 21, 2021
Member
rachelcarmena
left a comment
There was a problem hiding this comment.
Hi @mel4tonin4 !! Thanks again for your contribution 🙌
Here an updated list of missing changes to include this example:
- Use of latest Kotlin 1.5.0-RC
- Upgrade to Gradle 6.8.3 (required by Kotlin version)
- Update repositories:
- maven { url 'https://oss.jfrog.org/artifactory/oss-snapshot-local/' }
+ maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }- Update the plugin:
- classDeclaration({ isAnnotatedWith<InlineSerializable>() } ) { c ->
+ classDeclaration(this, { isAnnotatedWith<InlineSerializable>() } ) { c ->- Replace the use of deprecated
withName - Update kotlin.serialization dependency version.
Please, let us know if we can help you!
Thanks!!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a small compiler plug-in that generates a serializer for a given class with a single
valargument in the primary constructor which will serialize the class inline. This is typically something that you may want withdata 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
@InlineSerializablewill cause this compiler plug-in to generate a serializer that will serialize the same object as4.5The serializer is also associated with the class.
Note that, while
data classes of this kind are obvious candidates for beinginline classes, currently Kotlin does not support serialization ofinline classes. In my case, this means that I have a plethora ofdata classes waiting to be converted toinline 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.