【发布时间】:2018-05-14 09:22:49
【问题描述】:
我正在尝试从 JSONObect 中的键值对中提取值。这是结构:
{"key1 ":["dog","cat"],"key2":["house","boat"]}
所以,我想提取价值狗和猫,也价值房子和船。我在 Java 中尝试了以下操作:
//obj - has this JSON.
Iterator iter = obj.keys();
for (int i=0; i<len; i++){
String key = (String)iter.next();
System.out.println("Key is --> "+key); //This is correctly giving me the keys.
System.out.println("Value is --> "+clientDetails.getJSONArray(key)); //This is not working. I tried lots of other things but to no avail.
}
有人可以在这里指导我吗?
谢谢, 凯
【问题讨论】:
-
这里的
clientDetails是什么?
标签: java arrays json key-value