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.

@JsonProperty field names not respected in superclass fields

See original GitHub issue

Repro: https://bitbucket.org/marshallpierce/repro-jackson-kotlin-inheritance/src/master/

Put briefly, serializing this:

open class SuperClass(@JsonProperty("annotationName") val someCrazyFieldName: String)
class ChildClass(s: String) : SuperClass(s)

results in the following, which uses the field name instead of what’s defined in the annotation

{"someCrazyFieldName":"asdf"}

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
arekolekcommented, Jul 16, 2018

@or-dvir Just using:

open class SuperClass(@get:JsonProperty("annotationName") val someCrazyFieldName: String)
class ChildClass(s: String) : SuperClass(s)

works fine

0reactions
dinomitecommented, Sep 22, 2021

Agreed. The example at the top of this issue is perfect because it has no dependencies beyond those that j-m-k itself uses https://bitbucket.org/marshallpierce/repro-jackson-kotlin-inheritance/src/master/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jackson Serialize Field to Different Name - Stack Overflow
I was looking for a solution to this problem for weeks. But most of the solutions are vague and not flexible enough. In...
Read more >
More Jackson Annotations - Baeldung
This article covers some lesser-known JSON processing annotations provided by Jackson.
Read more >
FieldUtils (Apache Commons Lang 3.12.0 API)
Gets an accessible Field by name respecting scope. Superclasses/interfaces will be considered. Parameters: cls - the Class to reflect, must not be ...
Read more >
Jackson Property Custom Naming Strategy - DZone
This allows us to have a constant name for the properties inspite of ... followed by lowercase ones and there are no separators, ......
Read more >
Json Field Names - Nick Difino
Json Field NamesREST Field Name. in Value section of HTML table but the same approach does ... To exclude fields/getters when writing a...
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