Deserializing DynamoDBResults with gson fails
<p>I have a specific use case where I store the results from my one table in DynamoDB to be stored in a serialized manner in another DynamoDB. 
Now when I use gson to deserialize the data being retrieved,
I get this error:</p>

<pre><code>java.lang.RuntimeException: Unable to invoke no-args constructor for class java.nio.ByteBuffer. Register an InstanceCreator with Gson for this type may fix this problem.
        at com.google.gson.internal.ConstructorConstructor$12.construct(ConstructorConstructor.java:210)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:186)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:103)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:196)
        at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
        at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:187)
        at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:145)
        at com.google.gson.Gson.fromJson(Gson.java:810)
        at com.google.gson.Gson.fromJson(Gson.java:775)
</code></pre>

<p>My method looks like this:</p>

<pre><code>public void store(MyCustomObject obj) {
String primaryKey = obj.getKey();

List&lt;Map&lt;String, AttributeValue&gt;&gt; results = AmazonDynamoDB.query(...).getItems();
Gson gson = new Gson();
List&lt;String&gt;records = results .stream()
            .map(mappedResult-&gt; gson.toJson(mappedResult))
            .collect(Collectors.toList());

Map&lt;String, AttributeValue&gt; attributeMap = transformToAttributeMap(records);
PutItemRequest putItemRequest = new PutItemRequest().withItem(attributeMap);
AmazonDynamoDB.putItem(...);
}
</code></pre>

<p>The method to retrieve the records looks something like this:</p>

<pre><code>public void retrieve(String id) {
QueryRequest...
Map&lt;String, AttributeValue&gt; records = DynamoDB.query(...).getItems();

List&lt;String&gt; serializedRecords = new ArrayList&lt;&gt;();
List&lt;AttributeValue&gt; values = records.get("key");
for( AttributeValue attributeValue: values) {
     serializedRecords.add(attributeValue.getS());
}

Gson gson = new Gson();
Type recordType = new TypeToken&lt;Map&lt;String, AttributeValue&gt;&gt;() { }.getType();
List&lt;Map&lt;String, AttributeValue&gt;&gt; actualRecords = serializedRecords.stream()
                .map(record-&gt; gson.fromJson(record, recordType))
                .collect(Collectors.toList());
}
</code></pre>

<p>What am I doing wrong?</p>