我们正在努力开始使用Dynamo db,而且我在解决映射问题时已经不知所措了。
我有一个模型Match和matchPlayer。
Match有一个map属性,其中包含matchPlayer对象。
我无法使用dynamodb来正确映射此属性。 我尝试了json Marshaller,但这只会导致错误
预期值S {M:{player2 = {M:(More json)
是否有任何好的示例或教程用于映射/编组具有复杂对象的地图以使用dynamodb?我找到了处理简单复杂对象的教程,但没有找到对象图。
我很高兴得到任何帮助!
@DynamoDBTable(tableName="Matches")
public class Match {
private String matchId;
private Boolean active;
private int currentRound;
private Boolean finished;
private Map<String, MatchPlayers> players;
@DynamoDBHashKey(attributeName = "matchId")
public String getMatchId() {
return matchId;
}
public void setMatchId(String matchId) {
this.matchId = matchId;
}
@DynamoDBIndexRangeKey(attributeName = "active")
public Boolean getActive() {
return active;
}
public void setActive(Boolean active) {
this.active = active;
}
@DynamoDBIndexRangeKey(attributeName = "currentRound")
public int getCurrentRound() {
return currentRound;
}
public void setCurrentRound(int currentRound) {
this.currentRound = currentRound;
}
@DynamoDBIndexRangeKey(attributeName = "finished")
public Boolean getFinished() {
return finished;
}
public void setFinished(Boolean finished) {
this.finished = finished;
}
@DynamoDBMarshalling(marshallerClass = MatchPlayersMarshaller.class)
@DynamoDBIndexRangeKey(attributeName = "players")
public Map<String, MatchPlayers> getPlayers() {
return players;
}
public void setPlayers(Map<String, MatchPlayers> players) {
this.players = players;
}
}
答案 0 :(得分:1)
Android版DynamoDB Object Mapper目前不支持阵列和地图的复杂数据类型映射。您需要手动将字典映射到自定义对象。