Last active
December 27, 2015 17:29
-
-
Save johnlcox/7362881 to your computer and use it in GitHub Desktop.
jackson-scala-module List of case class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it("should deserialize a List of a case class") { | |
case class InListCaseClass(id: Long) | |
val paramTypes = Array(objectMapper.getTypeFactory().constructSimpleType(classOf[InListCaseClass], | |
Array.empty[JavaType])) | |
val listType = objectMapper.getTypeFactory.constructSimpleType(classOf[List[InListCaseClass]], paramTypes) | |
val value = List(InListCaseClass(2), InListCaseClass(5)) | |
val json = """"[{"id":2},{"id":5"}]"""" | |
val list = mapper.readValue(json, listType) | |
list should equal(value) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment