我有轉換 JSON 的要求,我試圖多次使用相同的值。有沒有一種方法可以多次使用值,以前我確實在陣列中使用過,但這次我必須通過關卡。任何幫助表示贊賞,謝謝。
注意我想根據名稱過濾產品配置。
如何在 Jolt 的多個地方使用相同的欄位值
輸入:
{
"sample": {
"Result": {
"value": {
"ImplProductConfigurationsOptionsEcomResponse": {
"transactionId": "12345678",
"timeStamp": 1646087177771,
"orderCorrelationId": "11039714",
"implValidateMultiProductConfigurationsResponse": {
"productConfigurations": [
{
"productConfiguration": {
"productSpecification": {
"name": "Private",
"id": "247541"
}
}
},
{
"productConfiguration": {
"productSpecification": {
"name": " sample Miscellaneous",
"id": "22222"
}
}
}
]
}
}
}
}
}
}
電流輸出:
{
"productConfigurations": {
"productConfiguration": {
"productSpecification": {
"name": "Private",
"id": "247541"
}
}
}
}
預期輸出:
{
"productConfigurations": {
"productConfiguration": {
"productSpecification": {
"name": "Private",
"id": "247541"
}
}
},
"Details": {
"ImplProductConfigurationsOptionsEcomResponse": {
"transactionId": "12345678",
"timeStamp": 1646087177771,
"orderCorrelationId": "11039714",
"implValidateMultiProductConfigurationsResponse": {
"productConfigurations": [
{
"productConfiguration": {
"productSpecification": {
"name": "Private",
"id": "247541"
}
}
},
{
"productConfiguration": {
"productSpecification": {
"name": " sample Miscellaneous",
"id": "22222"
}
}
}
]
}
}
}
}
我的規格:
[
{
"operation": "shift",
"spec": {
"sample": {
"Result": {
"value": {
"ImplProductConfigurationsOptionsEcomResponse": {
"implValidateMultiProductConfigurationsResponse": {
"productConfigurations": {
"*": {
"productConfiguration": {
"productSpecification": {
"name": {
"*Miscellaneous": null,
"*": {
"@4": "productConfigurations"
}
}
}
}
}
}
}
}
}
}
}
}
}
]
uj5u.com熱心網友回復:
您可以參考物件兩次以及移位轉換規范,例如
[
{
"operation": "shift",
"spec": {
"*": {
"*": {
"*": {
"*": {
"*": "Details.&1.&",
"implValidateMultiProductConfigurationsResponse": {
"*": {
"*": {
"*": {
"*": {
"name": {
"*Miscellaneous": {
"@3": "Details.&8.&7.&6[].&4"
},
"*": {
"@4": "&6",
"@3": "Details.&8.&7.&6[].&4"
}
}
}
}
}
}
}
}
}
}
}
}
}
]
網站上的演示
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/435541.html
下一篇:JQ-列印特定的鍵值對
