我有以下 JSON 結構:
{
"data": {
"a1": "value1",
"a2": "value1",
"a3": "value1",
"collection": [
{
"events": [
{
"x1": 123,
"x2": "NA",
"x3": 5678
},
{
"x1": 432,
"x2": 854,
"x3": 912
}
]
}
]
}
}
我想使用 Jolt 洗掉欄位 x2,只要它的值為“NA”或“NV”
期望的輸出:
{
"data": {
"a1": "value1",
"a2": "value1",
"a3": "value1",
"collection": [
{
"events": [
{
"x1": 123,
"x3": 5678
},
{
"x1": 432,
"x2": 854,
"x3": 912
}
]
}
]
}
}
uj5u.com熱心網友回復:
您可以將以下班次轉換規范與條件邏輯一起使用
[
{
"operation": "shift",
"spec": {
"data": {
"*": "&1.&",
"collection": {
"*": {
"events": {
"*": {
"x2": {
"NA|NV": { // | is OR operator
"*": ""
},
"*": {
"@1": "&7.&6[&5].&4[&3].&2" // &7 represents the level of "data", &6 represents the level of "collection", [&5] -> the indexes of it, &4 -> the level of "events" etc.
}
},
"*": "&5.&4[&3].&2[&1].&" // reduce two level with respect to the above value identifier
}
}
}
}
}
}
}
]
網站
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/519948.html
標籤:json颠簸
