I have written a lambda function that scans all items in dynamoDB but it retrieves them with its types. How can I remove them? Should I try to parse data in an appropriate way for me or there is a better way of doing it?
public class Get implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().build();
DynamoDB dynamoDB = new DynamoDB(client);
ScanRequest scanRequest = new ScanRequest()
.withTableName("xxx");
static final int STATUS_CODE_NO_CONTENT = 204;
static final int STATUS_CODE_CREATED = 201;
static final int STATUS_CODE_FAILED = 400;
@Override
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent request, Context context) {
Map<String, String> map = request.getPathParameters();
ContactDetails contactDetails = null;
APIGatewayProxyResponseEvent response = null;
int code = STATUS_CODE_NO_CONTENT;
try {
ScanResult result = client.scan(scanRequest);
code = STATUS_CODE_CREATED;
response = new APIGatewayProxyResponseEvent().withStatusCode(code).withIsBase64Encoded(Boolean.FALSE).withHeaders(Collections.emptyMap()).withBody(new Gson().toJson(result.getItems()));
} catch (Exception e) {
code = STATUS_CODE_FAILED;
response = new APIGatewayProxyResponseEvent().withStatusCode(code).withIsBase64Encoded(Boolean.FALSE).withHeaders(Collections.emptyMap()).withBody(e.toString());
}
return response;
}
}
response: [{"kontent":{"s":"ys"},"id":{"s":"ys"}},{"id":{"s":"asdassa"}}] need to make it [{"id":"ys", "kontent": "ys"}, {"id":"asdassa"}]