java - DynamoDB - Object to AttributeValue -
i'm aware of dynamodbmapper in case can't use because don't know attributes beforehand.
i have json , it's parsed map of objects using jackson
parser:
map<string, object> userdata = mapper.readvalue(new file("user.json"), map.class);
looping through each attribute, how can convert value attributevalue
given dynamodb attributevalue
supports boolean, string, number, bytes, list, etc.
is there efficient way this? there library already? naive approach check if each value of type boolean/string/number/etc. , call appropriate attributevalue
method, e.g: new attributevalue().withn(value.tostring())
- gives me long lines of if, else if
finally figured out looking @ how aws parses json
basically, code:
item item = new item().withjson("document", jsonstr); map<string,attributevalue> attributes = internalutils.toattributevalues(item); return attributes.get("document").getm();
very neat.
Comments
Post a Comment