我正在尝试将下面的数据转换成某种形式的Java结构。数据代表了一个网球锦标赛,乔6-3,6-4击败肯,萨利6-4,2-6,6-1击败露西。就我所能理解的而言,我应该能够使用一个普通的映射,类似于这个Map1<Key1, Map2<Key2, Map3<Key3, Value>>>
的东西让我感到困惑的是,我不会每次都深入到最后一层(GameResult)。将FixtureResult和MatchResult的变量视为示例。而且,每个MatchResult都会有多个GameResult集,那么如何从MatchResult (父级)透视图中给出GameResult对象的唯一键?
<FixtureResult>
<Id>1</Id>
<FixtureId>1</FixtureId>
<DateSubmitted>07-01-2017</DateSubmitted>
<MatchResult>
<Id>1</Id>
<WinnerName>Joe</WinnerName>
<LoserName>Ken</LoserName>
<GameResult>
<Id>1</Id>
<WinnerPoints>6</WinnerPoints>
<LoserPoints>3</LoserPoints>
<Ordinal>1</Ordinal>
</GameResult>
<GameResult>
<Id>2</Id>
<WinnerPoints>6</WinnerPoints>
<LoserPoints>4</LoserPoints>
<Ordinal>2</Ordinal>
</GameResult>
</MatchResult>
<MatchResult>
<Id>2</Id>
<WinnerName>Sally</WinnerName>
<LoserName>Lucy</LoserName>
<GameResult>
<Id>3</Id>
<WinnerPoints>6</WinnerPoints>
<LoserPoints>4</LoserPoints>
<Ordinal>1</Ordinal>
</GameResult>
<GameResult>
<Id>4</Id>
<WinnerPoints>2</WinnerPoints>
<LoserPoints>6</LoserPoints>
<Ordinal>2</Ordinal>
</GameResult>
<GameResult>
<Id>5</Id>
<WinnerPoints>6</WinnerPoints>
<LoserPoints>1</LoserPoints>
<Ordinal>3</Ordinal>
</GameResult>
</MatchResult>
</FixtureResult>
发布于 2017-02-08 08:48:15
为什么不使用你定义的结构呢?
class FixtureResult {
Integer id;
Integer FixtureId;
Date dateSubmitted;
List<MatchResult> matchResults
}
class MatchResult {
Integer id;
String winnerName;
String loserName;
List<GameResult> gameResults
}
class GameResult {
Integer id;
Integer winnerPoints;
Integer loserPoints;
Integer ordinal;
}
https://stackoverflow.com/questions/42107784
复制相似问题