Kotlin how to Map JSONArray to Type (Stream)
问题 I'm trying to map my JSONArray to a Array<String?> . I'm doing it like this: fun getTextResponse(responseJson: JSONObject): Array<String?>{ val resultData = responseJson.getJSONArray("data") .getJSONObject(0) .getJSONArray("result") return resultData.map{ it.getString("label") }.toTypedArray() } But it is not typed as a JSONObject , is there any way I can force type it to JSONObject ? 回答1: The problem is that resultData has a type of JSONArray , which is a JSON utility class that doesn't