为什么这不起作用?json4s无法用mixin特征序列化案例类
object JsonExample extends App {
import org.json4s._
import org.json4s.native.Serialization
import org.json4s.native.Serialization.{read, write}
implicit val formats = Serialization.formats(NoTypeHints)
case class Winner(id: Long, numbers: List[Int])
trait Greet { val greeting = "hi"}
val obj = new Winner(1, List(1,2)) with Greet
println(write(obj))
}
这将打印一个空的JSON对象
{}
而如果我删除了 “以迎接” 我获得(正确)结果:
{"id":1,"numbers":[1,2]}