我正在通过java调用API,该API返回xml。
我的代码是:
func animateButton() {
swirlButton.layer.add(rotateAnimation(), forKey: nil)
CATransaction.begin()
let upAnimation = bounceAnimation()
CATransaction.setCompletionBlock{ () in
self.swirlButton.layer.add(self.bounceAnimation(animatingDown: true), forKey: nil)
}
swirlButton.layer.add(upAnimation, forKey: nil)
CATransaction.commit()
}
func rotateAnimation() -> CABasicAnimation {
let rotate = CABasicAnimation(keyPath: "transform.rotation")
rotate.fromValue = 0
rotate.toValue = -6*CGFloat.pi
rotate.duration = 2
return rotate
}
func bounceAnimation(animatingDown: Bool = false) -> CABasicAnimation {
let buttonY = swirlButton.layer.position.y
let buttonX = swirlButton.layer.position.x
let translate = CABasicAnimation(keyPath: "position")
translate.fromValue = animatingDown ? [buttonX, buttonY - 200] : [buttonX, buttonY]
translate.toValue = animatingDown ? [buttonX, buttonY] : [buttonX, buttonY - 200]
translate.duration = 1
translate.fillMode = .forwards
translate.isRemovedOnCompletion = false
return translate
}
当我打印responseJSON时,我可以原样看到它。但是,当我在浏览器中查看response_obj的内容时,我会看到类似以下内容:JSONObject responses_obj = new JSONObject();
string url = "http://localhost:8080/myAPI";
URL obj = new URL(null, url , new sun.net.www.protocol.http.Handler());
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
String urlParameters = "{\"patient_id\":" +"\"" +document_id_list[2] +"\", \"dob\" : " + "\"" + date_of_birth + "\", \"document_id\" : " + "\""+ document_id + "\"}";
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "text");
// Send post request
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer responseJSON = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
responseJSON.append(inputLine);
System.out.println(responseJSON);
responses_obj.put("getDocument",responseJSON);
}
in.close()
正确的应该是<ClinicalDocument xmlns=\"urn:hl7-org:v3\" xmlns:epsos=\"....
是否可以删除这些“ \”字符?