我需要一些幫助。我在android開發人員中還是個新手。JSONObject到JSONArray
下面是示例中的數據的
strAPI_TERMINAL= "{ 'terminal': { 'id': 2, 'fmt_id': 'fmt0002', 'terminal_type': 'multiple' }}"
我需要這個對象的數據解析,以JSONArray
這裏我已經做...
JSONObject jsonObject = new JSONObject(strAPI_TERMINAL);
JSONArray terminal_array = new JSONArray();
JSONArray t_array = terminal_array.put(jsonObject);
當我註銷數據...是的,它已經解析到陣列就像這樣
t_array[{"terminal":{"fmt_id":"fmt0002","id":2,"terminal_type":"multiple"}]
,但是當我想用它以此來獲得「終端」的數據...
JSONArray TERMINAL_JSON=new JSONArray(t_array.getJSONObject(i).getString("terminal").toString());
它說:
Error:Value {"id":2,"fmt_id":"fmt0002","terminal_type":"multiple"}
請人幫我嗎?
感謝您的幫助......
稍作修正:result.length()長度 - 在這種情況下是方法名稱 – heximal
@heximal感謝您的糾正。 :) – GrIsHu