Amazon dynamodb dynamodb UpdateItem json有效负载

Amazon dynamodb dynamodb UpdateItem json有效负载,amazon-dynamodb,updates,aws-api-gateway,Amazon Dynamodb,Updates,Aws Api Gateway,我正在使用AWS服务代理将DynamoDB公开为API。对于PutItem,它可以正常工作,但我不知道如何更新对象的数组。 下面的“paymentDetail”是映射列表,我可以发布到DynamoDB,但更新JSON负载失败。不确定DynamoDB是否支持此功能,我总是收到以下消息: {“_type”:“com.amazon.coral.service#SerializationException”} 任何人都可以分享您关于如何使用映射模板更新JSON负载的想法吗?提前谢谢 这是我的代码,请提供

我正在使用AWS服务代理将DynamoDB公开为API。对于PutItem,它可以正常工作,但我不知道如何更新对象的数组。 下面的“paymentDetail”是映射列表,我可以发布到DynamoDB,但更新JSON负载失败。不确定DynamoDB是否支持此功能,我总是收到以下消息:

{“_type”:“com.amazon.coral.service#SerializationException”}

任何人都可以分享您关于如何使用映射模板更新JSON负载的想法吗?提前谢谢

这是我的代码,请提供建议和帮助。如果信息不充分,请告知我

------UpdateItem的请求方法------------

{
    "TableName": "claim",
    "Key": {
        "claimNumber": {
            "S": "$input.params("claimNumber")"
        }
    },
    "UpdateExpression": "set claimStatus = :claimStatus, statusUpdateDate = :statusUpdateDate, netClaimAmount = :netClaimAmount, paymentDetail = :paymentDetail, updatedAt = :updatedAt",
    "ConditionExpression": "claimNumber = :claimNumber",
    "ExpressionAttributeValues": {
        ":claimNumber": {"S": "$input.params("claimNumber")"},
        ":claimStatus": {"S": "$input.path("$.claimStatus")"},
        ":statusUpdateDate": {"S": "$input.path("$.statusUpdateDate")"},
        ":netClaimAmount": {"N": "$input.path("$.netClaimAmount")"},
        ":paymentDetail": {"L": "$input.path("$.paymentDetail")"},
        ":updatedAt": {"S": "$input.path("$.updatedAt")"}
},
"ReturnValues": "UPDATED_NEW"
#set($inputRoot = $input.path('$'))
{
    "TableName": "claim",
    "Item": {
        "claimNumber": {
            "S": "$input.path("$.claimNumber")"
        },
        "policyNumber": {
            "S": "$input.path("$.policyNumber")"
        },
        "productName": {
            "S": "$input.path("$.productName")"
        },
        "lossDate": {
            "S": "$input.path("$.lossDate")"
        },
        "lossTime": {
            "S": "$input.path("$.lossTime")"
        },
        "reportedDate": {
            "S": "$input.path("$.reportedDate")"
        },
        "lossCause": {
            "S": "$input.path("$.lossCause")"
        },
        "description": {
            "S": "$input.path("$.description")"
        },
        "prefectureCode": {
            "S": "$input.path("$.prefectureCode")"
        },
        "city": {
            "S": "$input.path("$.city")"
        },
        "address": {
            "S": "$input.path("$.address")"
        },
        "reportedByType": {
            "S": "$input.path("$.reportedByType")"
        },
        "createdAt": {
            "S": "$input.path("$.createdAt")"
        },
        "updatedAt": {
            "S": "$input.path("$.updatedAt")"
        },
        "claimImageId": {
            "S": "$input.path("$.claimImageId")"
        },
        "contact": {
            "M": {
                "lastName": {
                    "S": "$input.path("$.contact.lastName")"
                },
                "firstName": {
                    "S": "$input.path("$.contact.firstName")"
                },
                "postCode": {
                    "S": "$input.path("$.contact.postCode")"
                },
                "prefectureCode": {
                    "S": "$input.path("$.contact.prefectureCode")"
                },
                "city": {
                    "S": "$input.path("$.contact.city")"
                },
                "address": {
                    "S": "$input.path("$.contact.address")"
                },
                "homePhone": {
                    "S": "$input.path("$.contact.homePhone")"
                },
                "email": {
                    "S": "$input.path("$.contact.email")"
                }
            }
        },
        "claimStatus": {
            "S": "$input.path("$.claimStatus")"
        },
        "statusUpdateDate": {
            "S": "$input.path("$.statusUpdateDate")"
        },
        "netClaimAmount": {
            "N": "$input.path("$.netClaimAmount")"
        },
        "paymentDetail": {
            "L":[
                #foreach($elem in $inputRoot.paymentDetail){
                        "M": {
                            "coverage": {
                                "S": "$elem.coverage"
                            },
                            "claimPaymentDate": {
                                "S": "$elem.claimPaymentDate"
                            },
                            "claimAmount": {
                                "S": "$elem.claimAmount"
                            },
                            "costCategory": {
                                "S": "$elem.costCategory"
                            },
                            "costType": {
                                "S": "$elem.costType"
                            }
                        }
                }#if($foreach.hasNext),#end
                #end
            ]
        }
    }
}
}

------更新项的测试数据------------

{
    "claimNumber": "000-00-000959",
    "updatedAt":"2017-09-10",
    "claimStatus": "close",
    "statusUpdateDate": "2017-09-13",
    "netClaimAmount": 60000000,
    "paymentDetail": [
        {
            "coverage": "AAA",
            "claimPaymentDate": "2017-09-03",
            "claimAmount": "10000000",
            "costCategory": "1",
            "costType": "A"
        },
        {
            "coverage": "BBB",
            "claimPaymentDate": "2017-09-03",
            "claimAmount": "20000000",
            "costCategory": "2",
            "costType": "B"
        },
        {
            "coverage": "CCC",
            "claimPaymentDate": "2017-09-03",
            "claimAmount": "30000000",
            "costCategory": "3",
            "costType": "C"
        }
    ]
}
——请输入您的信息---

{
    "TableName": "claim",
    "Key": {
        "claimNumber": {
            "S": "$input.params("claimNumber")"
        }
    },
    "UpdateExpression": "set claimStatus = :claimStatus, statusUpdateDate = :statusUpdateDate, netClaimAmount = :netClaimAmount, paymentDetail = :paymentDetail, updatedAt = :updatedAt",
    "ConditionExpression": "claimNumber = :claimNumber",
    "ExpressionAttributeValues": {
        ":claimNumber": {"S": "$input.params("claimNumber")"},
        ":claimStatus": {"S": "$input.path("$.claimStatus")"},
        ":statusUpdateDate": {"S": "$input.path("$.statusUpdateDate")"},
        ":netClaimAmount": {"N": "$input.path("$.netClaimAmount")"},
        ":paymentDetail": {"L": "$input.path("$.paymentDetail")"},
        ":updatedAt": {"S": "$input.path("$.updatedAt")"}
},
"ReturnValues": "UPDATED_NEW"
#set($inputRoot = $input.path('$'))
{
    "TableName": "claim",
    "Item": {
        "claimNumber": {
            "S": "$input.path("$.claimNumber")"
        },
        "policyNumber": {
            "S": "$input.path("$.policyNumber")"
        },
        "productName": {
            "S": "$input.path("$.productName")"
        },
        "lossDate": {
            "S": "$input.path("$.lossDate")"
        },
        "lossTime": {
            "S": "$input.path("$.lossTime")"
        },
        "reportedDate": {
            "S": "$input.path("$.reportedDate")"
        },
        "lossCause": {
            "S": "$input.path("$.lossCause")"
        },
        "description": {
            "S": "$input.path("$.description")"
        },
        "prefectureCode": {
            "S": "$input.path("$.prefectureCode")"
        },
        "city": {
            "S": "$input.path("$.city")"
        },
        "address": {
            "S": "$input.path("$.address")"
        },
        "reportedByType": {
            "S": "$input.path("$.reportedByType")"
        },
        "createdAt": {
            "S": "$input.path("$.createdAt")"
        },
        "updatedAt": {
            "S": "$input.path("$.updatedAt")"
        },
        "claimImageId": {
            "S": "$input.path("$.claimImageId")"
        },
        "contact": {
            "M": {
                "lastName": {
                    "S": "$input.path("$.contact.lastName")"
                },
                "firstName": {
                    "S": "$input.path("$.contact.firstName")"
                },
                "postCode": {
                    "S": "$input.path("$.contact.postCode")"
                },
                "prefectureCode": {
                    "S": "$input.path("$.contact.prefectureCode")"
                },
                "city": {
                    "S": "$input.path("$.contact.city")"
                },
                "address": {
                    "S": "$input.path("$.contact.address")"
                },
                "homePhone": {
                    "S": "$input.path("$.contact.homePhone")"
                },
                "email": {
                    "S": "$input.path("$.contact.email")"
                }
            }
        },
        "claimStatus": {
            "S": "$input.path("$.claimStatus")"
        },
        "statusUpdateDate": {
            "S": "$input.path("$.statusUpdateDate")"
        },
        "netClaimAmount": {
            "N": "$input.path("$.netClaimAmount")"
        },
        "paymentDetail": {
            "L":[
                #foreach($elem in $inputRoot.paymentDetail){
                        "M": {
                            "coverage": {
                                "S": "$elem.coverage"
                            },
                            "claimPaymentDate": {
                                "S": "$elem.claimPaymentDate"
                            },
                            "claimAmount": {
                                "S": "$elem.claimAmount"
                            },
                            "costCategory": {
                                "S": "$elem.costCategory"
                            },
                            "costType": {
                                "S": "$elem.costType"
                            }
                        }
                }#if($foreach.hasNext),#end
                #end
            ]
        }
    }
}

您的身体映射模板似乎有问题。 请看下面的更正

#set($inputRoot = $input.path('$'))
{
    "TableName": "claim",
    "Key": {
        "claimNumber": {
            "S": "$input.path("$.claimNumber")"
        }
    },
    "UpdateExpression": "set claimStatus = :claimStatus, statusUpdateDate = :statusUpdateDate, netClaimAmount = :netClaimAmount, paymentDetail = :paymentDetail, updatedAt = :updatedAt",
    "ConditionExpression": "claimNumber = :claimNumber",
    "ExpressionAttributeValues": {
        ":claimNumber": {"S": "$input.path("$.claimNumber")"},
        ":claimStatus": {"S": "$input.path("$.claimStatus")"},
        ":statusUpdateDate": {"S": "$input.path("$.statusUpdateDate")"},
        ":netClaimAmount": {"N": "$input.path("$.netClaimAmount")"},
                ":updatedAt": {"S": "$input.path("$.updatedAt")"},
         ":paymentDetail": {
            "L":[
                #foreach($elem in $inputRoot.paymentDetail){
                        "M": {
                            "coverage": {
                                "S": "$elem.coverage"
                            },
                            "claimPaymentDate": {
                                "S": "$elem.claimPaymentDate"
                            },
                            "claimAmount": {
                                "S": "$elem.claimAmount"
                            },
                            "costCategory": {
                                "S": "$elem.costCategory"
                            },
                            "costType": {
                                "S": "$elem.costType"
                            }
                        }
                }#if($foreach.hasNext),#end
                #end
            ]
        }
    },
"ReturnValues": "UPDATED_NEW"
}

