如何在AWS Api网关映射模板中使用IF条件.如果不使用foreach就可以使用条件吗? [英] How to use IF condition in AWS Api gateway mapping templates. can i use if condition without using foreach?

查看:143
本文介绍了如何在AWS Api网关映射模板中使用IF条件.如果不使用foreach就可以使用条件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#if($ inputRoot.objectType =='Test'),"TableName":"StudentTests",#else,"TableName":"UserActions",#end

如果使用if条件,我在邮递员链接中出现错误##"__type":"com.amazon.coral.service#SerializationException" ##

if use if condition i got an error in postman link ## "__type": "com.amazon.coral.service#SerializationException" ##

推荐答案

我了解您的问题的方式:

The way I understand your question I would do :

#if($inputRoot.objectType == "Test")
    #set($tableName = "StudentTests"
#else
    #set($tableName = "UserActions"
#end

{
    "TableName": "$tableName",
    "Key": ...
}

这篇关于如何在AWS Api网关映射模板中使用IF条件.如果不使用foreach就可以使用条件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