处理http返回的json串:
HttpManager httpManager = new HttpManager();
httpManager.sendHttpGetRequest(httpclient, operationUrl,
operationName);
HttpGet httpGet = new HttpGet(operationUrl);
httpGet.addHeader("Content-Type"
httpManager.sendHttpGetRequest(httpclient, operationUrl,
operationName);
HttpGet httpGet = new HttpGet(operationUrl);
httpGet.addHeader("Content-Type"
"application/json;charset=UTF-8");
org.apache.http.client.ResponseHandler handler = new BasicResponseHandler();
String rsp = (String) httpclient.execute(httpGet, handler);
JsonParser jsonParser = new JsonParser();
JsonObject jsonObject = (JsonObject) jsonParser.parse(rsp);
JsonObject resObj = jsonObject.get("resObj")
.getAsJsonObject();
JsonArray nodeList = resObj.get("alarms").getAsJsonArray();
for (int i = 0; i < nodeList.size(); i++) {
JsonObject subJsonObject = nodeList.get(i)
.getAsJsonObject();
Hdalm hdalm = new Hdalm(dbname, instName, check_time);
hdalm.fillData(subJsonObject);
socketClient.sendMsg(httpIP, httpPort, hdalm.toString()
+ "\r\n");
}
org.apache.http.client.ResponseHandler handler = new BasicResponseHandler();
String rsp = (String) httpclient.execute(httpGet, handler);
JsonParser jsonParser = new JsonParser();
JsonObject jsonObject = (JsonObject) jsonParser.parse(rsp);
JsonObject resObj = jsonObject.get("resObj")
.getAsJsonObject();
JsonArray nodeList = resObj.get("alarms").getAsJsonArray();
for (int i = 0; i < nodeList.size(); i++) {
JsonObject subJsonObject = nodeList.get(i)
.getAsJsonObject();
Hdalm hdalm = new Hdalm(dbname, instName, check_time);
hdalm.fillData(subJsonObject);
socketClient.sendMsg(httpIP, httpPort, hdalm.toString()
+ "\r\n");
}