hutool-all 包把实体Bean转化成字符串,以及把字符串转化成Bean对象
Posted z360519549
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hutool-all 包把实体Bean转化成字符串,以及把字符串转化成Bean对象相关的知识,希望对你有一定的参考价值。
GxyJobEntity gxyJobEntity1 = new GxyJobEntity(); gxyJobEntity1.setUserId("user001"); gxyJobEntity1.setPlanId("plan001"); gxyJobEntity1.setStudentId("stu001"); System.out.println(gxyJobEntity1); String str = JSONUtil.toJsonStr(gxyJobEntity1); System.out.println(str); GxyJobEntity studentEntity= JSONUtil.toBean(str,GxyJobEntity.class); System.out.println(studentEntity); System.out.println(gxyJobEntity1.equals(studentEntity));
输出:
GxyJobEntity [jobId=null, studentId=stu001, planId=plan001, userId=user001]
"studentId":"stu001","planId":"plan001","userId":"user001"
GxyJobEntity [jobId=null, studentId=stu001, planId=plan001, userId=user001]
false
以上是关于hutool-all 包把实体Bean转化成字符串,以及把字符串转化成Bean对象的主要内容,如果未能解决你的问题,请参考以下文章
请问怎样将有java.sql.Date属性的Bean转换成json字符串,再把json字符串转换回Bean请大侠指教!!!