score:10

Accepted answer

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

val mapper = new ObjectMapper()
mapper.registerModule(DefaultScalaModule)

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)

score:1

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

Related Query

More Query from same tag