-2

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

cchantep
  • 9,118
  • 3
  • 30
  • 41
HDev007
  • 325
  • 2
  • 6
  • 15

1 Answers1

2

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.

Matthias Berndt
  • 4,387
  • 1
  • 11
  • 25