java如何遍历json 请具体点
{"info":[{"goodsId":"1234","goodsq":"10"},{"goodsId":"5678","goodsq":"20"}]}...
{"info":[{"goodsId":"1234","goodsq":"10"},{"goodsId":"5678","goodsq":"20"}]}
展开
1个回答
展开全部
JSONObject jsonObject = new JSONObject(jsonString);
JSONArray jsonArray =jsonObject.getJSONArray(“info”);
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jo = jsonArray.getJSONObject(i);
System.out.println(jo.getString("goodsld"));
System.out.println(jo.getString("goodsq"));
}
JSONArray jsonArray =jsonObject.getJSONArray(“info”);
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jo = jsonArray.getJSONObject(i);
System.out.println(jo.getString("goodsld"));
System.out.println(jo.getString("goodsq"));
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询