您的身体映射模板似乎有问题。 请看下面的更正

#set($inputRoot = $input.path('$'))
{
    "TableName": "claim",
    "Key": {
        "claimNumber": {
            "S": "$input.path("$.claimNumber")"
        }
    },
    "UpdateExpression": "set claimStatus = :claimStatus, statusUpdateDate = :statusUpdateDate, netClaimAmount = :netClaimAmount, paymentDetail = :paymentDetail, updatedAt = :updatedAt",
    "ConditionExpression": "claimNumber = :claimNumber",
    "ExpressionAttributeValues": {
        ":claimNumber": {"S": "$input.path("$.claimNumber")"},
        ":claimStatus": {"S": "$input.path("$.claimStatus")"},
        ":statusUpdateDate": {"S": "$input.path("$.statusUpdateDate")"},
        ":netClaimAmount": {"N": "$input.path("$.netClaimAmount")"},
                ":updatedAt": {"S": "$input.path("$.updatedAt")"},
         ":paymentDetail": {
            "L":[
                #foreach($elem in $inputRoot.paymentDetail){
                        "M": {
                            "coverage": {
                                "S": "$elem.coverage"
                            },
                            "claimPaymentDate": {
                                "S": "$elem.claimPaymentDate"
                            },
                            "claimAmount": {
                                "S": "$elem.claimAmount"
                            },
                            "costCategory": {
                                "S": "$elem.costCategory"
                            },
                            "costType": {
                                "S": "$elem.costType"
                            }
                        }
                }#if($foreach.hasNext),#end
                #end
            ]
        }
    },
"ReturnValues": "UPDATED_NEW"
}