我有一个 JSON
有效负载:
{
"fields":[
{
"title":"Priority",
"value":"low",
"short":"true"
},
{
"title":"Priority",
"value":"medium",
"short":"true"
},
{
"title":"Priority",
"value":"high",
"short":"true"
},
{
"title":"Priority",
"value":"blocker",
"short":"true"
},
{
"title":"",
"value":"",
"short":"true"
},
{
"title":"",
"value":"",
"short":"true"
}
]
}
如果属性 title
或 value
为空,我想删除数组元素。我正在使用 Jolt 变换处理器。我需要的o/p
{
"fields":[
{
"title":"Priority",
"value":"low",
"short":"true"
},
{
"title":"Priority",
"value":"medium",
"short":"true"
},
{
"title":"Priority",
"value":"high",
"short":"true"
},
{
"title":"Priority",
"value":"blocker",
"short":"true"
}
]
}
任何人都可以引用我可以学习如何编写规范的地方,我将非常感激。我已经提到过https://jolt-demo.appspot.com/#inception
最佳答案
尝试先按 title
删除节点,然后按 value
删除节点:
[
{
"operation": "shift",
"spec": {
"fields": {
"*": {
"title": {
"": null,
"*": {
"@2": "fields[]"
}
}
}
}
}
}, {
"operation": "shift",
"spec": {
"fields": {
"*": {
"value": {
"": null,
"*": {
"@2": "fields[]"
}
}
}
}
}
}
]
另请参阅:
关于json - 如果某些属性为空,则使用 nifi 中的 jolt 变换规范从 Json 数组中删除 Json 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55114435/