Created
April 18, 2017 17:27
-
-
Save avendasora/41576de21c3b9b1617d982ee84ecdb1c to your computer and use it in GitHub Desktop.
AWS API Gateway body mapping template to convert simple JSON into DynamoDB JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #set($tableName = $input.params("tableName")) | |
| #set($inputRoot = $input.path('$')) | |
| { | |
| "TableName": "$tableName", | |
| "Item": { | |
| "request_id": { | |
| "S": "$context.requestId" | |
| }, | |
| #foreach($key in $inputRoot.keySet()) | |
| #set($value = $inputRoot.get($key)) | |
| #set($class = $value.class) | |
| ##$class | |
| #if($class == "class java.lang.Integer" | |
| || $class == "class java.lang.Double" | |
| || $class == "class java.lang.Float" | |
| || $class == "class java.lang.BigDecimal" | |
| || $class == "class java.lang.BigInteger" | |
| ) | |
| #set($type = "N") | |
| #elseif($class == "class java.lang.Boolean") | |
| #set($type = "BOOL") | |
| #else | |
| #set($type = "S") | |
| #end | |
| "$key": { | |
| "$type": "$value" | |
| }#if($foreach.hasNext),#end | |
| #end | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment