Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deriving external serializer for another Kotlin class #2895

Open
melvinotieno opened this issue Jan 6, 2025 · 1 comment
Open

Deriving external serializer for another Kotlin class #2895

melvinotieno opened this issue Jan 6, 2025 · 1 comment

Comments

@melvinotieno
Copy link

I have a third party class that is generated as the following

data class Example (
    property: String
)

data class AnotherExample (
    property: Example
)

I want to serialize the class AnotherExample so I am doing it as below

@OptIn(ExperimentalSerializationApi::class)
@Serializer(forClass = AnotherExample::class)
object AnotherExampleSerializer

However, during compilation, I am getting the error Serializer for element of type Example has not been found. Going by this, I need to create another custom serializer but this time for Example, which I have done the same way as I did for AnotherExample class. Problem is, how do I link the two given they are both 3rd party classes?

@sandwwraith
Copy link
Member

There is currently no such feature. Perhaps if you use @file:UseSerializers annotation, it can be picked by the plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants