我有一个启用了流式处理的Dynamodb表,并为该表创建了一个触发器,调用一个AWS Lambda函数。在lambda函数内部,我试图从Dynamodb流中读取新图像(修改后的Dynamodb项),并尝试获取其中的纯json字符串。我的问题是如何获得通过流发送的DynamoDB项的纯json字符串?我正在使用下面给出的代码片段获取新图像,但我不知道如何从中获取json字符串。感谢您的帮助。
public class LambdaFunctionHandler implements RequestHandler<DynamodbEvent, Object> {
@Override
public Object handleRequest(DynamodbEvent input, Context context) {
context.getLogger().log("Input: " + input);
for (DynamodbStreamRecord record : input.getRecords()){
context.getLogger().log(record.getEventID());
context.getLogger().log(record.getEventName());
context.getLogger().log(record.getDynamodb().toString());
Map<String,AttributeValue> currentRecord = record.getDynamodb().getNewImage();
//how to get the pure json string of the new image
//..............................................
}
return "Successfully processed " + input.getRecords().size() + " records.";
}
}