我试图从我的服务器使用restful服务获得响应,我以json格式返回,更改为字符串变量然后我尝试从字符串变量更改为json对象,但我收到错误这里是我的类在我的类是我的堆栈跟踪然后我的字符串变量之后,当我尝试从字符串转换为json对象时发生错误,感谢您的帮助:
private class DownloadWebPageTask extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... urls) {
String response = "";
for (String url : urls) {
DefaultHttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
try {
HttpResponse execute = client.execute(httpGet);
InputStream content = execute.getEntity().getContent();
BufferedReader buffer = new BufferedReader(
new InputStreamReader(content));
String s = "";
while ((s = buffer.readLine()) != null) {
response += s;
}
} catch (Exception e) {
e.printStackTrace();
}
}
try {
//JSONObject json = …Run Code Online (Sandbox Code Playgroud)