JSONObject obj = new JSONObject();
obj.put("id",lab.getLabId());
obj.put("name",lab.getLabName());
obj.put("type",lab.getLabType());
obj.put("desc",lab.getLabDesc());
JSONArray array = new JSONArray();
array.put(obj);
JSONObject ob = new JSONObject();
ob.put("lab",array);
输出:{"lab":[{"id":10,"desc":"for computer science","name":"LAB-CMP-1","type":1}]}
原文链接:https://www.f2er.com/json/290498.html