【发布时间】:2015-04-16 21:03:49
【问题描述】:
我以 json 格式将 10 个学生信息从一个应用程序传递到另一个应用程序。我必须将 25 个 lacs 学生信息从一个应用程序发送到另一个应用程序。我想知道,我可以发送多少数据?我可以发送多少个 json 格式的学生。?
以下是发送方应用程序的代码。
JSONObject jsonObject = new JSONObject();
JSONArray jArray = new JSONArray();
try {
for (Student student : listStudent) {
JSONObject studentJSON = new JSONObject();
studentJSON.put("First Name", student.getFirstName());
studentJSON.put("Last Name", student.getLastName());
jArray.put(studentJSON);
}
jsonObject.put("StudentArray", jArray);
response.setContentType("application/json");
response.getWriter().write(jsonObject.toString());
} catch (IOException e) {
e.printStackTrace();
}
以下是接收器应用程序的代码。
URL url = new URL("http:"//xyz.com);
BufferedReader reader = new BufferedReader(newInputStreamReader(url.openStream()));
JSONObject object = null ;
String line=null;
while ((line = reader.readLine()) != null)
{
object= new JSONObject(line);
}
【问题讨论】:
-
取决于您发送数据的服务器...
-
您是遇到错误还是这只是一个一般性问题?
-
一般问题。我已经完成了它的开发。但我想澄清我的疑问,这样如果一个应用程序一次以 json 格式发送更多(25 lacs)用户信息,它就不会中断。
标签: java json urlconnection