【发布时间】:2017-10-20 13:41:27
【问题描述】:
这行得通:
val rpcResponse = Serialization.read[RPCResponse[Map[String, Double]]](call("listaccounts"))
但是这个
val rpcResponse:RPCResponse[Map[String, Double]] = Serialization.read(call("listaccounts"))
给我一个例外:
MappingException: Parsed JSON values do not match with class constructor args=
arg types=
executable=Executable(Constructor(public scala.runtime.Nothing$()))
cause=null
types comparison result=
两种结构不应该以相同的方式工作吗?
编辑:
示例案例类:
case class AA[R](f1: String, f2: R)
和代码:
val rpcResponse: AA[Map[String, Double]] = Serialization.read(
"""
|{
| "f1": "fff",
| "f2": {
| "a":1,
| "b":2
| }
|}
""".stripMargin)
println(rpcResponse)
【问题讨论】:
-
请提供您用于转换等的案例类
-
@Pavel:给你
-
我会假设你在提到 RPCResponse 时使用的是 scala-json-rpc ?
-
@Pavel:不。为什么你认为这很重要?
-
好吧,我正在尝试在本地复制这个问题,在 json4s 中的任何地方都找不到 RPCResponse