Prueba con esto:
Una vez que tienes tu objeto jsonObject ya puedes empezar a recorrerlo.
Un saludo
JSONObject jsonObject = new JSONObject( readJSON( tu URL ) );
public String readJSON(String url) {
StringBuilder builder = new StringBuilder();
try {
httpGet.setURI( new URI(url) );
HttpResponse response = client.execute(httpGet);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == 200) {
HttpEntity entity = response.getEntity();
InputStream content = entity.getContent();
BufferedReader reader = new BufferedReader(
new InputStreamReader(content));
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
} else {
Log.e(ParseJSON.class.toString(), "Failed to download file");
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch ( URISyntaxException e){
e.printStackTrace();
}
return builder.toString();
}
|