Skip to content

Instantly share code, notes, and snippets.

@johnlcox
Last active December 27, 2015 17:29
Show Gist options
  • Save johnlcox/7362881 to your computer and use it in GitHub Desktop.
Save johnlcox/7362881 to your computer and use it in GitHub Desktop.
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],
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