Here's my use case: I need to access to an Array in a JSON document and then iterate on it in order to apply JSON coast-to-coast transformation to each object and get a collection of the transformed object.
I was thinking about an approach like this:
def myTransformerFunc(json: JsValue): JsResult[JsObject] = {}
val results = (res.json \ "results") // access to the the array
val transformedObjects = results.map( myTransformerFunc(_) )
But results
is a JsLookupResult
type and has no .map()
method.
What do I need to do?
Here you go:
val results = (res.json \ "results").as[String]