GSON解析转化成含有泛型的对象

时间:2025-03-18 21:22:34
import ; import ; import ; import .CommonJson4List; import ; import ; import ; import ; public class Test { @SuppressWarnings("unchecked") public static void main(String[] args) { CommonJson<AverageStarLevelAndCount> cj = new CommonJson<AverageStarLevelAndCount>(); AverageStarLevelAndCount data = new AverageStarLevelAndCount(); (4.7f); (10); (); (data); String res1 = (AverageStarLevelAndCount.class); (res1); CommonJson<AverageStarLevelAndCount> cj2 = (res1, AverageStarLevelAndCount.class); (()); (().getAverageStarLevel()); EvalutionProfile p = new EvalutionProfile(); (10); (29); StarLevelStatistics s = new StarLevelStatistics(); s.setStar1(0); s.setStar2(10); s.setStar3(30); s.setStar4(40); s.setStar5(20); (s); Evalution e1 = new Evalution(); (4); ("2013-02-27 07:21:48"); ("评价方未及时做出评价,系统默认满意!"); ("/cms/upload/2012/186/684/486681_1232736939.png"); (""); ("y**f"); Evalution e2 = new Evalution(); (4); ("2013-02-27 07:21:48"); ("评价方未及时做出评价,系统默认满意!"); ("/cms/upload/2012/186/684/486681_1232736939.png"); (""); ("y**f"); List<Evalution> le = new ArrayList<Evalution>(); (e1); (e2); (le); CommonJson<EvalutionProfile> ce = new CommonJson<EvalutionProfile>(); (); (p); String res2 = (EvalutionProfile.class); (res2); String ps = "{\"data\":{\"pageCount\":29,\"page\":\"1\",\"list\":[{\"starLevel\":4,\"remarkTime\":\"2013-04-10 05:17:42\",\"explainTime\":\"\",\"remarkContent\":\"评价方未及时做出评价,系统默认满意!\",\"tpLogoURL\":\"\",\"explainContent\":\"\",\"postMemberId\":\"b**6\"},{\"starLevel\":4,\"remarkTime\":\"2013-04-05 04:42:40\",\"explainTime\":\"\",\"remarkContent\":\"评价方未及时做出评价,系统默认满意!\",\"tpLogoURL\":\"\",\"explainContent\":\"\",\"postMemberId\":\"b**8\"},{\"starLevel\":4,\"remarkTime\":\"2013-03-20 00:52:18\",\"explainTime\":\"\",\"remarkContent\":\"评价方未及时做出评价,系统默认满意!\",\"tpLogoURL\":\"\",\"explainContent\":\"\",\"postMemberId\":\"b**5\"},{\"starLevel\":4,\"remarkTime\":\"2013-03-07 01:51:01\",\"explainTime\":\"\",\"remarkContent\":\"评价方未及时做出评价,系统默认满意!\",\"tpLogoURL\":\"\",\"explainContent\":\"\",\"postMemberId\":\"b**7\"},{\"starLevel\":4,\"remarkTime\":\"2013-03-06 03:38:57\",\"explainTime\":\"\",\"remarkContent\":\"评价方未及时做出评价,系统默认满意!\",\"tpLogoURL\":\"\",\"explainContent\":\"\",\"postMemberId\":\"z**2\"},{\"starLevel\":4,\"remarkTime\":\"2013-03-06 03:17:33\",\"explainTime\":\"\",\"remarkContent\":\"评价方未及时做出评价,系统默认满意!\",\"tpLogoURL\":\"\",\"explainContent\":\"\",\"postMemberId\":\"b**2\"},{\"starLevel\":4,\"remarkTime\":\"2013-03-03 01:40:17\",\"explainTime\":\"\",\"remarkContent\":\"评价方未及时做出评价,系统默认满意!\",\"tpLogoURL\":\"\",\"explainContent\":\"\",\"postMemberId\":\"a**6\"},{\"starLevel\":4,\"remarkTime\":\"2013-03-01 02:41:31\",\"explainTime\":\"\",\"remarkContent\":\"评价方未及时做出评价,系统默认满意!\",\"tpLogoURL\":\"\",\"explainContent\":\"\",\"postMemberId\":\"b**4\"},{\"starLevel\":4,\"remarkTime\":\"2013-02-28 03:20:45\",\"explainTime\":\"\",\"remarkContent\":\"评价方未及时做出评价,系统默认满意!\",\"tpLogoURL\":\"\",\"explainContent\":\"\",\"postMemberId\":\"t**y\"},{\"starLevel\":4,\"remarkTime\":\"2013-02-27 07:21:48\",\"explainTime\":\"\",\"remarkContent\":\"评价方未及时做出评价,系统默认满意!\"," + "\"tpLogoURL\":\"" + "/cms/upload/2012/186/684/486681_1232736939.png\",\"explainContent\":\"\",\"postMemberId\":\"y**f\"}]," + "\"statistics\":{\"star5\":59,\"star4\":38,\"star3\":2,\"star2\":1,\"star1\":0}},\"success\":true}"; CommonJson<EvalutionProfile> re = (ps, EvalutionProfile.class); (().getStatistics().getStar5()); (().getPageCount()); (().getList().get(0).getPostMemberId()); CommonJson4List<Evalution> cjl = new CommonJson4List<Evalution>(); (); (le); ("###" + (Evalution.class)); String sList = "{\"data\":[{\"starLevel\":4,\"remarkCotnent\":\"评价方未及时做出评价,系统默认满意!\",\"remarkTime\":\"2013-02-27 07:21:48\",\"explainContent\":\"\",\"postMemberId\":\"y**f\",\"tpLogoURL\":\"/cms/upload/2012/186/684/486681_1232736939.png\"},{\"starLevel\":4,\"remarkCotnent\":\"评价方未及时做出评价,系统默认满意!\",\"remarkTime\":\"2013-02-27 07:21:48\",\"explainContent\":\"\",\"postMemberId\":\"y**f\",\"tpLogoURL\":\"/cms/upload/2012/186/684/486681_1232736939.png\"}],\"success\":true}"; CommonJson4List<Evalution> cjle = (sList, Evalution.class); ("***" + ().get(0).getPostMemberId()); } }