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

SerialDescriptor serialName is not respected #2923

Open
rcaceiro opened this issue Feb 6, 2025 · 1 comment
Open

SerialDescriptor serialName is not respected #2923

rcaceiro opened this issue Feb 6, 2025 · 1 comment

Comments

@rcaceiro
Copy link

rcaceiro commented Feb 6, 2025

Describe the bug
I have the necessity of build a custom KSerializer, when I try to use your builders I cannot specify the serial name, like the sample below:

override val descriptor: SerialDescriptor = mapSerialDescriptor(
            keyDescriptor = ,
            valueDescriptor = ,
        )

When I try the snippet below the serial name is ignored also:

               private val mSerializer = MapSerializer(
            keySerializer = Scope.serializer(),
            valueSerializer = SetSerializer(elementSerializer = UuidSerializer),
        )
        override val descriptor: SerialDescriptor = SerialDescriptor("custom_name", this.mSerializer.descriptor)

Expected behavior
Or I can pass in the serial name in mapSerialDescriptor and similars, or I can override the serial name with SerialDescriptor

I didn't update yet to 1.8.0 because I am using Ktor 3.0.3 and Ktor uses Kotlinx serialization 1.7.3 and when I tried to update it throws an exception.

Environment

  • Kotlin version: 2.1.0
  • Library version: 1.7.3
  • Kotlin platforms: JVM
  • Gradle version: 8.11.1
  • Other relevant context JVM 21
@pdvrieze
Copy link
Contributor

pdvrieze commented Feb 6, 2025

@rcaceiro Creating custom list/map serializers does not work well. The reason is that some formats on decoding actually have to go in to the serializer type to access the "append"/update functionality. Obviously this special casing is not supported for custom serializers.

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