我必须创建一个JOLT过滤器来删除基于条件的字段,而且该过滤器必须使用两种不同的JSON结构。
- 所以,情况是这样的**
我有这些JSON:
- JSON 1:**
{
"header": {
"key": "value"
},
"payload": {
"someArray": [
{
"key1": "val1"
}
],
"elements": [
{
"service": "serviceOne",
"something": "somethingValue"
},
{
"service": "THIS_SERVICE",
"attributes": [
{
"something": "somethingValue",
"attributes_here": {
"key1": "val1",
"key2": "val2",
"key3": "val3",
"key4": "val4",
"key5": "val5",
"key6": "val6"
}
}
]
}
]
},
"data": {
"key1": "val1"
}
}
- JSON 2:**
{
"responseMessage": {
"header": {
"key": "value"
},
"payload": {
"someArray": [
{
"key1": "val1"
}
],
"elements": [
{
"service": "serviceOne",
"something": "somethingValue"
},
{
"service": "THIS_SERVICE",
"attributes": [
{
"something": "somethingValue",
"attributes_here": {
"key1": "val1",
"key2": "val2",
"key3": "val3",
"key4": "val4",
"key5": "val5",
"key6": "val6"
}
}
]
}
]
},
"data": {
"key1": "val1"
},
"state": {
"state1": "state1"
}
},
"status": [],
"notes": []
}
例如,我需要过滤器从attributes_here
中删除key2
和key5
(仅当service
值为THIS_SERVICE
时),并为JSON保留相同的结构。
- 预期产出:**
- JSON 1:**
{
"header": {
"key": "value"
},
"payload": {
"someArray": [
{
"key1": "val1"
}
],
"elements": [
{
"service": "serviceOne",
"something": "somethingValue"
},
{
"service": "THIS_SERVICE",
"attributes": [
{
"something": "somethingValue",
"attributes_here": {
"key1": "val1",
"key3": "val3",
"key4": "val4",
"key6": "val6"
}
}
]
}
]
},
"data": {
"key1": "val1"
}
}
- JSON 2:**
{
"responseMessage": {
"header": {
"key": "value"
},
"payload": {
"someArray": [
{
"key1": "val1"
}
],
"elements": [
{
"service": "serviceOne",
"something": "somethingValue"
},
{
"service": "THIS_SERVICE",
"attributes": [
{
"something": "somethingValue",
"attributes_here": {
"key1": "val1",
"key3": "val3",
"key4": "val4",
"key6": "val6"
}
}
]
}
]
},
"data": {
"key1": "val1"
},
"state": {
"state1": "state1"
}
},
"status": [],
"notes": []
}
任何帮助都将不胜感激。谢谢你,祝你有一个伟大的一天!
2条答案
按热度按时间piztneat1#
可以使用以下等级库作为选项:
ia2d9nvy2#
请尝试以下震动规格:
您可以根据需要在
remove
操作中删除字段。