-
-
Notifications
You must be signed in to change notification settings - Fork 143
Open
Description
import com.fasterxml.jackson.databind.{ObjectMapper, SerializationFeature}
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import com.fasterxml.jackson.databind.json.{JsonMapper}
case class B(a: String, b: String)
val mapper = JsonMapper.builder().addModule(DefaultScalaModule).build()
mapper.writeValueAsString(B("a", "b"))
// "{\"a\":\"a\",\"b\":\"b\"}"
val s = mapper.writeValueAsString(List(B("a", "b"), B("c", "d")))
// "[{\"a\":\"a\",\"b\":\"b\"},{\"a\":\"c\",\"b\":\"d\"}]"
mapper.readValue(s, classOf[List[B]])
// List(Map("a" -> "a", "b" -> "b"), Map("a" -> "c", "b" -> "d"))
Any attempt to use the values throws a cast error. Unable to cast Map2 to B.
Metadata
Metadata
Assignees
Labels
No labels