在第一张图片中,json 数组大小为 10。从 json 数组获取 10 个对象后,大小动态更改为 20。?
[1]:/image/3HpDD.png 强文字
如何解决这样的问题?我想一次获取所有数组对象。
最佳答案
您没有清除您的documentArray
。它一次又一次地添加。因此,请在 for
loop
if (documentArray == null)
documentArray = new JSONArray();
else
documentArray.clear();
for()// your for loop here
关于java - 为什么使用 Json Simple API 在 java 中动态增加 json 数组大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42952262/