0
我有幾個情況需要將地圖字段轉換爲有時嵌套幾層的數組字段。這些是需要在文檔中更改的唯一字段,所以其他字段不需要對它們執行任何類型的轉換。我目前的做法是在每個級別上不變的領域進行復制,這樣的:使用Jolt更改目標字段
[
{
"operation": "shift",
"spec": {
"agentsMetrics": {
"metricsPerAgent": {
"*": {
"$": "agentsMetrics.metricsPerAgent[#2].agentId",
"@": "agentsMetrics.metricsPerAgent[#2].value"
}
},
"*": {
"@": "agentsMetrics.&"
}
},
"skillsMetricsPerAgent": {
"metricsPerSkill": {
"*": {
"$": "skillsMetricsPerAgent.metricsPerSkill[#2].skillId",
"metricsPerAgent": {
"*": {
"$": "skillsMetricsPerAgent.metricsPerSkill[#4].metricsPerAgent[#2].agentId",
"@": "skillsMetricsPerAgent.metricsPerSkill[#4].metricsPerAgent[#2].value"
}
},
"*": {
"@": "skillsMetricsPerAgent.metricsPerSkill[#3].&"
}
}
},
"*": {
"@": "skillsMetricsPerAgent.&"
}
}
}
}
]
當我輸入的是這樣的:
{
"agentsMetrics": {
"metricsTotals": {
"connectedEngagements": 70,
"nonInteractiveTotalHandlingTime": 309,
"totalHandlingTime": 47696,
"totalNonInteractiveChats": 2,
"totalInteractiveChats": 73
},
"metricsPerAgent": {
"645355412": {
"connectedEngagements": 2,
"nonInteractiveTotalHandlingTime": 0,
"totalHandlingTime": 1718,
"totalNonInteractiveChats": 0,
"totalInteractiveChats": 2
},
"645366912": {
"connectedEngagements": 1,
"nonInteractiveTotalHandlingTime": 0,
"totalHandlingTime": 488,
"totalNonInteractiveChats": 0,
"totalInteractiveChats": 1
}
}
},
"skillsMetricsPerAgent": {
"metricsTotals": {
"connectedEngagements": 70,
"nonInteractiveTotalHandlingTime": 309,
"totalHandlingTime": 47696,
"totalNonInteractiveChats": 2,
"totalInteractiveChats": 73
},
"metricsPerSkill": {
"641431612": {
"metricsTotals": {
"connectedEngagements": 7,
"nonInteractiveTotalHandlingTime": 0,
"totalHandlingTime": 6377,
"totalNonInteractiveChats": 0,
"totalInteractiveChats": 8
},
"metricsPerAgent": {
"645355312": {
"connectedEngagements": 1,
"nonInteractiveTotalHandlingTime": 0,
"totalHandlingTime": 115,
"totalNonInteractiveChats": 0,
"totalInteractiveChats": 1
},
"645365512": {
"connectedEngagements": 0,
"nonInteractiveTotalHandlingTime": 0,
"totalHandlingTime": 766,
"totalNonInteractiveChats": 0,
"totalInteractiveChats": 1
}
}
},
"1218517512": {
"metricsTotals": {
"connectedEngagements": 2,
"nonInteractiveTotalHandlingTime": 0,
"totalHandlingTime": 1379,
"totalNonInteractiveChats": 0,
"totalInteractiveChats": 2
},
"metricsPerAgent": {
"645367512": {
"connectedEngagements": 1,
"nonInteractiveTotalHandlingTime": 0,
"totalHandlingTime": 571,
"totalNonInteractiveChats": 0,
"totalInteractiveChats": 1
},
"645378812": {
"connectedEngagements": 1,
"nonInteractiveTotalHandlingTime": 0,
"totalHandlingTime": 808,
"totalNonInteractiveChats": 0,
"totalInteractiveChats": 1
}
}
}
}
}
}
有什麼辦法,以針對特定的領域和操縱它們他們自己而離開一切,因爲它是?在這種情況下,我想定位metricsPerAgent和metricsPerSkill。