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

@JsonNames does not work on enums #1458

Closed
DavyHubrecht opened this issue May 7, 2021 · 0 comments
Closed

@JsonNames does not work on enums #1458

DavyHubrecht opened this issue May 7, 2021 · 0 comments
Assignees

Comments

@DavyHubrecht
Copy link

Describe the bug

The @JsonNames annotation to provide alternative names when decoding json does not work on enums.

To Reproduce

Create an enum with @JsonNames, for example:

@Serializable
enum class SomeEnum {
    @JsonNames("someValue", "some_value", "test")
    SOME_VALUE
}

Trying to decode a json with one of the JsonNames will result in a SerializationException:
kotlinx.serialization.SerializationException: com.zorabots.mqtt.model.filtering.SomeEnum does not contain element with name 'someValue'

Expected behavior

"SOME_VALUE", "someValue", "some_value" or "test" should work, instead of only "SOME_VALUE".

Environment

  • Kotlin version: 1.5.0
  • Library version: 1.2.0
  • Kotlin platforms: JVM
  • Gradle version: 6.1.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants