我使用AWS网关作为DynamoDb的代理,如本文档所示:https://aws.amazon.com/blogs/compute/using-amazon-api-gateway-as-a-proxy-for-dynamodb/
当在API网关中测试时,结果如下:
{
"Count": 6,
"Items": [
{
"mini_description": {
"S": "A veg sandwich"
},
"item_description": {
"S": "A veg sandwich filled with a lot of healthy vegetables"
},
"id": {
"S": "6d0e0870-......-c5ccfbc0424c"
},
"image_url": {
"S": "https://......png"
},
"price": {
"N": "25"
},
"name": {
"S": "Veg Sandwich"
},
"item_type": {
"S": "Main Dish"
}
},
{
"mini_description": {
"S": "A normal hot coffee"
},.....我需要以下格式:
{
"Count": 6,
"Items": [
{
"mini_description": "A veg sandwich",
"item_description": "A veg sandwich filled with a lot of healthy vegetables",
"id": "6d0e0870-.......-c5ccfbc0424c",
"image_url": "https://.......png",
"price": 25,
"name": "Veg Sandwich",
"item_type": "Main Dish"
},
{
"mini_description": "A normal hot coffee",............有什么程序可以通过API网关的集成响应来改变这种情况吗?
发布于 2019-01-31 05:55:34
在API网关中GET方法的集成响应中,我使用了以下映射模板实现了这一点:
#set($inputRoot = $input.path('$'))
{
"Items": [
#foreach($elem in $inputRoot.Items)
{
"mini_description" : "$elem.mini_description.S",
"item_description" : "$elem.item_description.S",
"id" : "$elem.id.S",
"image_url" : "$elem.image_url.S",
"price" : $elem.price.N,
"name" : "$elem.name.S",
"item_type" : "$elem.item_type.S"
}#if($foreach.hasNext),#end
#end
]
}发布于 2019-01-30 16:03:41
如果您有直接到DynamoDB的API网关,就无法解锁数据。但是,您可以在API网关和DynamoDB之间添加一个Lambda函数,然后使用Unmar应当从Javascript中运行。 (或任何其他首选语言)删除DynamoDB JSON元素。
https://stackoverflow.com/questions/54444055
复制相似问题