次のコードを使用して、整形式の文字列から Java の JSONObject に変換します。
public void getStatus(){
String status = "";
try{
String line;
StringBuilder result = new StringBuilder("");
HttpURLConnection conn;
URL url;
url = new URL("http://bromio.com.mx/explore/PointOfInterestService.svc/GetData");
BufferedReader rd;
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while ((line = rd.readLine()) != null) {
result.append(line);
}
rd.close();
Log.d("JSON: ", result.toString());
JSONObject jsonObject = new JSONObject(result.toString());
}catch (Exception e){
e.printStackTrace();
}
}
しかし、例外がスローされています。その特定の文字列を JSONObject にキャストできないようです。JSON はこのページにアクセスできます: (大きすぎて表示できません!) http://bromio.com.mx/explore/PointOfInterestService.svc/GetData この問題を解決する助けがあれば、大いに役立ちます。ありがとうございました