Bootstrap

关于HttpResponse返回结果解析

需要导入jar包  

import org.apache.http.*;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
import redis.clients.jedis.Jedis;
import org.apache.http.HttpResponse;

import net.sf.json.*;
JSONObject object = null;
HttpEntity entity = response.getEntity();
if(entity!=null){
   String result = EntityUtils.toString(entity,"UTF-8");

   object = JSONObject.fromObject(result);
   System.out.println(object);

}

注意这里的JSONObject需要的jar不是ali的那个 

百度盘  https://pan.baidu.com/s/1i4SKqVz

转载于:https://my.oschina.net/u/3559695/blog/1600534

;