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

Support for registering reference types (when they can't be inferred) #545

Merged
merged 18 commits into from
Sep 21, 2021

Conversation

pjfanning
Copy link
Member

@pjfanning pjfanning commented Sep 20, 2021

  • current code can't handle deserialization for case class OptionLong(valueLong: Option[Long])
    • type erasure of scala.Long (an alias for the java long primitive) causes this
  • You can use java.lang.Long, scala.BigInt or other reference types with no issue
  • You can use Jackson JsonDeserialize annotation to annotate the valueLong field
  • This new support is experimental and you should prefer the existing workarounds
  • ScalaAnnotationIntrospector.registerReferencedType(clazz: Class[_], fieldName: String, referencedType: Class[_]) is the main API for this change
    • in the OptionLong example: ScalaAnnotationIntrospector.registerReferencedValueType(classOf[OptionLong], "valueLong", classOf[Long])

@pjfanning pjfanning marked this pull request as draft September 20, 2021 16:50
@pjfanning
Copy link
Member Author

@Mergifyio rebase

@pjfanning pjfanning marked this pull request as ready for review September 21, 2021 13:50
@pjfanning pjfanning merged commit 0493e50 into 2.13 Sep 21, 2021
@pjfanning pjfanning deleted the option-long-workaround branch September 21, 2021 13:50
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

Successfully merging this pull request may close these issues.

1 participant