try{
OkHttpClient client=new OkHttpClient();
Request request =new Request.Builder().url(getcompetitionurl).build();
Response response =client.newCall(request).execute();
String responseData=response.body().string();
JSONObject jsonObject=new JSONObject(responseData);
//请求人数
JSONArray num = jsonObject.getJSONArray("Number");
listnum=num.length();
nums=new String[num.length()+1];
for (int i = 0; i < num.length(); i++) {
nums[i]=num.optString(i);
}
String b=nums[1];
Log.i("人数:",b);
//请求比赛名称
JSONArray name = jsonObject.getJSONArray("Name");
names=new String[name.length()+1];
for (int i = 0; i < name.length(); i++) {
names[i]=name.optString(i);
}
String a=names[1];
Log.i("name:",a);
1224android中网络请求对象数组的解析
最新推荐文章于 2021-05-27 03:33:30 发布