【发布时间】:2014-06-27 01:30:17
【问题描述】:
我正在使用 mapquest 导航。我正在使用 javascript 代码来检索数据。
我正在应用程序中获取 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 ...
-
您到底想知道什么?如何将返回的字符串解析为 JSON 或如何使用 JSON 创建叙述导航?还是两者兼而有之?
标签: javascript android json jsonp mapquest