comes from the server such json:
{ "command":"client_history_requests", "client_requests": [ {"client_id_request":"10", "client_request_year":"2016", "client_request_mounth":"06", "client_request_day":"07", "client_request_hour":"19", "client_request_minute":"12", "client_request_second":"42"}, {"client_id_request":"11", "client_request_year":"2016", "client_request_mounth":"06", "client_request_day":"07", "client_request_hour":"19", "client_request_minute":"35", "client_request_second":"49"}, {"client_id_request":"12", "client_request_year":"2016", "client_request_mounth":"06", "client_request_day":"07", "client_request_hour":"19", "client_request_minute":"37", "client_request_second":"53"}, {"client_id_request":"13", "client_request_year":"2016", "client_request_mounth":"06", "client_request_day":"07", "client_request_hour":"19", "client_request_minute":"40", "client_request_second":"00"}, ] } those. client_requests contains an array. In Android, I do this:
JSONObject jsonFromServer = new JSONObject(dataFromServer); String command = jsonFromServer.getString("command"); if (command.equals(SERVER_COMMAND_CLIENT_HISTORY_REQUESTS)){ JSONArray arrayClentHistoryRequest = jsonFromServer.getJSONArray("client_requests"); JSONObject jsonArrayRequest= new JSONObject(arrayClentHistoryRequest.getString(1)); Toast.makeText(AddNewRequestActivity.this, jsonArrayRequest.getString("client_request_year"), Toast.LENGTH_LONG).show(); and I will be issued in Toast 2016, i.e. the value of the client_request_year of the first element. and how to get client_request_year from the third and so on?