简体   繁体   English

从jsonArray读取值

[英]Read the values from the jsonArray

I have a JSONArray like below 我有一个像下面的JSONArray

System.out.println(jsonArray.get(i));
//output
["4","3","2","1","3","5","6"]

How can i access the values inside the array. 我如何访问数组中的值。 For Example if i want value 2 from the above array which is at index 2, what should i use to get the value 例如,如果我想从上面的数组中获得索引2的值2,我应该使用什么来获取值

Assuming you have a org.json.JSONArray 假设您有一个org.json.JSONArray

String s = jsonArray.getJSONArray(i).getString(2);

should do the trick. 应该可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM