JSON转换实体类
程序员文章站
2022-06-15 12:02:16
...
String stu = {
"employees": [{"firstName": "Bill","lastName": "Gates"},
{"firstName":"George","lastName":"Bush"},
{"firstName": "Thomas","lastName": "Carter"}]}
JSONObject jsonObject = JSONObject.fromObject(stu);
Bean stu1 = (Bean) JSONObject.toBean(jsonObject, Bean.class);
JSONObject jsonObject2 = JSONObject.fromObject(stu1.getEmployees.get(0));
Bean1 stu2 = (Bean1) JSONObject.toBean(jsonObject2, Bean1.class);
上一篇: python资源交流群