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
]
}
답변함 일 년 전