【问题标题】:what is best way to call rest api repeatedly by changing parameter in android通过更改android中的参数来重复调用rest api的最佳方法是什么
【发布时间】:2016-04-22 10:24:54
【问题描述】:
[ 11547212, 11546098, 11544988, 11546490, 11543083, 11544016, 11545112, 11545975, 11543258, 11541675, 11544510, 11543188, 11544254, 11544374, 11541702, 11545351, 11542995, 11542005, 11543646, 11540747, 11541834, 11541242, 11544686, 11544523, 11546077, 11543321, 11544010, 11544342, 11541474, 11547035, 11545970, 11544047, 11533500, 11547236, 11541971, 11543798, 11547042, 11542803, 11540825]

这是 webservice https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty 的响应,这里每个 id 都包含特定的数据,这里是获取每个项目数据的服务 https://hacker-news.firebaseio.com/v0/item/11533382.json?print=pretty 这里如何获取所有项目的数据,如何重复调用第二个url,最好的调用方式是什么。

【问题讨论】:

  • 简单地使用 for 循环。

标签: android json okhttp restful-url


【解决方案1】:

使用循环

for(int i = 0; i < json.length; i++){
 //here is your code...
}

或者把这个 JSONArray 作为字符串

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-02-20
    • 2010-09-16
    • 1970-01-01
    • 2015-10-13
    • 1970-01-01
    • 2014-01-25
    • 2014-04-28
    • 1970-01-01
    相关资源
    最近更新 更多