關於HttpResponse返回結果解析

須要導入jar包  redis

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的那個 apache

百度盤  https://pan.baidu.com/s/1i4SKqVzjson

相關文章
相關標籤/搜索