How to parse JSON in Kotlin
How can I parse JSON in Kotlin? It gets the entire array from JSON but can not get a particular object from the Array. It worked in Java but not in Kotlin. try { val jsonObject = JSONObject(result) val users = jsonObject.getJSONArray("Users") for (i in 0 until users.length()) { Toast.makeText(applicationContext,"Json Result is----"+result,Toast.LENGTH_LONG).show() val obj = users.getJSONObject(i) val name = obj.get("name").toString() Toast.makeText(applicationContext, "User name: "+name , Toast.LENGTH_LONG).show(); } }catch(e: JSONException){}
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.