1 個回答
- 最新
- 最多得票
- 最多評論
0
This is kinda hacky, but you need to work in strings a little further as once you are in json objects there doesn't seem a way to re-stringiify... Here is my snippet...
{ "StreamName": "event-stream-qa", "Records": [
#set($datakey = ".data")
#set($partitionkey = ".key")
#foreach($elem in $input.path('$.records'))
#set($pathBegin = "$.records[")
#set($pathEnd = "]")
#set($currentIndex = $foreach.index)
#set($dataPath = "$pathBegin$currentIndex$pathEnd$datakey")
#set($partitionPath = "$pathBegin$currentIndex$pathEnd$partitionkey")
#set($dataJson = $input.json($dataPath))
#set($partitionJson = $input.json($partitionPath))
{
"Data": "$util.base64Encode($dataJson)",
"PartitionKey": $partitionJson
}
#if($foreach.hasNext),#end
#end
]
}
已回答 1 年前
相關內容
- AWS 官方已更新 2 年前
- AWS 官方已更新 7 個月前
- AWS 官方已更新 2 年前
- AWS 官方已更新 10 個月前