我必须将账户复制到输出中的两个级别。并且我需要从一个级别中删除fullAccountNumber。但是在我的jolt规范中,它是从两个级别中删除的。我在jolt中的删除规范中遗漏了什么吗?
我有以下输入
{
"applicant": {
"accounts": [
{
"fullAccountNumber": "00000000006276110961",
"maskedAccountNumber": "XXXXXX0961",
"accountType": "Checking"
},
{
"fullAccountNumber": "00000000006276110961",
"maskedAccountNumber": "XXXXXX0961",
"accountType": "Saving"
}
]
}
}
字符串
期望输出
{
"accounts": [
{
"fullAccountNumber": "00000000006276110961",
"maskedAccountNumber": "XXXXXX0961",
"accountType": "Checking"
},
{
"fullAccountNumber": "00000000006276110961",
"maskedAccountNumber": "XXXXXX0961",
"accountType": "Saving"
}
],
"ma-loan": {
"accounts": [
{
"maskedAccountNumber": "XXXXXX0961",
"accountType": "Checking"
},
{
"maskedAccountNumber": "XXXXXX0961",
"accountType": "Saving"
}
]
}
}
震动:
[
{
"operation": "shift",
"spec": {
"applicant": {
"accounts": ["accounts", "ma-loan.accounts"]
}
}
},
{
"operation": "remove",
"spec": {
"ma-loan": {
"accounts": {
"*": {
"fullAccountNumber": ""
}
}
}
}
}
]
电流输出:(从两个级别删除fullAccountNumber)
{
"accounts": [
{
"maskedAccountNumber": "XXXXXX0961",
"accountType": "Checking"
},
{
"maskedAccountNumber": "XXXXXX0961",
"accountType": "Saving"
}
],
"ma-loan": {
"accounts": [
{
"maskedAccountNumber": "XXXXXX0961",
"accountType": "Checking"
},
{
"maskedAccountNumber": "XXXXXX0961",
"accountType": "Saving"
}
]
}
}
2条答案
按热度按时间cwdobuhd1#
我找到了我上面问题的解决方案。在我的例子中,remove 操作不起作用,我必须对第一个 shift 操作规范的结果使用 shift 操作。
解决方案1:
解决方案二:
解决方案改进不大,采用单 * 班 * 操作。
zujrkrfu2#
我发现了另一种方法来得到这个输出JSON。我只是分享这个规范作为一个信息。我希望这个规范会帮助一些人。
质量标准
所需输出