问题描述
我创建了一个逻辑应用程序,其中包含一些触发器,一个"http"连接器以及一个"If"条件活动. "http"连接器返回"json"结果,例如jsonObj
.
我可以将条件检查为@equal(body('HTTP')['jsonObj'].someProperty,'someValue')
,但不能对该someProperty
值进行null
检查.
下面是我尝试过的一些方法,这些方法都行不通.
@equal(body('HTTP')['jsonObj'].someProperty, null) --Unable to save
@equal(body('HTTP')['jsonObj']?.someProperty,'null') --Comparing with string value 'null'
我没有找到真正的方法来对直接测试或但是,选择足够的随机"字符串时采取以下解决办法应该工作coalesce
...
"propExists": "@equals(coalesce(triggerBody()?.prop, 'Fallback42'), 'Fallback42')"
...
例如,以下逻辑应用将回显属性prop
以及是否实际指定了该属性
{
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Response": {
"inputs": {
"body": {
"propNull": "@equals(coalesce(triggerBody()?.prop, 'undefined'), 'undefined')",
"prop": "@triggerBody()?.prop"
},
"statusCode": 200
},
"runAfter": {},
"type": "Response"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"request": {
"inputs": {
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
}
这样带有
的请求{
"prop": "test"
}
结果
{
"prop": "test",
"propNull": false
}
而带有
的请求{
"propOther": "test"
}
结果
{
"prop": null,
"propNull": true
}
I've created a logic app which contains some trigger, an 'http' connector and then an 'If' condition activity. The 'http' connector returns a 'json' result say jsonObj
.
I'm able to check condition as @equal(body('HTTP')['jsonObj'].someProperty,'someValue')
but not able to do a null
check on that someProperty
value.
Below are some ways I tried which are not working.
@equal(body('HTTP')['jsonObj'].someProperty, null) --Unable to save
@equal(body('HTTP')['jsonObj']?.someProperty,'null') --Comparing with string value 'null'
I did not found a real way to directly test against null
or undefined
but the following workaround should work when choosing a sufficient 'random' string as fallback for the coalesce
...
"propExists": "@equals(coalesce(triggerBody()?.prop, 'Fallback42'), 'Fallback42')"
...
For example the following Logic App would echo back the property prop
and whether it was actually specified or not
{
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Response": {
"inputs": {
"body": {
"propNull": "@equals(coalesce(triggerBody()?.prop, 'undefined'), 'undefined')",
"prop": "@triggerBody()?.prop"
},
"statusCode": 200
},
"runAfter": {},
"type": "Response"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"request": {
"inputs": {
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
}
so that a request with
{
"prop": "test"
}
results in
{
"prop": "test",
"propNull": false
}
whereas a request with
{
"propOther": "test"
}
results in
{
"prop": null,
"propNull": true
}
这篇关于如何在Azure Logic App的``是否''条件操作中执行``空''检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!