日期:2014-05-16 浏览次数:20377 次
User user = new User(); user.setId("1"); user.setName("wan"); System.out.println(JSONObject.fromObject(user).toString()); String str2 = "{\"id\":\"1\",\"name\":\"wan\"}"; JSONObject jsonObject = JSONObject.fromObject(str2); User user2 = (User)JSONObject.toBean(jsonObject, User.class);
?
采用的json库是json-lib库(下载地址:http://json-lib.sourceforge.net/),该库还需要