的JSON文件格式,我需要使用看起來像這樣安卓:如何解析JSON陣列串
[{"fName":"Bob","lName":"Smoe","info":"is tall"},{"fName":"Claire","lName":"Smoegan","info":"has a big forehead"}]
我有我添加到一個JSON數組人的對象列表。代碼如下所示
for (int i = 0; i < peopleList.size(); i++){
try {
jArray.put(peopleList.get(i));
}catch (Exception e){
e.printStackTrace();
}
}
的問題是,我需要將其轉換爲字符串寫入一個文件,但是當我使用「jArray.toString()」返回
"["[email protected]", "[email protected]", "[email protected]"....]
我如何得到它以上面請求的格式返回?
首先,這不是*解析*。解析是另一種方式(字符串到JSON)。其次,它取決於'jArray'是什麼。 – Andreas
jArray是JSONArray – zachThePerson