Is there any Java API for DynamoDB to convert from Item to Map<String, AttributeValue> without implementing it on my own?
EDIT
item.asMap() will return Map<String, Object>, not Map<String, AttributeValue>. Just wondering is there any direct API for this?
Yeah, but I've managed to find it:
// Item item
InternalUtils.toAttributeValues(item)
However, above API is deprecated in newer DynamoDB library which basically delegates the call to ItemUtils which is not deprecated fortunately. So I ended up using this:
ItemUtils.toAttributeValues(item)
Hope this will help others in future!
You can use the method asMap:
Returns all attributes of the current item as a map.
Updated answer:
To get a Map<String, AttributeValue> you can use ItemUtils.toAttributeValue:
Converts an Item into the low-level representation; or null if the input is null.
as follow
Map<String, AttributeValue> map = ItemUtils.toAttributeValue(item);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With