• JsonConvert


    package j2ee.util;
    
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    import net.sf.json.JSONArray;
    import net.sf.json.JSONObject;
    
    public class JsonConvert {
    
    	@SuppressWarnings("unchecked")
    	//list 专程 jsonobject
    	public static JSONObject generate(List list) {
    		Map<String, Object> map = new HashMap<String, Object>();
    		map.put("totalCount", list.size());
    		map.put("root", list);
    		return JSONObject.fromObject(map);
    	}
    	@SuppressWarnings("unchecked")
    	public static JSONArray generate1(List list) {
    		Map<String, Object> map = new HashMap<String, Object>();
    		map.put("totalCount", list.size());
    		map.put("root", list);
    		return JSONArray.fromObject(map);
    	}
    
    	public static JSONObject javabean2json(Object object) {
    		Map<String, Object> map = new HashMap<String, Object>();
    		map.put("success", true);
    		map.put("data", object);
    		return JSONObject.fromObject(map);
    	}
    
    	@SuppressWarnings("unchecked")
    	public static JSONObject objectcollect2json(List list, String total) {
    		Map<String, Object> map = new HashMap<String, Object>();
    		map.put("totalProperty", total);
    		map.put("root", list);
    		return JSONObject.fromObject(map);
    	}
    
    }
    
     
  • 相关阅读:
    hdu1247 字典树或者hash
    hdu1247 字典树或者hash
    hdu1251 hash或者字典树
    hdu1251 hash或者字典树
    hdu4421 2-sat(枚举二进制每一位)
    hdu4421 2-sat(枚举二进制每一位)
    poj3648 2-sat
    poj3648 2-sat
    hdu 1814 字典序最小的2sat(暴力深搜)
    hdu 1814 字典序最小的2sat(暴力深搜)
  • 原文地址:https://www.cnblogs.com/qq1988627/p/6606932.html
Copyright © 2020-2023  润新知