`

Json转换利器Gson之实例一-简单对象转化和带泛型的List转化

    博客分类:
  • java
阅读更多
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);  
        }  
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics