I have in Scala an array array1 that contains, among other things, another array array2.
Now, I'm trying to replicate the structure in Json using Play. This is my attempt:
var json = JsObject(Seq())
array1.foreach(a1 => {
json += "a1" -> JsNumber(a1.name) +
"a2" -> a1.array2.foreach {
a2 => "a2" -> JsString(a2.name)
}
})
The error I'm getting is type mismatch; found : Unit required: play.api.libs.json.JsValue
How to fix this? thanks in advance.
mapinstead offoreach.foreachis for side-effect operations