android - 如何在没有使用 Volley 的节点 js 的 Android 中合并 JSON 的情况下获得多 Json 响应?
问题描述
我正在使用带有 Nodejs 的 Android Studio。要获取数据,我想使用'volley'从nodejs服务器获取Json在服务器(Nodejs,Express)交付Tow JSon
res.write(JSON.stringify(results));
res.write(JSON.stringify(hot));
我想将这些 Json 从服务器获取到 Android 但失败了……我只能得到一个首先交付的 JSON,这个
res.write(JSON.stringify(results));
我怎样才能得到两个 JSON ?不合并 JSON
public void onButton1Clicked(View v){
String url=editText.getText().toString();
StringRequest request = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
println(response);
JSONArray jarray= new JSONArray(response);
for(int i=0;i<jarray.length();i++)
{
JSONObject Jobs=jarray.getJSONObject(i);
String title=Jobs.getString("title");
String content=Jobs.getString("content");
println(" title : " + title);
println(" content : " + content);
}
} catch (Exception e) {
println("에러남!");
e.printStackTrace();
}
}
},new Response.ErrorListener(){
@Override
public void onErrorResponse(VolleyError error) {
println("error!@@@");
error.printStackTrace();
}
}
){
@Override
protected Map<String, String> getParams(){
Map<String, String> params = new HashMap<>();
return params;
}
};
request.setShouldCache(false);
Volley.newRequestQueue(this).add(request);
println("웹 서버에 요청함 : "+url);
}
解决方案
推荐阅读
- ruby-on-rails - 在 Elasticsearch 索引更新完成之前查询返回旧数据
- angular - 角度路由延迟加载不适用于书签路线
- azure - 使用 LogicApp 占用 40 分钟的并行性三重 Foreach 执行缓慢?
- composer-php - composer require 如何解析项目中已有的依赖包?
- javascript - Javascript Selenium - 出于某种原因,我的代码不会在 Internet Explorer 的谷歌页面上单击或导航
- typescript - Electron-forge:如何将入口点设置为 url 而不是静态 html 文件
- python - NameError:名称“x1”未在加利福尼亚住房数据中定义
- node.js - 无法将帖子路由到 Atlas mongoDB
- c# - 如何在 Graph API 中展开两个项目
- reactjs - 如何调用 API?