Last active
August 9, 2018 11:37
-
-
Save dhiraj/1958edf1beb4d3f9be7cd5d359287c16 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@Test | |
fun getTodos(){ | |
OkHttpClient().newCall(Request.Builder().url("https://jsonplaceholder.typicode.com/todos").build()).enqueue(object : Callback { | |
override fun onFailure(call: Call?, e: IOException?) {} //Handle Network failure | |
override fun onResponse(call: Call?, response: Response?) { | |
response!!.body()!!.use {responsebody -> | |
val root = JsonParser().parse(responsebody.charStream()) | |
assertTrue(root is JsonElement) //root is a JsonElement object | |
assertTrue(root is JsonArray) //root is actually, a JsonArray object | |
} | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment