これが機能しないのはなぜですか?
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 オブジェクトを出力します
{}
「with Greet」を削除すると、(正しい)結果が得られます。
{"id":1,"numbers":[1,2]}