Map的存储结构式Key/Value形式,Key 和 Value可以是普通类型,也可以是自己写的JavaBean(上一篇博客),还可以是带有泛型的List(本文).本例中您要重点看如何将Json转回 为带泛型的对象List,并且List中的泛型对象有多种实体.
?
?
实体类:
?
?
?
- import?java.util.Date;??
- ??
- public?class?Student?{??
- ????private?int?id;??
- ????private?String?name;??
- ????private?Date?birthDay;??
- ??
- ????public?int?getId()?{??
- ????????return?id;??
- ????}??
- ??
- ????public?void?setId(int?id)?{??
- ????????this.id?=?id;??
- ????}??
- ??
- ????public?String?getName()?{??
- ????????return?name;??
- ????}??
- ??
- ????public?void?setName(String?name)?{??
- ????????this.name?=?name;??
- ????}??
- ??
- ????public?Date?getBirthDay()?{??
- ????????return?birthDay;??
- ????}??
- ??
- ????public?void?setBirthDay(Date?birthDay)?{??
- ????????this.birthDay?=?birthDay;??
- ????}??
- ??
- ????@Override??
- ????public?String?toString()?{??
- ????????return?"Student?[birthDay="?+?birthDay?+?",?id="?+?id?+?",?name="??
- ????????????????+?name?+?"]";??
- ????}??
- ??
- }??
?
?
?
- public?class?Teacher?{??
- ????private?int?id;??