I want to retrieve JSON from a web-service and parse it then.
Am I on the right way?
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(url);
HttpResponse response;
try {
response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
if (entity != null) {
// parsing JSON
}
} catch (Exception e) {
}
Unfortunately I don't know how to convert HttpEntity
into a JSONObject.
This is my JSON (extract):
{
"names": [
{
"name": "Zachary"
},
{
"name": "Wyatt"
},
{
"name": "William"
}
]
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…