如果我想反序列化以下 JSON 格式,我的 POJO 声明应该是什么:
{
"id":2,
"content":"skfdjhsfjhsfjkshdkjfhskdjf",
"created_at":"2012-11-14T00:10:59Z",
"feeds":
[
{
"feed":{"name":"twitter"}
}
]
}
目前我的 POJO 是这样的:
Broadcast.java - 最外层的对象
public class Broadcast {
private String content;
private String created_at;
private Feeds feed[];
private int id;
public Broadcast() { }
public int getId() { return id; }
public String getContent() { return content; }
public String getCreatedAt() { return created_at; }
}
Feed.java - Broadcast 的内部子节点,可以是一个数组,每个 feed 都有一个 name 属性:
public class Feeds {
private String name;
public Feeds() {}
public String getName() {
return name;
}
}