我想從JSONObject中獲取一個字符串。閱讀Java中的JSON二維數組
我的JSON是這樣的:
{
"agent":
[
{"name":"stringName1", "value":"stringValue1"},
{"name":"stringName2", "value":"stringValue2"}
]
}
我想從字符串名稱和字符串名稱的值。所以首先,我試圖讓這個「代理商」使用這個:
JSONObject agent = (JSONObject) jsonObject.get("agent");
但是,這會引發一個錯誤。
你有什麼想法如何處理?
「agent」是JSONArray。 'jsonObject.optJSONArray(「agent」);' – Blackbelt