0
我正在使用mapquest導航。我正在使用JavaScript代碼來檢索數據。mapquest:如何解析mapquest json請求
我得到在應用中JSON內容,但不知道如何使用這些數據進行導航。我創建了一個新項目並運行代碼
class jsonapp extends AsyncTask<String, Void, String>{
@Override
protected String doInBackground(String... uri) {
// TODO Auto-generated method stub
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response;
String responseString = null;
try {
response = httpclient.execute(new HttpGet(uri[0]));
StatusLine statusLine = response.getStatusLine();
if(statusLine.getStatusCode() == HttpStatus.SC_OK){
ByteArrayOutputStream out = new ByteArrayOutputStream();
response.getEntity().writeTo(out);
out.close();
responseString = out.toString();
Log.d("Filter", ""+responseString);
} else{
//Closes the connection.
response.getEntity().getContent().close();
throw new IOException(statusLine.getReasonPhrase());
}
} catch (ClientProtocolException e) {
//TODO Handle problems..
} catch (IOException e) {
//TODO Handle problems..
}
return responseString;
我正在嘗試進行敘述式導航。我該怎麼做?
我在做對吧?
在此先感謝
好像沒有JSONP JSON ... – Selvin
究竟你想知道些什麼?如何將返回的字符串解析爲JSON或如何使用JSON創建敘述性導航?或兩者? – mrunde