I've followed here by creating the MyCustomMarshaller.
MyCustomMarshaller
public class MyCustomMarshaller implements DynamoDBMarshaller<List<DemoClass>> {
private static final ObjectMapper mapper = new ObjectMapper();
private static final ObjectWriter writer = mapper.writer();
@Override
public String marshall(List<DemoClass> obj) {
try {
return writer.writeValueAsString(obj);
} catch (JsonProcessingException e) {
throw failure(e,
"Unable to marshall the instance of " + obj.getClass()
+ "into a string");
}
}
@Override
public List<DemoClass> unmarshall(Class<List<DemoClass>> clazz, String json) {
final CollectionType
type =
mapper.getTypeFactory().constructCollectionType(List.class, DemoClass.class);
try {
return mapper.readValue(json, type);
} catch (Exception e) {
throw failure(e, "Unable to unmarshall the string " + json
+ "into " + clazz);
}
}
}
My dynamoDb class
@DynamoDBAttribute
@DynamoDBMarshalling(marshallerClass = MyCustomMarshaller.class)
List<DemoClass> Object;
DemoClass
public class DemoClass {
String name;
int id;
}
All the codes were working great.By the thing is
com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMarshalling is deprecated
So how can I change my code without using this dynamoDBmarshalling?
Thanks in Advance,
Jay