내 페이지에서 입력 스트림으로받은 데이터가 json으로 변환되고 변환 될 때 문자열이 아닌 내용을 원합니다. 누군가 내 코드를 편집하여 제 PL에 인상을 줄 수 있습니까? 정말 끝내야 해. 그것을 할 것입니다표시하려면 json으로 입력 스트림을 변환하십시오
The Code:
// 8. Execute POST request to the given URL
HttpResponse httpResponse = httpclient.execute(httpPost);
// 9. receive response as inputStream
inputStream = httpResponse.getEntity().getContent();
// 10. convert inputstream to string
if(inputStream != null)
result = convertInputStreamToString(inputStream);
else
result = "Did not work!";
} catch (Exception e) {
Log.d("InputStream", e.getLocalizedMessage());
}
// 11. return result
return result ;
}
private static String convertInputStreamToString(InputStream inputStream)
throws IOException{
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
String line = "";
String result = "";
while((line = bufferedReader.readLine()) != null)
result += line;
inputStream.close();
return result;
}
'JSONObject json = new JSONObject (result); ' – bGorle
해결 했습니까? – axierjhtjz