我们有一个嵌套列表,我们正在使用GET方法来检索嵌套列表内的属性(CarName)之一,我们无法做到这一点
我们无法做到这一点,因为CarName不是根属性,也不是DynamoDB表(嵌套列表内的属性)中的列。
控制器类
@GetMapping("/car/{carName}")
public ResponseEntity<Map<String, Object>> getCarName(@PathVariable("carName") String carName) {
return new ResponseEntity<>(carService.getByCarName(carName), HttpStatus.OK);
}
服务等级
public Map<String, Object> getByCarName((String carName) {
Map<String, Object> map = new HashMap<>();
Item item = table.getItem("carName", carName);
map.putAll(item.asMap());
return map;
}
JSON格式示例
{
"id":"4",
"List":
[
{
"id":"4",
"carName": "health",
"startTime":"12:30 PM",
"car" :
[
{
"attributeName":["what disease"],
},
{
"attributeName":["what disease"],
}
]
}
使用JSON格式的POST请求时收到此错误消息
"message": "com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException: The provided key element does not match the schema (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException; Request ID: ODQVTSCU30F2VE949S2UIF524BVV4KQNSO5AEMVJF66Q9ASUAAJG)",