鉴于:
import argonaut._
import Argonaut._
def f(c: HCursor): Option[CursorHistory] =
(c --\ "foo").hcursor.map(_.history)
scala> val json = Parse.parse("""{"foo" : 42}""")
json: Either[String,argonaut.Json] = Right({"foo":42})
scala> f(json.right.get.hcursor)
res52: Option[argonaut.CursorHistory] =
Some(CursorHistory(List(El(CursorOpDownField(foo),true))))
scala> res52.get.toList.head
res53: argonaut.CursorOp = El(CursorOpDownField(foo),true)
如何foo
从CursorOp
in获取 JSON 密钥的名称,即res53
?
换句话说,给定一个HCursor
,我想知道List[String]
已经遍历了哪些字段,即 。