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

@JsonProperty ignored when used in super-class constructor #706

Closed
1 task done
Queatz opened this issue Aug 21, 2023 · 1 comment
Closed
1 task done

@JsonProperty ignored when used in super-class constructor #706

Queatz opened this issue Aug 21, 2023 · 1 comment
Labels

Comments

@Queatz
Copy link

Queatz commented Aug 21, 2023

Search before asking

  • I searched in the issues and found nothing similar.

Describe the bug

I could not for the life of me figure out why my field was always deserializing as null (I'm using ArangoDB which uses Jackson internally.) After learning a bit about Jackson I had a hunch that it was something to do with the property alias, which ultimately was the cause.

Fails:

@Serializable
class B : A()

@Serializable
open class A(
    @JsonProperty("_a")
    @JsonAlias("a")
    var a: String? = null
)

Gives: UnrecognizedPropertyException: Unrecognized field "_a" (class com.queatz.B), not marked as ignorable (one known property: "a"])

Moving the property out of the constructor makes everything okay:

@Serializable
class B : A()

@Serializable
open class A {
    @JsonProperty("_a")
    @JsonAlias("a")
    var a: String? = null
}

This correctly deserializes _a

To Reproduce

No response

Expected behavior

No response

Versions

Kotlin: 1.8.21
Jackson-module-kotlin: latest
Jackson-databind: latest

Additional context

No response

@k163377
Copy link
Contributor

k163377 commented Aug 23, 2023

There are no plans to fix this issue.
Please see #658 for more information.

Close as a duplicate.

@k163377 k163377 closed this as completed Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants