java數據轉化為json數據 – Android移動開發技術文章_手機開發 Android移動開發教學課程

public class Convert {
    public static JSONObject  generate(List list) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put(“totalProperty”, list.size());
        map.put(“root”, list);
        return JSONObject.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);
    }
}

You May Also Like