解析具有未知密钥的JSON? [英] Parse JSON with unknown key?
本文介绍了解析具有未知密钥的JSON?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个这样的Json输出:
i have a Json output like this :
数字2922和3910是随机数. 如何存储数组中名称"中的所有值?
The numbers 2922 and 3910 are random numbers. How can i store all values that are in "name" in an array?
谢谢.
推荐答案
You can use Iterator.
使用Iterator,您可以迭代任一列表中的所有元素 方向.您可以通过调用next()方法访问下一个元素.
Using Iterator, you can iterate all elements of a list in either direction. You can access next element by calling next() method .
JSONObject reader = new JSONObject(success);
Iterator iteratorObj = reader .keys();
ArrayList<String> al_getAllKeys=new ArrayList<String>();
while (iteratorObj.hasNext())
{
String getJsonObj = (String)iteratorObj.next();
System.out.println("KEY: " + "------>" + getJsonObj);
}
这篇关于解析具有未知密钥的JSON?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文