I am trying to iterate over play JsArray as below
for (id <- myJSArray) {
val bn = new Person(new IDM(id.asInstanceOf[String]))
request.add(bn)
}
but the above does not works with for each...error is cannot resolve symbol foreach
You can call the .value
method to access a container that will work with a for loop.
That said, there's hardly any reason to ever do that. Most things with Play-Json can be achieved in better ways. You would have to tell us more about what you're trying to do here – iterating over an array is not a goal, merely a means to an end.