如果节点不存在或条件为假,则删除节点? [英] Delete a node if not existing or condition is false?
问题描述
输入JSON
{
assignment_group:测试,
类别: 软件,
评论:测试,
configuration_item:测试,
描述:测试,
文件:{
},
影响:3,
数字:INCxxxxxx,
short_description:TESt,
州:有效,
子类别 :windows,
紧急:4
}
变压器
{
行动:更新,
类型:事件,
correlation_id:#valueof($。number),
payload:{
short_description:#valueueof($ .short_description) ,
description:#valueof($。description),
state:#ifcondition(#valueof ($ .state),新的,1,
#ifcondition(#valueof($。state),已解决,6,
#ifcondition(#valueof($。state) ),正在进行中,9,
#ifcondition(#valueof($。state),等待用户信息,10,
#ifcondition(#valueof($。state),已取消,6,
#ifcondition (#valueof($。state),Other,#valueof($。state),'')))))),
影响:#ifcondition(#valueof($。impact),1,1,
#ifcondition(#valueof($。impact),2,1,
#ifcondition(#valueof($。impact),3,2,
#ifcondition(#valueof($。impact),4,3,true)))),< br $>
紧急度:#ifcondition(#valueof($。urgency),1,1,
#ifcondition(#valueof($。urgency),2,1,
#ifcondition(#valueof($。urgency),3,2,
#ifcondition( #valueof($。urgency),4,3,true)))),
'assignment_group':'#ifcondition (#valueof($。assignment_group),Test,True,
#ifcondition(#valueof($。assignment_group),Other,Test2,False))',
< br $> b $ b
cmdb_ci:#valueof($ .configuration_item),
//close_code:#valueof($。close_code ),
close_notes:#valueof($。close_notes),
comments:#value($。comments),
附件:{
file_name:#valueof($。attachment.file_name),
content:#valueof($。attachment.content) ,
content_type:#valueof($。attachment.content_type)
}
}
}
我尝试了什么:
场景-1
在我的输入中没有密码,但在Transforamtion中有密码的值,它被发送为Null。如果不存在,我想删除它。
我尝试了几种方法。
//close_code:#ifcondition(#exists( $ .close_code),true,#delete($。close_code)),
//close_code:[#valueof($。close_code),#delete($。close_code) ],
但它给我一个错误
2)第二种情况是如果(如果) - 条件不被饱和,然后该节点也被删除。
Input JSON
{
"assignment_group": "Test",
"category": "software",
"comments": "Test",
"configuration_item": "Test",
"description": "TEST",
"file": {
},
"impact": "3",
"number": "INCxxxxxx",
"short_description": "TESt",
"state": "Active",
"subcategory": "windows",
"urgency": "4"
}
Transformer
{
"action":"update" ,
"type":"incident",
"correlation_id": "#valueof($.number)",
"payload":{
"short_description": "#valueof($.short_description)",
"description": "#valueof($.description)",
"state": "#ifcondition(#valueof($.state),New,1,
#ifcondition(#valueof($.state),Resolved,6,
#ifcondition(#valueof($.state),Work In Progress,9,
#ifcondition(#valueof($.state),Awaiting User Info,10,
#ifcondition(#valueof($.state),Cancelled,6,
#ifcondition(#valueof($.state),Other,#valueof($.state),''))))))",
"impact": "#ifcondition(#valueof($.impact),1,1,
#ifcondition(#valueof($.impact),2,1,
#ifcondition(#valueof($.impact),3,2,
#ifcondition(#valueof($.impact),4,3,true))))",
"urgency": "#ifcondition(#valueof($.urgency),1,1,
#ifcondition(#valueof($.urgency),2,1,
#ifcondition(#valueof($.urgency),3,2,
#ifcondition(#valueof($.urgency),4,3,true))))",
'assignment_group':'#ifcondition(#valueof($.assignment_group),Test,True,
#ifcondition(#valueof($.assignment_group),Other,Test2,False))' ,
"cmdb_ci": "#valueof($.configuration_item)",
//"close_code": "#valueof($.close_code)",
"close_notes": "#valueof($.close_notes)",
"comments": "#valueof($.comments)",
"attachment":{
"file_name": "#valueof($.attachment.file_name)",
"content": "#valueof($.attachment.content)",
"content_type": "#valueof($.attachment.content_type)"
}
}
}
What I have tried:
Scenario-1
In my input there is no close code,but in Transforamtion there is value of close code which is being sent as Null.I want to delete the same if not existing.
I tried couple of methods.
//"close_code":"#ifcondition(#exists($.close_code),true,#delete($.close_code))" ,
//"close_code": ["#valueof($.close_code)","#delete($.close_code)"],
But it throws me an error
2)Second scenario is that if(if)-condition is not satsified then also that node be deleted.
推荐答案
.number),
有效载荷:{
short_description:#valueueof (
.number)",
"payload":{
"short_description": "#valueof(
.short_description),
description:#valueof(
.short_description)",
"description": "#valueof(
.description),< br $>
州:#ifcondition(#valueof(
.description)",
"state": "#ifcondition(#valueof(
这篇关于如果节点不存在或条件为假,则删除节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!