Skip to content

Instantly share code, notes, and snippets.

Last active December 27, 2015 17:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
jackson-scala-module List of case class
it("should deserialize a List of a case class") {
case class InListCaseClass(id: Long)
val paramTypes = Array(objectMapper.getTypeFactory().constructSimpleType(classOf[InListCaseClass],
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