我的代码获取图像网址
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/herwadeshirish123@Gmail.com/Pic.jpg
但我每次都会 http:\/\/www.dvimaytech.com\/markphoto\/upload\/herwadeshirish123@Gmail.com\/Pic.jpg
如果这个问题无法解决,那么另一个解决方案(对我来说最后一个选择)是删除每个 。
但是当我尝试使用 url = url.replace("\","");
它给出语法错误字符串文字未正确用双引号关闭
最佳答案
只需使用像 gson 这样的 JSON 解析器库来为您解码 JSON 数据包。 http://code.google.com/p/google-gson/
这将使您的生活变得更加轻松,并避免使用 string.replace() 特定字符。
关于java - extra\in json 响应之前/在 java、android 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14066259/