我有一个失败的测试用例如下:
解码失败并报错:
我有以下无法通过的测试用例:
case class ActionRequest(action: String, `type`:String, key: String)
"Actions " should " be decoded correctly" in {
val actionJson =
"""[
|{"Action":"view","Type":"Product","Key":"1210"},
|{"action":"filter","type":"by-price","key":"low-hi"}
|]
|""".stripMargin
val actions = decode[List[ActionRequest]](actionJson).right.getOrElse(List())
assert(actions.size == 2)
}
解码失败并报错:
LeftProjection(Left(DecodingFailure([A]List[A], List(DownField(action), DownArray))))
解码器是否可以忽略大小写映射字段?或者使用decoder.prepare以优雅的方式处理这个问题,有什么好方法吗?
谢谢!