I need help here. I am still new to Android developer.
Here is sample data
strAPI_TERMINAL= "{ 'terminal': { 'id': 2, 'fmt_id': 'fmt0002', 'terminal_type': 'multiple' }}"
I need to parse the data of this object in a JSONArray
Here is what I did ...
JSONObject jsonObject = new JSONObject(strAPI_TERMINAL); JSONArray terminal_array = new JSONArray(); JSONArray t_array = terminal_array.put(jsonObject);
When I exit the data ... yes, it was an array parsing, like this
t_array[{"terminal":{"fmt_id":"fmt0002","id":2,"terminal_type":"multiple"}]
But when I want to use it to get "terminal" data, using this ...
JSONArray TERMINAL_JSON=new JSONArray(t_array.getJSONObject(i).getString("terminal").toString());
It says:
Error:Value {"id":2,"fmt_id":"fmt0002","terminal_type":"multiple"}
Someone please help me ???
thanks for any help ...
source share