【发布时间】:2017-11-02 13:16:45
【问题描述】:
给定这样的结构:
{
"nameOfObject": { "score": 100 },
"anotherObject": { "score": 30 }
}
是否可以将其映射到:
class Container {
Map<String, ScoreKeeper> scoreKeepers;
}
class ScoreKeeper {
String name;
int score;
}
所以您最终会将ScoreKeeper 实例的name 属性分别设置为"nameOfObject" 和"anotherObject"?
【问题讨论】:
-
您可能需要创建一个中间对象来序列化为 ,然后可以将其转换为您想要的表示形式。