Scala 2.11, having the below code:
import play.api.libs.json._ ... val data = // read json from file (3) val JSON: JsValue = Json.parse(data mkString "\n") (4) val items = JSON \ "items" for (i <- 0 until 100) yield items(i)
- if I unite the last two lines
for (i <- 0 until 100) yield (JSON \ "items")(i), will the term
JSON \ "items"be evaluated for each
ior only once?
- is it worth to parallelise the list construction with this
for-expression(I don't care about the order in which items will appear in the list), where
itemsis an array of JSON objects?
- what is the best way to handle exceptions from parsing the JSON in the lines (3 - 4) and validate it?