1.
String result = [
"_id": "123",
"username": "Andro"
]
JSONObject resultObj = new JSONObject(result);
String _id = resultObj.getString("_id");
String username = resultObj.getString("username");
2.
String result = [
{
"_id": "123",
"username": "Andro"
},
{
"_id": "124",
"username": "陳俊安"
}
]
JSONArray resultObjArr = new JSONArray(result);
for(int i = 0; i < resultObjArr.length(); i++) {
JSONObject resultObj = resultObjArr.getJSONObject(i);
String _id = resultObj.getString("_id");
String username = resultObj.getString("username");
}
沒有留言 :
張貼留言