json接口相关(建议结合JFinal框架)

/**
 * 
 */
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

posted @ 2015-12-15 12:05  *新星月-倪新生*  阅读(540)  评论(0编辑  收藏  举报