question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

API to get serializer for a class without creating kotlin reflection class

See original GitHub issue

What 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:closed
  • Created 2 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
qwwdfsadcommented, Jan 18, 2022

In the new release,it should be enough to use Type-based functions, they avoid instantiating KClass as much as possible

1reaction
qwwdfsadcommented, Jan 10, 2022

Let me rephrase it directly: consider we have an API Class<?>.serializer() which mirrors KClass<?>.serializer() – supports all the types the latter does, instantiates KClass 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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found