Tag: 翻新2

Kotlin / Android应用程序使用Retrofit2。 JSON查询不能按我期望的那样工作

在一个小的android应用程序工作,以帮助我了解JSON查询。 小测试应用程序的工作,直到我试图深入钻到我的测试JSON数据。 我将发布一个链接到我正在使用的JSON数据,以节省空间。 这是来自weatherwunderground的API并托管在myjson.com上的示例代码。 JSON: https : //api.myjson.com/bins/19uurt 主要活动代码 class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val retriever = CycloneRetriever() val callback = object : Callback { override fun onResponse(call: Call?, response: Response?) { println(“Got a response!”) println(response?.body()?.currenthurricane?.get(1)?.stormInfo?.get(0)?.stormName).toString() } override fun onFailure(call: Call?, t: Throwable?) { println(“The thing, it failed!”) […]