/** * */ package net.wicp.wvqusrtg; import java.util.HashMap; import net.sf.json.JSONArray; import net.sf.json.JSONObject; /** * @author Administrator * */ public class json { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub HashMap<String, Object> param =new HashMap<String, Object>() ; HashMap<String, Object> param2 =new HashMap<String, Object>() ; JSONArray ja = new JSONArray(); JSONObject jb = new JSONObject(); JSONObject jb2 = new JSONObject(); jb.put("s1", "2");jb.put("s2", "2");jb.put("s3", "2");jb.put("s4", "2"); ja.add(jb);ja.add(jb); param.put("array", ja); param.put("array2", "nixinsheng"); param2.put("Rsp", param); System.out.println("Result:"+ja.toString()); System.out.println(JSONObject.fromObject(param)); System.out.println(JSONObject.fromObject(param2)); } }
类库地址:http://pan.baidu.com/s/1i3LPALJ
原文:http://www.cnblogs.com/wvqusrtg/p/5047772.html