Here you can find the source of handleJsonResponse(HttpResponse response)
public static Map handleJsonResponse(HttpResponse response)
//package com.java2s; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.apache.http.HttpResponse; import org.apache.http.ParseException; import org.apache.http.util.EntityUtils; import org.json.JSONException; import org.json.JSONObject; public class Main { public static Map handleJsonResponse(HttpResponse response) { JSONObject oauthLoginResponse = null; String contentType = response.getEntity().getContentType() .getValue();//from w ww.java 2 s .c o m try { oauthLoginResponse = new JSONObject( EntityUtils.toString(response.getEntity())); } catch (ParseException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } System.out.println(); System.out.println("********** JSON Response Received **********"); Map<String, Object> outMap = new HashMap<String, Object>(); Iterator<String> keysIterator = oauthLoginResponse.keys(); while (keysIterator.hasNext()) { String keyStr = (String) keysIterator.next(); Object value = null; try { value = oauthLoginResponse.get(keyStr); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } outMap.put(keyStr, value); System.out.println(String.format(" %s = %s", keyStr, value)); } return outMap; } }