I'm calling an API through java that returns an xml.
My code is:
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()
When I'm printing the responseJSON I can see it as it is. However, when I'm viewing the content of responses_obj in browser I can see something like: <ClinicalDocument xmlns=\"urn:hl7-org:v3\" xmlns:epsos=\"....
The correct one should be <ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:epsos="...
Is ther a way to remove these "\" characters?