Given:
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)
How can I get the JSON keys' names, i.e. foo
, from the CursorOp
in res53
?
In other words, given an HCursor
, I'd like to know which fields, i.e. List[String]
, have been traversed.