I am using java to call a url that returns a JSON object:
url = new URL(\"my URl\"); urlInputStream = url.openConnection().getInputStream();
Kotlin version with Gson
to read the response JSON:
val response = BufferedReader( InputStreamReader(conn.inputStream, "UTF-8") ).use { it.readText() }
to parse response we can use Gson:
val model = Gson().fromJson(response, YourModelClass::class.java)