I have the following code in my main activity:
var qNa_list = parseQuestions(loadJSONFromAsset("qna_list.json"))
fun loadJSONFromAsset(file_name:String): String? {
var json: String? = null
try {
val isis = assets.open(file_name)
val size = isis.available()
val buffer = ByteArray(size)
isis.read(buffer)
isis.close()
json = String(buffer, "UTF-8")
} catch (ex: IOException) {
ex.printStackTrace()
return null
}
return json
}
When I try to compile it I get the following error.
I fixed some other errors caused due to nullables, but this one is something I'm unable to decode.
Error:(127, 35) Type mismatch: inferred type is String but Charset was expected
I have changed some of the values to nullable to accomidate for the errors, but the json = String(buffer, "UTF-8")
(UTF-8) is always underlined in red.