我已经编写了这段代码来使用circe来读写josn
import io.circe._, io.circe.generic.auto._, io.circe.parser._, io.circe.syntax._
case class Foo(i: Int)
val f = Foo(10)
val json = f.asJson.toString
val t1 = decode[Foo](json)
Run Code Online (Sandbox Code Playgroud)
这非常有效.但是,如果我创建一个普通的类Bar
class Bar { var i : Int = 0 }
decode[Bar](json)
Run Code Online (Sandbox Code Playgroud)
现在我收到错误
could not find implicit value for evidence parameter of type io.circe.Decoder[$sess.cmd25.Bar]
Run Code Online (Sandbox Code Playgroud)
那么有可能使用普通类并使用Circe从json解码它们吗?
| 归档时间: |
|
| 查看次数: |
891 次 |
| 最近记录: |