I tried a lot to convert my scala list to Json using while loop; the code is as follows:
var json = null
while (list != null) {
json = new Gson().toJson(list)
}
the json variable must be accessed outside of the loop, so I declared it outside of the loop and initialized with null, but the Scala compiler gives me a type mismatch exception...