请问可以用web pages 返回json吗

请问可以用web pages 返回json吗

湖上湖
浏览 399回答 1
1回答

慕运维8079593

返回的时候封装成json即可。参考: Student st1 = new Student(1, "dg", 18, new Date());Student st2 = new Student(2, "dg", 18, new Date());Student st3 = new Student(3, "dg", 18, new Date());Student st4 = new Student(4, "dg", 18, new Date());Student st5 = new Student(5, "dg", 18, new Date());List li = new ArrayList();JSONObject JO1 = new JSONObject(st1);JSONObject JO2 = new JSONObject(st2);JSONObject JO3 = new JSONObject(st3);JSONObject JO4 = new JSONObject(st4);JSONObject JO5 = new JSONObject(st5);li.add(JO1);li.add(JO2);li.add(JO3);li.add(JO4);li.add(JO5);JSONArray Ja = new JSONArray(li);Map ma = new HashMap();ma.put("Result", "OK");ma.put("Records", Ja);JSONObject js = new JSONObject(ma); 
打开App,查看更多内容
随时随地看视频慕课网APP