我有下面的Jolt,并且想把desc body放在"no"
orwithout "no"
取决于"yang:operation"
中定义的delete
操作。在Jolt下尝试,但看起来没有达到"\@desc"
中定义的条件:
输入JSON
{
"ABC": [
{
"@desc": {
"yang:operation": "delete"
},
"desc": "attr1"
}
]
}
Jolt Spec提供
[
{
"operation": "shift",
"spec": {
"ABC": {
"*": {
"\@desc": {
"yang:operation": {
"#delete": {
"desc": "no.desc.\$\.DESC.\.DESC"
},
"*": {
"desc": "desc.\$\.DESC.\.DESC"
}
}
},
"desc": "desc.\$\.DESC.\.DESC"
}
}
}
}
]
预期输出
{
"no" : {
"desc" : {
"$.DESC" : {
".DESC" : "attr1"
}
}
}
}
确实你是如此接近解决方案,只是最内层的desc
键应该用#
通配符限定,例如。#desc
;而不是最高级别的delete
键
[
{
"operation": "shift",
"spec": {
"ABC": {
"*": {
"\@desc": {
"yang:operation": {
"delete": {
"#desc": "no.desc.\$\.DESC.\.DESC"
},
"*": {
"#desc": "desc.\$\.DESC.\.DESC"
}
}
}
}
}
}
}
]
和外层(第二个)"desc": "desc.\$\.DESC.\.DESC"
似乎没有意义,只是删除它。