我有以下失败的测试用例:
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处理这个?
谢谢!