java - Deserialing Guava class with custom comparator using Jackson -
i using guava treemultiset in 1 of classes field needs serialized/deserialized sorted multiset. using custom comparator build treemultiset:
private sortedmultiset<userfavcatsnode> ms = treemultiset.create(new customcomparator());
serialization seems working fine, deserialization fails jackson not have access custom comparator build treemuliset instance. how i pass comparator instance while deserializing?
i searched , found 2 options:
implement comparable interface. works, imposing custom ordering on class unsatisfactory. i tried around writing wrapper class based on post (http://jackson-users.ning.com/forum/topics/de-serialize-treeset-by-first-defining-a-comparator), , calling using @jsondeserialize annotationpublic constructor(@jsondeserialize(as = customtreemultiset.class) field) { // }
this strategy fails because guava treemultiset final , cannot implement customtreemultiset extends provide wrapper deserialization class. there improve solution infuse custom ordering logic class?
java json jackson guava fasterxml
No comments:
Post a Comment