{
"location":{
"residents":[{
"renting":[{
"name":"John Doe"
"pets":"2"
},{
"name":"Jane Smith"
"pets":"2"
}]
}]
}
}
I can successfully traverse location with this -
val json = ...
val rentReads = (__ \ 'location).read[String]
val rentResult = json.validate[String](rentReads)
rentResult match {
case s: JsSuccess[String] => Ok(s.get)
case e: JsError => Ok("Errors: " + JsError.toFlatJson(e).toString())
}
Based on the documentation, I should be able to do something like this -
val skillReads = ((__ \ 'location) \ 'residents)(0).read[String]
but it results in the following error -
Errors: {"obj.VariationResultsWrapper.VariationResultSets[0]":[{"msg":"error.path.missing","args":[]}]}
At this point I'm just trying to understand how to return values from "renting" only. Eventually, I would like to map that result to a case class.