1 Answer
- Newest
- Most votes
- Most comments
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
]
}
answered a year ago
Relevant content
- Accepted Answerasked 8 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 16 days ago