Skip to content

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 force-pushed the option-long-workaround branch from 30eaa53 to ec3df12 Compare September 20, 2021 18:37
@pjfanning pjfanning force-pushed the option-long-workaround branch from 9ad9d70 to 8bd6978 Compare September 20, 2021 19:25
@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