返参数类型:
{
"success": true,
"code": 200,
"message": "",
"data": {
"ciClass": {
"id": 1396630046100810,
"classCode": "classCode",
"className": "className",
"classStdCode": "classStdCode"
},
"attrDefs": [{
}]
}
}
处理方式:
// 入参String json
public static void main(String[] args) {
JSONObject pa1 = null;
try {
CloseableHttpClient httpClient = HttpClients.createDefault();
Map<String, Object> mapParam = new HashMap<String, Object>();
mapParam.put("id", "传值id");
JSONObject json = new JSONObject(mapParam);
HttpPost httpPost = new HttpPost("http://****.com/****/****");
httpPost.addHeader("Content-Type", "application/json");
httpPost.setEntity(new StringEntity(json.toJSONString(), "UTF-8"));
CloseableHttpResponse response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
String result = EntityUtils.toString(entity, "UTF-8");
JSONObject pa = JSONObject.parseObject(result);
if (pa != null && pa.get("data") != null && !"{}".equals(pa.get("data").toString())) {
pa1 = JSONObject.parseObject(pa.get("data").toString());
}
response.close();
httpClient.close();
} catch (Exception ex) {
ex.printStackTrace();
}
return pa1;
}