Accepted answer

In order to make it work, you need to register DefaultScalaModule with the object mapper:

val mapper = new ObjectMapper()

Also, you need to update your case class and provide Jackson with property name to field name binding:

case class Person(@JsonProperty("DP-Name") name: String, 
                  @JsonProperty("DP-Age") age: Int, 
                  @JsonProperty("DP-height") height: Int, 
                  @JsonProperty("DP-weight") weight: Int)


  • The problem is you have not registered DefaultScalaModule with ObjectMapper.
lazy val mapper = new ObjectMapper() with ScalaObjectMapper
  • Please find a working and detailed answer which I have provided using generics here.

Related Query

More Query from same tag