We are trying to get started with dynamo db and I'm breaking my head over a mapping problem.
I have a model Match and matchPlayer.
Match has a map property which contains matchPlayer objects.
I can't get dynamodb to correctly map this property. I tried the json Marshaller but that just results into an error
Expected S in value {M: {player2={M:(More json)
Are there any good examples or tutorials for mapping/ marshalling a map with complex objects to work with dynamodb? I found tutorials for working with simple complex objects but not with a map of objects.
I'm glad for any help!
@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;
}
}
The DynamoDB Object Mapper for Android currently does not support complex data type mapping for the array and map. You need to manually map a dictionary to a custom object for yourself.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.