0
我一直在嘗試獲取JSONObject的鍵和值。我不知道爲什麼這不起作用,因爲String鍵顯然是一個字符串?獲取帶值的JSON鍵
我的代碼:
JSONObject obj = new JSONObject(historie2.getData());
Iterator<?> keys = obj.keys();
while(keys.hasNext()) {
String key = (String)keys.next();
String value = obj.getString(key); //This is where the error comes
}
的的JSONObject:
{
"relatie_website": ["www.apple.com"],
"relatie_kvknummer": ["NL3234234"],
"relatie_naam": ["Apple international inc."],
"relatie_d400code": [null],
"relatie_zoeknaam": ["APPLE INC"],
"relatie_debiteurnummer": ["3523523"],
"relatie_btwnummer": ["332342"]
}
這是我一直得到的錯誤:
org.json.JSONException:JSONObject的[ 「relatie_website」 ]不是一個字符串。
'[「www.apple.com」]'是一個1元素的數組,而不是一個字符串。 – Thomas
你的對象是數組而不是字符串,你需要從值中移除[] – unkgd
哦,哇,謝謝你們! *捂臉* – Yoshi