I am using circe optics like this
import io.circe.parser._
import io.circe.optics._
import io.circe.optics.JsonPath._
val json = parse("""{"response": {"person": {"firstname": "foo", "lastname":"bar"}}}""").right.get
Now I want to extract the whole person object in string form ... from this json like
val p = root.response.person.string
and then decode it into a case class like
case class Person(firstname: String, lastname: String)
decode[Person](p.getOption(json).get)
But it doesn't work because root.response.person.string
returns null. I think it only works on actual string and integer columns.
So can circe optics be used to extract entire sections of json (for example the person object inside of json)? and then that section is decoded into a case class?