我的代碼來獲得圖像URL額外在每一個前JSON響應/ java中,Android的
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
InputStream inputStream = httpEntity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "iso-8859-1"), 8);
StringBuilder stringBuilder = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
stringBuilder.append(line + "\n");
}
inputStream.close();
return stringBuilder.toString();
其中服務器的代碼是在PHP
但問題是有多餘的\每前/ 例如在數據庫中的圖像鏈接,http://www.dvimaytech.com/markphoto/upload/[email protected]/Pic.jpg
但每次都遇到http:\/\/www.dvimaytech.com\/markphoto\/upload\/[email protected]\/Pic.jpg
是這個問題不解決的,那麼另一種解決方案(對我來說它的最後一個選項)是刪除所有。
但是當我嘗試,使用url = url.replace("\","");
它給語法錯誤String literal is not properly closed by a double-quote
或[傑克遜(http://jackson.codehaus.org/),例如。無論哪種方式,都不應該用字符串替換來完成。另外,我會[驗證](http://jsonlint.com/)原始的JSON來查看它是否實際上是JSON。 – eis