You can try like this....
var ls: ListBuffer[(String, Map[String, String])] = ListBuffer()
val res = list1.toList.iterator
while (res.hasNext) {
ls += (("id", getMyMap().toMap))
}
println(ls);
ls.toList
ok(write(ls.toMap))
def getMyMap(): scala.collection.mutable.Map[String, String] = {
var m=scala.collection.mutable.Map("Address" -> "strt1", "Mobile" -> 98974)
m
}
:
{"0":{"Address":"strt1","Mobile":"98974"}}