Json转换利器Gson之实例一-简单对象转化和带泛型的List转化
程序员文章站
2022-04-04 12:50:56
...
List<EhomepayReviewRecord> reviewList = new ArrayList<EhomepayReviewRecord>(); EhomepayReviewRecord review = new EhomepayReviewRecord(); review.setId(1); review.setAuditResult("1"); reviewList.add(review); review.setId(2); review.setAuditResult("2"); reviewList.add(review); Gson gson = new Gson(); String lastReviewListStr = gson.toJson(reviewList); System.out.println(lastReviewListStr); List<EhomepayReviewRecord> reviewListyy = new ArrayList<EhomepayReviewRecord>(); List<EhomepayReviewRecord> retList = gson.fromJson(lastReviewListStr, new TypeToken<List<EhomepayReviewRecord>>() { }.getType()); for (EhomepayReviewRecord stu : retList) { System.out.println(stu); }
上一篇: java 手机号码+邮箱的验证
下一篇: Java电话号码和手机号码正则验证