大家好,我的json输入是这样的:
{
"chequesCollateral": [
{
"accountNum": "0026.0002.62.0300162968",
"agreement": "0026.5501.90.0490520505",
"checkno": "229425941 ",
"amount": 20000,
"issueBank": "0026",
"branch": "0154",
"currency": "EUR",
"expDate": "2019-09-20"
},
{
"accountNum": "0026.0002.62.0300162968",
"agreement": "0026.5501.90.0490520505",
"checkno": "322108888 ",
"amount": 2500,
"issueBank": "0011",
"branch": "0335",
"currency": "EUR",
"expDate": "2019-10-26"
},
{
"accountNum": "0026.0002.62.0300162968",
"agreement": "0026.5501.90.0490520505",
"checkno": "321979826 ",
"amount": 3964.77,
"issueBank": "0011",
"branch": "0104",
"currency": "EUR",
"expDate": "2019-10-31"
}
]
}
我使用此转换来产生此结果:
[
{
"operation": "shift",
"spec": {
"chequesCollateral": {
"*": {
"issueBank": "distinctBinData.&0"
}
}
}
}
]
这是产生的:
{
"distinctBinData" : {
"issueBank" : [ "0026", "0011", "0011" ]
}
}
我想产生这个:
{
"distinctBinData" : [ "0026", "0011", "0011" ]
}
我该怎么办?
最佳答案
您不必在目标键中指定&0
部分。 &0
指当前级别的JSON密钥,在您的情况下为issueBank
。因此,当您将目标键指定为distinctBinData.&0
时,它将解析为distinctBinData.issueBank
。因此,只需使用distinctBinData
作为目标键,如下所示。
[
{
"operation": "shift",
"spec": {
"chequesCollateral": {
"*": {
"issueBank": "distinctBinData"
}
}
}
}
]