如何解决在Azure逻辑应用中,我们如何验证JSON主体中是否存在任何字段
按照我的逻辑,我期望以下json结构。
{
"id": "233343344","eventSourceId": 124443,"eventSourceUuid": "3655444","eventTime": "1323","notificationTime": "2333232","eventType": "appointment-reminder-add","notificationType": [
"EMAIL"
],"transportParameters": [
{
"emailTransportParameters": {
"version": 1,"toAddress": "abc@gmail.com","fromAddress": "xyz@gmail.com","fromName": "test","templateId": "1233","content": [
{
"type": "aa","name": "bb","value": "ccc"
}
]
}
}
]
}
如果不存在,则需要几个字段,我需要采取其他措施。 如何验证Azure逻辑应用程序中的字段是否存在以及字段是否为空?
//pseudo-code
if(eventSourceId !=null && eventSourceId.length >0)
解决方法
您可以使用coalesce
函数进行测试,如下所示(此处我假设您的数据是通过http触发器发送的
equals(coalesce(triggerBody()?['eventSourceId'],'EMPTY'),'EMPTY')
当eventSourceId不存在时,它将返回true,如果eventSourceId可以包含EMPTY,则显然不是测试的好选择。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。