给定lift-json
2.0 和以下 Scala 类和密封特性:
sealed trait Location
case class Coordinate(latitude: Double,
longitude: Double) extends Location
case class Address(...) extends Location
我希望能够在不确定具体实现的情况下反序列化 Location 对象:
deserialize[Location](""" { "latitude":0.0, "longitude":0.0 } """)
应该产生相当于:
val location: Location = Coordinate(0.0, 0.0)
有什么办法吗?