1、包
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
2、
//创建JSON{}对象
JSONObject sbjson = new JSONObject();
JSONObject sbjson2 = new JSONObject();
//创建JSON[]数组
JSONArray jsonArray = new JSONArray();
//插入普通对象{"loginusername":"xxx"}
sbjson.put("loginusername", u1.getUserName());
//插入[sbjson2]数组
jsonArray.add(sbjson2);
sbjson.put("user", jsonArray);