Created
May 22, 2021 12:16
-
-
Save ibrahim4851/06fdceea3658b42e3893f96878d8f5ed to your computer and use it in GitHub Desktop.
GetJsonObject
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun getRequest() { | |
var url = "https://raw.githubusercontent.com/ibrahim4851/VolleyRequests/master/nestedjson.json" | |
val queue: RequestQueue = Volley.newRequestQueue(this) | |
val request = JsonObjectRequest( | |
Request.Method.GET, | |
url, | |
null, | |
{ response -> | |
val glossary = response.getJSONObject("glossary") | |
val GlossDiv = glossary.getJSONObject("GlossDiv") | |
val GlossList = GlossDiv.getJSONObject("GlossList") | |
val GlossEntry = GlossList.getJSONObject("GlossEntry") | |
val id = GlossEntry.getString("ID") | |
val GlossDef = GlossEntry.getJSONObject("GlossDef") | |
val jsonArray = GlossDef.getJSONArray("GlossSeeAlso") | |
for (i in 0 until jsonArray.length()) { | |
var string = jsonArray.getString(i) | |
Log.i("value", string) | |
} | |
}, | |
{ error -> Log.i("errormessage", "Connection Error") }) | |
queue.add(request) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment