1

I have a class that contains a List<Pair<String,String>>. Where pair is Javafx.util.pair

It can serialize just fine, but when Jackson tries to deserialize, It throws the following exception

Cannot construct instance of javafx.util.Pair (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)

I know i could subclass pair and give it a default constructor, but is there a cleaner way to do this with Jackson? Or maybe I should look at another library for serialization?

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
Steve
  • 4,457
  • 12
  • 48
  • 89
  • The cleanest way I can think of is using Jackson's MixIn Annontations. https://github.com/FasterXML/jackson-docs/wiki/JacksonMixInAnnotations At least it sounds like a standard use case. Quote: "Mix-in" annotations are a way to associate annotations with classes, without modifying (target) classes themselves, originally intended to help support 3rd party datatypes where user can not modify sources to add annotations. – Doe Johnson Oct 16 '18 at 15:38

0 Answers0