今天做了一個通過HTTP請求調接口的功能,返回的是一個JSON
{
Status: true
Code: "Success"
Message: "操作成功"
}
本想通過Map<String,String>后獲取Status判斷,但一直不能成功,因為boolean不能轉String。
解決方法:
1 JSONObject object = JsonUtil.parseNotThrowException(entity.getData(), JSONObject.class); 2 3 boolean status =Boolean.valueOf(object.get("Status").toString()); 4 boolean code = object.get("Code").equals("Success");