API to get serializer for a class without creating kotlin reflection class
See original GitHub issueWhat is your use-case and why do you need this feature?
Current experimental API ::kotlin.get().serializer()
implies creating extra kotlin reflection class. That’s not acceptable from a performance point of view in all cases.
Describe the solution you’d like
Could you please provide API to use just a java Class
?
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Obtaining serializer for a class in kotlinx.serialization
Assume that C is a serializable class: @Serializable class C. I have at least four ways of obtaining serializer for this class.
Read more >Serialization | Kotlin
First, make a class serializable by annotating it with @Serializable . import kotlinx.serialization.Serializable @Serializable data class Data( ...
Read more >Android Data Serialization Tutorial with the Kotlin Serialization ...
Integrate the library with Retrofit to interact with an API. Write custom serializers for Kotlin classes. Learn the limitations of the ...
Read more >Using Kotlin - Quarkus
When using Kotlin data classes with native-image you may experience serialization errors that do not occur with the JVM version, despite the Kotlin...
Read more >Object serialization - R3 Documentation
For a Kotlin class, without the @ConstructorForDeserialization annotation, the primary constructor will be selected. In Kotlin, this maps cleanly to a data ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In the new release,it should be enough to use
Type
-based functions, they avoid instantiatingKClass
as much as possibleLet me rephrase it directly: consider we have an API
Class<?>.serializer()
which mirrorsKClass<?>.serializer()
– supports all the types the latter does, instantiatesKClass
for polymorphic serializers and does all the checks required for API to function – whether the class is enum, interface and so on, will such API be useful for you? Are you still going to adopt it?